Skip to content

Commit

Permalink
Fix status icon not disappearing after being disabled (bug 1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
smunkel authored and thp committed Feb 8, 2013
1 parent 60e541f commit 0aae78c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions share/gpodder/extensions/gtk_statusicon.py
Expand Up @@ -15,6 +15,7 @@
__disable_in__ = 'unity'

import gtk
import os.path

class gPodderExtension:
def __init__(self, container):
Expand All @@ -23,21 +24,31 @@ def __init__(self, container):
self.gpodder = None

def on_load(self):
self.status_icon = gtk.status_icon_new_from_icon_name('gpodder')
path = os.path.join(os.path.dirname(__file__), '..', '..', 'icons')
icon_path = os.path.abspath(path)

theme = gtk.icon_theme_get_default()
theme.append_search_path(icon_path)

if theme.has_icon('gpodder'):
self.status_icon = gtk.status_icon_new_from_icon_name('gpodder')
else:
self.status_icon = gtk.status_icon_new_from_icon_name('stock_mic')

self.status_icon.connect('activate', self.on_toggle_visible)
self.status_icon.set_has_tooltip(True)
self.status_icon.set_tooltip_text("gPodder")

def on_toggle_visible(self, status_icon):
if self.gpodder is None:
return

if self.gpodder.main_window.get_property('visible'):
self.gpodder.main_window.hide()
else:
self.gpodder.main_window.show()
visibility = self.gpodder.main_window.get_visible()
self.gpodder.main_window.set_visible(not visibility)

def on_unload(self):
if self.status_icon is not None:
self.status_icon.hide()
self.status_icon.set_visible(False)
self.status_icon = None

def on_ui_object_available(self, name, ui_object):
Expand Down

0 comments on commit 0aae78c

Please sign in to comment.