Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluxgui ported to Gtk 3 #111

Closed
LaBatata101 opened this issue Dec 2, 2018 · 31 comments
Closed

fluxgui ported to Gtk 3 #111

LaBatata101 opened this issue Dec 2, 2018 · 31 comments

Comments

@LaBatata101
Copy link
Collaborator

Since the #48 didn't give any results I decided to port fluxgui to python 3 and gtk 3 if you to see how is going here's the link, the gui still the basicly the same. I just need to fix a little bug before send the PR.

@ntc2
Copy link
Member

ntc2 commented Dec 3, 2018 via email

@LaBatata101
Copy link
Collaborator Author

LaBatata101 commented Dec 3, 2018

I need help with this three things to do in the program:

  • There's a bug that don't show the systray icon. I think it's related to this message (fluxgui:10031):Gdk-CRITICAL **: 19:05:54.240: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed I don't know how to fix it.
    screenshot_2018-12-03_19-13-47
  • Solve a logical bug related to the new configuration system
  • In the installation process move the configuration file(apps.fluxgui.gschema.xml) to /usr/share/glib-2.0/schemas and use glib-compile-schemas /usr/share/glib-2.0/schemas

Can I send the PR anyway?

@ntc2
Copy link
Member

ntc2 commented Dec 3, 2018

Yes, please send the PR anyway. Once you've made the PR public it's easier to get help.

@ntc2
Copy link
Member

ntc2 commented Dec 13, 2018

The PR is here: #112

@ntc2
Copy link
Member

ntc2 commented Dec 13, 2018

I just took a brief look at your PR #112, but haven't had a chance to try running it yet. Do I need to do anything special to run it? E.g. the glib-compile-schemas step you mention above?

And if you need help with the "logical bug related to the new config system", can you say more about that?

@LaBatata101
Copy link
Collaborator Author

You just need to move the file apps.fluxgui.gschema.xml to /usr/share/glib-2.0/schemas and use glib-compile-schemas /usr/share/glib-2.0/schemas with sudo as mentioned above and run the program with PATH=`pwd`:$PATH PYTHONPATH=`pwd`/src:$PYTHONPATH ./fluxgui & as said in the README.
The bug was related to this part of the code(because the config file has the default values for the fields latitude and zipcode empty). When you started the application and clicked the preferences in the menu the window showed up with the display_no_zipcode_or_latitude_error_box message dialog and when you clicked the ok button the application crashed. Apparently this doesn't happen anymore, other people besides me need to test it.
2018-12-13_12-46

@ntc2
Copy link
Member

ntc2 commented Dec 20, 2018

I'm getting an error about AppIndicator3 when I try to run your branch:

$ PATH=`pwd`:$PATH PYTHONPATH=`pwd`/src:$PYTHONPATH python3 fluxgui
Traceback (most recent call last):
  File "fluxgui", line 17, in <module>
    from fluxgui.fluxapp import main
  File "/home/conathan/local/opt/fluxgui-py3.git/src/fluxgui/fluxapp.py", line 8, in <module>
    gi.require_version('AppIndicator3', '0.1')
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 102, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AppIndicator3 not available

Any ideas? These are the packages with "appindicator" in the name that I have installed (Ubuntu 16.04):

$ aptitude search '~iapp.*ind'                                                       
i A libappindicator1                  - Application Indicators                      
i   libappindicator3-1                - Application Indicators                      
i   python-appindicator               - Python bindings for libappindicator

@ntc2
Copy link
Member

ntc2 commented Dec 20, 2018

Solved the AppIndicator3 problem with sudo apt install gir1.2-appindicator3-0.1, as suggested here. The libappindicator3-dev package depends on that gir1.2-appindicator3-0.1, but I didn't have that one installed.

@ntc2
Copy link
Member

ntc2 commented Dec 20, 2018

Ran into another problem that might be harder to fix: it looks like the version of GTK3 that ships with my Ubuntu 16.04 is too old. I should have a chance to continue with this on Friday.

Current way to run fluxgui locally without installing the schemas globally (in the repo root):

glib-compile-schemas .
mkdir glib-2.0/schemas -p
cd glib-2.0/schemas 
ln -fs ../../gschemas.compiled ./
cd ../..
XDG_DATA_DIRS=`pwd`:$XDG_DATA_DIRS PATH=`pwd`:$PATH PYTHONPATH=`pwd`/src:$PYTHONPATH python3 fluxgui

But that fails with

(fluxgui:21450): Gtk-ERROR **: failed to add UI: /home/conathan/local/opt/fluxgui-py3.git/src/fluxgui/preferences.glade:5:1 Required gtk+ version 3.20, current version is 3.18
zsh: trace trap (core dumped)  XDG_DATA_DIRS=`pwd`:$XDG_DATA_DIRS PATH=`pwd`:$PATH PYTHONPATH= python3 

(According to
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/ch29s06.html
the schemas are searched for under glib-2.0/schemas in all dirs in
$XDG_DATA_DIRS.)

@LaBatata101
Copy link
Collaborator Author

I'm using manjaro so the packages are always the latest version, just put you gtk version in this line . I think should work

The systray icon is working now!
2018-12-20_13-21

@ntc2
Copy link
Member

ntc2 commented Dec 23, 2018

I wish I would have read your last comment about changing my GTK version in the .glade file first, but instead I decided to do a long overdue upgrade from Ubuntu 16.04 to 18.04 in order to get the newer GTK version. After spending many hours unbreaking my window manager setup, I was ready to continue with this and found out that xflux doesn't work on my laptop anymore! Oh, the irony. Specifically, I'm experiencing #27 now :(

However, I am able to run your PR now, my screen color just doesn't change ...

@LaBatata101
Copy link
Collaborator Author

I wish I would have read your last comment about changing my GTK version in the .glade file first, but instead I decided to do a long overdue upgrade from Ubuntu 16.04 to 18.04 in order to get the newer GTK version. After spending many hours unbreaking my window manager setup, I was ready to continue with this and found out that xflux doesn't work on my laptop anymore! Oh, the irony. Specifically, I'm experiencing #27 now :(

However, I am able to run your PR now, my screen color just doesn't change ...

That's sucks. What we do now?

@ntc2
Copy link
Member

ntc2 commented Dec 23, 2018

Let my see I can use your .glade fix to run your PR in a Ubuntu 16.04 VM ...

@LaBatata101 LaBatata101 mentioned this issue Dec 24, 2018
6 tasks
@ntc2
Copy link
Member

ntc2 commented Dec 24, 2018

The 16.04 VM didn't work -- I guess it just passes the graphics through to the underlying 18.04 system -- but next I will try using an old laptop that still had 16.04 installed ...

And FYI, I rebased the PR onto a newer version of this repo, and then --force-with-lease pushed to your fork repo.

@ntc2
Copy link
Member

ntc2 commented Dec 24, 2018

Instead of trying on the old laptop, I worked on updating the setup.py to work with Python 3. However, when I do the local install with

./setup.py install --user --record installed.txt

the icon is broken/doesn't show up, and when I do the global install with

sudo ./setup.py install --record installed.txt

the permissions are messed up: many files get created with mode rwx------ and so when I run fluxgui it fails with permissions errors. If I do

xargs sudo chmod -R a+rX < installed.txt

after doing the global install then I can run fluxgui and get an icon.

So, question: how are you installing fluxgui to test it?

@ntc2
Copy link
Member

ntc2 commented Dec 24, 2018

Actually, the local install works OK now?! And to clarify, I haven't modified the setup.py to install the gschema, i'm just doing GSETTINGS_SCHEMA_DIR=. fluxgui to use the gschemas.compiled I have locally.

@LaBatata101
Copy link
Collaborator Author

Instead of trying on the old laptop, I worked on updating the setup.py to work with Python 3. However, when I do the local install with

./setup.py install --user --record installed.txt

the icon is broken/doesn't show up, and when I do the global install with

sudo ./setup.py install --record installed.txt

the permissions are messed up: many files get created with mode rwx------ and so when I run fluxgui it fails with permissions errors. If I do

xargs sudo chmod -R a+rX < installed.txt

after doing the global install then I can run fluxgui and get an icon.

So, question: how are you installing fluxgui to test it?

I didn't have permissions issues, I think because I'm using pyenv...
Also, I found out one thing about the icon being broken. If I run with XDG_DATA_DIRS=`pwd`:$XDG_DATA_DIRS fluxgui the icon shows up otherwise don't

@ntc2
Copy link
Member

ntc2 commented Dec 24, 2018

OK, well we're going to need a way to install fluxgui system wide that's compatible with Debian package creation (for the PPA). I assume pyenv is not an option for that, but I'm not sure. Could you try installing and running fluxgui using setup.py like this:

sudo ./setup.py install --record installed.txt
xargs sudo chmod -R a+rX < installed.txt
glib-compile-schemas .
GSETTINGS_SCHEMA_DIR=. fluxgui

Do you get an icon? (I get an icon, altho it's not the right icon for my theme, but I'm not sure who's fault that is yet).

When you're done you can uninstall all the files that setup.py created with

sudo xargs rm -vr < installed.txt

The other thing we need to figure out is how to actually install and compile the .gschema.xml, instead of running glib-compile-schemas . and then using GSETTING_SCHEMA_DIR=.. If we could find a Debian package for a Python 3 program that uses a .gchema.xml that would probably include a solution.

@LaBatata101
Copy link
Collaborator Author

LaBatata101 commented Dec 24, 2018

I've created a solution for compiling the .gschema.xml file and setting GSETTING_SCHEMA_DIR, it's in this branch. If works in your pc I will merge to master. I only modified setup.py and flluxapp.py

@LaBatata101
Copy link
Collaborator Author

OK, well we're going to need a way to install fluxgui system wide that's compatible with Debian package creation (for the PPA). I assume pyenv is not an option for that, but I'm not sure. Could you try installing and running fluxgui using setup.py like this:

sudo ./setup.py install --record installed.txt
xargs sudo chmod -R a+rX < installed.txt
glib-compile-schemas .
GSETTINGS_SCHEMA_DIR=. fluxgui

Do you get an icon? (I get an icon, altho it's not the right icon for my theme, but I'm not sure who's fault that is yet).

When you're done you can uninstall all the files that setup.py created with

sudo xargs rm -vr < installed.txt

The other thing we need to figure out is how to actually install and compile the .gschema.xml, instead of running glib-compile-schemas . and then using GSETTING_SCHEMA_DIR=.. If we could find a Debian package for a Python 3 program that uses a .gchema.xml that would probably include a solution.

I ran without problems but didn't get the icon working

@ntc2
Copy link
Member

ntc2 commented Dec 25, 2018 via email

@LaBatata101
Copy link
Collaborator Author

I made a new version, check it out. In this version setup.py checks if we have sudo permission and install gschema.xml globally otherwise locally. And fluxapp.py check if gschema.xml is installed locally, if so, set GSETTINGS_SCHEMA_DIR enviroment variable.

@ntc2
Copy link
Member

ntc2 commented Dec 26, 2018

I looked at your new version -- diff here LaBatata101/fluxgui@master...LaBatata101:pre_install -- but I'd like a solution that uses setup.py's built-in support for global vs --user installs. What you're doing is trying to guess which mode setup.py is being run in based the UID, and guessing paths based on __file__. I realize I'm probably not being very clear about what kind of solution I'm looking for, so let me try to come up with one and show you ...

In the mean time, I think I figured out how to get the permissions right for the global setup.py install. Could you try the following and see if the icon shows up correctly for you? What happens if you do

# Fix any permissions that setup.py has already screwed up.
sudo chmod -R a+rX /usr/local/share/icons /usr/local/share/applications /usr/local/lib/python*/dist-packages
# Install globally using setup.py, but with umask set to avoid setup.py creating directories with the wrong permissions.
sudo sh -c 'umask 000 && ./setup.py install --record installed.txt'
# Fix permissions for any files that setup.py copied with too restrictive permissions.
xargs sudo chmod -R a+rX < installed.txt
# Run fluxgui on PATH
GSETTINGS_SCHEMA_DIR=. `which fluxgui`

In the last step is the same as GSETTINGS_SCHEMA_DIR=. fluxgui of course, but I want to clear that I don't mean run the the fluxgui from the repo with GSETTINGS_SCHEMA_DIR=. ./fluxgui.

In other news, I changed the GTK3 version bound in the .glade file as you suggested and can now run fluxgui in Ubuntu 16.04 both with the --local and global setup.py installs (but using the GSETTINGS_SCHEMA_DIR=. hack of course). The icon shows up correctly, so I think it's just the gschema.xml stuff that remains ...

@LaBatata101
Copy link
Collaborator Author

Weird, I don't have these permissions problems. Anyway, here's the new version it uses distutils.command.install to create a custom install command.

@ntc2
Copy link
Member

ntc2 commented Dec 27, 2018

Weird, I don't have these permissions problems.

Which means the fluxgui icon shows up correctly when you use the global setup.py install? Last time you said "I ran without problems but didn't get the icon working". On my system, the icon problem was due to bad permissions on /usr/local/share/icons.

Anyway, here's the new version it uses distutils.command.install to create a custom install command.

That's closer, but we should use the data_files to install apps.fluxgui.gschema.xml into share/glib-2.0/schemas, with setup.py taking care of what prefix to use (as it does with all files in data_files). Then we want to get setup.py to tell us where it installed apps.fluxgui.gschema.xml so we can run glib-compile-schemas there.

@LaBatata101
Copy link
Collaborator Author

The icon shows up, forgot to say. But I don't know if we will have acess to data_files variable. The distutils doc is very poorly.

@ntc2
Copy link
Member

ntc2 commented Dec 27, 2018

Glad to hear the icon shows up for you now!

Re the lack of distutils documentation, here's a program that uses setup.py to install a .gschema.xml file and run glib-compile-schemas: https://gitlab.gnome.org/GNOME/meld.

Their glib-compile-schemas magic is here:
https://gitlab.gnome.org/GNOME/meld/blob/master/meld/build_helpers.py#L390

Their setup is more complicated than ours, because they need to support Windows NT and have special logic for that: https://gitlab.gnome.org/GNOME/meld/blob/master/meld/build_helpers.py#L71

We just need a very simple version of their setup. I'll implement it tonight ...

@LaBatata101
Copy link
Collaborator Author

Great!!!!

@ntc2
Copy link
Member

ntc2 commented Dec 27, 2018

I just pushed a version of setup.py that installs and compiles the .gschema.xml file. And it works with both global and local --user installs. So, I think we're basically ready to merge. The Debian package stuff in :/debian will probably need to be updated, but that can be fixed later.

@ntc2
Copy link
Member

ntc2 commented Dec 27, 2018

I just merged your PR (#112), thanks! The Debian install stuff is probably still out of date, and the deps in the README are probably wrong, but those can be fixed later as needed.

@ntc2 ntc2 closed this as completed Dec 27, 2018
@ntc2
Copy link
Member

ntc2 commented Dec 27, 2018

@LaBatata101 I just noticed that GitHub is not giving you credit for you fluxgui commits: https://github.com/xflux-gui/fluxgui/graphs/contributors.

I believe this is because the email address on your commits, <labatata***@linuxmail.org>, is not registered with your GitHub account. Just a heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants