dummytray for pygtk 2.8

This commit is contained in:
Zach Tibbitts 2007-03-01 19:30:06 +00:00
parent e439ebb86f
commit e163c1301c
2 changed files with 20 additions and 8 deletions

View File

@ -67,7 +67,15 @@ class DelugeGTK:
## Construct the Interface ## Construct the Interface
self.build_tray_icon() try:
self.build_tray_icon()
except AttributeError:
#python-pygtk is < 2.9
self.tray_icon = dgtk.StupidTray()
self.has_tray = False
else:
self.has_tray = True
self.build_about_dialog() self.build_about_dialog()
self.build_pref_dialog() self.build_pref_dialog()
self.build_torrent_table() self.build_torrent_table()
@ -77,8 +85,6 @@ class DelugeGTK:
self.connect_signals() self.connect_signals()
try: try:
self.load_window_settings() self.load_window_settings()
except KeyError: except KeyError:
@ -153,7 +159,6 @@ class DelugeGTK:
item_clear.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)) item_clear.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU))
item_plug.set_image(gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)) item_plug.set_image(gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU))
item_show.connect("activate", self.force_show_hide) item_show.connect("activate", self.force_show_hide)
item_add.connect("activate", self.add_torrent_clicked) item_add.connect("activate", self.add_torrent_clicked)
item_clear.connect("activate", self.clear_finished) item_clear.connect("activate", self.clear_finished)
@ -193,9 +198,6 @@ class DelugeGTK:
else: else:
self.window.show() self.window.show()
def build_about_dialog(self): def build_about_dialog(self):
gtk.about_dialog_set_url_hook(dcommon.open_url_in_browser) gtk.about_dialog_set_url_hook(dcommon.open_url_in_browser)
self.abt = gtk.glade.XML(dcommon.get_glade_file("aboutdialog.glade")).get_widget("aboutdialog") self.abt = gtk.glade.XML(dcommon.get_glade_file("aboutdialog.glade")).get_widget("aboutdialog")
@ -959,7 +961,7 @@ class DelugeGTK:
def close(self, widget, event): def close(self, widget, event):
if self.config.get("close_to_tray", bool, default=False) and self.config.get("enable_system_tray", bool, default=True): if self.config.get("close_to_tray", bool, default=False) and self.config.get("enable_system_tray", bool, default=True) and self.has_tray:
self.save_window_geometry() self.save_window_geometry()
self.window.hide() self.window.hide()
return True return True

View File

@ -28,6 +28,16 @@ pygtk.require('2.0')
import gtk import gtk
import gtk.glade import gtk.glade
# This is a dummy tray object to allow Deluge to run on PyGTK < 2.9
class StupidTray:
def __init__(self):
pass
def set_visible(self, value):
pass
def set_tooltip(self, value):
pass
## Browse for .torrent files ## Browse for .torrent files
def show_file_open_dialog(parent=None): def show_file_open_dialog(parent=None):
chooser = gtk.FileChooserDialog(_("Choose a .torrent file"), parent, gtk.FILE_CHOOSER_ACTION_OPEN, chooser = gtk.FileChooserDialog(_("Choose a .torrent file"), parent, gtk.FILE_CHOOSER_ACTION_OPEN,