2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/systray.py
|
2005-03-11 18:57:35 +01:00
|
|
|
##
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2003-2005 Vincent Hanquez <tab AT snarc.org>
|
|
|
|
## Copyright (C) 2003-2008 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2005 Norman Rasmussen <norman AT rasmussen.co.za>
|
|
|
|
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com>
|
|
|
|
## Travis Shirk <travis AT pobox.com>
|
|
|
|
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem AT gmail.com>
|
|
|
|
## Copyright (C) 2006 Stefan Bethge <stefan AT lanpartei.de>
|
|
|
|
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Copyright (C) 2007 Lukas Petrovicky <lukas AT petrovicky.net>
|
|
|
|
## Julien Pivotto <roidelapluie AT gmail.com>
|
2005-03-11 18:57:35 +01:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2005-03-11 18:57:35 +01:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2005-03-11 18:57:35 +01:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2005-03-11 18:57:35 +01:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-03-11 18:57:35 +01:00
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-22 13:13:13 +02:00
|
|
|
##
|
2005-03-11 18:57:35 +01:00
|
|
|
|
|
|
|
import gtk
|
2005-07-31 21:21:11 +02:00
|
|
|
import gobject
|
2005-06-20 19:45:04 +02:00
|
|
|
import os
|
2005-03-11 18:57:35 +01:00
|
|
|
|
2006-03-05 17:07:27 +01:00
|
|
|
import dialogs
|
|
|
|
import config
|
2005-08-15 01:52:12 +02:00
|
|
|
import tooltips
|
2005-10-31 19:06:36 +01:00
|
|
|
import gtkgui_helpers
|
2005-08-15 01:52:12 +02:00
|
|
|
|
2005-04-17 18:06:12 +02:00
|
|
|
from common import gajim
|
2005-05-20 17:58:23 +02:00
|
|
|
from common import helpers
|
2009-04-12 20:13:37 +02:00
|
|
|
from common import pep
|
2005-03-11 18:57:35 +01:00
|
|
|
|
2006-03-24 19:48:26 +01:00
|
|
|
HAS_SYSTRAY_CAPABILITIES = True
|
|
|
|
|
2005-05-17 22:31:43 +02:00
|
|
|
try:
|
|
|
|
import egg.trayicon as trayicon # gnomepythonextras trayicon
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2005-05-17 22:31:43 +02:00
|
|
|
try:
|
|
|
|
import trayicon # our trayicon
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2005-05-17 22:31:43 +02:00
|
|
|
gajim.log.debug('No trayicon module available')
|
2006-03-24 19:48:26 +01:00
|
|
|
HAS_SYSTRAY_CAPABILITIES = False
|
2005-05-17 22:31:43 +02:00
|
|
|
|
2005-03-11 18:57:35 +01:00
|
|
|
|
2005-03-29 18:37:59 +02:00
|
|
|
class Systray:
|
2005-08-15 21:52:18 +02:00
|
|
|
'''Class for icon in the notification area
|
2006-10-05 01:30:03 +02:00
|
|
|
This class is both base class (for statusicon.py) and normal class
|
2005-08-15 21:52:18 +02:00
|
|
|
for trayicon in GNU/Linux'''
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2006-03-08 02:27:01 +01:00
|
|
|
self.single_message_handler_id = None
|
2006-05-09 00:22:40 +02:00
|
|
|
self.new_chat_handler_id = None
|
2005-06-15 13:14:59 +02:00
|
|
|
self.t = None
|
2006-11-20 14:12:52 +01:00
|
|
|
# click somewhere else does not popdown menu. workaround this.
|
2008-12-03 22:56:12 +01:00
|
|
|
self.added_hide_menuitem = False
|
2005-06-15 13:14:59 +02:00
|
|
|
self.img_tray = gtk.Image()
|
|
|
|
self.status = 'offline'
|
2006-05-02 17:53:25 +02:00
|
|
|
self.xml = gtkgui_helpers.get_glade('systray_context_menu.glade')
|
2005-06-15 13:14:59 +02:00
|
|
|
self.systray_context_menu = self.xml.get_widget('systray_context_menu')
|
|
|
|
self.xml.signal_autoconnect(self)
|
2006-04-08 01:07:14 +02:00
|
|
|
self.popup_menus = []
|
2005-06-15 13:14:59 +02:00
|
|
|
|
2007-03-10 12:30:23 +01:00
|
|
|
def subscribe_events(self):
|
|
|
|
'''Register listeners to the events class'''
|
|
|
|
gajim.events.event_added_subscribe(self.on_event_added)
|
|
|
|
gajim.events.event_removed_subscribe(self.on_event_removed)
|
|
|
|
|
|
|
|
def unsubscribe_events(self):
|
|
|
|
'''Unregister listeners to the events class'''
|
|
|
|
gajim.events.event_added_unsubscribe(self.on_event_added)
|
|
|
|
gajim.events.event_removed_unsubscribe(self.on_event_removed)
|
|
|
|
|
|
|
|
def on_event_added(self, event):
|
|
|
|
'''Called when an event is added to the event list'''
|
|
|
|
if event.show_in_systray:
|
|
|
|
self.set_img()
|
|
|
|
|
2007-03-11 09:58:08 +01:00
|
|
|
def on_event_removed(self, event_list):
|
2007-03-10 12:30:23 +01:00
|
|
|
'''Called when one or more events are removed from the event list'''
|
|
|
|
self.set_img()
|
|
|
|
|
2006-09-02 23:01:11 +02:00
|
|
|
def set_img(self):
|
2006-07-17 23:41:11 +02:00
|
|
|
if not gajim.interface.systray_enabled:
|
|
|
|
return
|
2006-09-02 23:01:11 +02:00
|
|
|
if gajim.events.get_nb_systray_events():
|
2007-07-13 12:11:49 +02:00
|
|
|
state = 'event'
|
2005-03-11 18:57:35 +01:00
|
|
|
else:
|
2005-08-16 22:24:56 +02:00
|
|
|
state = self.status
|
2009-01-25 10:19:24 +01:00
|
|
|
if state != 'event' and gajim.config.get('trayicon') == 'on_event':
|
|
|
|
self.t.hide()
|
|
|
|
else:
|
|
|
|
self.t.show()
|
2008-04-17 16:17:14 +02:00
|
|
|
image = gajim.interface.jabber_state_images['16'][state]
|
2005-03-11 18:57:35 +01:00
|
|
|
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
|
|
|
self.img_tray.set_from_animation(image.get_animation())
|
|
|
|
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
|
|
|
self.img_tray.set_from_pixbuf(image.get_pixbuf())
|
|
|
|
|
2005-07-31 21:32:06 +02:00
|
|
|
def change_status(self, global_status):
|
|
|
|
''' set tray image to 'global_status' '''
|
2008-12-03 22:56:12 +01:00
|
|
|
# change image and status, only if it is different
|
2005-07-30 11:09:47 +02:00
|
|
|
if global_status is not None and self.status != global_status:
|
2005-07-30 02:20:28 +02:00
|
|
|
self.status = global_status
|
2005-07-30 11:09:47 +02:00
|
|
|
self.set_img()
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-03-11 18:57:35 +01:00
|
|
|
def start_chat(self, widget, account, jid):
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
2006-01-25 03:43:55 +01:00
|
|
|
if gajim.interface.msg_win_mgr.has_window(jid, account):
|
2006-03-08 02:27:01 +01:00
|
|
|
gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(
|
|
|
|
jid, account)
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
elif contact:
|
2008-04-20 20:14:04 +02:00
|
|
|
gajim.interface.new_chat(contact, account)
|
2006-03-08 02:27:01 +01:00
|
|
|
gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(
|
|
|
|
jid, account)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2006-03-08 02:27:01 +01:00
|
|
|
def on_single_message_menuitem_activate(self, widget, account):
|
|
|
|
dialogs.SingleMessageWindow(account, action = 'send')
|
2005-03-11 18:57:35 +01:00
|
|
|
|
2006-05-09 00:22:40 +02:00
|
|
|
def on_new_chat(self, widget, account):
|
|
|
|
dialogs.NewChatDialog(account)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2006-10-05 01:30:03 +02:00
|
|
|
def make_menu(self, event_button, event_time):
|
|
|
|
'''create chat with and new message (sub) menus/menuitems'''
|
2006-04-08 01:07:14 +02:00
|
|
|
for m in self.popup_menus:
|
|
|
|
m.destroy()
|
|
|
|
|
2005-03-15 01:40:08 +01:00
|
|
|
chat_with_menuitem = self.xml.get_widget('chat_with_menuitem')
|
2006-10-05 01:30:03 +02:00
|
|
|
single_message_menuitem = self.xml.get_widget(
|
|
|
|
'single_message_menuitem')
|
2005-06-20 19:45:04 +02:00
|
|
|
status_menuitem = self.xml.get_widget('status_menu')
|
2006-04-09 13:13:39 +02:00
|
|
|
join_gc_menuitem = self.xml.get_widget('join_gc_menuitem')
|
2006-11-04 02:42:29 +01:00
|
|
|
sounds_mute_menuitem = self.xml.get_widget('sounds_mute_menuitem')
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2006-03-08 02:27:01 +01:00
|
|
|
if self.single_message_handler_id:
|
|
|
|
single_message_menuitem.handler_disconnect(
|
|
|
|
self.single_message_handler_id)
|
|
|
|
self.single_message_handler_id = None
|
2006-05-09 00:22:40 +02:00
|
|
|
if self.new_chat_handler_id:
|
|
|
|
chat_with_menuitem.disconnect(self.new_chat_handler_id)
|
|
|
|
self.new_chat_handler_id = None
|
2005-06-20 19:45:04 +02:00
|
|
|
|
|
|
|
sub_menu = gtk.Menu()
|
2006-04-08 01:07:14 +02:00
|
|
|
self.popup_menus.append(sub_menu)
|
2005-06-20 19:45:04 +02:00
|
|
|
status_menuitem.set_submenu(sub_menu)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2006-04-09 13:13:39 +02:00
|
|
|
gc_sub_menu = gtk.Menu() # gc is always a submenu
|
|
|
|
join_gc_menuitem.set_submenu(gc_sub_menu)
|
2005-06-20 19:45:04 +02:00
|
|
|
|
2005-06-20 21:18:53 +02:00
|
|
|
# We need our own set of status icons, let's make 'em!
|
|
|
|
iconset = gajim.config.get('iconset')
|
2007-08-06 00:57:04 +02:00
|
|
|
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
2008-04-17 21:26:09 +02:00
|
|
|
state_images = gtkgui_helpers.load_iconset(path)
|
2005-06-20 19:45:04 +02:00
|
|
|
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'muc_active' in state_images:
|
2006-09-20 19:21:59 +02:00
|
|
|
join_gc_menuitem.set_image(state_images['muc_active'])
|
|
|
|
|
2005-10-27 15:15:03 +02:00
|
|
|
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
|
2005-10-09 18:08:18 +02:00
|
|
|
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
|
2005-08-09 18:33:45 +02:00
|
|
|
item = gtk.ImageMenuItem(uf_show)
|
|
|
|
item.set_image(state_images[show])
|
2005-06-20 19:45:04 +02:00
|
|
|
sub_menu.append(item)
|
2008-11-18 21:16:23 +01:00
|
|
|
item.connect('activate', self.on_show_menuitem_activate, show)
|
2005-06-20 19:45:04 +02:00
|
|
|
|
2005-10-09 16:49:14 +02:00
|
|
|
item = gtk.SeparatorMenuItem()
|
|
|
|
sub_menu.append(item)
|
|
|
|
|
2005-10-10 00:24:18 +02:00
|
|
|
item = gtk.ImageMenuItem(_('_Change Status Message...'))
|
2006-03-29 18:42:06 +02:00
|
|
|
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png')
|
2005-10-09 20:45:03 +02:00
|
|
|
img = gtk.Image()
|
|
|
|
img.set_from_file(path)
|
|
|
|
item.set_image(img)
|
2005-10-09 16:49:14 +02:00
|
|
|
sub_menu.append(item)
|
2008-11-18 21:16:23 +01:00
|
|
|
item.connect('activate', self.on_change_status_message_activate)
|
2008-10-01 18:53:23 +02:00
|
|
|
|
2006-04-08 12:28:53 +02:00
|
|
|
connected_accounts = gajim.get_number_of_connected_accounts()
|
2006-04-06 20:37:24 +02:00
|
|
|
if connected_accounts < 1:
|
2005-10-09 16:49:14 +02:00
|
|
|
item.set_sensitive(False)
|
|
|
|
|
2008-12-22 11:38:05 +01:00
|
|
|
connected_accounts_with_private_storage = 0
|
|
|
|
|
2005-10-09 16:49:14 +02:00
|
|
|
item = gtk.SeparatorMenuItem()
|
|
|
|
sub_menu.append(item)
|
|
|
|
|
2005-10-09 18:08:18 +02:00
|
|
|
uf_show = helpers.get_uf_show('offline', use_mnemonic = True)
|
2005-10-09 16:49:14 +02:00
|
|
|
item = gtk.ImageMenuItem(uf_show)
|
|
|
|
item.set_image(state_images['offline'])
|
|
|
|
sub_menu.append(item)
|
2008-11-18 21:16:23 +01:00
|
|
|
item.connect('activate', self.on_show_menuitem_activate, 'offline')
|
2005-10-09 16:49:14 +02:00
|
|
|
|
2006-10-12 05:22:57 +02:00
|
|
|
iskey = connected_accounts > 0 and not (connected_accounts == 1 and
|
|
|
|
gajim.connections[gajim.connections.keys()[0]].is_zeroconf)
|
2005-04-22 03:35:36 +02:00
|
|
|
chat_with_menuitem.set_sensitive(iskey)
|
2006-03-08 02:27:01 +01:00
|
|
|
single_message_menuitem.set_sensitive(iskey)
|
2006-04-09 13:13:39 +02:00
|
|
|
join_gc_menuitem.set_sensitive(iskey)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2009-06-15 21:00:14 +02:00
|
|
|
accounts_list = sorted(gajim.contacts.get_accounts())
|
|
|
|
# items that get shown whether an account is zeroconf or not
|
2008-12-22 11:38:05 +01:00
|
|
|
if connected_accounts > 1: # 2 or more connections? make submenus
|
2005-03-14 18:30:52 +01:00
|
|
|
account_menu_for_chat_with = gtk.Menu()
|
|
|
|
chat_with_menuitem.set_submenu(account_menu_for_chat_with)
|
2006-04-08 01:07:14 +02:00
|
|
|
self.popup_menus.append(account_menu_for_chat_with)
|
2005-03-14 18:30:52 +01:00
|
|
|
|
2006-04-06 20:37:24 +02:00
|
|
|
for account in accounts_list:
|
2008-12-22 11:38:05 +01:00
|
|
|
if gajim.account_is_connected(account):
|
2008-10-01 18:53:23 +02:00
|
|
|
# for chat_with
|
2006-04-06 20:37:24 +02:00
|
|
|
item = gtk.MenuItem(_('using account %s') % account)
|
|
|
|
account_menu_for_chat_with.append(item)
|
2008-11-18 21:16:23 +01:00
|
|
|
item.connect('activate', self.on_new_chat, account)
|
2006-04-09 13:13:39 +02:00
|
|
|
|
2006-04-06 20:37:24 +02:00
|
|
|
elif connected_accounts == 1: # one account
|
|
|
|
# one account connected, no need to show 'as jid'
|
|
|
|
for account in gajim.connections:
|
2006-04-16 15:13:44 +02:00
|
|
|
if gajim.connections[account].connected > 1:
|
2008-12-22 11:38:05 +01:00
|
|
|
# for start chat
|
2006-05-09 00:22:40 +02:00
|
|
|
self.new_chat_handler_id = chat_with_menuitem.connect(
|
2008-12-22 11:38:05 +01:00
|
|
|
'activate', self.on_new_chat, account)
|
|
|
|
break # No other connected account
|
|
|
|
|
|
|
|
# menu items that don't apply to zeroconf connections
|
|
|
|
if connected_accounts == 1 or (connected_accounts == 2 and \
|
|
|
|
gajim.zeroconf_is_connected()):
|
|
|
|
# only one 'real' (non-zeroconf) account is connected, don't need
|
|
|
|
# submenus
|
|
|
|
for account in gajim.connections:
|
|
|
|
if gajim.account_is_connected(account) and \
|
|
|
|
not gajim.config.get_per('accounts', account, 'is_zeroconf'):
|
|
|
|
if gajim.connections[account].private_storage_supported:
|
|
|
|
connected_accounts_with_private_storage += 1
|
|
|
|
|
2006-04-06 20:37:24 +02:00
|
|
|
# for single message
|
|
|
|
single_message_menuitem.remove_submenu()
|
2006-10-05 01:30:03 +02:00
|
|
|
self.single_message_handler_id = single_message_menuitem.\
|
|
|
|
connect('activate',
|
|
|
|
self.on_single_message_menuitem_activate, account)
|
2006-04-09 13:13:39 +02:00
|
|
|
# join gc
|
2008-11-18 21:16:23 +01:00
|
|
|
gajim.interface.roster.add_bookmarks_list(gc_sub_menu,
|
|
|
|
account)
|
2008-12-22 11:38:05 +01:00
|
|
|
break # No other account connected
|
|
|
|
else:
|
|
|
|
# 2 or more 'real' accounts are connected, make submenus
|
|
|
|
account_menu_for_single_message = gtk.Menu()
|
|
|
|
single_message_menuitem.set_submenu(
|
|
|
|
account_menu_for_single_message)
|
|
|
|
self.popup_menus.append(account_menu_for_single_message)
|
|
|
|
|
|
|
|
for account in accounts_list:
|
|
|
|
if gajim.connections[account].is_zeroconf or \
|
|
|
|
not gajim.account_is_connected(account):
|
|
|
|
continue
|
|
|
|
if gajim.connections[account].private_storage_supported:
|
|
|
|
connected_accounts_with_private_storage += 1
|
|
|
|
# for single message
|
|
|
|
item = gtk.MenuItem(_('using account %s') % account)
|
|
|
|
item.connect('activate',
|
|
|
|
self.on_single_message_menuitem_activate, account)
|
|
|
|
account_menu_for_single_message.append(item)
|
|
|
|
|
|
|
|
# join gc
|
|
|
|
gc_item = gtk.MenuItem(_('using account %s') % account, False)
|
|
|
|
gc_sub_menu.append(gc_item)
|
|
|
|
gc_menuitem_menu = gtk.Menu()
|
|
|
|
gajim.interface.roster.add_bookmarks_list(gc_menuitem_menu,
|
|
|
|
account)
|
|
|
|
gc_item.set_submenu(gc_menuitem_menu)
|
|
|
|
gc_sub_menu.show_all()
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2008-09-09 19:34:31 +02:00
|
|
|
newitem = gtk.SeparatorMenuItem() # separator
|
|
|
|
gc_sub_menu.append(newitem)
|
|
|
|
newitem = gtk.ImageMenuItem(_('_Manage Bookmarks...'))
|
|
|
|
img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
|
|
|
|
newitem.set_image(img)
|
2008-11-18 21:16:23 +01:00
|
|
|
newitem.connect('activate',
|
|
|
|
gajim.interface.roster.on_manage_bookmarks_menuitem_activate)
|
2008-09-09 19:34:31 +02:00
|
|
|
gc_sub_menu.append(newitem)
|
2008-12-22 11:38:05 +01:00
|
|
|
if connected_accounts_with_private_storage == 0:
|
|
|
|
newitem.set_sensitive(False)
|
2008-09-09 19:34:31 +02:00
|
|
|
|
2006-11-04 02:42:29 +01:00
|
|
|
sounds_mute_menuitem.set_active(not gajim.config.get('sounds_on'))
|
2006-11-20 14:12:52 +01:00
|
|
|
|
2007-12-15 13:33:21 +01:00
|
|
|
if os.name == 'nt':
|
2009-04-27 21:28:53 +02:00
|
|
|
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
|
2007-12-15 13:33:21 +01:00
|
|
|
|
2005-08-15 21:52:18 +02:00
|
|
|
self.systray_context_menu.show_all()
|
2008-11-18 21:16:23 +01:00
|
|
|
self.systray_context_menu.popup(None, None, None, 0,
|
2007-12-15 13:33:21 +01:00
|
|
|
event_time)
|
2005-06-15 13:14:59 +02:00
|
|
|
|
2005-10-30 02:08:39 +02:00
|
|
|
def on_show_all_events_menuitem_activate(self, widget):
|
2006-09-02 23:01:11 +02:00
|
|
|
events = gajim.events.get_systray_events()
|
|
|
|
for account in events:
|
|
|
|
for jid in events[account]:
|
|
|
|
for event in events[account][jid]:
|
|
|
|
gajim.interface.handle_event(account, jid, event.type_)
|
2005-10-30 02:08:39 +02:00
|
|
|
|
2006-11-04 02:42:29 +01:00
|
|
|
def on_sounds_mute_menuitem_activate(self, widget):
|
2008-12-03 22:56:12 +01:00
|
|
|
gajim.config.set('sounds_on', not widget.get_active())
|
2006-11-04 02:42:29 +01:00
|
|
|
gajim.interface.save_config()
|
|
|
|
|
2005-10-30 02:08:39 +02:00
|
|
|
def on_show_roster_menuitem_activate(self, widget):
|
|
|
|
win = gajim.interface.roster.window
|
|
|
|
win.present()
|
|
|
|
|
2005-06-15 13:14:59 +02:00
|
|
|
def on_preferences_menuitem_activate(self, widget):
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'preferences' in gajim.interface.instances:
|
2005-11-13 16:08:47 +01:00
|
|
|
gajim.interface.instances['preferences'].window.present()
|
2005-06-15 13:14:59 +02:00
|
|
|
else:
|
2006-03-05 17:07:27 +01:00
|
|
|
gajim.interface.instances['preferences'] = config.PreferencesWindow()
|
2005-06-15 13:14:59 +02:00
|
|
|
|
2008-12-03 22:56:12 +01:00
|
|
|
def on_quit_menuitem_activate(self, widget):
|
2008-03-20 17:31:21 +01:00
|
|
|
gajim.interface.roster.on_quit_request()
|
2005-03-15 01:40:08 +01:00
|
|
|
|
2005-08-11 15:46:37 +02:00
|
|
|
def on_left_click(self):
|
2005-10-20 13:17:17 +02:00
|
|
|
win = gajim.interface.roster.window
|
2009-02-12 12:07:09 +01:00
|
|
|
if len(gajim.events.get_systray_events()) == 0:
|
|
|
|
# No pending events, so toggle visible/hidden for roster window
|
2009-04-05 19:35:05 +02:00
|
|
|
if not win.iconify_initially and (win.get_property(
|
2009-03-22 09:53:31 +01:00
|
|
|
'has-toplevel-focus') or os.name == 'nt'):
|
2009-02-12 12:07:09 +01:00
|
|
|
# visible in ANY virtual desktop?
|
|
|
|
|
|
|
|
# we could be in another VD right now. eg vd2
|
|
|
|
# and we want to show it in vd2
|
|
|
|
if not gtkgui_helpers.possibly_move_window_in_current_desktop(win):
|
2009-04-05 19:35:05 +02:00
|
|
|
win.set_property('skip-taskbar-hint', False)
|
2009-04-03 20:48:31 +02:00
|
|
|
win.iconify() # else we hide it from VD that was visible in
|
|
|
|
win.set_property('skip-taskbar-hint', True)
|
2009-02-12 12:07:09 +01:00
|
|
|
else:
|
|
|
|
win.deiconify()
|
2009-04-03 20:48:31 +02:00
|
|
|
if not gajim.config.get('roster_window_skip_taskbar'):
|
|
|
|
win.set_property('skip-taskbar-hint', False)
|
|
|
|
win.present_with_time(gtk.get_current_event_time())
|
2005-08-11 15:46:37 +02:00
|
|
|
else:
|
2009-02-12 12:07:09 +01:00
|
|
|
self.handle_first_event()
|
2005-10-30 02:08:39 +02:00
|
|
|
|
|
|
|
def handle_first_event(self):
|
2006-09-02 23:01:11 +02:00
|
|
|
account, jid, event = gajim.events.get_first_systray_event()
|
2009-05-20 10:58:46 +02:00
|
|
|
if not event:
|
|
|
|
return
|
2006-09-02 23:01:11 +02:00
|
|
|
gajim.interface.handle_event(account, jid, event.type_)
|
2005-10-30 02:08:39 +02:00
|
|
|
|
2005-08-11 15:46:37 +02:00
|
|
|
def on_middle_click(self):
|
2005-10-31 20:35:17 +01:00
|
|
|
'''middle click raises window to have complete focus (fe. get kbd events)
|
|
|
|
but if already raised, it hides it'''
|
2009-02-12 12:07:09 +01:00
|
|
|
win = gajim.interface.roster.window
|
|
|
|
if win.is_active(): # is it fully raised? (eg does it receive kbd events?)
|
|
|
|
win.hide()
|
|
|
|
else:
|
|
|
|
win.present()
|
2005-08-11 15:46:37 +02:00
|
|
|
|
|
|
|
def on_clicked(self, widget, event):
|
|
|
|
self.on_tray_leave_notify_event(widget, None)
|
2006-10-05 01:34:12 +02:00
|
|
|
if event.type != gtk.gdk.BUTTON_PRESS:
|
|
|
|
return
|
|
|
|
if event.button == 1: # Left click
|
2009-02-12 12:07:09 +01:00
|
|
|
self.on_left_click()
|
2006-02-27 00:29:49 +01:00
|
|
|
elif event.button == 2: # middle click
|
2005-08-11 15:46:37 +02:00
|
|
|
self.on_middle_click()
|
2006-02-27 00:29:49 +01:00
|
|
|
elif event.button == 3: # right click
|
2006-10-05 01:30:03 +02:00
|
|
|
self.make_menu(event.button, event.time)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-06-20 19:45:04 +02:00
|
|
|
def on_show_menuitem_activate(self, widget, show):
|
2005-11-08 12:13:47 +01:00
|
|
|
# we all add some fake (we cannot select those nor have them as show)
|
|
|
|
# but this helps to align with roster's status_combobox index positions
|
|
|
|
l = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'SEPARATOR',
|
|
|
|
'CHANGE_STATUS_MSG_MENUITEM', 'SEPARATOR', 'offline']
|
2005-07-19 22:12:02 +02:00
|
|
|
index = l.index(show)
|
2007-11-09 10:21:38 +01:00
|
|
|
if not helpers.statuses_unified():
|
|
|
|
gajim.interface.roster.status_combobox.set_active(index + 2)
|
|
|
|
return
|
2007-10-14 18:55:03 +02:00
|
|
|
current = gajim.interface.roster.status_combobox.get_active()
|
|
|
|
if index != current:
|
|
|
|
gajim.interface.roster.status_combobox.set_active(index)
|
2005-10-09 16:49:14 +02:00
|
|
|
|
|
|
|
def on_change_status_message_activate(self, widget):
|
2005-11-06 18:10:55 +01:00
|
|
|
model = gajim.interface.roster.status_combobox.get_model()
|
2005-11-07 15:06:39 +01:00
|
|
|
active = gajim.interface.roster.status_combobox.get_active()
|
2005-11-05 18:52:49 +01:00
|
|
|
status = model[active][2].decode('utf-8')
|
2009-04-12 20:13:37 +02:00
|
|
|
def on_response(message, pep_dict):
|
2008-08-04 15:34:29 +02:00
|
|
|
if message is None: # None if user press Cancel
|
|
|
|
return
|
2005-10-10 00:24:18 +02:00
|
|
|
accounts = gajim.connections.keys()
|
|
|
|
for acct in accounts:
|
2005-10-10 21:10:59 +02:00
|
|
|
if not gajim.config.get_per('accounts', acct,
|
|
|
|
'sync_with_global_status'):
|
|
|
|
continue
|
2005-10-10 00:24:18 +02:00
|
|
|
show = gajim.SHOW_LIST[gajim.connections[acct].connected]
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.send_status(acct, show, message)
|
2009-04-12 20:13:37 +02:00
|
|
|
gajim.interface.roster.send_pep(acct, pep_dict)
|
2008-08-04 15:34:29 +02:00
|
|
|
dlg = dialogs.ChangeStatusMessageDialog(on_response, status)
|
2009-10-26 19:56:42 +01:00
|
|
|
dlg.dialog.present()
|
2005-10-09 16:49:14 +02:00
|
|
|
|
2005-07-31 21:21:11 +02:00
|
|
|
def show_tooltip(self, widget):
|
|
|
|
position = widget.window.get_origin()
|
|
|
|
if self.tooltip.id == position:
|
|
|
|
size = widget.window.get_size()
|
2006-02-28 11:13:42 +01:00
|
|
|
self.tooltip.show_tooltip('', size[1], position[1])
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-07-31 21:21:11 +02:00
|
|
|
def on_tray_motion_notify_event(self, widget, event):
|
|
|
|
position = widget.window.get_origin()
|
|
|
|
if self.tooltip.timeout > 0:
|
|
|
|
if self.tooltip.id != position:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
if self.tooltip.timeout == 0 and \
|
|
|
|
self.tooltip.id != position:
|
|
|
|
self.tooltip.id = position
|
|
|
|
self.tooltip.timeout = gobject.timeout_add(500,
|
|
|
|
self.show_tooltip, widget)
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-07-31 21:21:11 +02:00
|
|
|
def on_tray_leave_notify_event(self, widget, event):
|
|
|
|
position = widget.window.get_origin()
|
|
|
|
if self.tooltip.timeout > 0 and \
|
|
|
|
self.tooltip.id == position:
|
|
|
|
self.tooltip.hide_tooltip()
|
2006-07-26 21:01:01 +02:00
|
|
|
|
|
|
|
def on_tray_destroyed(self, widget):
|
|
|
|
'''re-add trayicon when systray is destroyed'''
|
|
|
|
self.t = None
|
2006-07-28 07:54:46 +02:00
|
|
|
if gajim.interface.systray_enabled:
|
|
|
|
self.show_icon()
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-03-11 18:57:35 +01:00
|
|
|
def show_icon(self):
|
|
|
|
if not self.t:
|
2005-03-15 15:21:09 +01:00
|
|
|
self.t = trayicon.TrayIcon('Gajim')
|
2006-07-26 21:01:01 +02:00
|
|
|
self.t.connect('destroy', self.on_tray_destroyed)
|
2005-03-11 18:57:35 +01:00
|
|
|
eb = gtk.EventBox()
|
2005-07-30 12:06:58 +02:00
|
|
|
# avoid draw seperate bg color in some gtk themes
|
|
|
|
eb.set_visible_window(False)
|
2005-07-31 21:21:11 +02:00
|
|
|
eb.set_events(gtk.gdk.POINTER_MOTION_MASK)
|
2005-03-15 15:21:09 +01:00
|
|
|
eb.connect('button-press-event', self.on_clicked)
|
2005-07-31 21:21:11 +02:00
|
|
|
eb.connect('motion-notify-event', self.on_tray_motion_notify_event)
|
|
|
|
eb.connect('leave-notify-event', self.on_tray_leave_notify_event)
|
2005-10-20 13:17:17 +02:00
|
|
|
self.tooltip = tooltips.NotificationAreaTooltip()
|
2005-07-31 21:32:06 +02:00
|
|
|
|
2005-03-11 18:57:35 +01:00
|
|
|
self.img_tray = gtk.Image()
|
|
|
|
eb.add(self.img_tray)
|
|
|
|
self.t.add(eb)
|
|
|
|
self.set_img()
|
2007-03-10 12:30:23 +01:00
|
|
|
self.subscribe_events()
|
2005-03-11 18:57:35 +01:00
|
|
|
self.t.show_all()
|
2006-07-26 21:01:01 +02:00
|
|
|
|
2005-03-11 18:57:35 +01:00
|
|
|
def hide_icon(self):
|
|
|
|
if self.t:
|
|
|
|
self.t.destroy()
|
|
|
|
self.t = None
|
2007-03-10 12:30:23 +01:00
|
|
|
self.unsubscribe_events()
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-07-31 10:49:31 +02:00
|
|
|
# vim: se ts=3:
|