From 89edefc0532b876a394559aa5c7a64bb28b8c677 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sun, 27 Aug 2006 15:39:11 +0000 Subject: [PATCH] default status msg remove bold add border to make it HIG --- data/glade/preferences_window.glade | 5 +- src/gajim.py | 27 +++++---- src/roster_window.py | 9 +-- src/statusicon.py | 93 +++++++++++++++++++++++++++++ src/systray.py | 4 +- 5 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 src/statusicon.py diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade index 2b408d9d0..5fc605202 100644 --- a/data/glade/preferences_window.glade +++ b/data/glade/preferences_window.glade @@ -2547,6 +2547,7 @@ Disabled + 6 True True GTK_POLICY_AUTOMATIC @@ -2573,9 +2574,9 @@ Disabled True - <b>Default Status Messages</b> + Default Status Messages False - True + False GTK_JUSTIFY_LEFT False False diff --git a/src/gajim.py b/src/gajim.py index 1e35f83ab..8b2fb2101 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1884,18 +1884,23 @@ class Interface: self.systray_enabled = False self.systray_capabilities = False - if os.name == 'nt': - try: - import systraywin32 - except: # user doesn't have trayicon capabilities - pass + if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0): + import statusicon + self.systray = statusicon.StatusIcon() + self.systray_capabilities = True + else: #FIXME: remove the following (and the files) when we migrate to 2.10 + if os.name == 'nt': + try: + import systraywin32 + except: # user doesn't have trayicon capabilities + pass + else: + self.systray_capabilities = True + self.systray = systraywin32.SystrayWin32() else: - self.systray_capabilities = True - self.systray = systraywin32.SystrayWin32() - else: - self.systray_capabilities = systray.HAS_SYSTRAY_CAPABILITIES - if self.systray_capabilities: - self.systray = systray.Systray() + self.systray_capabilities = systray.HAS_SYSTRAY_CAPABILITIES + if self.systray_capabilities: + self.systray = systray.Systray() if self.systray_capabilities and gajim.config.get('trayicon'): self.show_systray() diff --git a/src/roster_window.py b/src/roster_window.py index 0ebea5941..e381251f9 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -655,14 +655,11 @@ class RosterWindow: def on_history_manager_menuitem_activate(self, widget): if os.name == 'nt': if os.path.exists('history_manager.exe'): # user is running stable - os.startfile('history_manager.exe') + helpers.exec_command('history_manager.exe') else: # user is running svn - try: - os.startfile('history_manager.py') - except: # user doesn't have pywin32, too bad for him - pass + helpers.exec_command('history_manager.py') else: # Unix user - os.system('python history_manager.py &') + helpers.exec_command('python history_manager.py &') def get_and_connect_advanced_menuitem_menu(self, account): '''adds FOR ACCOUNT options''' diff --git a/src/statusicon.py b/src/statusicon.py new file mode 100644 index 000000000..279861a71 --- /dev/null +++ b/src/statusicon.py @@ -0,0 +1,93 @@ +## statusicon.py +## +## Copyright (C) 2006 Nikos Kouremenos +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 2 +## of the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## + +import gtk +import systray + +class StatusIcon(systray.Systray): + '''Class for the notification area icon''' + #FIXME: when we migrate to GTK 2.10 stick only to this class + # (remove systraywin32.py and systray.py) + def __init__(self): + self.status_icon = gtk.StatusIcon() + + def show_icon(self): + self.status_icon.props.visible = True + + def hide_icon(self): + self.status_icon.props.visible = False + + def on_clicked(self, widget, event): + self.on_tray_leave_notify_event(widget, None) + if event.button == 1: # Left click + self.on_left_click() + elif event.button == 2: # middle click + self.on_middle_click() + elif event.button == 3: # right click + self.make_menu(event) + + def add_jid(self, jid, account, typ): + systray.Systray.add_jid(self, jid, account, typ) + + unread_messages = gajim.interface.roster.nb_unread + for acct in gajim.connections: + # in chat / groupchat windows + for kind in ('chats', 'gc'): + jids = gajim.interface.instances[acct][kind] + for jid in jids: + if jid != 'tabbed': + unread_messages += jids[jid].nb_unread[jid] + + text = i18n.ngettext( + 'Gajim - %d unread message', + 'Gajim - %d unread messages', + unread_messages, unread_messages, unread_messages) + + self.status_icon.set_tooltip(text) + + def remove_jid(self, jid, account, typ): + systray.Systray.remove_jid(self, jid, account, typ) + + unread_messages = gajim.interface.roster.nb_unread + for acct in gajim.connections: + # in chat / groupchat windows + for kind in ('chats', 'gc'): + for jid in gajim.interface.instances[acct][kind]: + if jid != 'tabbed': + unread_messages += gajim.interface.instances[acct][kind][jid].nb_unread[jid] + + if unread_messages > 0: + text = i18n.ngettext( + 'Gajim - %d unread message', + 'Gajim - %d unread messages', + unread_messages, unread_messages, unread_messages) + else: + text = 'Gajim' + self.status_icon.set_tooltip(text) + + def set_img(self): + if not gajim.interface.systray_enabled: + return + if len(self.jids) > 0: + state = 'message' + else: + state = self.status + image = gajim.interface.roster.jabber_state_images['16'][state] + if image.get_storage_type() == gtk.IMAGE_PIXBUF: + self.status_icon.props.pixbuf = image.get_pixbuf() + #FIXME: oops they forgot to support GIF animation? + #or they were lazy to get it to work under Windows! WTF! + #elif image.get_storage_type() == gtk.IMAGE_ANIMATION: + # self.img_tray.set_from_animation(image.get_animation()) diff --git a/src/systray.py b/src/systray.py index b7e780919..2599224e0 100644 --- a/src/systray.py +++ b/src/systray.py @@ -2,7 +2,7 @@ ## ## Copyright (C) 2003-2006 Yann Le Boulanger ## Copyright (C) 2003-2004 Vincent Hanquez -## Copyright (C) 2005-2006 Nikos Kouremenos +## Copyright (C) 2005-2006 Nikos Kouremenos ## Copyright (C) 2005 Dimitur Kirov ## Copyright (C) 2005-2006 Travis Shirk ## Copyright (C) 2005 Norman Rasmussen @@ -77,7 +77,7 @@ class Systray: def add_jid(self, jid, account, typ, advanced_notif_num = None): l = [account, jid, typ] - # We can keep several single message 'cause we open them one by one + # We can keep several single message because we open them one by one if not l in self.jids or typ == 'normal': self.jids.append(l) self.set_img(advanced_notif_num)