After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 681883 - Make clocks installable
Make clocks installable
Status: RESOLVED FIXED
Product: gnome-clocks
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Clocks maintainer(s)
Clocks maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-08-14 22:29 UTC by Paolo Borelli
Modified: 2012-08-16 13:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rename 'src' dir to 'gnomeclocks' (1.75 KB, patch)
2012-08-14 22:29 UTC, Paolo Borelli
none Details | Review
Move gnome_clocks.py to gnome-clocks (3.12 KB, patch)
2012-08-14 22:29 UTC, Paolo Borelli
none Details | Review
Load css and image files from the correct dir (5.28 KB, patch)
2012-08-14 22:30 UTC, Paolo Borelli
none Details | Review
Make gnome-clocks installable (1.07 KB, patch)
2012-08-14 22:30 UTC, Paolo Borelli
none Details | Review
Add a basic desktop file. (916 bytes, patch)
2012-08-14 22:30 UTC, Paolo Borelli
none Details | Review
first patch (15.01 KB, patch)
2012-08-14 22:31 UTC, Paolo Borelli
none Details | Review
Split the GtkApplication code in app.py (23.40 KB, patch)
2012-08-15 08:58 UTC, Paolo Borelli
none Details | Review
Remove unused files (15.05 KB, patch)
2012-08-15 13:58 UTC, Paolo Borelli
none Details | Review
Rename 'src' dir to 'gnomeclocks' (36.74 KB, patch)
2012-08-15 13:58 UTC, Paolo Borelli
none Details | Review
Move gnome_clocks.py to gnome-clocks (3.27 KB, patch)
2012-08-15 13:58 UTC, Paolo Borelli
none Details | Review
Load css and image files from the correct dir (5.26 KB, patch)
2012-08-15 13:58 UTC, Paolo Borelli
none Details | Review
Make gnome-clocks installable (1.07 KB, patch)
2012-08-15 13:58 UTC, Paolo Borelli
none Details | Review
Add a basic desktop file. (916 bytes, patch)
2012-08-15 13:59 UTC, Paolo Borelli
none Details | Review
Split the GtkApplication code in app.py (23.32 KB, patch)
2012-08-15 13:59 UTC, Paolo Borelli
none Details | Review
Add i18n support (16.25 KB, patch)
2012-08-15 13:59 UTC, Paolo Borelli
none Details | Review
Rename 'src' dir to 'gnomeclocks' (139.30 KB, patch)
2012-08-15 17:51 UTC, Paolo Borelli
none Details | Review

Description Paolo Borelli 2012-08-14 22:29:53 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.
Comment 1 Paolo Borelli 2012-08-14 22:29:55 UTC
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.
Comment 2 Paolo Borelli 2012-08-14 22:29:58 UTC
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)
Comment 3 Paolo Borelli 2012-08-14 22:30:01 UTC
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.
Comment 4 Paolo Borelli 2012-08-14 22:30:04 UTC
Created attachment 221201 [details] [review]
Make gnome-clocks installable

Add a setup.py file that uses python-distutils-extra.
Comment 5 Paolo Borelli 2012-08-14 22:30:07 UTC
Created attachment 221202 [details] [review]
Add a basic desktop file.

The "Comment" field is taken from the bugzilla description
Comment 6 Paolo Borelli 2012-08-14 22:31:59 UTC
Created attachment 221203 [details] [review]
first patch

Ops, when using "git bz" I missed the first preliminary commit that just removes some unused files
Comment 7 Paolo Borelli 2012-08-15 08:58:28 UTC
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
Comment 8 Paolo Borelli 2012-08-15 13:58:03 UTC
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
Comment 9 Paolo Borelli 2012-08-15 13:58:14 UTC
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.
Comment 10 Paolo Borelli 2012-08-15 13:58:33 UTC
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)
Comment 11 Paolo Borelli 2012-08-15 13:58:43 UTC
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.
Comment 12 Paolo Borelli 2012-08-15 13:58:57 UTC
Created attachment 221260 [details] [review]
Make gnome-clocks installable

Add a setup.py file that uses python-distutils-extra.
Comment 13 Paolo Borelli 2012-08-15 13:59:08 UTC
Created attachment 221261 [details] [review]
Add a basic desktop file.

The "Comment" field is taken from the bugzilla description
Comment 14 Paolo Borelli 2012-08-15 13:59:18 UTC
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
Comment 15 Paolo Borelli 2012-08-15 13:59:27 UTC
Created attachment 221263 [details] [review]
Add i18n support

Add the gettext machinery and try to mark the translatables strings
with _()
Comment 16 Paolo Borelli 2012-08-15 14:01:17 UTC
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
Comment 17 Paolo Borelli 2012-08-15 17:51:39 UTC
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
Comment 18 Paolo Borelli 2012-08-16 12:42:29 UTC
pushed
Comment 19 Maël Lavault 2012-08-16 12:51:43 UTC
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 _
Comment 20 Paolo Borelli 2012-08-16 13:33:47 UTC
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!