hide main window instead of closing it when the systray icon is visible

This commit is contained in:
Yann Leboulanger 2005-01-16 21:40:31 +00:00
parent 1fde50b12f
commit fd2ca94da0
2 changed files with 16 additions and 4 deletions

View file

@ -18,8 +18,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Wed, 24 Sep 2003 20:54:02 GMT"/>
<signal name="unrealize" handler="on_Gajim_unrealize" last_modification_time="Wed, 13 Oct 2004 21:42:08 GMT"/> <signal name="unrealize" handler="on_Gajim_unrealize" last_modification_time="Wed, 13 Oct 2004 21:42:08 GMT"/>
<signal name="delete_event" handler="on_widget_destroy" last_modification_time="Sun, 16 Jan 2005 21:31:06 GMT"/>
<child> <child>
<widget class="GtkVBox" id="vbox1"> <widget class="GtkVBox" id="vbox1">

View file

@ -1592,6 +1592,15 @@ class roster_Window:
else: else:
w.window.destroy() w.window.destroy()
def on_close(self, widget, event):
"""When we want to close the window"""
if self.plugin.systray_visible:
win = self.xml.get_widget('Gajim')
win.iconify()
else:
self.on_quit(widget)
return 1
def on_quit(self, widget): def on_quit(self, widget):
"""When we quit the gtk plugin : """When we quit the gtk plugin :
tell that to the core and exit gtk""" tell that to the core and exit gtk"""
@ -1872,8 +1881,8 @@ class roster_Window:
self.browse_handler_id = 0 self.browse_handler_id = 0
self.join_handler_id = 0 self.join_handler_id = 0
window = self.xml.get_widget('Gajim') window = self.xml.get_widget('Gajim')
window.hide()
if self.plugin.config.has_key('saveposition'): if self.plugin.config.has_key('saveposition'):
window.hide()
if self.plugin.config['saveposition']: if self.plugin.config['saveposition']:
if self.plugin.config.has_key('x-position') and \ if self.plugin.config.has_key('x-position') and \
self.plugin.config.has_key('y-position'): self.plugin.config.has_key('y-position'):
@ -1946,7 +1955,7 @@ class roster_Window:
self.tree.enable_model_drag_dest(TARGETS, gtk.gdk.ACTION_DEFAULT) self.tree.enable_model_drag_dest(TARGETS, gtk.gdk.ACTION_DEFAULT)
self.tree.connect("drag_data_get", self.drag_data_get_data) self.tree.connect("drag_data_get", self.drag_data_get_data)
self.tree.connect("drag_data_received", self.drag_data_received_data) self.tree.connect("drag_data_received", self.drag_data_received_data)
self.xml.signal_connect('gtk_main_quit', self.on_quit) self.xml.signal_connect('on_widget_destroy', self.on_close)
self.xml.signal_connect('on_Gajim_unrealize', self.on_unrealize) self.xml.signal_connect('on_Gajim_unrealize', self.on_unrealize)
self.xml.signal_connect('on_preferences_activate', self.on_prefs) self.xml.signal_connect('on_preferences_activate', self.on_prefs)
self.xml.signal_connect('on_accounts_activate', self.on_accounts) self.xml.signal_connect('on_accounts_activate', self.on_accounts)
@ -2515,9 +2524,11 @@ class plugin:
def show_systray(self): def show_systray(self):
self.systray.show_icon() self.systray.show_icon()
self.systray_visible = 1
def hide_systray(self): def hide_systray(self):
self.systray.hide_icon() self.systray.hide_icon()
self.systray_visible = 0
def __init__(self, quIN, quOUT): def __init__(self, quIN, quOUT):
gtk.gdk.threads_init() gtk.gdk.threads_init()
@ -2600,6 +2611,7 @@ class plugin:
self.sleeper = common.sleepy.Sleepy( \ self.sleeper = common.sleepy.Sleepy( \
self.config['autoawaytime']*60, \ self.config['autoawaytime']*60, \
self.config['autoxatime']*60) self.config['autoxatime']*60)
self.systray_visible = 0
try: try:
global trayicon global trayicon
import trayicon import trayicon