gget r15 - trunk/gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r15 - trunk/gget
- Date: Wed, 25 Jun 2008 12:05:29 +0000 (UTC)
Author: johans
Date: Wed Jun 25 12:05:29 2008
New Revision: 15
URL: http://svn.gnome.org/viewvc/gget?rev=15&view=rev
Log:
Respect GNOMEs toolbar style setting.
Modified:
trunk/gget/Configuration.py
trunk/gget/MainWindow.py
Modified: trunk/gget/Configuration.py
==============================================================================
--- trunk/gget/Configuration.py (original)
+++ trunk/gget/Configuration.py Wed Jun 25 12:05:29 2008
@@ -27,6 +27,7 @@
from GUI import ErrorDialog
DIR_GGET = "/apps/gget"
+DIR_GNOME = "/desktop/gnome"
KEY_SHOW_STATUSBAR = "/general/show_statusbar"
KEY_SHOW_TOOLBAR = "/general/show_toolbar"
@@ -37,6 +38,8 @@
KEY_ASK_FOR_LOCATION = "/folders/ask_for_location"
KEY_DEFAULT_FOLDER = "/folders/default_folder"
+KEY_TOOLBAR_STYLE = "/interface/toolbar_style"
+
FUNCTION_SUFFIXES = {KEY_SHOW_TOOLBAR: 'bool',
KEY_SHOW_STATUSBAR: 'bool',
KEY_SHOW_STATUS_ICON: 'bool',
@@ -44,7 +47,9 @@
KEY_AUTOSTART: 'bool',
KEY_AUTORESUME: 'bool',
KEY_ASK_FOR_LOCATION: 'bool',
- KEY_DEFAULT_FOLDER: 'string'}
+ KEY_DEFAULT_FOLDER: 'string',
+ KEY_TOOLBAR_STYLE: 'string'
+ }
class Configuration(object):
"""Singleton representing the configuration"""
@@ -78,25 +83,25 @@
self.option_cache[key] = getattr(self, 'get_' +
os.path.basename(key))(False)
- def add_notify(self, key, callback):
- self.client.notify_add(DIR_GGET + key, callback)
+ def add_notify(self, key, callback, dir=DIR_GGET):
+ self.client.notify_add(dir + key, callback)
- def __get_option(self, option, type=None):
+ def __get_option(self, option, dir=DIR_GGET, type=None):
if self.debug:
- print '[GConf get]: %s%s' % (DIR_GGET, option)
+ print '[GConf get]: %s%s' % (dir, option)
if type:
return getattr(self.client, 'get_' +
- FUNCTION_SUFFIXES[option])(DIR_GGET + option, type)
+ FUNCTION_SUFFIXES[option])(dir + option, type)
else:
return getattr(self.client, 'get_' +
- FUNCTION_SUFFIXES[option])(DIR_GGET + option)
+ FUNCTION_SUFFIXES[option])(dir + option)
- def __set_option(self, option, value, type=None):
+ def __set_option(self, option, value, dir=DIR_GGET, type=None):
if self.debug:
- print '[GConf set]: %s%s=%s' % (DIR_GGET, option, str(value))
+ print '[GConf set]: %s%s=%s' % (dir, option, str(value))
if type:
getattr(self.client, 'set_' +
- FUNCTION_SUFFIXES[option])(DIR_GGET + option, type, value)
+ FUNCTION_SUFFIXES[option])(dir + option, type, value)
self.option_cache[option] = value
else:
getattr(self.client, 'set_' +
@@ -199,4 +204,16 @@
default_folder = property(get_default_folder, set_default_folder)
+ # Toolbar style
+ def get_toolbar_style(self, use_cache=True):
+ if use_cache:
+ return self.option_cache[KEY_TOOLBAR_STYLE]
+ else:
+ return self.__get_option(KEY_TOOLBAR_STYLE)
+
+ def set_toolbar_style(self, toolbar_style):
+ self.__set_option(KEY_TOOLBAR_STYLE, toolbar_style)
+
+ toolbar_style = property(get_toolbar_style, set_toolbar_style)
+
# vim: set sw=4 et sts=4 tw=79 fo+=l:
Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py (original)
+++ trunk/gget/MainWindow.py Wed Jun 25 12:05:29 2008
@@ -48,12 +48,15 @@
self.__connect_widgets()
self.__add_config_notifications()
+ # Set widget states from configuration
self.show_toolbar_menu_item.set_active(self.config.show_toolbar)
self.show_statusbar_menu_item.set_active(self.config.show_statusbar)
self.toolbar.props.visible = self.config.show_toolbar
self.statusbar.props.visible = self.config.show_statusbar
+ self.__set_toolbar_style(self.config.toolbar_style)
+
def __get_widgets(self):
"""Get widgets from the glade file."""
xml = gtk.glade.XML(GUI.glade_file, domain=NAME.lower())
@@ -315,8 +318,11 @@
self.__show_toolbar_key_changed)
self.config.add_notify(Configuration.KEY_SHOW_STATUSBAR,
self.__show_statusbar_key_changed)
+ self.config.add_notify(Configuration.KEY_TOOLBAR_STYLE,
+ self.__toolbar_style_key_changed)
def __show_toolbar_key_changed(self, client, cnxn_id, entry, data):
+ """Called when the gconf key for toolbar visibility is changed"""
if not entry.value:
self.toolbar.props.visible = True
elif entry.value.type == gconf.VALUE_BOOL:
@@ -325,6 +331,7 @@
self.toolbar.props.visible = True
def __show_statusbar_key_changed(self, client, cnxn_id, entry, data):
+ """Called when the gconf key for statusbar visibility is changed"""
if not entry.value:
self.statusbar.props.visible = True
elif entry.value.type == gconf.VALUE_BOOL:
@@ -332,6 +339,25 @@
else:
self.statusbar.props.visible = True
+ def __toolbar_style_key_changed(self, client, cnxn_id, entry, data):
+ """Called when the gconf key for toolbar style is changed"""
+ if not entry.value:
+ self.toolbar.set_style = "both"
+ elif entry.value.type == gconf.VALUE_STRING:
+ self.toolbar.set_style = entry.value.get_string()
+ else:
+ self.toolbar.set_style = "both"
+
+ def __set_toolbar_style(self, toolbar_style):
+ if toolbar_style == "icons":
+ self.toolbar.set_style(gtk.TOOLBAR_ICONS)
+ elif toolbar_style == "both":
+ self.toolbar.set_style(gtk.TOOLBAR_BOTH)
+ elif toolbar_style == "both-horiz":
+ self.toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
+ elif toolbar_style == "text":
+ self.toolbar.set_style(gtk.TOOLBAR_TEXT)
+
def __download_added(self, download_manager, download):
"""Called when a new download is added to DownloadManager. Adds the
download to the treeview model and sets up the update handler."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]