[gnome-clocks] Port build system to autotools



commit 39d5c151efc5962c9a801d9b495a820bea93dd5a
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 9 23:36:57 2012 +0100

    Port build system to autotools
    
    I really tried to stick to distutils(-extras) this time, but it is time
    to give up. We need something that deals well with --prefix, propery
    check for dependecies and that will easily allow us to have some C
    modules if needed.
    
    While touching the build system I also reorganized files a bit

 .gitignore                                         |    4 -
 Makefile.am                                        |   99 +++++++++
 README                                             |   26 ---
 autogen.sh                                         |   19 ++
 configure.ac                                       |   44 ++++
 data/{ => css}/button-border-go-active.svg         |    0
 data/{ => css}/button-border-go.svg                |    0
 data/{ => css}/button-border-stop-active.svg       |    0
 data/{ => css}/button-border-stop.svg              |    0
 data/{gtk-style.css => css/gnome-clocks.css}       |    0
 data/gnome-clocks.desktop.in                       |    2 +-
 .../16x16/apps/gnome-clocks.png}                   |  Bin 1004 -> 1004 bytes
 .../22x22/apps/gnome-clocks.png}                   |  Bin 1493 -> 1493 bytes
 .../256x256/apps/gnome-clocks.png}                 |  Bin 30951 -> 30951 bytes
 .../32x32/apps/gnome-clocks.png}                   |  Bin 2460 -> 2460 bytes
 .../48x48/apps/gnome-clocks.png}                   |  Bin 4140 -> 4140 bytes
 .../icons/{clocks.svg => hicolor/gnome-clocks.svg} |    0
 data/{cities => images}/day.jpg                    |  Bin 79416 -> 79416 bytes
 data/{cities => images}/day.png                    |  Bin 34012 -> 34012 bytes
 data/{cities => images}/night.jpg                  |  Bin 6426 -> 6426 bytes
 data/{cities => images}/night.png                  |  Bin 5169 -> 5169 bytes
 git.mk                                             |  218 ++++++++++++++++++++
 gnome-clocks                                       |   34 ---
 gnomeclocks/__init__.py                            |   16 ++-
 gnomeclocks/alarm.py                               |    2 +-
 gnomeclocks/app.py                                 |   10 +-
 gnomeclocks/defs.py.in                             |    6 +
 gnomeclocks/utils.py                               |   29 +--
 gnomeclocks/world.py                               |    4 +-
 m4/.gitignore                                      |    3 +
 setup.py                                           |   23 --
 31 files changed, 423 insertions(+), 116 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..55c27a3
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,99 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = po
+
+# desktop file
+# (we can't use INTLTOOL_DESKTOP_RULE here due to lp#605826)
+%.desktop: %.desktop.in
+	$(MKDIR_P) $(dir $@); LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
+applicationsdir = $(datadir)/applications
+applications_DATA = data/gnome-clocks.desktop
+dist_noinst_DATA = data/gnome-clocks.desktop.in
+
+# icons
+icon16dir = $(datadir)/icons/hicolor/16x16/apps
+icon16_DATA = data/icons/hicolor/16x16/apps/gnome-clocks.png
+icon22dir = $(datadir)/icons/hicolor/22x22/apps
+icon22_DATA = data/icons/hicolor/22x22/apps/gnome-clocks.png
+icon32dir = $(datadir)/icons/hicolor/32x32/apps
+icon32_DATA = data/icons/hicolor/32x32/apps/gnome-clocks.png
+icon48dir = $(datadir)/icons/hicolor/48x48/apps
+icon48_DATA = data/icons/hicolor/48x48/apps/gnome-clocks.png
+icon256dir = $(datadir)/icons/hicolor/256x256/apps
+icon256_DATA = data/icons/hicolor/256x256/apps/gnome-clocks.png
+icon_files = \
+	$(icon16_DATA) \
+	$(icon22_DATA) \
+	$(icon32_DATA) \
+	$(icon48_DATA) \
+	$(icon256_DATA) \
+	data/icons/hicolor/gnome-clocks.svg
+
+gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+
+install-data-hook: update-icon-cache
+uninstall-hook: update-icon-cache
+update-icon-cache:
+	@-if test -z "$(DESTDIR)"; then \
+		echo "Updating Gtk icon cache."; \
+		$(gtk_update_icon_cache); \
+	else \
+		echo "*** Icon cache not updated.  After (un)install, run this:"; \
+		echo "***   $(gtk_update_icon_cache)"; \
+	fi
+
+# images
+imagesdir = $(datadir)/gnome-clocks/images
+images_DATA = \
+	data/images/day.png \
+	data/images/night.png
+
+# css
+cssdir = $(datadir)/gnome-clocks/css
+css_DATA = \
+	data/css/gnome-clocks.css \
+	data/css/button-border-go-active.svg \
+	data/css/button-border-go.svg \
+	data/css/button-border-stop-active.svg \
+	data/css/button-border-stop.svg
+
+# main script
+bin_SCRIPTS = gnome-clocks
+
+# python module (nobase means dirname is preserved in site-packages
+packagesdir = $(pythondir)
+nobase_dist_packages_PYTHON = \
+	$(wildcard $(srcdir)/gnomeclocks/*.py)
+
+EXTRA_DIST = \
+	$(icon_files) \
+	$(images_DATA) \
+	$(css_DATA) \
+	$(bin_SCRIPTS)
+
+CLEANFILES = \
+	$(applications_DATA)
+	$(wildcard $(srcdir)/gnomeclocks/*.pyc)
+
+DISTCLEANFILES = \
+	gnomeclocks/defs.py
+
+MAINTAINERCLEANFILES = 		\
+	ABOUT-NLS \
+	aclocal.m4 \
+	config.guess \
+	config.rpath \
+	config.sub \
+	install-sh \
+	missing \
+	po/Makevars.template \
+	po/Rules-quot \
+	po/boldquot.sed \
+	po/en boldquot header \
+	po/en quot header \
+	po/insert-header.sin \
+	po/quot.sed \
+	po/remove-potcdate.sin \
+	py-compile
+
+-include $(top_srcdir)/git.mk
diff --git a/README b/README
index b5323be..c065d52 100644
--- a/README
+++ b/README
@@ -13,29 +13,3 @@ Requirements
 - libnotify
 
 
-Installing
-----------
- - It is not mandatory to install, you can run the program from the source directory
- - If you want to install, run ./setup.py install (if you want you can specify an
-   installation prefix, e.g. ./setup.py install --prefix=/opt/gnome
-
-
-Running
--------
-
- - To run the program from the source directory, simply use ./gnome-clocks
- - If you installed the program in a custom prefix, you will need to export
-   the following environment variables:
-
-export GNOME_CLOCKS_IMAGE_PATH=/opt/gnome/share/gnome-clocks
-export GNOME_CLOCKS_DATA_PATH=/opt/gnome/share/gnome-clocks
-export GNOME_CLOCKS_LOCALE_PATH=/opt/gnome/share/locale
-
-   where "/opt/gnome" is the installation prefix. If you are using jhbuild
-   you can add the following lines to your .jhbuildrc file:
-
-os.environ['GNOME_CLOCKS_DATA_PATH'] = '/opt/gnome/share/gnome-clocks'
-os.environ['GNOME_CLOCKS_IMAGE_PATH'] = '/opt/gnome/share/gnome-clocks'
-os.environ['GNOME_CLOCKS_LOCALE_PATH'] = '/opt/gnome/share/locale'
-
-
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a69b69b
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+PKG_NAME="gnome-clocks"
+
+test -f $srcdir/configure.ac || {
+    echo "**Error**: Directory "\`$srcdir\'" does not look like the top-level $PKG_NAME directory"
+    exit 1
+}
+
+which gnome-autogen.sh || {
+    echo "You need to install gnome-common from GNOME Git (or from your OS vendor's package manager)."
+    exit 1
+}
+
+. gnome-autogen.sh "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..5156985
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,44 @@
+AC_PREREQ(2.63)
+
+AC_INIT([gnome-clocks],
+        [0.1.6],
+        [http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-clocks],
+        [gnome-clocks])
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip foreign])
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+
+AM_PATH_PYTHON([2.7])
+
+IT_PROG_INTLTOOL(0.40)
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.17])
+GETTEXT_PACKAGE=AC_PACKAGE_NAME
+AC_SUBST([GETTEXT_PACKAGE])
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
+
+PKG_PROG_PKG_CONFIG([0.22])
+
+PKG_CHECK_MODULES(CLOCKS, [
+    pycairo
+    pygobject-3.0 > 3.4.2
+])
+
+AC_CONFIG_FILES([
+    Makefile
+    gnomeclocks/defs.py
+    po/Makefile.in
+])
+
+AC_OUTPUT
+
+echo "
+    gnome-clocks ${VERSION}
+
+    prefix: ${prefix}
+    Python interpreter: ${PYTHON}
+
+    Now type 'make' to build ${PACKAGE}
+"
diff --git a/data/button-border-go-active.svg b/data/css/button-border-go-active.svg
similarity index 100%
rename from data/button-border-go-active.svg
rename to data/css/button-border-go-active.svg
diff --git a/data/button-border-go.svg b/data/css/button-border-go.svg
similarity index 100%
rename from data/button-border-go.svg
rename to data/css/button-border-go.svg
diff --git a/data/button-border-stop-active.svg b/data/css/button-border-stop-active.svg
similarity index 100%
rename from data/button-border-stop-active.svg
rename to data/css/button-border-stop-active.svg
diff --git a/data/button-border-stop.svg b/data/css/button-border-stop.svg
similarity index 100%
rename from data/button-border-stop.svg
rename to data/css/button-border-stop.svg
diff --git a/data/gtk-style.css b/data/css/gnome-clocks.css
similarity index 100%
rename from data/gtk-style.css
rename to data/css/gnome-clocks.css
diff --git a/data/gnome-clocks.desktop.in b/data/gnome-clocks.desktop.in
index f919229..5aa5b65 100644
--- a/data/gnome-clocks.desktop.in
+++ b/data/gnome-clocks.desktop.in
@@ -5,7 +5,7 @@ _X-GNOME-FullName=GNOME Clocks
 _Comment=Clocks for world times, plus alarms, stopwatch and a timer
 _Keywords=time;timer;alarm;world clock;stopwatch;time zone;
 Exec=gnome-clocks
-Icon=clocks
+Icon=gnome-clocks
 Terminal=false
 Type=Application
 Categories=GNOME;GTK;Utility;Clock;
diff --git a/data/icons/16x16/apps/clocks.png b/data/icons/hicolor/16x16/apps/gnome-clocks.png
similarity index 100%
rename from data/icons/16x16/apps/clocks.png
rename to data/icons/hicolor/16x16/apps/gnome-clocks.png
diff --git a/data/icons/22x22/apps/clocks.png b/data/icons/hicolor/22x22/apps/gnome-clocks.png
similarity index 100%
rename from data/icons/22x22/apps/clocks.png
rename to data/icons/hicolor/22x22/apps/gnome-clocks.png
diff --git a/data/icons/256x256/apps/clocks.png b/data/icons/hicolor/256x256/apps/gnome-clocks.png
similarity index 100%
rename from data/icons/256x256/apps/clocks.png
rename to data/icons/hicolor/256x256/apps/gnome-clocks.png
diff --git a/data/icons/32x32/apps/clocks.png b/data/icons/hicolor/32x32/apps/gnome-clocks.png
similarity index 100%
rename from data/icons/32x32/apps/clocks.png
rename to data/icons/hicolor/32x32/apps/gnome-clocks.png
diff --git a/data/icons/48x48/apps/clocks.png b/data/icons/hicolor/48x48/apps/gnome-clocks.png
similarity index 100%
rename from data/icons/48x48/apps/clocks.png
rename to data/icons/hicolor/48x48/apps/gnome-clocks.png
diff --git a/data/icons/clocks.svg b/data/icons/hicolor/gnome-clocks.svg
similarity index 100%
rename from data/icons/clocks.svg
rename to data/icons/hicolor/gnome-clocks.svg
diff --git a/data/cities/day.jpg b/data/images/day.jpg
similarity index 100%
rename from data/cities/day.jpg
rename to data/images/day.jpg
diff --git a/data/cities/day.png b/data/images/day.png
similarity index 100%
rename from data/cities/day.png
rename to data/images/day.png
diff --git a/data/cities/night.jpg b/data/images/night.jpg
similarity index 100%
rename from data/cities/night.jpg
rename to data/images/night.jpg
diff --git a/data/cities/night.png b/data/images/night.png
similarity index 100%
rename from data/cities/night.png
rename to data/images/night.png
diff --git a/git.mk b/git.mk
new file mode 100644
index 0000000..5313358
--- /dev/null
+++ b/git.mk
@@ -0,0 +1,218 @@
+# git.mk
+#
+# Copyright 2009, Red Hat, Inc.
+# Copyright 2010,2011 Behdad Esfahbod
+# Written by Behdad Esfahbod
+#
+# Copying and distribution of this file, with or without modification,
+# is permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+#
+# The canonical source for this file is https://github.com/behdad/git.mk.
+#
+# To use in your project, import this file in your git repo's toplevel,
+# then do "make -f git.mk".  This modifies all Makefile.am files in
+# your project to -include git.mk.  Remember to add that line to new
+# Makefile.am files you create in your project, or just rerun the
+# "make -f git.mk".
+#
+# This enables automatic .gitignore generation.  If you need to ignore
+# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
+# But think twice before doing that.  If a file has to be in .gitignore,
+# chances are very high that it's a generated file and should be in one
+# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
+#
+# The only case that you need to manually add a file to GITIGNOREFILES is
+# when remove files in one of mostlyclean-local, clean-local, distclean-local,
+# or maintainer-clean-local make targets.
+#
+# Note that for files like editor backup, etc, there are better places to
+# ignore them.  See "man gitignore".
+#
+# If "make maintainer-clean" removes the files but they are not recognized
+# by this script (that is, if "git status" shows untracked files still), send
+# me the output of "git status" as well as your Makefile.am and Makefile for
+# the directories involved and I'll diagnose.
+#
+# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
+# Makefile.am.sample in the git.mk git repo.
+#
+# Don't EXTRA_DIST this file.  It is supposed to only live in git clones,
+# not tarballs.  It serves no useful purpose in tarballs and clutters the
+# build dir.
+#
+# This file knows how to handle autoconf, automake, libtool, gtk-doc,
+# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu.
+#
+#
+# KNOWN ISSUES:
+#
+# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
+#   submodule doesn't find us.  If you have configure.{in,ac} files in
+#   subdirs, add a proxy git.mk file in those dirs that simply does:
+#   "include $(top_srcdir)/../git.mk".  Add more ..'s to your taste.
+#   And add those files to git.  See vte/gnome-pty-helper/git.mk for
+#   example.
+#
+
+git-all: git-mk-install
+
+git-mk-install:
+	@echo Installing git makefile
+	@any_failed=; \
+		find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
+		if grep 'include .*/git.mk' $$x >/dev/null; then \
+			echo $$x already includes git.mk; \
+		else \
+			failed=; \
+			echo "Updating $$x"; \
+			{ cat $$x; \
+			  echo ''; \
+			  echo '-include $$(top_srcdir)/git.mk'; \
+			} > $$x.tmp || failed=1; \
+			if test x$$failed = x; then \
+				mv $$x.tmp $$x || failed=1; \
+			fi; \
+			if test x$$failed = x; then : else \
+				echo Failed updating $$x; >&2 \
+				any_failed=1; \
+			fi; \
+	fi; done; test -z "$$any_failed"
+
+.PHONY: git-all git-mk-install
+
+
+### .gitignore generation
+
+$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
+	$(AM_V_GEN) \
+	{ \
+		if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
+			for x in \
+				$(DOC_MODULE)-decl-list.txt \
+				$(DOC_MODULE)-decl.txt \
+				tmpl/$(DOC_MODULE)-unused.sgml \
+				"tmpl/*.bak" \
+				xml html \
+			; do echo /$$x; done; \
+		fi; \
+		if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
+			for lc in $(DOC_LINGUAS); do \
+				for x in \
+					$(if $(DOC_MODULE),$(DOC_MODULE).xml) \
+					$(DOC_PAGES) \
+					$(DOC_INCLUDES) \
+				; do echo /$$lc/$$x; done; \
+			done; \
+			for x in \
+				$(_DOC_OMF_ALL) \
+				$(_DOC_DSK_ALL) \
+				$(_DOC_HTML_ALL) \
+				$(_DOC_MOFILES) \
+				$(DOC_H_FILE) \
+				"*/.xml2po.mo" \
+				"*/*.omf.out" \
+			; do echo /$$x; done; \
+		fi; \
+		if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
+			for lc in $(HELP_LINGUAS); do \
+				for x in \
+					$(HELP_FILES) \
+					"$$lc.stamp" \
+					"$$lc.mo" \
+				; do echo /$$lc/$$x; done; \
+			done; \
+		fi; \
+		if test "x$(gsettings_SCHEMAS)" = x; then :; else \
+			for x in \
+				$(gsettings_SCHEMAS:.xml=.valid) \
+				$(gsettings__enum_file) \
+			; do echo /$$x; done; \
+		fi; \
+		if test -f $(srcdir)/po/Makefile.in.in; then \
+			for x in \
+				po/Makefile.in.in \
+				po/Makefile.in \
+				po/Makefile \
+				po/POTFILES \
+				po/stamp-it \
+				po/.intltool-merge-cache \
+				"po/*.gmo" \
+				"po/*.mo" \
+				po/$(GETTEXT_PACKAGE).pot \
+				intltool-extract.in \
+				intltool-merge.in \
+				intltool-update.in \
+			; do echo /$$x; done; \
+		fi; \
+		if test -f $(srcdir)/configure; then \
+			for x in \
+				autom4te.cache \
+				configure \
+				config.h \
+				stamp-h1 \
+				libtool \
+				config.lt \
+			; do echo /$$x; done; \
+		fi; \
+		if test "x$(DEJATOOL)" = x; then :; else \
+			for x in \
+				$(DEJATOOL) \
+			; do echo /$$x.sum; echo /$$x.log; done; \
+			echo /site.exp; \
+		fi; \
+		for x in \
+			.gitignore \
+			$(GITIGNOREFILES) \
+			$(CLEANFILES) \
+			$(PROGRAMS) \
+			$(check_PROGRAMS) \
+			$(EXTRA_PROGRAMS) \
+			$(LTLIBRARIES) \
+			so_locations \
+			.libs _libs \
+			$(MOSTLYCLEANFILES) \
+			"*.$(OBJEXT)" \
+			"*.lo" \
+			$(DISTCLEANFILES) \
+			$(am__CONFIG_DISTCLEAN_FILES) \
+			$(CONFIG_CLEAN_FILES) \
+			TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
+			"*.tab.c" \
+			$(MAINTAINERCLEANFILES) \
+			$(BUILT_SOURCES) \
+			$(DEPDIR) \
+			Makefile \
+			Makefile.in \
+			"*.orig" \
+			"*.rej" \
+			"*.bak" \
+			"*~" \
+			".*.sw[nop]" \
+			".dirstamp" \
+		; do echo /$$x; done; \
+	} | \
+	sed "s ^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
+	sed 's@/[.]/@/@g' | \
+	LC_ALL=C sort | uniq > $  tmp && \
+	mv $  tmp $@;
+
+all: $(srcdir)/.gitignore gitignore-recurse-maybe
+gitignore-recurse-maybe:
+	@if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
+		$(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \
+	fi;
+gitignore-recurse:
+	@for subdir in $(DIST_SUBDIRS); do \
+	  case " $(SUBDIRS) " in \
+	    *" $$subdir "*) :;; \
+	    *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \
+	  esac; \
+	done
+gitignore: $(srcdir)/.gitignore gitignore-recurse
+
+maintainer-clean: gitignore-clean
+gitignore-clean:
+	-rm -f $(srcdir)/.gitignore
+
+.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
diff --git a/gnome-clocks b/gnome-clocks
index e77c0a5..68a41f7 100755
--- a/gnome-clocks
+++ b/gnome-clocks
@@ -19,42 +19,8 @@
 #
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
-import os
 import signal
 import sys
-
-# Detect if we are running from the source dir
-if os.path.exists("gnome-clocks.doap"):
-    ENV_PATHS = {
-        "GNOME_CLOCKS_DATA_PATH": "data/",
-        "GNOME_CLOCKS_IMAGE_PATH": "data/",
-        "GNOME_CLOCKS_LOCALE_PATH": "locale/",
-    }
-else:
-    ENV_PATHS = {
-        "GNOME_CLOCKS_DATA_PATH": "/usr/share/gnome-clocks/",
-        "GNOME_CLOCKS_IMAGE_PATH": "/usr/share/gnome-clocks/",
-        "GNOME_CLOCKS_LOCALE_PATH": "/usr/share/locale/",
-    }
-
-for var, path in ENV_PATHS.iteritems():
-    os.environ.setdefault(var, path)
-
-# Setup i18n support
-import locale
-import gettext
-
-from gnomeclocks.utils import Dirs
-
-locale_domain = "gnome-clocks"
-try:
-    locale.setlocale(locale.LC_ALL, '')
-except:
-    pass
-gettext.bindtextdomain(locale_domain, Dirs.get_locale_dir())
-gettext.textdomain(locale_domain)
-gettext.install(locale_domain, Dirs.get_locale_dir())
-
 from gnomeclocks.app import ClocksApplication
 
 if __name__ == "__main__":
diff --git a/gnomeclocks/__init__.py b/gnomeclocks/__init__.py
index 94a0e8a..917d541 100644
--- a/gnomeclocks/__init__.py
+++ b/gnomeclocks/__init__.py
@@ -18,7 +18,20 @@
 #
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
-__version__ = "0.1.5"
+import locale
+import gettext
+from defs import *
+
+
+# Setup i18n support
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
+gettext.bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR)
+gettext.textdomain(GETTEXT_PACKAGE)
+gettext.install(GETTEXT_PACKAGE, LOCALEDIR)
+
 
 # Credit every contributor, in alphabetical order
 AUTHORS = [
@@ -36,6 +49,7 @@ AUTHORS = [
     "Jakub Steiner"
 ]
 
+
 COPYRIGHTS = \
     """2011 Â Collabora Ltd.
        2012 Â Collabora Ltd., Seif Lotfy
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index beca06a..d17cdcf 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -411,7 +411,7 @@ class AlarmStandalone(Gtk.EventBox):
 
     def open_edit_dialog(self):
         # implicitely disable, we do not want to ring while editing.
-        self.edited_active = self.alarm.active;
+        self.edited_active = self.alarm.active
         self.alarm.set_active(False)
         window = AlarmDialog(self.get_toplevel(), self.alarm)
         window.connect("response", self._on_dialog_response)
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index 94b3e19..767aa85 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -27,7 +27,7 @@ from stopwatch import Stopwatch
 from timer import Timer
 from widgets import Embed
 from utils import Dirs
-from gnomeclocks import __version__, AUTHORS, COPYRIGHTS
+from gnomeclocks import VERSION, AUTHORS, COPYRIGHTS
 
 
 class Window(Gtk.ApplicationWindow):
@@ -46,8 +46,8 @@ class Window(Gtk.ApplicationWindow):
         self.add_action(action)
 
         css_provider = Gtk.CssProvider()
-        css_provider.load_from_path(os.path.join(Dirs.get_data_dir(),
-                                                 "gtk-style.css"))
+        css_provider.load_from_path(os.path.join(Dirs.get_css_dir(),
+                                                 "gnome-clocks.css"))
         context = Gtk.StyleContext()
         context.add_provider_for_screen(Gdk.Screen.get_default(),
                                         css_provider,
@@ -133,8 +133,8 @@ class Window(Gtk.ApplicationWindow):
         about = Gtk.AboutDialog()
         about.set_title(_("About Clocks"))
         about.set_program_name(_("GNOME Clocks"))
-        about.set_logo_icon_name("clocks")
-        about.set_version(__version__)
+        about.set_logo_icon_name("gnome-clocks")
+        about.set_version(VERSION)
         about.set_copyright(COPYRIGHTS)
         about.set_comments(
             _("Utilities to help you with the time."))
diff --git a/gnomeclocks/defs.py.in b/gnomeclocks/defs.py.in
new file mode 100644
index 0000000..11407a5
--- /dev/null
+++ b/gnomeclocks/defs.py.in
@@ -0,0 +1,6 @@
+# -.- coding: utf-8 -.-
+
+VERSION = "@VERSION@"
+GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"
+LOCALEDIR = "@prefix@/@DATADIRNAME@/locale"
+GNOMECLOCKS_DATADIR = "@prefix@/@DATADIRNAME@/gnome-clocks"
diff --git a/gnomeclocks/utils.py b/gnomeclocks/utils.py
index 9e86865..79e84fa 100644
--- a/gnomeclocks/utils.py
+++ b/gnomeclocks/utils.py
@@ -20,6 +20,7 @@ import os
 import time
 import datetime
 import pycanberra
+from gnomeclocks import GNOMECLOCKS_DATADIR
 from xdg import BaseDirectory
 from gi.repository import GObject, Gio, GnomeDesktop, Notify
 
@@ -29,29 +30,19 @@ def N_(message):
 
 
 class Dirs:
-    @staticmethod
-    def get_data_dir():
-        try:
-            path = os.environ['GNOME_CLOCKS_DATA_PATH']
-        except:
-            path = "../data"
-        return path
+    if os.path.exists(os.path.join("gnome-clocks.doap")):
+        print "Running from a source checkout, loading local data"
+        datadir = os.path.join("data")
+    else:
+        datadir = GNOMECLOCKS_DATADIR
 
     @staticmethod
-    def get_image_dir():
-        try:
-            path = os.environ['GNOME_CLOCKS_IMAGE_PATH']
-        except:
-            path = "../data"
-        return path
+    def get_css_dir():
+        return os.path.join(Dirs.datadir, "css")
 
     @staticmethod
-    def get_locale_dir():
-        try:
-            path = os.environ['GNOME_CLOCKS_LOCALE_PATH']
-        except:
-            path = "locale"
-        return path
+    def get_images_dir():
+        return os.path.join(Dirs.datadir, "images")
 
     @staticmethod
     def get_user_data_dir():
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index 5908451..ddb3e4f 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -308,9 +308,9 @@ class World(Clock):
         self.notebook.set_show_border(False)
         self.add(self.notebook)
 
-        f = os.path.join(Dirs.get_image_dir(), "cities", "day.png")
+        f = os.path.join(Dirs.get_images_dir(), "day.png")
         self.daypixbuf = GdkPixbuf.Pixbuf.new_from_file(f)
-        f = os.path.join(Dirs.get_image_dir(), "cities", "night.png")
+        f = os.path.join(Dirs.get_images_dir(), "night.png")
         self.nightpixbuf = GdkPixbuf.Pixbuf.new_from_file(f)
 
         self.liststore = Gtk.ListStore(bool, str, object)
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..84c29cc
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,3 @@
+# this directory should be empty in git
+# (but should exist)
+*



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]