diff --git a/deluge/ui/gtkui/details_tab.py b/deluge/ui/gtkui/details_tab.py index ddbefb1aa..cc04bde98 100644 --- a/deluge/ui/gtkui/details_tab.py +++ b/deluge/ui/gtkui/details_tab.py @@ -51,8 +51,6 @@ class DetailsTab(Tab): self._child_widget = glade.get_widget("details_tab") self._tab_label = glade.get_widget("details_tab_label") - self._child_widget.connect("button-press-event", self.on_button_press_event) - self.label_widgets = [ (glade.get_widget("summary_name"), None, ("name",)), (glade.get_widget("summary_total_size"), deluge.common.fsize, ("total_size",)), @@ -63,10 +61,6 @@ class DetailsTab(Tab): (glade.get_widget("summary_hash"), str, ("hash",)) ] - def on_button_press_event(self, widget, event): - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() - def update(self): # Get the first selected torrent selected = component.get("TorrentView").get_selected_torrents() diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index b97020487..99b25cbac 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -376,8 +376,6 @@ class FilesTab(Tab): def _on_button_press_event(self, widget, event): """This is a callback for showing the right-click context menu.""" log.debug("on_button_press_event") - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() # We only care about right-clicks if event.button == 3: x, y = event.get_coords() diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 55467f0eb..1532466d7 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -77,6 +77,7 @@ class MainWindow(component.Component): self.window.connect("delete-event", self.on_window_delete_event) self.window.connect("drag-data-received", self.on_drag_data_received_event) self.vpaned.connect("notify::position", self.on_vpaned_position_event) + self.window.connect("expose-event", self.on_expose_event) if not(self.config["start_in_tray"] and \ self.config["enable_system_tray"]) and not \ @@ -116,7 +117,7 @@ class MainWindow(component.Component): component.resume("TorrentDetails") except: pass - + self.window.present() self.load_window_state() @@ -199,3 +200,6 @@ class MainWindow(component.Component): args.append(urllib.unquote(urlparse(uri).path)) process_args(args) drag_context.finish(True, True) + + def on_expose_event(self, widget, event): + component.get("SystemTray").blink(False) diff --git a/deluge/ui/gtkui/notification.py b/deluge/ui/gtkui/notification.py index c13b87a5e..60b437ba6 100644 --- a/deluge/ui/gtkui/notification.py +++ b/deluge/ui/gtkui/notification.py @@ -44,7 +44,7 @@ class Notification: def notify(self, torrent_id): if self.config["ntf_tray_blink"]: - self.blink() + self.tray.blink(True) if self.config["ntf_popup"] or self.config["ntf_email"]: self.get_torrent_status(torrent_id) @@ -61,14 +61,6 @@ class Notification: self.email(status) if self.config["ntf_sound"]: self.sound() - - def blink(self): - """blinks the tray icon""" - self.tray.on_set_tray_flashing_on() - - def stop_blink(self): - """stops blinking the tray icon""" - self.tray.on_set_tray_flashing_off() def popup(self, status): """popups up notification of finished torrent""" diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtkui/options_tab.py index 2db117987..8a6e0390b 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtkui/options_tab.py @@ -43,8 +43,6 @@ class OptionsTab(Tab): self._name = "Options" self._child_widget = glade.get_widget("options_tab") self._tab_label = glade.get_widget("options_tab_label") - - self._child_widget.connect("button-press-event", self.on_button_press_event) self.spin_max_download = glade.get_widget("spin_max_download") self.spin_max_upload = glade.get_widget("spin_max_upload") @@ -79,10 +77,6 @@ class OptionsTab(Tab): def stop(self): pass - - def on_button_press_event(self, widget, event): - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() def update(self): # Get the first selected torrent diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py index 5f6f6922d..bc9f77f54 100644 --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtkui/peers_tab.py @@ -68,8 +68,6 @@ class PeersTab(Tab): self._child_widget = glade.get_widget("peers_tab") self._tab_label = glade.get_widget("peers_tab_label") - self._child_widget.connect("button-press-event", self.on_button_press_event) - self.listview = glade.get_widget("peers_listview") # country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, gobject.TYPE_UINT, gtk.gdk.Pixbuf, float) @@ -168,10 +166,6 @@ class PeersTab(Tab): self.torrent_id = None - def on_button_press_event(self, widget, event): - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() - def save_state(self): filename = "peers_tab.state" state = [] diff --git a/deluge/ui/gtkui/statistics_tab.py b/deluge/ui/gtkui/statistics_tab.py index 7bb33151e..11fb40a74 100644 --- a/deluge/ui/gtkui/statistics_tab.py +++ b/deluge/ui/gtkui/statistics_tab.py @@ -68,8 +68,6 @@ class StatisticsTab(Tab): self._child_widget = glade.get_widget("statistics_tab") self._tab_label = glade.get_widget("statistics_tab_label") - self._child_widget.connect("button-press-event", self.on_button_press_event) - self.label_widgets = [ (glade.get_widget("summary_pieces"), fpeer_size_second, ("num_pieces", "piece_length")), (glade.get_widget("summary_availability"), fratio, ("distributed_copies",)), @@ -148,7 +146,3 @@ class StatisticsTab(Tab): widget[0].set_text("") component.get("MainWindow").main_glade.get_widget("progressbar").set_fraction(0.0) - - def on_button_press_event(self, widget, event): - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index c9681cd69..d12ba004e 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -235,16 +235,19 @@ class SystemTray(component.Component): except Exception, e: log.debug("Unable to disable system tray: %s", e) - def on_set_tray_flashing_off(self): - """makes the tray icon stop blinking""" - if self.tray.get_blinking(): - log.debug("stop blinking the tray icon..") - self.tray.set_blinking(False) - - def on_set_tray_flashing_on(self): - """makes the tray icon blink""" - log.debug("start blinking the tray icon..") - self.tray.set_blinking(True) + def blink(self, value): + self.tray.set_blinking(value) + + #def on_set_tray_flashing_off(self): + # """makes the tray icon stop blinking""" + # if self.tray.get_blinking(): + # log.debug("stop blinking the tray icon..") + # self.tray.set_blinking(False) + # + #def on_set_tray_flashing_on(self): + # """makes the tray icon blink""" + # log.debug("start blinking the tray icon..") + # self.tray.set_blinking(True) def on_enable_system_tray_set(self, key, value): """Called whenever the 'enable_system_tray' config key is modified""" @@ -255,7 +258,8 @@ class SystemTray(component.Component): def on_tray_clicked(self, icon): """Called when the tray icon is left clicked.""" - self.on_set_tray_flashing_off() + self.blink(False) + if self.window.active(): self.window.hide() else: @@ -266,7 +270,8 @@ class SystemTray(component.Component): def on_tray_popup(self, status_icon, button, activate_time): """Called when the tray icon is right clicked.""" - self.on_set_tray_flashing_off() + self.blink(False) + if self.window.visible(): self.tray_glade.get_widget("menuitem_show_deluge").set_active(True) else: diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 539c1a12e..93b311251 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -428,9 +428,6 @@ class TorrentView(listview.ListView, component.Component): def on_button_press_event(self, widget, event): """This is a callback for showing the right-click context menu.""" log.debug("on_button_press_event") - from deluge.ui.gtkui.notification import Notification - Notification().stop_blink() - # We only care about right-clicks if event.button == 3: x, y = event.get_coords()