changeset 18384:22b9b6f148be

Add a 'Close' option for pietray to close the docklet.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 30 Jun 2007 23:50:07 +0000
parents 9eb2f4d27990
children c9a28619cfd5
files finch/plugins/pietray.py
diffstat 1 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/finch/plugins/pietray.py	Sat Jun 30 06:45:59 2007 +0000
+++ b/finch/plugins/pietray.py	Sat Jun 30 23:50:07 2007 +0000
@@ -78,9 +78,27 @@
 def toggle_pref(item, pref):
 	purple.PurplePrefsSetBool(pref, item.get_active())
 
+def quit_finch(item, null):
+	# XXX: Ask first
+	purple.PurpleCoreQuit()
+	gtk.main_quit()
+
+def close_docklet(item, null):
+	gtk.main_quit()
+
 def popup_menu(icon, button, tm, none):
 	menu = gtk.Menu()
 
+	#item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
+	#item.connect("activate", quit_finch, None)
+	#menu.append(item)
+
+	item = gtk.ImageMenuItem(gtk.STOCK_CLOSE)
+	item.connect("activate", close_docklet, None)
+	menu.append(item)
+
+	menu.append(gtk.MenuItem())
+
 	item = gtk.CheckMenuItem("Blink for unread IM")
 	item.set_active(purple.PurplePrefsGetBool("/plugins/dbus/docklet/blink/im"))
 	item.connect("activate", toggle_pref, "/plugins/dbus/docklet/blink/im")
@@ -176,8 +194,14 @@
 t = gtk.StatusIcon()
 t.connect("popup-menu", popup_menu, None)
 
-init_prefs()
-detect_unread_conversations()
+try:
+	init_prefs()
+	detect_unread_conversations()
+	gtk.main ()
+except:
+	dialog = gtk.Dialog("pietray: Error", None, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL, ("Close", gtk.RESPONSE_CLOSE))
+	dialog.set_resizable(False)
+	dialog.vbox.pack_start(gtk.Label("There was some error. Perhaps a purple client is not running."), False, False, 0)
+	dialog.show_all()
+	dialog.run()
 
-gtk.main ()
-