trayicon for windows is 100% ready
This commit is contained in:
parent
ea47fd6f08
commit
9c05382fc5
|
@ -88,8 +88,8 @@ class PreferencesWindow:
|
||||||
self.auto_away_message_entry = self.xml.get_widget \
|
self.auto_away_message_entry = self.xml.get_widget \
|
||||||
('auto_away_message_entry')
|
('auto_away_message_entry')
|
||||||
self.auto_xa_checkbutton = self.xml.get_widget('auto_xa_checkbutton')
|
self.auto_xa_checkbutton = self.xml.get_widget('auto_xa_checkbutton')
|
||||||
self.auto_xa_time_spinbutton = self.xml.get_widget \
|
self.auto_xa_time_spinbutton = self.xml.get_widget(
|
||||||
('auto_xa_time_spinbutton')
|
'auto_xa_time_spinbutton')
|
||||||
self.auto_xa_message_entry = self.xml.get_widget('auto_xa_message_entry')
|
self.auto_xa_message_entry = self.xml.get_widget('auto_xa_message_entry')
|
||||||
self.trayicon_checkbutton = self.xml.get_widget('trayicon_checkbutton')
|
self.trayicon_checkbutton = self.xml.get_widget('trayicon_checkbutton')
|
||||||
self.notebook = self.xml.get_widget('preferences_notebook')
|
self.notebook = self.xml.get_widget('preferences_notebook')
|
||||||
|
@ -99,10 +99,7 @@ class PreferencesWindow:
|
||||||
st = gajim.config.get('trayicon')
|
st = gajim.config.get('trayicon')
|
||||||
self.trayicon_checkbutton.set_active(st)
|
self.trayicon_checkbutton.set_active(st)
|
||||||
else:
|
else:
|
||||||
if os.name == 'nt':
|
self.trayicon_checkbutton.set_sensitive(False)
|
||||||
self.trayicon_checkbutton.set_no_show_all(True)
|
|
||||||
else:
|
|
||||||
self.trayicon_checkbutton.set_sensitive(False)
|
|
||||||
|
|
||||||
#Show roster on Gajim startup
|
#Show roster on Gajim startup
|
||||||
st = gajim.config.get('show_roster_on_startup')
|
st = gajim.config.get('show_roster_on_startup')
|
||||||
|
|
|
@ -1506,7 +1506,6 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
|
|
||||||
def on_manage_bookmarks_menuitem_activate(self, widget):
|
def on_manage_bookmarks_menuitem_activate(self, widget):
|
||||||
config.ManageBookmarksWindow(self.plugin)
|
config.ManageBookmarksWindow(self.plugin)
|
||||||
#config.FirstTimeWizardWindow(self.plugin)
|
|
||||||
|
|
||||||
def close_all(self, dic):
|
def close_all(self, dic):
|
||||||
'''close all the windows in the given dictionary'''
|
'''close all the windows in the given dictionary'''
|
||||||
|
@ -1769,7 +1768,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
image = gtk.Image()
|
image = gtk.Image()
|
||||||
image.show()
|
image.show()
|
||||||
imgs[state] = image
|
imgs[state] = image
|
||||||
for file in files:
|
for file in files: # loop seeking for either gif or png
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
image.set_from_file(file)
|
image.set_from_file(file)
|
||||||
break
|
break
|
||||||
|
|
|
@ -27,7 +27,6 @@ import os
|
||||||
import tooltips
|
import tooltips
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common.connection import STATUS_LIST
|
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import i18n
|
from common import i18n
|
||||||
|
|
||||||
|
@ -65,10 +64,10 @@ class Systray:
|
||||||
|
|
||||||
def set_img(self):
|
def set_img(self):
|
||||||
if len(self.jids) > 0:
|
if len(self.jids) > 0:
|
||||||
status = 'message'
|
state = 'message'
|
||||||
else:
|
else:
|
||||||
status = self.status
|
state = self.status
|
||||||
image = self.plugin.roster.jabber_state_images[status]
|
image = self.plugin.roster.jabber_state_images[state]
|
||||||
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||||
self.img_tray.set_from_animation(image.get_animation())
|
self.img_tray.set_from_animation(image.get_animation())
|
||||||
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
||||||
|
@ -79,10 +78,10 @@ class Systray:
|
||||||
if not l in self.jids:
|
if not l in self.jids:
|
||||||
self.jids.append(l)
|
self.jids.append(l)
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we append to the number of unread messages
|
# we append to the number of unread messages
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ['chats', 'gc']:
|
||||||
jids = self.plugin.windows[acct][kind]
|
jids = self.plugin.windows[acct][kind]
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
|
@ -94,10 +93,10 @@ class Systray:
|
||||||
if l in self.jids:
|
if l in self.jids:
|
||||||
self.jids.remove(l)
|
self.jids.remove(l)
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we remove from the number of unread messages
|
# we remove from the number of unread messages
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ['chats', 'gc']:
|
||||||
for jid in self.plugin.windows[acct][kind]:
|
for jid in self.plugin.windows[acct][kind]:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
|
|
|
@ -21,14 +21,12 @@
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
|
|
||||||
__version__ = '1.01'
|
|
||||||
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import win32gui
|
import win32gui
|
||||||
import win32con # winapi contants
|
import win32con # winapi contants
|
||||||
import systray
|
import systray
|
||||||
import gtk
|
import gtk
|
||||||
|
import os
|
||||||
|
|
||||||
WM_TASKBARCREATED = win32gui.RegisterWindowMessage('TaskbarCreated')
|
WM_TASKBARCREATED = win32gui.RegisterWindowMessage('TaskbarCreated')
|
||||||
WM_TRAYMESSAGE = win32con.WM_USER + 20
|
WM_TRAYMESSAGE = win32con.WM_USER + 20
|
||||||
|
@ -202,7 +200,7 @@ class NotifyIcon:
|
||||||
self.remove
|
self.remove
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
||||||
|
|
||||||
#FIXME: subclass us under Systray
|
|
||||||
class SystrayWin32(systray.Systray):
|
class SystrayWin32(systray.Systray):
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
# Note: gtk window must be realized before installing extensions.
|
# Note: gtk window must be realized before installing extensions.
|
||||||
|
@ -213,6 +211,8 @@ class SystrayWin32(systray.Systray):
|
||||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'systray_context_menu', APP)
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'systray_context_menu', APP)
|
||||||
self.systray_context_menu = self.xml.get_widget('systray_context_menu')
|
self.systray_context_menu = self.xml.get_widget('systray_context_menu')
|
||||||
|
|
||||||
|
self.tray_ico_imgs = self.load_icos()
|
||||||
|
|
||||||
self.systray_winapi = SystrayWINAPI(self.plugin.roster.window)
|
self.systray_winapi = SystrayWINAPI(self.plugin.roster.window)
|
||||||
|
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
|
@ -223,8 +223,10 @@ class SystrayWin32(systray.Systray):
|
||||||
})
|
})
|
||||||
|
|
||||||
def show_icon(self):
|
def show_icon(self):
|
||||||
self.systray_winapi.add_notify_icon(self.systray_context_menu, tooltip = 'Gajim')
|
#self.systray_winapi.add_notify_icon(self.systray_context_menu, tooltip = 'Gajim')
|
||||||
self.systray_winapi.notify_icon.menu = self.systray_context_menu
|
#self.systray_winapi.notify_icon.menu = self.systray_context_menu
|
||||||
|
# do not remove set_img does both above. maybe I can only change img without readding
|
||||||
|
# the notify icon? F$ck WINAPI
|
||||||
self.set_img()
|
self.set_img()
|
||||||
|
|
||||||
def hide_icon(self):
|
def hide_icon(self):
|
||||||
|
@ -240,67 +242,81 @@ class SystrayWin32(systray.Systray):
|
||||||
self.on_left_click()
|
self.on_left_click()
|
||||||
|
|
||||||
def add_jid(self, jid, account):
|
def add_jid(self, jid, account):
|
||||||
print 'FIXME: add_jid'
|
l = [account, jid]
|
||||||
return
|
if not l in self.jids:
|
||||||
list = [account, jid]
|
self.jids.append(l)
|
||||||
if not list in self.jids:
|
|
||||||
self.jids.append(list)
|
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we look for the number of unread messages
|
# we append to the number of unread messages
|
||||||
#in roster
|
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ['chats', 'gc']:
|
||||||
jids = self.plugin.windows[acct][kind]
|
jids = self.plugin.windows[acct][kind]
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
nb += jids[jid].nb_unread[jid]
|
nb += jids[jid].nb_unread[jid]
|
||||||
|
|
||||||
|
#FIXME: prepare me for transltaion (ngeetext() and all) for 0.9
|
||||||
if nb > 1:
|
if nb > 1:
|
||||||
label = _('Gajim - %s unread messages') % nb
|
text = 'Gajim - %s unread messages' % nb
|
||||||
else:
|
else:
|
||||||
label = _('Gajim - 1 unread message')
|
text = 'Gajim - 1 unread message'
|
||||||
self.tip.set_tip(self.t, label)
|
self.systray_winapi.notify_icon.set_tooltip(text)
|
||||||
|
|
||||||
def set_img(self):
|
|
||||||
print 'set_img'
|
|
||||||
self.systray_winapi.remove_notify_icon()
|
|
||||||
if len(self.jids) > 0:
|
|
||||||
status = 'message'
|
|
||||||
else:
|
|
||||||
#status = self.status
|
|
||||||
path_to_ico = '../data/pixmaps/gajim.ico'
|
|
||||||
hinst = win32gui.GetModuleHandle(None)
|
|
||||||
icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
|
|
||||||
hicon = win32gui.LoadImage(hinst,
|
|
||||||
path_to_ico, #FIXME: path
|
|
||||||
win32con.IMAGE_ICON,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
icon_flags)
|
|
||||||
self.systray_winapi.add_notify_icon(self.systray_context_menu, hicon, 'Gajim')
|
|
||||||
self.systray_winapi.notify_icon.menu = self.systray_context_menu
|
|
||||||
|
|
||||||
def remove_jid(self, jid, account):
|
def remove_jid(self, jid, account):
|
||||||
print 'FIXME: remove_jid'
|
l = [account, jid]
|
||||||
return
|
if l in self.jids:
|
||||||
list = [account, jid]
|
self.jids.remove(l)
|
||||||
if list in self.jids:
|
|
||||||
self.jids.remove(list)
|
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we look for the number of unread messages
|
# we remove from the number of unread messages
|
||||||
#in roster
|
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ['chats', 'gc']:
|
||||||
for jid in self.plugin.windows[acct][kind]:
|
for jid in self.plugin.windows[acct][kind]:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid]
|
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid]
|
||||||
|
|
||||||
|
#FIXME: prepare me for transltaion (ngeetext() and all) for 0.9
|
||||||
if nb > 1:
|
if nb > 1:
|
||||||
label = _('Gajim - %s unread messages') % nb
|
text = 'Gajim - %s unread messages' % nb
|
||||||
elif nb == 1:
|
elif nb == 1:
|
||||||
label = _('Gajim - 1 unread message')
|
text = 'Gajim - 1 unread message'
|
||||||
else:
|
else:
|
||||||
label = 'Gajim'
|
text = 'Gajim'
|
||||||
self.tip.set_tip(self.t, label)
|
self.systray_winapi.notify_icon.set_tooltip(text)
|
||||||
|
|
||||||
|
|
||||||
|
def set_img(self):
|
||||||
|
self.systray_winapi.remove_notify_icon()
|
||||||
|
if len(self.jids) > 0:
|
||||||
|
state = 'message'
|
||||||
|
else:
|
||||||
|
state = self.status # FIXME: get LoadImage code to images[] dict in systray.py
|
||||||
|
hicon = self.tray_ico_imgs[state]
|
||||||
|
|
||||||
|
self.systray_winapi.add_notify_icon(self.systray_context_menu, hicon, 'Gajim')
|
||||||
|
self.systray_winapi.notify_icon.menu = self.systray_context_menu
|
||||||
|
|
||||||
|
def load_icos(self):
|
||||||
|
'''load .ico files and return them to a dic of SHOW --> img_obj'''
|
||||||
|
#iconset = gajim.config.get('iconset')
|
||||||
|
#if not iconset:
|
||||||
|
# iconset = 'sun'
|
||||||
|
|
||||||
|
iconset = 'gnome' # FIXME: add icos in all folders (icos are not as good as pngs in colors etc..)
|
||||||
|
|
||||||
|
imgs = {}
|
||||||
|
path = os.path.join(gajim.DATA_DIR, 'iconsets/' + iconset + '/16x16/icos/')
|
||||||
|
states_list = gajim.SHOW_LIST
|
||||||
|
states_list.append('message') # trayicon apart from show holds message state too
|
||||||
|
for state in states_list:
|
||||||
|
path_to_ico = path + state + '.ico'
|
||||||
|
if os.path.exists(path_to_ico):
|
||||||
|
hinst = win32gui.GetModuleHandle(None)
|
||||||
|
img_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
|
||||||
|
image = win32gui.LoadImage(hinst, path_to_ico, win32con.IMAGE_ICON,
|
||||||
|
0, 0, img_flags)
|
||||||
|
imgs[state] = image
|
||||||
|
|
||||||
|
return imgs
|
Loading…
Reference in New Issue