we can now add and remove the icon in systray without retarting Gajim
This commit is contained in:
parent
6fdb50f67a
commit
8e0fb06706
2 changed files with 42 additions and 21 deletions
|
@ -254,8 +254,10 @@ class preference_Window:
|
||||||
#trayicon
|
#trayicon
|
||||||
if self.chk_trayicon.get_active():
|
if self.chk_trayicon.get_active():
|
||||||
self.plugin.config['trayicon'] = 1
|
self.plugin.config['trayicon'] = 1
|
||||||
|
self.plugin.show_systray()
|
||||||
else:
|
else:
|
||||||
self.plugin.config['trayicon'] = 0
|
self.plugin.config['trayicon'] = 0
|
||||||
|
self.plugin.hide_systray()
|
||||||
self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui'))
|
self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui'))
|
||||||
self.plugin.roster.draw_roster()
|
self.plugin.roster.draw_roster()
|
||||||
#log presences in user file
|
#log presences in user file
|
||||||
|
|
|
@ -1582,7 +1582,7 @@ class roster_Window:
|
||||||
self.plugin.send('QUIT', None, ('gtkgui', 1))
|
self.plugin.send('QUIT', None, ('gtkgui', 1))
|
||||||
print _("plugin gtkgui stopped")
|
print _("plugin gtkgui stopped")
|
||||||
self.close_all(self.plugin.windows)
|
self.close_all(self.plugin.windows)
|
||||||
self.plugin.systray.t.destroy()
|
self.plugin.hide_systray()
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
def on_row_activated(self, widget, path, col=0):
|
def on_row_activated(self, widget, path, col=0):
|
||||||
|
@ -1949,6 +1949,10 @@ class systrayDummy:
|
||||||
pass
|
pass
|
||||||
def set_status(self, status):
|
def set_status(self, status):
|
||||||
pass
|
pass
|
||||||
|
def show_icon(self):
|
||||||
|
pass
|
||||||
|
def hide_icon(self):
|
||||||
|
pass
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.t = gtk.Button()
|
self.t = gtk.Button()
|
||||||
|
|
||||||
|
@ -2090,23 +2094,33 @@ class systray:
|
||||||
else:
|
else:
|
||||||
self.iconified = 0
|
self.iconified = 0
|
||||||
|
|
||||||
|
def show_icon(self):
|
||||||
|
if not self.t:
|
||||||
|
self.t = trayicon.TrayIcon("Gajim")
|
||||||
|
eb = gtk.EventBox()
|
||||||
|
eb.connect("button-press-event", self.on_clicked)
|
||||||
|
self.tip = gtk.Tooltips()
|
||||||
|
self.tip.set_tip(self.t, 'Gajim')
|
||||||
|
self.img_tray = gtk.Image()
|
||||||
|
eb.add(self.img_tray)
|
||||||
|
self.t.add(eb)
|
||||||
|
self.set_img()
|
||||||
|
self.t.show_all()
|
||||||
|
|
||||||
|
def hide_icon(self):
|
||||||
|
if self.t:
|
||||||
|
self.t.destroy()
|
||||||
|
self.t = None
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.jids = []
|
self.jids = []
|
||||||
self.iconified = 0
|
self.iconified = 0
|
||||||
win = self.plugin.roster.xml.get_widget('Gajim')
|
win = self.plugin.roster.xml.get_widget('Gajim')
|
||||||
win.connect("window-state-event", self.state_changed)
|
win.connect("window-state-event", self.state_changed)
|
||||||
self.t = trayicon.TrayIcon("Gajim")
|
self.t = None
|
||||||
eb = gtk.EventBox()
|
|
||||||
eb.connect("button-press-event", self.on_clicked)
|
|
||||||
self.tip = gtk.Tooltips()
|
|
||||||
self.tip.set_tip(self.t, 'Gajim')
|
|
||||||
self.img_tray = gtk.Image()
|
self.img_tray = gtk.Image()
|
||||||
eb.add(self.img_tray)
|
|
||||||
self.t.add(eb)
|
|
||||||
self.t.show_all()
|
|
||||||
self.status = 'offline'
|
self.status = 'offline'
|
||||||
self.set_img()
|
|
||||||
|
|
||||||
|
|
||||||
class plugin:
|
class plugin:
|
||||||
|
@ -2477,6 +2491,12 @@ class plugin:
|
||||||
self.roster.send_status(a, 'online', 'Online', 1)
|
self.roster.send_status(a, 'online', 'Online', 1)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def show_systray(self):
|
||||||
|
self.systray.show_icon()
|
||||||
|
|
||||||
|
def hide_systray(self):
|
||||||
|
self.systray.hide_icon()
|
||||||
|
|
||||||
def __init__(self, quIN, quOUT):
|
def __init__(self, quIN, quOUT):
|
||||||
gtk.gdk.threads_init()
|
gtk.gdk.threads_init()
|
||||||
self.queueIN = quIN
|
self.queueIN = quIN
|
||||||
|
@ -2558,18 +2578,17 @@ 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)
|
||||||
if self.config['trayicon']:
|
try:
|
||||||
try:
|
global trayicon
|
||||||
global trayicon
|
import trayicon
|
||||||
import trayicon
|
except:
|
||||||
except:
|
self.config['trayicon'] = 0
|
||||||
self.config['trayicon'] = 0
|
self.send('CONFIG', None, ('GtkGui', self.config, 'GtkGui'))
|
||||||
self.send('CONFIG', None, ('GtkGui', self.config, 'GtkGui'))
|
|
||||||
self.systray = systrayDummy()
|
|
||||||
else:
|
|
||||||
self.systray = systray(self)
|
|
||||||
else:
|
|
||||||
self.systray = systrayDummy()
|
self.systray = systrayDummy()
|
||||||
|
else:
|
||||||
|
self.systray = systray(self)
|
||||||
|
if self.config['trayicon']:
|
||||||
|
self.show_systray()
|
||||||
gtk.gdk.threads_enter()
|
gtk.gdk.threads_enter()
|
||||||
self.autoconnect()
|
self.autoconnect()
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue