[Pkg-bazaar-commits] ./bzr-gtk/unstable r619: Add notifications tab in preferences dialog.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:50:58 UTC 2009


------------------------------------------------------------
revno: 619
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-10-28 17:02:01 +0100
message:
  Add notifications tab in preferences dialog.
added:
  preferences/notifications.py
modified:
  notify.py
  preferences/__init__.py
-------------- next part --------------
=== modified file 'notify.py'
--- a/notify.py	2008-07-18 20:19:45 +0000
+++ b/notify.py	2008-10-28 16:02:01 +0000
@@ -17,6 +17,13 @@
 """Notification area icon and notification for Bazaar."""
 
 import gtk
+import bzrlib.plugins.dbus
+
+def has_dbus():
+    return (getattr(bzrlib.plugins, "dbus", None) is not None)
+
+def has_avahi():
+    return (getattr(bzrlib.plugins, "avahi", None) is not None)
 
 class NotifyPopupMenu(gtk.Menu):
     def __init__(self):
@@ -24,26 +31,26 @@
         self.create_items()
 
     def create_items(self):
+        item = gtk.CheckMenuItem('_Gateway to LAN')
+        item.connect('toggled', self.toggle_lan_gateway)
+        self.append(item)
+        self.append(gtk.SeparatorMenuItem())
         try:
             from bzrlib.plugins.dbus.activity import LanGateway
             self.langateway = LanGateway()
-            item = gtk.CheckMenuItem('_Gateway to LAN')
-            item.connect('toggled', self.toggle_lan_gateway)
-            self.append(item)
-            self.append(gtk.SeparatorMenuItem())
         except ImportError:
-            pass
+            item.set_sensitive(False)
 
+        item = gtk.CheckMenuItem('Announce _branches on LAN')
+        item.connect('toggled', self.toggle_announce_branches)
+        self.append(item)
+        self.append(gtk.SeparatorMenuItem())
         try:
             from bzrlib.plugins.avahi.share import ZeroConfServer
             from bzrlib import urlutils
             self.zeroconfserver = ZeroConfServer(urlutils.normalize_url('.'))
-            item = gtk.CheckMenuItem('Announce _branches on LAN')
-            item.connect('toggled', self.toggle_announce_branches)
-            self.append(item)
-            self.append(gtk.SeparatorMenuItem())
         except ImportError:
-            pass
+            item.set_sensitive(False)
 
         item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
         item.connect('activate', self.show_preferences)

=== modified file 'preferences/__init__.py'
--- a/preferences/__init__.py	2008-10-25 06:02:09 +0000
+++ b/preferences/__init__.py	2008-10-28 16:02:01 +0000
@@ -25,6 +25,7 @@
 from bzrlib.config import GlobalConfig
 from identity import IdentityPage
 from plugins import PluginsPage
+from notifications import NotificationsPage
 
 class PreferencesWindow(gtk.Dialog):
     """Displays global preferences windows."""
@@ -60,7 +61,8 @@
 
     def _create_pages(self):
         return [("Identity", IdentityPage(self.config)), 
-                ("Plugins", PluginsPage())]
+                ("Plugins", PluginsPage()),
+                ("Notifications", NotificationsPage(self.config))]
 
     def display(self):
         self.window.show_all()

=== added file 'preferences/notifications.py'
--- a/preferences/notifications.py	1970-01-01 00:00:00 +0000
+++ b/preferences/notifications.py	2008-10-28 16:02:01 +0000
@@ -0,0 +1,38 @@
+# Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+try:
+    import pygtk
+    pygtk.require("2.0")
+except:
+    pass
+
+import gtk
+
+from bzrlib.plugins.gtk.notify import has_avahi, has_dbus
+
+class NotificationsPage(gtk.VBox):
+    def __init__(self, config):
+        self.config = config
+        gtk.VBox.__init__(self)
+
+        self.gateway_to_lan = gtk.CheckButton("_Gateway to LAN")
+        self.pack_start(self.gateway_to_lan)
+        self.gateway_to_lan.set_sensitive(has_dbus())
+
+        self.announce_on_lan = gtk.CheckButton("_Announce on LAN")
+        self.pack_start(self.announce_on_lan)
+        self.announce_on_lan.set_sensitive(has_avahi())



More information about the Pkg-bazaar-commits mailing list