2005-04-18 16:05:30 +02:00
|
|
|
## dialogs.py
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
|
|
|
## Gajim Team:
|
2005-03-29 18:37:59 +02:00
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## - Vincent Hanquez <tab@snarc.org>
|
|
|
|
## - Nikos Kouremenos <kourem@gmail.com>
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
2005-01-07 22:52:38 +01:00
|
|
|
## Copyright (C) 2003-2005 Gajim Team
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
|
|
|
## 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; version 2 only.
|
|
|
|
##
|
|
|
|
## 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
|
2005-03-01 14:46:22 +01:00
|
|
|
import gtk.glade
|
|
|
|
import gobject
|
2005-04-18 18:54:49 +02:00
|
|
|
from gajim import User
|
2005-04-14 09:05:10 +02:00
|
|
|
from common import gajim
|
2004-05-17 01:47:14 +02:00
|
|
|
from common import i18n
|
2005-04-22 03:47:03 +02:00
|
|
|
from vcard import Vcard_window
|
2005-04-24 01:57:02 +02:00
|
|
|
from advanced import Advanced_window
|
2004-05-17 01:47:14 +02:00
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|
|
|
gtk.glade.textdomain (APP)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
GTKGUI_GLADE = 'gtkgui.glade'
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-17 18:41:09 +01:00
|
|
|
class Edit_groups_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for the edit group dialog window'''
|
2005-03-17 18:41:09 +01:00
|
|
|
def __init__(self, user, account, plugin):
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'edit_groups_dialog', APP)
|
|
|
|
self.dialog = self.xml.get_widget('edit_groups_dialog')
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
self.user = user
|
2005-04-17 23:31:18 +02:00
|
|
|
self.changes_made = False
|
2005-03-17 18:41:09 +01:00
|
|
|
self.list = self.xml.get_widget('groups_treeview')
|
2005-03-18 01:47:50 +01:00
|
|
|
self.xml.get_widget('nickname_label').set_markup(\
|
|
|
|
_('Contact\'s name: <i>%s</i>') % user.name)
|
|
|
|
self.xml.get_widget('jid_label').set_markup(\
|
|
|
|
_('JID: <i>%s</i>') % user.jid)
|
2005-03-17 18:41:09 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.dialog.show_all()
|
2005-03-17 18:41:09 +01:00
|
|
|
self.init_list()
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.dialog.run()
|
|
|
|
self.dialog.destroy()
|
2005-04-17 23:31:18 +02:00
|
|
|
if self.changes_made:
|
|
|
|
gajim.connections[self.account].update_user(self.user.jid, \
|
|
|
|
self.user.name, self.user.groups)
|
2005-03-17 18:41:09 +01:00
|
|
|
|
|
|
|
def update_user(self):
|
2005-03-19 12:32:29 +01:00
|
|
|
self.plugin.roster.remove_user(self.user, self.account)
|
2005-03-17 18:41:09 +01:00
|
|
|
self.plugin.roster.add_user_to_roster(self.user.jid, self.account)
|
|
|
|
|
|
|
|
def on_add_button_clicked(self, widget):
|
|
|
|
group = self.xml.get_widget('group_entry').get_text()
|
|
|
|
if not group:
|
|
|
|
return
|
|
|
|
# check if it already exists
|
|
|
|
model = self.list.get_model()
|
|
|
|
iter = model.get_iter_root()
|
|
|
|
while iter:
|
|
|
|
if model.get_value(iter, 0) == group:
|
|
|
|
return
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
model.append((group, True))
|
|
|
|
self.user.groups.append(group)
|
|
|
|
self.update_user()
|
|
|
|
|
|
|
|
def group_toggled_cb(self, cell, path):
|
2005-04-17 23:31:18 +02:00
|
|
|
self.changes_made = True
|
2005-03-17 18:41:09 +01:00
|
|
|
model = self.list.get_model()
|
|
|
|
if model[path][1] and len(self.user.groups) == 1: # we try to remove
|
|
|
|
# the latest group
|
|
|
|
Error_dialog(_('There must be at least one group for each contact'))
|
|
|
|
return
|
|
|
|
model[path][1] = not model[path][1]
|
|
|
|
if model[path][1]:
|
|
|
|
self.user.groups.append(model[path][0])
|
|
|
|
else:
|
|
|
|
self.user.groups.remove(model[path][0])
|
|
|
|
self.update_user()
|
|
|
|
|
|
|
|
def init_list(self):
|
|
|
|
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
|
|
|
|
self.list.set_model(store)
|
|
|
|
for g in self.plugin.roster.groups[self.account].keys():
|
|
|
|
iter = store.append()
|
|
|
|
store.set(iter, 0, g)
|
|
|
|
if g in self.user.groups:
|
|
|
|
store.set(iter, 1, True)
|
|
|
|
else:
|
|
|
|
store.set(iter, 1, False)
|
|
|
|
column = gtk.TreeViewColumn(_('Group'))
|
|
|
|
self.list.append_column(column)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
column.pack_start(renderer)
|
2005-04-22 01:20:18 +02:00
|
|
|
column.set_attributes(renderer, text = 0)
|
2005-03-17 18:41:09 +01:00
|
|
|
|
|
|
|
column = gtk.TreeViewColumn(_('In the group'))
|
|
|
|
self.list.append_column(column)
|
|
|
|
renderer = gtk.CellRendererToggle()
|
|
|
|
column.pack_start(renderer)
|
|
|
|
renderer.set_property('activatable', True)
|
|
|
|
renderer.connect('toggled', self.group_toggled_cb)
|
2005-04-22 01:20:18 +02:00
|
|
|
column.set_attributes(renderer, active = 1)
|
2005-03-17 18:41:09 +01:00
|
|
|
|
2005-03-07 18:01:56 +01:00
|
|
|
class Passphrase_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for Passphrase dialog'''
|
2004-10-07 16:43:59 +02:00
|
|
|
def run(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Wait for OK button to be pressed and return passphrase/password'''
|
2005-03-15 11:20:10 +01:00
|
|
|
if self.autoconnect:
|
|
|
|
gtk.gdk.threads_enter()
|
2005-03-02 11:46:12 +01:00
|
|
|
rep = self.window.run()
|
2004-10-07 16:43:59 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 11:46:12 +01:00
|
|
|
passphrase = self.passphrase_entry.get_text()
|
2004-10-07 16:43:59 +02:00
|
|
|
else:
|
2005-03-02 11:46:12 +01:00
|
|
|
passphrase = -1
|
|
|
|
save_passphrase_checkbutton = self.xml.\
|
|
|
|
get_widget('save_passphrase_checkbutton')
|
|
|
|
self.window.destroy()
|
2004-12-02 01:00:57 +01:00
|
|
|
if self.autoconnect:
|
2005-03-15 11:20:10 +01:00
|
|
|
gtk.gdk.threads_leave()
|
|
|
|
return passphrase, save_passphrase_checkbutton.get_active()
|
2004-12-02 01:00:57 +01:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def __init__(self, labeltext, checkbuttontext, autoconnect = 0):
|
2005-03-02 11:46:12 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'passphrase_dialog', APP)
|
|
|
|
self.window = self.xml.get_widget('passphrase_dialog')
|
|
|
|
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
|
|
|
|
self.passphrase = -1
|
2004-12-02 01:00:57 +01:00
|
|
|
self.autoconnect = autoconnect
|
2005-03-02 13:38:33 +01:00
|
|
|
self.xml.get_widget('message_label').set_text(labeltext)
|
|
|
|
self.xml.get_widget('save_passphrase_checkbutton').set_label(checkbuttontext)
|
2005-03-02 11:46:12 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 14:04:47 +01:00
|
|
|
class choose_gpg_key_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for GPG key dialog'''
|
2004-10-10 20:44:38 +02:00
|
|
|
def run(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Wait for Ok button to be pressed and return the selected key'''
|
2005-03-02 12:46:51 +01:00
|
|
|
rep = self.window.run()
|
2004-10-10 20:44:38 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 12:46:51 +01:00
|
|
|
selection = self.keys_treeview.get_selection()
|
2004-10-10 20:44:38 +02:00
|
|
|
(model, iter) = selection.get_selected()
|
|
|
|
keyID = [model.get_value(iter, 0), model.get_value(iter, 1)]
|
|
|
|
else:
|
|
|
|
keyID = -1
|
2005-03-02 12:46:51 +01:00
|
|
|
self.window.destroy()
|
2004-10-10 20:44:38 +02:00
|
|
|
return keyID
|
|
|
|
|
|
|
|
def fill_tree(self, list):
|
2005-03-02 12:46:51 +01:00
|
|
|
model = self.keys_treeview.get_model()
|
2004-10-10 20:44:38 +02:00
|
|
|
for keyID in list.keys():
|
|
|
|
model.append((keyID, list[keyID]))
|
|
|
|
|
2005-04-12 23:09:06 +02:00
|
|
|
def __init__(self, secret_keys):
|
2004-10-10 20:44:38 +02:00
|
|
|
#list : {keyID: userName, ...}
|
2005-03-02 12:46:51 +01:00
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'choose_gpg_key_dialog', APP)
|
|
|
|
self.window = xml.get_widget('choose_gpg_key_dialog')
|
|
|
|
self.keys_treeview = xml.get_widget('keys_treeview')
|
2004-10-10 20:44:38 +02:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.set_model(model)
|
2004-10-10 20:44:38 +02:00
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.insert_column_with_attributes(-1, _('KeyID'), \
|
2005-04-22 01:20:18 +02:00
|
|
|
renderer, text = 0)
|
2004-10-10 20:44:38 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.insert_column_with_attributes(-1, _('User name'), \
|
2005-04-22 01:20:18 +02:00
|
|
|
renderer, text = 1)
|
2005-04-12 23:09:06 +02:00
|
|
|
self.fill_tree(secret_keys)
|
2004-10-10 20:44:38 +02:00
|
|
|
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
|
|
|
|
2005-03-16 02:27:37 +01:00
|
|
|
class Change_status_message_dialog:
|
2005-04-04 18:46:35 +02:00
|
|
|
def __init__(self, plugin, status, autoconnect = 0):
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP)
|
|
|
|
self.window = self.xml.get_widget('change_status_message_dialog')
|
|
|
|
self.window.set_title(status.capitalize() + ' Status Message')
|
|
|
|
self.plugin = plugin
|
|
|
|
self.autoconnect = autoconnect
|
|
|
|
message_textview = self.xml.get_widget('message_textview')
|
|
|
|
self.message_buffer = message_textview.get_buffer()
|
2005-04-12 23:09:06 +02:00
|
|
|
self.message_buffer.set_text(gajim.config.get('last_msg'))
|
2005-04-04 18:46:35 +02:00
|
|
|
self.values = {'':''}
|
2005-04-16 19:36:27 +02:00
|
|
|
for msg in gajim.config.get_per('statusmsg'):
|
|
|
|
self.values[msg] = gajim.config.get_per('statusmsg', msg, 'message')
|
2005-04-04 18:46:35 +02:00
|
|
|
liststore = gtk.ListStore(str, str)
|
|
|
|
message_comboboxentry = self.xml.get_widget('message_comboboxentry')
|
|
|
|
message_comboboxentry.set_model(liststore)
|
|
|
|
message_comboboxentry.set_text_column(0)
|
|
|
|
for val in self.values.keys():
|
|
|
|
message_comboboxentry.append_text(val)
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def run(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Wait for OK button to be pressed and return away messsage'''
|
2005-03-15 20:51:48 +01:00
|
|
|
if self.autoconnect:
|
|
|
|
gtk.gdk.threads_enter()
|
2005-03-02 13:46:37 +01:00
|
|
|
rep = self.window.run()
|
2004-05-15 18:50:38 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 13:46:37 +01:00
|
|
|
beg, end = self.message_buffer.get_bounds()
|
|
|
|
message = self.message_buffer.get_text(beg, end, 0)
|
2005-04-12 23:09:06 +02:00
|
|
|
gajim.config.set('last_msg', message)
|
2004-05-15 18:50:38 +02:00
|
|
|
else:
|
2005-03-02 13:46:37 +01:00
|
|
|
message = -1
|
|
|
|
self.window.destroy()
|
2005-03-15 20:51:48 +01:00
|
|
|
if self.autoconnect:
|
|
|
|
gtk.gdk.threads_leave()
|
2005-03-02 13:46:37 +01:00
|
|
|
return message
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_message_comboboxentry_changed(self, widget, data = None):
|
2004-10-26 00:02:16 +02:00
|
|
|
model = widget.get_model()
|
|
|
|
active = widget.get_active()
|
|
|
|
if active < 0:
|
|
|
|
return None
|
|
|
|
name = model[active][0]
|
2005-03-02 13:46:37 +01:00
|
|
|
self.message_buffer.set_text(self.values[name])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-16 02:27:37 +01:00
|
|
|
def on_change_status_message_dialog_key_press_event(self, widget, event):
|
2005-03-18 02:28:59 +01:00
|
|
|
if event.keyval == gtk.keysyms.Return or \
|
2005-03-18 02:25:11 +01:00
|
|
|
event.keyval == gtk.keysyms.KP_Enter: # catch CTRL+ENTER
|
2005-01-08 15:40:08 +01:00
|
|
|
if (event.state & gtk.gdk.CONTROL_MASK):
|
2005-03-02 13:46:37 +01:00
|
|
|
self.window.response(gtk.RESPONSE_OK)
|
2005-04-04 18:46:35 +02:00
|
|
|
|
|
|
|
class Add_new_contact_window:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for Add_new_contact_window'''
|
2005-04-22 01:20:18 +02:00
|
|
|
def __init__(self, plugin, account, jid = None):
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections[account].connected < 2:
|
2005-04-04 18:46:35 +02:00
|
|
|
Error_dialog(_('You must be connected to add a contact'))
|
|
|
|
return
|
2004-10-26 00:02:16 +02:00
|
|
|
self.plugin = plugin
|
2005-04-04 18:46:35 +02:00
|
|
|
self.account = account
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_new_contact_window', APP)
|
|
|
|
self.window = self.xml.get_widget('add_new_contact_window')
|
2005-05-04 19:44:49 +02:00
|
|
|
self.uid_entry = self.xml.get_widget('uid_entry')
|
|
|
|
self.protocol_combobox = self.xml.get_widget('protocol_combobox')
|
|
|
|
self.jid_entry = self.xml.get_widget('jid_entry')
|
|
|
|
self.nickname_entry = self.xml.get_widget('nickname_entry')
|
2005-04-04 18:46:35 +02:00
|
|
|
self.old_uid_value = ''
|
|
|
|
liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
liststore.append(['Jabber', ''])
|
|
|
|
self.agents = ['Jabber']
|
|
|
|
jid_agents = []
|
|
|
|
for j in self.plugin.roster.contacts[account]:
|
|
|
|
user = self.plugin.roster.contacts[account][j][0]
|
|
|
|
if 'Agents' in user.groups:
|
|
|
|
jid_agents.append(j)
|
|
|
|
for a in jid_agents:
|
|
|
|
if a.find('aim') > -1:
|
|
|
|
name = 'AIM'
|
|
|
|
elif a.find('icq') > -1:
|
|
|
|
name = 'ICQ'
|
|
|
|
elif a.find('msn') > -1:
|
|
|
|
name = 'MSN'
|
|
|
|
elif a.find('yahoo') > -1:
|
|
|
|
name = 'Yahoo!'
|
|
|
|
else:
|
|
|
|
name = a
|
|
|
|
iter = liststore.append([name, a])
|
|
|
|
self.agents.append(name)
|
2005-05-04 19:44:49 +02:00
|
|
|
|
|
|
|
self.protocol_combobox.set_model(liststore)
|
|
|
|
self.protocol_combobox.set_active(0)
|
2005-04-04 18:46:35 +02:00
|
|
|
self.fill_jid()
|
|
|
|
if jid:
|
2005-05-04 19:44:49 +02:00
|
|
|
self.jid_entry.set_text(jid)
|
2005-04-04 18:46:35 +02:00
|
|
|
jid_splited = jid.split('@')
|
|
|
|
if jid_splited[1] in jid_agents:
|
2005-04-25 22:41:29 +02:00
|
|
|
uid = jid_splited[0].replace('%', '@')
|
2005-05-04 19:44:49 +02:00
|
|
|
self.uid_entry.set_text(uid)
|
|
|
|
self.protocol_combobox.set_active(jid_agents.index(jid_splited[1]) + 1)
|
2005-04-25 22:41:29 +02:00
|
|
|
else:
|
2005-05-04 19:44:49 +02:00
|
|
|
self.uid_entry.set_text(jid)
|
|
|
|
self.protocol_combobox.set_active(0)
|
2005-04-25 22:41:29 +02:00
|
|
|
self.set_nickname()
|
2005-04-04 18:46:35 +02:00
|
|
|
|
|
|
|
self.group_comboboxentry = self.xml.get_widget('group_comboboxentry')
|
|
|
|
liststore = gtk.ListStore(str)
|
|
|
|
self.group_comboboxentry.set_model(liststore)
|
|
|
|
for g in self.plugin.roster.groups[account].keys():
|
|
|
|
if g != 'not in the roster' and g != 'Agents':
|
|
|
|
self.group_comboboxentry.append_text(g)
|
|
|
|
|
2005-03-02 13:46:37 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-04-28 15:01:47 +02:00
|
|
|
def on_add_new_contact_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
|
|
|
self.window.destroy()
|
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Cancel button is clicked'''
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_subscribe_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Subscribe button is clicked'''
|
2005-05-04 19:44:49 +02:00
|
|
|
jid = self.jid_entry.get_text()
|
|
|
|
nickname = self.nickname_entry.get_text()
|
2005-03-01 00:44:52 +01:00
|
|
|
if not jid:
|
2004-11-18 20:22:33 +01:00
|
|
|
return
|
2005-03-01 00:44:52 +01:00
|
|
|
if jid.find('@') < 0:
|
2005-04-18 14:17:43 +02:00
|
|
|
Error_dialog(_('The contact\'s name must be something like login@hostname'))
|
2004-11-18 20:22:33 +01:00
|
|
|
return
|
2005-03-01 00:44:52 +01:00
|
|
|
message_buffer = self.xml.get_widget('message_textview').get_buffer()
|
|
|
|
start_iter = message_buffer.get_start_iter()
|
|
|
|
end_iter = message_buffer.get_end_iter()
|
|
|
|
message = message_buffer.get_text(start_iter, end_iter, 0)
|
2005-03-27 23:35:55 +02:00
|
|
|
group = self.group_comboboxentry.child.get_text()
|
|
|
|
self.plugin.roster.req_sub(self, jid, message, self.account, group,\
|
|
|
|
nickname)
|
2005-03-01 00:44:52 +01:00
|
|
|
if self.xml.get_widget('auto_authorize_checkbutton').get_active():
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].send_authorization(jid)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def fill_jid(self):
|
2005-05-04 19:44:49 +02:00
|
|
|
model = self.protocol_combobox.get_model()
|
|
|
|
index = self.protocol_combobox.get_active()
|
|
|
|
jid = self.uid_entry.get_text()
|
|
|
|
if index > 0: # it's not jabber but a transport
|
2005-03-01 00:44:52 +01:00
|
|
|
jid = jid.replace('@', '%')
|
2005-02-03 23:21:55 +01:00
|
|
|
agent = model[index][1]
|
|
|
|
if agent:
|
2005-03-01 00:44:52 +01:00
|
|
|
jid += '@' + agent
|
2005-05-04 19:44:49 +02:00
|
|
|
self.jid_entry.set_text(jid)
|
2005-02-03 23:21:55 +01:00
|
|
|
|
2005-03-23 14:25:48 +01:00
|
|
|
def on_protocol_combobox_changed(self, widget):
|
2005-03-01 00:44:52 +01:00
|
|
|
self.fill_jid()
|
2005-02-03 23:21:55 +01:00
|
|
|
|
|
|
|
def guess_agent(self):
|
2005-05-04 19:44:49 +02:00
|
|
|
uid = self.uid_entry.get_text()
|
|
|
|
model = self.protocol_combobox.get_model()
|
2005-02-03 23:21:55 +01:00
|
|
|
|
|
|
|
#If login contains only numbers, it's probably an ICQ number
|
2005-05-04 19:44:49 +02:00
|
|
|
if uid.isdigit():
|
2005-02-03 23:21:55 +01:00
|
|
|
if 'ICQ' in self.agents:
|
2005-05-04 19:44:49 +02:00
|
|
|
self.protocol_combobox.set_active(self.agents.index('ICQ'))
|
2005-02-03 23:21:55 +01:00
|
|
|
return
|
2005-02-04 08:58:40 +01:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def set_nickname(self):
|
2005-05-04 19:44:49 +02:00
|
|
|
uid = self.uid_entry.get_text()
|
|
|
|
nickname = self.nickname_entry.get_text()
|
2005-03-01 00:44:52 +01:00
|
|
|
if nickname == self.old_uid_value:
|
2005-05-04 19:44:49 +02:00
|
|
|
self.nickname_entry.set_text(uid.split('@')[0])
|
2005-02-03 23:21:55 +01:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_uid_entry_changed(self, widget):
|
2005-05-04 19:44:49 +02:00
|
|
|
uid = self.uid_entry.get_text()
|
|
|
|
if len(uid) == 0:
|
|
|
|
self.protocol_combobox.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.protocol_combobox.set_sensitive(True)
|
2005-02-04 08:58:40 +01:00
|
|
|
self.guess_agent()
|
2005-03-01 00:44:52 +01:00
|
|
|
self.set_nickname()
|
|
|
|
self.fill_jid()
|
|
|
|
self.old_uid_value = uid.split('@')[0]
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-09 22:29:20 +01:00
|
|
|
class About_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for about dialog'''
|
2005-04-04 18:46:35 +02:00
|
|
|
def __init__(self):
|
2005-03-15 01:40:08 +01:00
|
|
|
if gtk.pygtk_version < (2, 6, 0):
|
2005-03-22 20:02:27 +01:00
|
|
|
Information_dialog(_('Gajim - A GTK jabber client'))
|
2005-03-14 21:21:49 +01:00
|
|
|
return
|
2005-04-04 18:46:35 +02:00
|
|
|
|
2005-03-09 22:29:20 +01:00
|
|
|
dlg = gtk.AboutDialog()
|
|
|
|
dlg.set_name('Gajim')
|
2005-04-16 19:03:21 +02:00
|
|
|
dlg.set_version(gajim.version)
|
2005-03-16 03:16:29 +01:00
|
|
|
s = u'Copyright \xa9 2003-2005 Gajim Team'
|
|
|
|
dlg.set_copyright(s)
|
2005-04-16 19:03:21 +02:00
|
|
|
text = open('../COPYING').read()
|
2005-03-16 03:16:29 +01:00
|
|
|
dlg.set_license(text)
|
2005-03-09 22:29:20 +01:00
|
|
|
|
2005-03-22 20:02:27 +01:00
|
|
|
dlg.set_comments(_('A GTK jabber client'))
|
2005-03-09 22:29:20 +01:00
|
|
|
dlg.set_website('http://www.gajim.org')
|
2005-03-18 01:47:50 +01:00
|
|
|
|
2005-04-01 01:26:05 +02:00
|
|
|
authors = ['Yann Le Boulanger <asterix@lagaule.org>', 'Vincent Hanquez <tab@snarc.org>', 'Nikos Kouremenos <kourem@gmail.com>', 'Alex Podaras <bigpod@gmail.com>']
|
2005-03-16 03:16:29 +01:00
|
|
|
dlg.set_authors(authors)
|
2005-04-16 19:03:21 +02:00
|
|
|
dlg.set_logo(gtk.gdk.pixbuf_new_from_file('../data/pixmaps/logo.png'))
|
2005-03-16 03:16:29 +01:00
|
|
|
dlg.set_translator_credits(_('translator_credits'))
|
2005-03-09 22:29:20 +01:00
|
|
|
|
2005-04-04 17:51:29 +02:00
|
|
|
rep = dlg.run() # this run doesn't crash threads.. interesting..
|
2005-03-13 00:48:08 +01:00
|
|
|
dlg.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-05 19:47:12 +01:00
|
|
|
class Confirmation_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for confirmation dialog'''
|
2005-03-01 20:02:51 +01:00
|
|
|
def get_response(self):
|
|
|
|
response = self.dialog.run()
|
|
|
|
self.dialog.destroy()
|
2005-03-01 19:36:13 +01:00
|
|
|
return response
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def __init__(self, label):
|
2005-03-01 20:02:51 +01:00
|
|
|
self.dialog = gtk.MessageDialog(None,\
|
2005-03-01 19:36:13 +01:00
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, label)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-05 19:47:12 +01:00
|
|
|
class Warning_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for warning dialog'''
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-01 20:02:51 +01:00
|
|
|
def __init__(self, label):
|
2005-03-03 16:27:37 +01:00
|
|
|
dialog = gtk.MessageDialog(None,\
|
2005-03-01 20:02:51 +01:00
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-03 16:27:37 +01:00
|
|
|
|
2005-03-05 19:47:12 +01:00
|
|
|
class Information_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for information dialog'''
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-03 16:27:37 +01:00
|
|
|
def __init__(self, label):
|
|
|
|
dialog = gtk.MessageDialog(None,\
|
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-03 16:27:37 +01:00
|
|
|
|
2005-03-05 19:47:12 +01:00
|
|
|
class Error_dialog:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for error dialog'''
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-03 16:27:37 +01:00
|
|
|
def __init__(self, label):
|
|
|
|
dialog = gtk.MessageDialog(None,\
|
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-01 20:02:51 +01:00
|
|
|
|
2005-03-02 14:04:47 +01:00
|
|
|
class subscription_request_window:
|
2005-04-04 18:46:35 +02:00
|
|
|
def __init__(self, plugin, jid, text, account):
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'subscription_request_window', APP)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window = xml.get_widget('subscription_request_window')
|
2005-04-04 18:46:35 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.jid = jid
|
|
|
|
self.account = account
|
|
|
|
xml.get_widget('from_label').set_text(\
|
|
|
|
_('Subscription request from %s') % self.jid)
|
|
|
|
xml.get_widget('message_textview').get_buffer().set_text(text)
|
|
|
|
xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for authorization window :
|
|
|
|
window that appears when a user wants to add us to his/her roster'''
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Close button is clicked'''
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_authorize_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Accept the request'''
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].send_authorization(self.jid)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
if not self.plugin.roster.contacts[self.account].has_key(self.jid):
|
2005-03-28 03:39:12 +02:00
|
|
|
Add_new_contact_window(self.plugin, self.account, self.jid)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_deny_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''refuse the request'''
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].refuse_authorization(self.jid)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-04-04 18:46:35 +02:00
|
|
|
|
|
|
|
class Join_groupchat_window:
|
2005-04-22 01:20:18 +02:00
|
|
|
def __init__(self, plugin, account, server = '', room = ''):
|
2005-04-21 20:53:16 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections[account].connected < 2:
|
2005-04-05 23:37:50 +02:00
|
|
|
Error_dialog(_('You must be connected to join a groupchat'))
|
2005-04-04 18:46:35 +02:00
|
|
|
return
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'join_groupchat_window', APP)
|
|
|
|
self.window = self.xml.get_widget('join_groupchat_window')
|
|
|
|
self.xml.get_widget('server_entry').set_text(server)
|
|
|
|
self.xml.get_widget('room_entry').set_text(room)
|
2005-04-21 20:53:16 +02:00
|
|
|
self.xml.get_widget('nickname_entry').set_text(
|
|
|
|
self.plugin.nicks[self.account])
|
2005-04-04 18:46:35 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-07 13:25:59 +02:00
|
|
|
self.plugin.windows[account]['join_gc'] = self #now add us to open windows
|
2005-04-21 20:53:16 +02:00
|
|
|
our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
|
|
|
|
gajim.config.get_per('accounts', self.account, 'hostname')
|
|
|
|
if len(gajim.connections) > 1:
|
|
|
|
title = 'Join Groupchat as ' + our_jid
|
|
|
|
else:
|
|
|
|
title = 'Join Groupchat'
|
|
|
|
self.window.set_title(title)
|
2005-04-07 00:52:48 +02:00
|
|
|
|
|
|
|
self.recently_combobox = self.xml.get_widget('recently_combobox')
|
|
|
|
liststore = gtk.ListStore(str)
|
|
|
|
self.recently_combobox.set_model(liststore)
|
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
self.recently_combobox.pack_start(cell, True)
|
|
|
|
self.recently_combobox.add_attribute(cell, 'text', 0)
|
2005-04-12 23:09:06 +02:00
|
|
|
self.recently_groupchat = gajim.config.get('recently_groupchat').split()
|
2005-04-07 00:52:48 +02:00
|
|
|
for g in self.recently_groupchat:
|
|
|
|
self.recently_combobox.append_text(g)
|
|
|
|
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
def on_join_groupchat_window_destroy(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''close window'''
|
2005-04-07 13:25:59 +02:00
|
|
|
del self.plugin.windows[self.account]['join_gc'] # remove us from open windows
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-04-07 11:53:54 +02:00
|
|
|
def on_join_groupchat_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
|
|
|
widget.destroy()
|
|
|
|
|
2005-04-07 00:52:48 +02:00
|
|
|
def on_recently_combobox_changed(self, widget):
|
|
|
|
model = widget.get_model()
|
|
|
|
iter = widget.get_active_iter()
|
|
|
|
gid = model.get_value(iter, 0)
|
|
|
|
self.xml.get_widget('room_entry').set_text(gid.split('@')[0])
|
|
|
|
self.xml.get_widget('server_entry').set_text(gid.split('@')[1])
|
|
|
|
|
2005-03-04 14:41:48 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Cancel button is clicked'''
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
def on_join_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Join button is clicked'''
|
2005-03-02 13:32:44 +01:00
|
|
|
nickname = self.xml.get_widget('nickname_entry').get_text()
|
|
|
|
room = self.xml.get_widget('room_entry').get_text()
|
|
|
|
server = self.xml.get_widget('server_entry').get_text()
|
2005-03-04 14:41:48 +01:00
|
|
|
password = self.xml.get_widget('password_entry').get_text()
|
2005-03-02 00:48:05 +01:00
|
|
|
jid = '%s@%s' % (room, server)
|
2005-04-07 00:52:48 +02:00
|
|
|
if jid in self.recently_groupchat:
|
|
|
|
self.recently_groupchat.remove(jid)
|
|
|
|
self.recently_groupchat.insert(0, jid)
|
|
|
|
if len(self.recently_groupchat) > 10:
|
|
|
|
self.recently_groupchat = self.recently_groupchat[0:10]
|
2005-04-12 23:09:06 +02:00
|
|
|
gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat))
|
2005-04-23 16:26:04 +02:00
|
|
|
self.plugin.roster.new_room(jid, nickname, self.account)
|
2005-05-03 18:39:27 +02:00
|
|
|
self.plugin.windows[self.account]['gc'][jid].set_active_tab(jid)
|
2005-04-27 22:12:57 +02:00
|
|
|
self.plugin.windows[self.account]['gc'][jid].window.present()
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].join_gc(nickname, room, server, password)
|
2005-03-16 21:48:56 +01:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-04-04 18:46:35 +02:00
|
|
|
class New_message_dialog:
|
|
|
|
def __init__(self, plugin, account):
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections[account].connected < 2:
|
2005-04-04 18:46:35 +02:00
|
|
|
Error_dialog(_('You must be connected to send a message to a contact'))
|
2005-03-02 00:48:05 +01:00
|
|
|
return
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-04-04 18:46:35 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'new_message_dialog', APP)
|
|
|
|
self.window = self.xml.get_widget('new_message_dialog')
|
|
|
|
self.jid_entry = self.xml.get_widget('jid_entry')
|
|
|
|
|
2005-04-14 09:05:10 +02:00
|
|
|
our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
|
|
|
|
gajim.config.get_per('accounts', self.account, 'hostname')
|
2005-04-17 21:53:39 +02:00
|
|
|
if len(gajim.connections) > 1:
|
2005-04-04 18:46:35 +02:00
|
|
|
title = 'New Message as ' + our_jid
|
|
|
|
else:
|
|
|
|
title = 'New Message'
|
|
|
|
self.window.set_title(title)
|
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-05 19:47:12 +01:00
|
|
|
def on_delete_event(self, widget, event):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''close window'''
|
2005-03-05 19:47:12 +01:00
|
|
|
del self.plugin.windows['new_message']
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Cancel button is clicked'''
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
def on_chat_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Chat button is clicked'''
|
2005-03-03 23:14:50 +01:00
|
|
|
jid = self.jid_entry.get_text()
|
2005-04-01 16:55:56 +02:00
|
|
|
if jid.find('@') == -1: # if no @ was given
|
|
|
|
Error_dialog(_('User ID is not valid'))
|
|
|
|
return
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-03-03 18:14:37 +01:00
|
|
|
# use User class, new_chat expects it that way
|
2005-03-12 16:50:13 +01:00
|
|
|
# is it in the roster?
|
2005-04-01 02:28:45 +02:00
|
|
|
if self.plugin.roster.contacts[self.account].has_key(jid):
|
|
|
|
user = self.plugin.roster.contacts[self.account][jid][0]
|
|
|
|
else:
|
2005-04-18 18:54:49 +02:00
|
|
|
user = User(jid, jid, ['not in the roster'], \
|
2005-03-03 23:14:50 +01:00
|
|
|
'not in the roster', 'not in the roster', 'none', None, '', 0, '')
|
|
|
|
self.plugin.roster.contacts[self.account][jid] = [user]
|
2005-04-01 02:28:45 +02:00
|
|
|
self.plugin.roster.add_user_to_roster(user.jid, self.account)
|
|
|
|
|
2005-03-10 16:57:43 +01:00
|
|
|
if not self.plugin.windows[self.account]['chats'].has_key(jid):
|
2005-03-03 23:28:13 +01:00
|
|
|
self.plugin.roster.new_chat(user, self.account)
|
2005-05-03 18:39:27 +02:00
|
|
|
self.plugin.windows[self.account]['chats'][jid].set_active_tab(jid)
|
2005-03-10 19:20:23 +01:00
|
|
|
self.plugin.windows[self.account]['chats'][jid].window.present()
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-04-04 18:46:35 +02:00
|
|
|
class Change_password_dialog:
|
2005-03-02 19:38:27 +01:00
|
|
|
def __init__(self, plugin, account):
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections[account].connected < 2:
|
2005-04-04 18:46:35 +02:00
|
|
|
Error_dialog(_('You must be connected to change your password'))
|
2005-03-02 00:48:05 +01:00
|
|
|
return
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-04-04 18:46:35 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP)
|
|
|
|
self.dialog = self.xml.get_widget('change_password_dialog')
|
|
|
|
self.password1_entry = self.xml.get_widget('password1_entry')
|
|
|
|
self.password2_entry = self.xml.get_widget('password2_entry')
|
2005-03-28 03:39:12 +02:00
|
|
|
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2005-03-04 14:10:00 +01:00
|
|
|
|
|
|
|
def run(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Wait for OK button to be pressed and return new password'''
|
2005-03-04 14:10:00 +01:00
|
|
|
end = False
|
|
|
|
while not end:
|
|
|
|
rep = self.dialog.run()
|
|
|
|
if rep == gtk.RESPONSE_OK:
|
|
|
|
password1 = self.password1_entry.get_text()
|
|
|
|
if not password1:
|
2005-03-16 02:27:37 +01:00
|
|
|
Error_dialog(_('Your password cannot be empty'))
|
2005-03-04 14:10:00 +01:00
|
|
|
continue
|
|
|
|
password2 = self.password2_entry.get_text()
|
|
|
|
if password1 != password2:
|
2005-03-16 02:27:37 +01:00
|
|
|
Error_dialog(_('Confirmation password is not the same'))
|
2005-03-04 14:10:00 +01:00
|
|
|
continue
|
|
|
|
message = password1
|
|
|
|
else:
|
|
|
|
message = -1
|
|
|
|
end = True
|
|
|
|
self.dialog.destroy()
|
|
|
|
return message
|
|
|
|
|
2005-04-21 23:23:41 +02:00
|
|
|
class Popup_notification_window:
|
2005-04-12 17:30:09 +02:00
|
|
|
def __init__(self, plugin, event_type, jid, account):
|
2005-03-04 14:10:00 +01:00
|
|
|
self.plugin = plugin
|
2005-04-12 17:30:09 +02:00
|
|
|
self.account = account
|
|
|
|
self.jid = jid
|
2005-04-04 21:27:06 +02:00
|
|
|
|
2005-04-21 23:23:41 +02:00
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'popup_notification_window', APP)
|
|
|
|
self.window = xml.get_widget('popup_notification_window')
|
2005-04-04 21:27:06 +02:00
|
|
|
close_button = xml.get_widget('close_button')
|
2005-04-06 20:51:54 +02:00
|
|
|
event_type_label = xml.get_widget('event_type_label')
|
|
|
|
event_description_label = xml.get_widget('event_description_label')
|
|
|
|
eventbox = xml.get_widget('eventbox')
|
2005-04-05 17:06:11 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
event_type_label.set_markup('<b>' + event_type + '</b>')
|
2005-04-12 17:30:09 +02:00
|
|
|
|
|
|
|
if self.jid in self.plugin.roster.contacts[account]:
|
|
|
|
txt = self.plugin.roster.contacts[account][self.jid][0].name
|
|
|
|
else:
|
|
|
|
txt = self.jid
|
|
|
|
|
|
|
|
event_description_label.set_text(txt)
|
2005-04-04 18:46:35 +02:00
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
# set colors [ http://www.w3schools.com/html/html_colornames.asp ]
|
|
|
|
self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
|
|
|
|
if event_type == 'Contact Online':
|
|
|
|
close_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('forestgreen'))
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('forestgreen'))
|
|
|
|
elif event_type == 'Contact Offline':
|
|
|
|
close_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('firebrick'))
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('firebrick'))
|
|
|
|
elif event_type == 'New Message':
|
|
|
|
close_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('dodgerblue'))
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('dodgerblue'))
|
2005-04-12 17:30:09 +02:00
|
|
|
txt = 'From ' + txt
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-04-04 18:46:35 +02:00
|
|
|
# position the window to bottom-right of screen
|
2005-04-12 17:30:09 +02:00
|
|
|
window_width, self.window_height = self.window.get_size()
|
2005-04-21 23:30:56 +02:00
|
|
|
self.plugin.roster.popups_notification_height += self.window_height
|
2005-04-04 21:27:06 +02:00
|
|
|
self.window.move(gtk.gdk.screen_width() - window_width, \
|
2005-04-21 23:30:56 +02:00
|
|
|
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
|
2005-04-04 18:46:35 +02:00
|
|
|
|
2005-04-04 21:27:06 +02:00
|
|
|
xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2005-04-12 17:30:09 +02:00
|
|
|
gobject.timeout_add(5000, self.on_timeout)
|
2005-04-04 18:46:35 +02:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-21 23:23:41 +02:00
|
|
|
self.adjust_height_and_move_popup_notification_windows()
|
2005-04-04 21:27:06 +02:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
def on_timeout(self):
|
2005-04-21 23:23:41 +02:00
|
|
|
self.adjust_height_and_move_popup_notification_windows()
|
2005-04-05 17:06:11 +02:00
|
|
|
|
2005-04-21 23:23:41 +02:00
|
|
|
def adjust_height_and_move_popup_notification_windows(self):
|
2005-04-05 17:06:11 +02:00
|
|
|
#remove
|
2005-04-21 23:30:56 +02:00
|
|
|
self.plugin.roster.popups_notification_height -= self.window_height
|
2005-04-04 21:27:06 +02:00
|
|
|
self.window.destroy()
|
2005-04-05 17:06:11 +02:00
|
|
|
|
2005-04-21 23:23:41 +02:00
|
|
|
if len(self.plugin.roster.popup_notification_windows) > 0:
|
2005-04-05 17:06:11 +02:00
|
|
|
# we want to remove the first window added in the list
|
2005-04-21 23:23:41 +02:00
|
|
|
self.plugin.roster.popup_notification_windows.pop(0) # remove 1st item
|
2005-04-05 17:06:11 +02:00
|
|
|
|
|
|
|
# move the rest of popup windows
|
2005-04-21 23:30:56 +02:00
|
|
|
self.plugin.roster.popups_notification_height = 0
|
2005-04-21 23:23:41 +02:00
|
|
|
for window_instance in self.plugin.roster.popup_notification_windows:
|
2005-04-05 17:06:11 +02:00
|
|
|
window_width, window_height = window_instance.window.get_size()
|
2005-04-21 23:30:56 +02:00
|
|
|
self.plugin.roster.popups_notification_height += window_height
|
2005-04-05 17:06:11 +02:00
|
|
|
window_instance.window.move(gtk.gdk.screen_width() - window_width, \
|
2005-04-21 23:30:56 +02:00
|
|
|
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-04-21 23:23:41 +02:00
|
|
|
def on_popup_notification_window_button_press_event(self, widget, event):
|
2005-04-12 17:30:09 +02:00
|
|
|
# use User class, new_chat expects it that way
|
|
|
|
# is it in the roster?
|
|
|
|
if self.plugin.roster.contacts[self.account].has_key(self.jid):
|
|
|
|
user = self.plugin.roster.contacts[self.account][self.jid][0]
|
|
|
|
else:
|
2005-04-18 18:54:49 +02:00
|
|
|
user = User(self.jid, self.jid, ['not in the roster'], \
|
2005-04-12 17:30:09 +02:00
|
|
|
'not in the roster', 'not in the roster', 'none', None, '', 0, '')
|
|
|
|
self.plugin.roster.contacts[self.account][self.jid] = [user]
|
|
|
|
self.plugin.roster.add_user_to_roster(user.self.jid, self.account)
|
|
|
|
|
|
|
|
self.plugin.roster.new_chat(user, self.account)
|
2005-05-03 18:39:27 +02:00
|
|
|
chats_window = self.plugin.windows[self.account]['chats'][self.jid]
|
|
|
|
chats_window.set_active_tab(self.jid)
|
|
|
|
chats_window.window.present()
|
2005-04-21 23:23:41 +02:00
|
|
|
self.adjust_height_and_move_popup_notification_windows()
|