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:
Nikos Kouremenos 2006-10-04 23:30:03 +00:00
parent f97cdf1f4e
commit f644cf1136
2 changed files with 37 additions and 50 deletions

View File

@ -4,20 +4,11 @@ exec python -OOt "$0" ${1+"$@"}
' '''
## 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>
## Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Nikos Kouremenos <kourem@gmail.com>
## Dimitur Kirov <dkirov@gmail.com>
## Travis Shirk <travis@pobox.com>
## Norman Rasmussen <norman@rasmussen.co.za>
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov@gmail.com>
## Copyright (C) 2005 Travis Shirk <travis@pobox.com>
##
## This program is free software; you can redistribute it and/or modify
## 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)
import roster_window
import systray
import profile_window
import config
@ -1925,21 +1915,18 @@ class Interface:
self.systray_enabled = False
self.systray_capabilities = False
if os.name == 'nt':
pass
'''
try:
import systraywin32
except: # user doesn't have trayicon capabilities
pass
else:
self.systray_capabilities = True
self.systray = systraywin32.SystrayWin32()
'''
else:
if os.name == 'nt' and gtk.pygtk_version >= (2, 10, 0) and\
gtk.gtk_version >= (2, 10, 0):
import statusicon
self.systray = statusicon.StatusIcon()
self.systray_capabilities = True
else: # use ours, not GTK+ one
# [FIXME: remove this when we migrate to 2.10 and we can do
# cool tooltips somehow and (not dying to keep) animation]
import systray
self.systray_capabilities = systray.HAS_SYSTRAY_CAPABILITIES
if self.systray_capabilities:
self.systray = systray.Systray()
self.systray = systray.Systray()
if self.systray_capabilities and gajim.config.get('trayicon'):
self.show_systray()

View File

@ -43,7 +43,7 @@ except:
class Systray:
'''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'''
def __init__(self):
@ -94,16 +94,14 @@ class Systray:
def on_new_chat(self, widget, account):
dialogs.NewChatDialog(account)
def make_menu(self, event = None):
'''create chat with and new message (sub) menus/menuitems
event is None when we're in Windows
'''
def make_menu(self, event_button, event_time):
'''create chat with and new message (sub) menus/menuitems'''
for m in self.popup_menus:
m.destroy()
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')
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)
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)
accounts_list = gajim.contacts.get_accounts()
@ -195,9 +194,11 @@ class Systray:
label.set_use_underline(False)
gc_item = gtk.MenuItem()
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)
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
# one account connected, no need to show 'as jid'
@ -207,24 +208,23 @@ class Systray:
'activate', self.on_new_chat, account)
# for single message
single_message_menuitem.remove_submenu()
self.single_message_handler_id = single_message_menuitem.connect(
'activate', self.on_single_message_menuitem_activate, account)
self.single_message_handler_id = single_message_menuitem.\
connect('activate',
self.on_single_message_menuitem_activate, account)
# 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
if event is None:
# None means windows (we explicitly popup in systraywin32.py)
if self.added_hide_menuitem is False:
self.systray_context_menu.prepend(gtk.SeparatorMenuItem())
item = gtk.MenuItem(_('Hide this menu'))
self.systray_context_menu.prepend(item)
self.added_hide_menuitem = True
if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
self.systray_context_menu.popup(None, None,
gtk.status_icon_position_menu, event_button,
event_time, self.status_icon)
else: # GNU and Unices
self.systray_context_menu.popup(None, None, None, event.button,
event.time)
self.systray_context_menu.popup(None, None, None, event_button,
event_time)
self.systray_context_menu.show_all()
def on_show_all_events_menuitem_activate(self, widget):
@ -282,7 +282,7 @@ class Systray:
elif event.button == 2: # middle click
self.on_middle_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):
# we all add some fake (we cannot select those nor have them as show)