Author: js Date: 2008-10-02 19:53:25 +0200 (Thu, 02 Oct 2008) New Revision: 10464
Added: branches/osx_newbuildsys/src/dock.py Modified: branches/osx_newbuildsys/src/gajim.py branches/osx_newbuildsys/src/roster_window.py branches/osx_newbuildsys/src/statusicon.py Log: Set our icon in dock.
Added: branches/osx_newbuildsys/src/dock.py =================================================================== --- branches/osx_newbuildsys/src/dock.py (rev 0) +++ branches/osx_newbuildsys/src/dock.py 2008-10-02 17:53:25 UTC (rev 10464) @@ -0,0 +1,77 @@ +# -*- coding:utf-8 -*- +## src/dock.py +## +## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org> +## +## This file is part of Gajim. +## +## Gajim 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; version 3 only. +## +## Gajim 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. +## +## You should have received a copy of the GNU General Public License +## along with Gajim. If not, see http://www.gnu.org/licenses/. +## + +from common import gajim +from common import helpers + +HAS_SYSTRAY_CAPABILITIES = True +DOCK_IMAGES = {} + +try: + from AppKit import * +except ImportError: + pass + +class Dock: + '''Class for icon in the OS X dock''' + + def __init__(self): + self.status = 'offline' + + try: + # FIXME: We want svg for that! + for img in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', + 'offline', 'connecting', 'error', 'event']: + DOCK_IMAGES[img] = NSImage.alloc().initByReferencingFile_( + '../data/iconsets/dcraven/32x32/' + img + '.png') + except NameError: + pass + + gajim.events.event_added_subscribe(self.on_event_added) + gajim.events.event_removed_subscribe(self.on_event_removed) + + def on_event_added(self, event): + '''Called when an event is added to the event list''' + self.set_img() + + def on_event_removed(self, event_list): + '''Called when one or more events are removed from the event list''' + self.set_img() + + def set_img(self): + # FIXME: Using badging instead would be nicer + if gajim.events.get_nb_systray_events(): + state = 'event' + else: + state = self.status + + try: + NSApp.setApplicationIconImage_(DOCK_IMAGES[state]) + except NameError: + pass + + def change_status(self, global_status): + ''' set tray image to 'global_status' ''' + # change image and status, only if it is different + if global_status is not None and self.status != global_status: + self.status = global_status + self.set_img() + +# vim: se ts=3:
Modified: branches/osx_newbuildsys/src/gajim.py =================================================================== --- branches/osx_newbuildsys/src/gajim.py 2008-10-02 16:46:18 UTC (rev 10463) +++ branches/osx_newbuildsys/src/gajim.py 2008-10-02 17:53:25 UTC (rev 10464) @@ -3242,6 +3242,10 @@ if self.systray_capabilities: self.systray = systray.Systray()
+ if sys.platform == 'darwin': + import dock + self.dock = dock.Dock() + if self.systray_capabilities and gajim.config.get('trayicon'): self.show_systray()
Modified: branches/osx_newbuildsys/src/roster_window.py =================================================================== --- branches/osx_newbuildsys/src/roster_window.py 2008-10-02 16:46:18 UTC (rev 10463) +++ branches/osx_newbuildsys/src/roster_window.py 2008-10-02 17:53:25 UTC (rev 10464) @@ -1897,6 +1897,8 @@ gajim.interface.jabber_state_images['16']['connecting'] if gajim.interface.systray_enabled: gajim.interface.systray.change_status('connecting') + if sys.platform == 'darwin': + gajim.interface.dock.change_status('connecting')
def send_status(self, account, status, txt, auto=False, to=None): child_iterA = self._get_account_iter(account, self.model) @@ -1934,6 +1936,8 @@ gajim.interface.jabber_state_images['16']['offline'] if gajim.interface.systray_enabled: gajim.interface.systray.change_status('offline') + if sys.platform == 'darwin': + gajim.interface.dock.change_status('offline') self.update_status_combobox()
w = dialogs.PassphraseDialog(_('Password Required'), text, @@ -2146,6 +2150,8 @@ self.combobox_callback_active = True if gajim.interface.systray_enabled: gajim.interface.systray.change_status(show) + if sys.platform == 'darwin': + gajim.interface.dock.change_status(show)
def get_show(self, lcontact): prio = lcontact[0].priority @@ -4063,6 +4069,8 @@ # Update the systray if gajim.interface.systray_enabled: gajim.interface.systray.set_img() + if sys.platform == 'darwin': + gajim.interface.dock.set_img()
for win in gajim.interface.msg_win_mgr.windows(): for ctrl in win.controls():
Modified: branches/osx_newbuildsys/src/statusicon.py =================================================================== --- branches/osx_newbuildsys/src/statusicon.py 2008-10-02 16:46:18 UTC (rev 10463) +++ branches/osx_newbuildsys/src/statusicon.py 2008-10-02 17:53:25 UTC (rev 10464) @@ -78,11 +78,6 @@ text = helpers.get_notification_icon_tooltip_text() self.status_icon.set_tooltip(text) if gajim.events.get_nb_systray_events(): - if sys.platform == 'darwin': - try: - osx.nsapp.requestUserAttention() - except NameError: - pass state = 'event' self.status_icon.set_blinking(True) else: