GNOME Bugzilla – Bug 681883
Make clocks installable
Last modified: 2012-08-16 13:33:47 UTC
The following patchset makes gnome-clocks installable using python-distutils-extra (which is a distutils extension that is aware of .desktop files, translations, etc and which is available on all distros. The first patches are preliminary refactorings: to make things work easily the sources must be in a python module which ends up in the site-packages dir of the python install and the main script is renamed to gnome-clocks so that it matches the desktop files and all the rest.
Created attachment 221198 [details] [review] Rename 'src' dir to 'gnomeclocks' This is in preparation to making the application installable: gnomeclocks will be the directory under python's site-packages.
Created attachment 221199 [details] [review] Move gnome_clocks.py to gnome-clocks Using the dash and omitting the .py suffix is more customary for a system-wide command. Also move out of the gnomeclocks subdir since this is the "main" that uses that python module (this makes our life easier to install things)
Created attachment 221200 [details] [review] Load css and image files from the correct dir Detect at runtime if we are running from an installed setup or from the source dir and load the files from the appropriate directory. The directories are specified with the GNOME_CLOCKS_DATA_PATH and GNOME_CLOCKS_IMAGE_PATH environment variables. In the future it may make sense to add also HELP_DIR and LOCALE_DIR. To be honest I am not thrilled by this approach, but it seems like the de facto standard (d-feet, jokosher, etc do the same) The new utils.py file contains a Dirs class that makes accessing this values easier.
Created attachment 221201 [details] [review] Make gnome-clocks installable Add a setup.py file that uses python-distutils-extra.
Created attachment 221202 [details] [review] Add a basic desktop file. The "Comment" field is taken from the bugzilla description
Created attachment 221203 [details] [review] first patch Ops, when using "git bz" I missed the first preliminary commit that just removes some unused files
Created attachment 221241 [details] [review] Split the GtkApplication code in app.py Move Window and ClocksApplication to a separate app.py file, this way gnome-clocks is just a minimal script that just deals with the launch and does not contain any UI logic
Created attachment 221255 [details] [review] Remove unused files The css file is now in the data directory, main.py has been replaced by gnome_clocks.py and Makefile.am is not used
Created attachment 221256 [details] [review] Rename 'src' dir to 'gnomeclocks' This is in preparation to making the application installable: gnomeclocks will be the directory under python's site-packages. While at it, strip trailing whitespaces from the files.
Created attachment 221257 [details] [review] Move gnome_clocks.py to gnome-clocks Using the dash and omitting the .py suffix is more customary for a system-wide command. Also move out of the gnomeclocks subdir since this is the "main" that uses that python module (this makes our life easier to install things)
Created attachment 221259 [details] [review] Load css and image files from the correct dir Detect at runtime if we are running from an installed setup or from the source dir and load the files from the appropriate directory. The directories are specified with the GNOME_CLOCKS_DATA_PATH and GNOME_CLOCKS_IMAGE_PATH environment variables. In the future it may make sense to add also HELP_DIR and LOCALE_DIR. To be honest I am not thrilled by this approach, but it seems like the de facto standard (d-feet, jokosher, etc do the same) The new utils.py file contains a Dirs class that makes accessing this values easier.
Created attachment 221260 [details] [review] Make gnome-clocks installable Add a setup.py file that uses python-distutils-extra.
Created attachment 221261 [details] [review] Add a basic desktop file. The "Comment" field is taken from the bugzilla description
Created attachment 221262 [details] [review] Split the GtkApplication code in app.py Move Window and ClocksApplication to a separate app.py file, this way gnome-clocks is just a minimal script that just deals with the launch and does not contain any UI logic
Created attachment 221263 [details] [review] Add i18n support Add the gettext machinery and try to mark the translatables strings with _()
I reuploaded the whole patchset (sorry for the spam) since I amended the patches here and there to fix some minor whitespace issues. I also added a new patch to the series that adds i18n support using gettext
Created attachment 221295 [details] [review] Rename 'src' dir to 'gnomeclocks' When testing I spotted an error in the 2nd patch of the set: my script to remove trailing spaces ate the last line of a couple of files. This updated patch fixes that and replaces the 2nd one in the series
pushed
For i18n, i would suggest that you use gettext.install(LOCALE_DOMAIN, LOCALE_DIR) to install it to python namespace. It feels cleaner than : from gettext import gettext as _
I am no gettext expert, just followed some instructions I found on "sugar" website. Feel free to open a new bugreport and attach a patch, thanks!