gget r53 - in trunk: bin gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r53 - in trunk: bin gget
- Date: Tue, 5 Aug 2008 21:19:23 +0000 (UTC)
Author: johans
Date: Tue Aug 5 21:19:22 2008
New Revision: 53
URL: http://svn.gnome.org/viewvc/gget?rev=53&view=rev
Log:
It should now be possible to run GGet without running installing it.
Modified:
trunk/bin/gget.in
trunk/gget/ (props changed)
trunk/gget/Configuration.py
trunk/gget/GUI.py
trunk/gget/Utils.py
Modified: trunk/bin/gget.in
==============================================================================
--- trunk/bin/gget.in (original)
+++ trunk/bin/gget.in Tue Aug 5 21:19:22 2008
@@ -20,11 +20,20 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
+import os.path
PYTHON_DIR = "@PYTHONDIR@"
-if PYTHON_DIR not in sys.path:
- sys.path.insert(0, PYTHON_DIR)
+# Try to determine if we run from source or install and fix path accordingly
+def _check(path):
+ return os.path(path) and os.path.isdir(path) and \
+ os.path.isfile(path + "/AUTHORS")
+
+name = os.path.join(os.path.dirname(__file__), "..")
+if _check(name):
+ sys.path.insert(0, os.path.abspath(name))
+elif PYTHON_DIR not in sys.path:
+ sys.path.insert(0, os.path.abspath(PYTHON_DIR))
from gget import Main
Modified: trunk/gget/Configuration.py
==============================================================================
--- trunk/gget/Configuration.py (original)
+++ trunk/gget/Configuration.py Tue Aug 5 21:19:22 2008
@@ -18,6 +18,7 @@
# along with gget; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+import os
import os.path
import sys
from gettext import gettext as _
@@ -142,9 +143,13 @@
self.client.add_dir(DIR_GGET, gconf.CLIENT_PRELOAD_RECURSIVE)
self.debug = args[0] or os.getenv("GGET_DEBUG")
else:
- ed = GUI.ErrorDialog(_("Could not find configuration directory in GConf"), _("Please make sure that gget.schemas was correctly installed."))
- ed.run()
- sys.exit(1)
+ if Utils.runned_from_source():
+ os.system("gconftool-2 --install-schema-file %s" %
+ os.path.join(Utils.get_data_dir(), "gget.schemas"))
+ else:
+ ed = GUI.ErrorDialog(_("Could not find configuration directory in GConf"), _("Please make sure that gget.schemas was correctly installed."))
+ ed.run()
+ sys.exit(1)
def add_notify(self, key, callback, dir=DIR_GGET):
self.client.notify_add(dir + key, callback)
Modified: trunk/gget/GUI.py
==============================================================================
--- trunk/gget/GUI.py (original)
+++ trunk/gget/GUI.py Tue Aug 5 21:19:22 2008
@@ -28,11 +28,11 @@
import gnome.ui
import Utils
-from gget import NAME, DATA_DIR, LOCALE_DIR, IMAGES_DIR
+from gget import NAME, LOCALE_DIR
gtk.glade.bindtextdomain(NAME.lower(), LOCALE_DIR)
-glade_file = os.path.join(DATA_DIR, "gget.glade")
+glade_file = os.path.join(Utils.get_data_dir(), "gget.glade")
icon_theme = gtk.icon_theme_get_default()
@@ -46,7 +46,7 @@
pixbuf = None
if icon != None and icon != "":
try:
- icon_file = os.path.join(IMAGES_DIR, icon)
+ icon_file = os.path.join(Utils.get_images_dir(), icon)
if os.path.exists(icon_file):
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_file, width,
height)
@@ -66,6 +66,14 @@
return pixbuf
+# Register our icon with the icon theme if running from source
+if Utils.runned_from_source():
+ for size in [16, 22, 24, 32]:
+ icon_dir = os.path.join(Utils.get_images_dir(), "%sx%s" % (size, size))
+ icon_file = os.path.join(icon_dir, "gget.png")
+ pixbuf = load_icon(icon_file, size, size)
+ gtk.icon_theme_add_builtin_icon(NAME.lower(), size, pixbuf)
+
def load_icon_from_mime_type(mime_type, size=48):
"""Loads an icon from a mime type string. This is ugly and error prone,
there must be a better way to do this."""
Modified: trunk/gget/Utils.py
==============================================================================
--- trunk/gget/Utils.py (original)
+++ trunk/gget/Utils.py Tue Aug 5 21:19:22 2008
@@ -19,6 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import fnmatch
+import os
import os.path
import time
@@ -28,6 +29,40 @@
from Configuration import Configuration
+def runned_from_source():
+ path = os.path.join(os.path.dirname(__file__), "..")
+ return os.path.exists(path) and os.path.isdir(path) and \
+ os.path.isfile(path + "/AUTHORS")
+
+__data_dir = None
+def get_data_dir():
+ global __data_dir
+ if __data_dir is None:
+ if runned_from_source():
+ __data_dir = os.sep.join([os.path.dirname(__file__), "..",
+ "data"])
+ else:
+ try:
+ import gget
+ __data_dir = gget.DATA_DIR
+ except:
+ __data_dir = "./data"
+ return __data_dir
+
+__images_dir = None
+def get_images_dir():
+ global __images_dir
+ if __images_dir is None:
+ if runned_from_source():
+ __images_dir = os.path.join(get_data_dir(), "images")
+ else:
+ try:
+ import gget
+ __images_dir = gget.IMAGES_DIR
+ except:
+ __images_dir = "./data/images"
+ return __images_dir
+
def get_readable_size(bits):
if bits is None:
return ""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]