if we are windows users and we have GTK/PyGTK 2.10 we now use the GTK api about the status icon (trayicon). I tested under GNU/Linux [at gtk2.10 still is not out for Windows] and all works okay apart from the fact that we cannot do cool tooltips and cannot do animation (which is okay by me). TODO: make usage of basic tooltips [better something than nothing] for this new API
This commit is contained in:
parent
f97cdf1f4e
commit
f644cf1136
37
src/gajim.py
37
src/gajim.py
|
@ -4,20 +4,11 @@ exec python -OOt "$0" ${1+"$@"}
|
||||||
' '''
|
' '''
|
||||||
## gajim.py
|
## gajim.py
|
||||||
##
|
##
|
||||||
## Contributors for this file:
|
|
||||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
||||||
## - Nikos Kouremenos <kourem@gmail.com>
|
|
||||||
## - Dimitur Kirov <dkirov@gmail.com>
|
|
||||||
## - Travis Shirk <travis@pobox.com>
|
|
||||||
##
|
##
|
||||||
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||||
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov@gmail.com>
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
## Copyright (C) 2005 Travis Shirk <travis@pobox.com>
|
||||||
## Nikos Kouremenos <kourem@gmail.com>
|
|
||||||
## Dimitur Kirov <dkirov@gmail.com>
|
|
||||||
## Travis Shirk <travis@pobox.com>
|
|
||||||
## Norman Rasmussen <norman@rasmussen.co.za>
|
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published
|
## it under the terms of the GNU General Public License as published
|
||||||
|
@ -193,7 +184,6 @@ atexit.register(on_exit)
|
||||||
parser = optparser.OptionsParser(config_filename)
|
parser = optparser.OptionsParser(config_filename)
|
||||||
|
|
||||||
import roster_window
|
import roster_window
|
||||||
import systray
|
|
||||||
import profile_window
|
import profile_window
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
@ -1925,18 +1915,15 @@ class Interface:
|
||||||
self.systray_enabled = False
|
self.systray_enabled = False
|
||||||
self.systray_capabilities = False
|
self.systray_capabilities = False
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt' and gtk.pygtk_version >= (2, 10, 0) and\
|
||||||
pass
|
gtk.gtk_version >= (2, 10, 0):
|
||||||
'''
|
import statusicon
|
||||||
try:
|
self.systray = statusicon.StatusIcon()
|
||||||
import systraywin32
|
|
||||||
except: # user doesn't have trayicon capabilities
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.systray_capabilities = True
|
self.systray_capabilities = True
|
||||||
self.systray = systraywin32.SystrayWin32()
|
else: # use ours, not GTK+ one
|
||||||
'''
|
# [FIXME: remove this when we migrate to 2.10 and we can do
|
||||||
else:
|
# cool tooltips somehow and (not dying to keep) animation]
|
||||||
|
import systray
|
||||||
self.systray_capabilities = systray.HAS_SYSTRAY_CAPABILITIES
|
self.systray_capabilities = systray.HAS_SYSTRAY_CAPABILITIES
|
||||||
if self.systray_capabilities:
|
if self.systray_capabilities:
|
||||||
self.systray = systray.Systray()
|
self.systray = systray.Systray()
|
||||||
|
|
|
@ -43,7 +43,7 @@ except:
|
||||||
|
|
||||||
class Systray:
|
class Systray:
|
||||||
'''Class for icon in the notification area
|
'''Class for icon in the notification area
|
||||||
This class is both base class (for systraywin32.py) and normal class
|
This class is both base class (for statusicon.py) and normal class
|
||||||
for trayicon in GNU/Linux'''
|
for trayicon in GNU/Linux'''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -94,16 +94,14 @@ class Systray:
|
||||||
def on_new_chat(self, widget, account):
|
def on_new_chat(self, widget, account):
|
||||||
dialogs.NewChatDialog(account)
|
dialogs.NewChatDialog(account)
|
||||||
|
|
||||||
def make_menu(self, event = None):
|
def make_menu(self, event_button, event_time):
|
||||||
'''create chat with and new message (sub) menus/menuitems
|
'''create chat with and new message (sub) menus/menuitems'''
|
||||||
event is None when we're in Windows
|
|
||||||
'''
|
|
||||||
|
|
||||||
for m in self.popup_menus:
|
for m in self.popup_menus:
|
||||||
m.destroy()
|
m.destroy()
|
||||||
|
|
||||||
chat_with_menuitem = self.xml.get_widget('chat_with_menuitem')
|
chat_with_menuitem = self.xml.get_widget('chat_with_menuitem')
|
||||||
single_message_menuitem = self.xml.get_widget('single_message_menuitem')
|
single_message_menuitem = self.xml.get_widget(
|
||||||
|
'single_message_menuitem')
|
||||||
status_menuitem = self.xml.get_widget('status_menu')
|
status_menuitem = self.xml.get_widget('status_menu')
|
||||||
join_gc_menuitem = self.xml.get_widget('join_gc_menuitem')
|
join_gc_menuitem = self.xml.get_widget('join_gc_menuitem')
|
||||||
|
|
||||||
|
@ -171,7 +169,8 @@ class Systray:
|
||||||
self.popup_menus.append(account_menu_for_chat_with)
|
self.popup_menus.append(account_menu_for_chat_with)
|
||||||
|
|
||||||
account_menu_for_single_message = gtk.Menu()
|
account_menu_for_single_message = gtk.Menu()
|
||||||
single_message_menuitem.set_submenu(account_menu_for_single_message)
|
single_message_menuitem.set_submenu(
|
||||||
|
account_menu_for_single_message)
|
||||||
self.popup_menus.append(account_menu_for_single_message)
|
self.popup_menus.append(account_menu_for_single_message)
|
||||||
|
|
||||||
accounts_list = gajim.contacts.get_accounts()
|
accounts_list = gajim.contacts.get_accounts()
|
||||||
|
@ -195,9 +194,11 @@ class Systray:
|
||||||
label.set_use_underline(False)
|
label.set_use_underline(False)
|
||||||
gc_item = gtk.MenuItem()
|
gc_item = gtk.MenuItem()
|
||||||
gc_item.add(label)
|
gc_item.add(label)
|
||||||
gc_item.connect('state-changed', gtkgui_helpers.on_bm_header_changed_state)
|
gc_item.connect('state-changed',
|
||||||
|
gtkgui_helpers.on_bm_header_changed_state)
|
||||||
gc_sub_menu.append(gc_item)
|
gc_sub_menu.append(gc_item)
|
||||||
gajim.interface.roster.add_bookmarks_list(gc_sub_menu, account)
|
gajim.interface.roster.add_bookmarks_list(gc_sub_menu,
|
||||||
|
account)
|
||||||
|
|
||||||
elif connected_accounts == 1: # one account
|
elif connected_accounts == 1: # one account
|
||||||
# one account connected, no need to show 'as jid'
|
# one account connected, no need to show 'as jid'
|
||||||
|
@ -207,24 +208,23 @@ class Systray:
|
||||||
'activate', self.on_new_chat, account)
|
'activate', self.on_new_chat, account)
|
||||||
# for single message
|
# for single message
|
||||||
single_message_menuitem.remove_submenu()
|
single_message_menuitem.remove_submenu()
|
||||||
self.single_message_handler_id = single_message_menuitem.connect(
|
self.single_message_handler_id = single_message_menuitem.\
|
||||||
'activate', self.on_single_message_menuitem_activate, account)
|
connect('activate',
|
||||||
|
self.on_single_message_menuitem_activate, account)
|
||||||
|
|
||||||
# join gc
|
# join gc
|
||||||
gajim.interface.roster.add_bookmarks_list(gc_sub_menu, account)
|
gajim.interface.roster.add_bookmarks_list(gc_sub_menu,
|
||||||
|
account)
|
||||||
break # No other connected account
|
break # No other connected account
|
||||||
|
|
||||||
if event is None:
|
if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
|
||||||
# None means windows (we explicitly popup in systraywin32.py)
|
self.systray_context_menu.popup(None, None,
|
||||||
if self.added_hide_menuitem is False:
|
gtk.status_icon_position_menu, event_button,
|
||||||
self.systray_context_menu.prepend(gtk.SeparatorMenuItem())
|
event_time, self.status_icon)
|
||||||
item = gtk.MenuItem(_('Hide this menu'))
|
|
||||||
self.systray_context_menu.prepend(item)
|
|
||||||
self.added_hide_menuitem = True
|
|
||||||
|
|
||||||
else: # GNU and Unices
|
else: # GNU and Unices
|
||||||
self.systray_context_menu.popup(None, None, None, event.button,
|
self.systray_context_menu.popup(None, None, None, event_button,
|
||||||
event.time)
|
event_time)
|
||||||
self.systray_context_menu.show_all()
|
self.systray_context_menu.show_all()
|
||||||
|
|
||||||
def on_show_all_events_menuitem_activate(self, widget):
|
def on_show_all_events_menuitem_activate(self, widget):
|
||||||
|
@ -282,7 +282,7 @@ class Systray:
|
||||||
elif event.button == 2: # middle click
|
elif event.button == 2: # middle click
|
||||||
self.on_middle_click()
|
self.on_middle_click()
|
||||||
elif event.button == 3: # right click
|
elif event.button == 3: # right click
|
||||||
self.make_menu(event)
|
self.make_menu(event.button, event.time)
|
||||||
|
|
||||||
def on_show_menuitem_activate(self, widget, show):
|
def on_show_menuitem_activate(self, widget, show):
|
||||||
# we all add some fake (we cannot select those nor have them as show)
|
# we all add some fake (we cannot select those nor have them as show)
|
||||||
|
|
Loading…
Reference in New Issue