gget r9 - trunk/gget



Author: johans
Date: Mon Jun 16 22:39:36 2008
New Revision: 9
URL: http://svn.gnome.org/viewvc/gget?rev=9&view=rev

Log:
Added preferences entry to the status icon context menu and fixed so that the option for showing it is instantly applied.

Modified:
   trunk/gget/Main.py
   trunk/gget/MainWindow.py
   trunk/gget/PreferencesDialog.py
   trunk/gget/StatusIcon.py

Modified: trunk/gget/Main.py
==============================================================================
--- trunk/gget/Main.py	(original)
+++ trunk/gget/Main.py	Mon Jun 16 22:39:36 2008
@@ -65,8 +65,9 @@
     if config.show_main_window:
         main_window.window.show()
 
-    if config.show_status_icon:
-        status_icon = StatusIcon(main_window)
+    status_icon = StatusIcon(main_window)
+    if not config.show_status_icon:
+        status_icon.icon.set_visible(False)
 
     gtk.main()
 

Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py	(original)
+++ trunk/gget/MainWindow.py	Mon Jun 16 22:39:36 2008
@@ -62,7 +62,7 @@
 
         # Edit menu
         self.preferences_menu_item.connect("activate",
-                self.__preferences_menu_item_activate)
+                self.preferences_menu_item_activate)
 
         # Help
         self.about_menu_item.connect("activate",
@@ -75,7 +75,7 @@
         add = AddDownloadDialog()
         add.dialog.show()
 
-    def __preferences_menu_item_activate(self, menu_item):
+    def preferences_menu_item_activate(self, menu_item):
         pd = PreferencesDialog(self.config)
         pd.dialog.show()
 

Modified: trunk/gget/PreferencesDialog.py
==============================================================================
--- trunk/gget/PreferencesDialog.py	(original)
+++ trunk/gget/PreferencesDialog.py	Mon Jun 16 22:39:36 2008
@@ -28,6 +28,7 @@
 
 import Configuration
 import GUI
+from StatusIcon import StatusIcon
 from gget import NAME
 
 AUTOSTART_DIR = "~/.config/autostart"
@@ -46,6 +47,8 @@
         self.autostart_checkbutton.set_active(self.config.autostart)
         self.autoresume_checkbutton.set_active(self.config.autoresume)
 
+        self.main_window_checkbutton.set_sensitive(self.config.show_status_icon)
+
         if self.config.ask_for_location:
             self.ask_folder_radiobutton.set_active(True)
         else:
@@ -112,6 +115,8 @@
             self.status_icon_checkbutton.set_active(True)
         elif entry.value.type == gconf.VALUE_BOOL:
             value = entry.value.get_bool()
+            status_icon = StatusIcon()
+            status_icon.icon.set_visible(value)
             self.status_icon_checkbutton.set_active(value)
             # Main window must be showed if no status icon is showed
             if not value:

Modified: trunk/gget/StatusIcon.py
==============================================================================
--- trunk/gget/StatusIcon.py	(original)
+++ trunk/gget/StatusIcon.py	Mon Jun 16 22:39:36 2008
@@ -22,9 +22,19 @@
 
 from gget import NAME
 
-class StatusIcon:
-    def __init__(self, main_window):
-        self.main_window = main_window
+class StatusIcon(object):
+    """Singleton representing the status icon"""
+
+    instance = None
+
+    def __new__(type, *args):
+        if StatusIcon.instance is None:
+            StatusIcon.instance = object.__new__(type)
+            StatusIcon.instance.__init(*args)
+        return StatusIcon.instance
+
+    def __init(self, *args):
+        self.main_window = args[0]
 
         self.icon = gtk.status_icon_new_from_icon_name(NAME.lower())
 
@@ -43,6 +53,14 @@
         separator.show()
         self.context_menu.append(separator)
 
+        self.preferences_imi = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
+        self.preferences_imi.show()
+        self.context_menu.append(self.preferences_imi)
+
+        separator = gtk.SeparatorMenuItem()
+        separator.show()
+        self.context_menu.append(separator)
+
         self.quit_imi = gtk.ImageMenuItem(gtk.STOCK_QUIT)
         self.quit_imi.show()
         self.context_menu.append(self.quit_imi)
@@ -52,8 +70,10 @@
         self.icon.connect("popup-menu", self.__icon_popup_menu,
                 self.context_menu)
 
-        self.quit_imi.connect("activate", self.main_window.quit)
         self.add_imi.connect("activate", self.main_window.add_download)
+        self.preferences_imi.connect("activate",
+                self.main_window.preferences_menu_item_activate)
+        self.quit_imi.connect("activate", self.main_window.quit)
 
     def __icon_clicked(self, icon):
         if self.main_window.window.get_property("visible"):



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