Added minimize/unminimize to status icon

This commit is contained in:
Anna 2010-05-24 15:53:02 -04:00
parent e4a1823788
commit 59d9177f3a
2 changed files with 28 additions and 12 deletions

View File

@ -75,6 +75,8 @@ class Hrafn():
self.username = self.db['active_user'] self.username = self.db['active_user']
self.minimized = False
try: try:
self.api = self.accounts[self.username] self.api = self.accounts[self.username]
except KeyError: except KeyError:
@ -128,7 +130,7 @@ class Hrafn():
# Add a system tray icon # Add a system tray icon
self.tray_icon = gtk.status_icon_new_from_file('ui/icon.svg') self.tray_icon = gtk.status_icon_new_from_file('ui/icon.svg')
self.tray_icon.connect('activate', self.on_tray_icon_clicked)
# Set the account label # Set the account label
self.update_account_label() self.update_account_label()
@ -239,7 +241,7 @@ class Hrafn():
def on_about(self, widget): def on_about(self, widget):
print "STUB: help->about not yet implemented" print "stub: Hrafn.on_about()"
def on_reply(self, widget, data): def on_reply(self, widget, data):
@ -571,6 +573,21 @@ class Hrafn():
self.accounts_menu.append(menu_item) self.accounts_menu.append(menu_item)
menu_item.show() menu_item.show()
def on_tray_icon_clicked(self, event):
if self.minimized:
self.window.deiconify()
else:
self.window.iconify()
def on_window_state_changed(self, window, event):
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
self.minimized = True
else:
self.minimized = False
### end class Hrafn ### end class Hrafn

View File

@ -23,6 +23,7 @@
<signal name="hide" handler="gtk_main_quit" last_modification_time="Fri, 09 Apr 2010 03:40:14 GMT"/> <signal name="hide" handler="gtk_main_quit" last_modification_time="Fri, 09 Apr 2010 03:40:14 GMT"/>
<signal name="key_press_event" handler="global_key_press_handler" last_modification_time="Fri, 16 Apr 2010 15:35:22 GMT"/> <signal name="key_press_event" handler="global_key_press_handler" last_modification_time="Fri, 16 Apr 2010 15:35:22 GMT"/>
<signal name="configure_event" handler="on_resize" last_modification_time="Tue, 18 May 2010 03:10:23 GMT"/> <signal name="configure_event" handler="on_resize" last_modification_time="Tue, 18 May 2010 03:10:23 GMT"/>
<signal name="window_state_event" handler="on_window_state_changed" last_modification_time="Mon, 24 May 2010 19:45:21 GMT"/>
<child> <child>
<widget class="GtkVBox" id="main_box"> <widget class="GtkVBox" id="main_box">
@ -105,7 +106,6 @@
<widget class="GtkMenu" id="view_menu"> <widget class="GtkMenu" id="view_menu">
</widget> </widget>
</child> </child>
</widget> </widget>
</child> </child>
@ -119,7 +119,6 @@
<widget class="GtkMenu" id="accounts_menu"> <widget class="GtkMenu" id="accounts_menu">
</widget> </widget>
</child> </child>
</widget> </widget>
</child> </child>