2004-05-15 18:50:38 +02:00
|
|
|
## plugins/config.py
|
|
|
|
##
|
|
|
|
## Gajim Team:
|
2005-01-07 22:52:38 +01:00
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
2004-06-18 11:25:15 +02:00
|
|
|
## - Vincent Hanquez <tab@snarc.org>
|
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 pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
from gtk import TRUE, FALSE
|
|
|
|
import gtk.glade,gobject
|
2004-05-17 01:47:14 +02:00
|
|
|
import os,string
|
2004-05-28 06:20:30 +02:00
|
|
|
import common.sleepy
|
2004-05-17 01:47:14 +02:00
|
|
|
from common import i18n
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|
|
|
gtk.glade.textdomain (APP)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
from dialogs import *
|
2004-06-21 19:06:43 +02:00
|
|
|
import gtkgui
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
|
|
|
|
|
|
|
|
|
|
|
class vCard_Window:
|
|
|
|
"""Class for window that show vCard information"""
|
|
|
|
def delete_event(self, widget=None):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows[self.account]['infos'][self.jid]
|
|
|
|
|
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
|
|
|
self.xml.get_widget(entry_name).set_text(value)
|
|
|
|
except AttributeError, e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_values(self, vcard):
|
|
|
|
for i in vcard.keys():
|
|
|
|
if type(vcard[i]) == type({}):
|
|
|
|
for j in vcard[i].keys():
|
|
|
|
self.set_value('entry_'+i+'_'+j, vcard[i][j])
|
|
|
|
else:
|
|
|
|
if i == 'DESC':
|
|
|
|
self.xml.get_widget('textview_DESC').get_buffer().\
|
|
|
|
set_text(vcard[i], 0)
|
|
|
|
else:
|
|
|
|
self.set_value('entry_'+i, vcard[i])
|
|
|
|
|
|
|
|
def add_to_vcard(self, vcard, entry, txt):
|
|
|
|
"""Add an information to the vCard dictionary"""
|
|
|
|
entries = string.split(entry, '_')
|
|
|
|
loc = vcard
|
|
|
|
while len(entries) > 1:
|
|
|
|
if not loc.has_key(entries[0]):
|
|
|
|
loc[entries[0]] = {}
|
|
|
|
loc = loc[entries[0]]
|
|
|
|
del entries[0]
|
|
|
|
loc[entries[0]] = txt
|
|
|
|
return vcard
|
|
|
|
|
|
|
|
def make_vcard(self):
|
|
|
|
"""make the vCard dictionary"""
|
|
|
|
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\
|
|
|
|
'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',\
|
|
|
|
'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE']
|
|
|
|
vcard = {}
|
|
|
|
for e in entries:
|
|
|
|
txt = self.xml.get_widget('entry_'+e).get_text()
|
|
|
|
if txt != '':
|
|
|
|
vcard = self.add_to_vcard(vcard, e, txt)
|
|
|
|
buf = self.xml.get_widget('textview_DESC').get_buffer()
|
|
|
|
start_iter = buf.get_start_iter()
|
|
|
|
end_iter = buf.get_end_iter()
|
|
|
|
txt = buf.get_text(start_iter, end_iter, 0)
|
|
|
|
if txt != '':
|
|
|
|
vcard['DESC']= txt
|
|
|
|
return vcard
|
|
|
|
|
|
|
|
|
|
|
|
def on_retrieve(self, widget):
|
|
|
|
if self.plugin.connected[self.account]:
|
|
|
|
self.plugin.send('ASK_VCARD', self.account, self.jid)
|
|
|
|
else:
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("You must be connected to get your informations"))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_publish(self, widget):
|
|
|
|
if not self.plugin.connected[self.account]:
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("You must be connected to publish your informations"))
|
2004-05-15 18:50:38 +02:00
|
|
|
return
|
|
|
|
vcard = self.make_vcard()
|
|
|
|
nick = ''
|
|
|
|
if vcard.has_key('NICKNAME'):
|
|
|
|
nick = vcard['NICKNAME']
|
|
|
|
if nick == '':
|
|
|
|
nick = self.plugin.accounts[self.account]['name']
|
|
|
|
self.plugin.nicks[self.account] = nick
|
|
|
|
self.plugin.send('VCARD', self.account, vcard)
|
|
|
|
|
|
|
|
def __init__(self, jid, plugin, account):
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard', APP)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.window = self.xml.get_widget('vcard')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.jid = jid
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
|
|
|
|
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
self.xml.signal_connect('on_close_clicked', self.on_close)
|
|
|
|
self.xml.signal_connect('on_retrieve_clicked', self.on_retrieve)
|
|
|
|
self.xml.signal_connect('on_publish_clicked', self.on_publish)
|
|
|
|
|
|
|
|
class preference_Window:
|
|
|
|
"""Class for Preferences window"""
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows['preferences']
|
|
|
|
|
|
|
|
def on_cancel(self, widget):
|
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def write_cfg(self):
|
|
|
|
"""Save preferences in config File and apply them"""
|
|
|
|
#Color for incomming messages
|
2004-10-12 00:57:29 +02:00
|
|
|
color = self.xml.get_widget('colorbutton_in').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['inmsgcolor'] = colSt
|
2004-05-15 18:50:38 +02:00
|
|
|
#Color for outgoing messages
|
2004-10-12 00:57:29 +02:00
|
|
|
color = self.xml.get_widget('colorbutton_out').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['outmsgcolor'] = colSt
|
2004-05-15 18:50:38 +02:00
|
|
|
#Color for status messages
|
2004-10-12 00:57:29 +02:00
|
|
|
color = self.xml.get_widget('colorbutton_status').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['statusmsgcolor'] = colSt
|
|
|
|
#Color for account text
|
|
|
|
color = self.xml.get_widget('colorbutton_account_text').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['accounttextcolor'] = colSt
|
|
|
|
#Color for group text
|
|
|
|
color = self.xml.get_widget('colorbutton_group_text').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['grouptextcolor'] = colSt
|
|
|
|
#Color for user text
|
|
|
|
color = self.xml.get_widget('colorbutton_user_text').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['usertextcolor'] = colSt
|
|
|
|
#Color for background account
|
|
|
|
color = self.xml.get_widget('colorbutton_account_bg').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['accountbgcolor'] = colSt
|
|
|
|
#Color for background group
|
|
|
|
color = self.xml.get_widget('colorbutton_group_bg').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['groupbgcolor'] = colSt
|
|
|
|
#Color for background user
|
|
|
|
color = self.xml.get_widget('colorbutton_user_bg').get_color()
|
|
|
|
colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\
|
|
|
|
+(hex(color.blue)+'0')[2:4]
|
|
|
|
self.plugin.config['userbgcolor'] = colSt
|
2004-10-12 12:13:47 +02:00
|
|
|
#Font for account
|
|
|
|
fontStr = self.xml.get_widget('fontbutton_account_text').get_font_name()
|
|
|
|
self.plugin.config['accountfont'] = fontStr
|
|
|
|
#Font for group
|
|
|
|
fontStr = self.xml.get_widget('fontbutton_group_text').get_font_name()
|
|
|
|
self.plugin.config['groupfont'] = fontStr
|
|
|
|
#Font for user
|
|
|
|
fontStr = self.xml.get_widget('fontbutton_user_text').get_font_name()
|
|
|
|
self.plugin.config['userfont'] = fontStr
|
2004-05-15 18:50:38 +02:00
|
|
|
#update opened chat windows
|
|
|
|
for a in self.plugin.accounts.keys():
|
2005-02-12 00:13:19 +01:00
|
|
|
if self.plugin.windows[a]['chats'].has_key('tabbed'):
|
|
|
|
self.plugin.windows[a]['chats']['tabbed'].update_tags()
|
|
|
|
else:
|
|
|
|
for jid in self.plugin.windows[a]['chats'].keys():
|
|
|
|
self.plugin.windows[a]['chats'][jid].update_tags()
|
2004-05-15 18:50:38 +02:00
|
|
|
#IconStyle
|
|
|
|
ist = self.combo_iconstyle.entry.get_text()
|
|
|
|
self.plugin.config['iconstyle'] = ist
|
|
|
|
self.plugin.roster.mkpixbufs()
|
2004-10-13 23:46:10 +02:00
|
|
|
#save position
|
|
|
|
chk = self.xml.get_widget('save_position_checkbutton')
|
|
|
|
if chk.get_active():
|
|
|
|
self.plugin.config['saveposition'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['saveposition'] = 0
|
2005-01-17 14:43:15 +01:00
|
|
|
#merge groups
|
|
|
|
chk = self.xml.get_widget('merge_checkbutton')
|
|
|
|
if chk.get_active():
|
|
|
|
self.plugin.config['mergeaccounts'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['mergeaccounts'] = 0
|
|
|
|
self.plugin.roster.regroup = self.plugin.config['mergeaccounts']
|
2005-02-05 18:18:49 +01:00
|
|
|
#use tabbed chat window
|
|
|
|
chk = self.xml.get_widget('checkbutton_tabbed')
|
|
|
|
if chk.get_active():
|
|
|
|
self.plugin.config['usetabbedchat'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['usetabbedchat'] = 0
|
2005-01-22 21:03:19 +01:00
|
|
|
#Emoticons
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.get_iter_first()
|
|
|
|
emots = []
|
|
|
|
while iter:
|
|
|
|
emots.append(model.get_value(iter, 0))
|
|
|
|
emots.append(model.get_value(iter, 1))
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
self.plugin.config['emoticons'] = string.join(emots, '\t')
|
2005-01-18 11:17:03 +01:00
|
|
|
#use emoticons
|
|
|
|
chk = self.xml.get_widget('use_emoticons_checkbutton')
|
|
|
|
if chk.get_active():
|
|
|
|
self.plugin.config['useemoticons'] = 1
|
|
|
|
self.plugin.roster.mkemoticons()
|
|
|
|
else:
|
|
|
|
self.plugin.config['useemoticons'] = 0
|
2005-02-10 01:07:55 +01:00
|
|
|
#sound player
|
|
|
|
self.plugin.config['soundplayer'] = \
|
|
|
|
self.xml.get_widget('entry_soundplayer').get_text()
|
|
|
|
#sounds
|
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
iter = model.get_iter_first()
|
|
|
|
while iter:
|
2005-02-14 23:30:04 +01:00
|
|
|
path = model.get_path(iter)
|
|
|
|
if model[path][1]:
|
|
|
|
self.plugin.config['sound_' + model.get_value(iter, 0)] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['sound_' + model.get_value(iter, 0)] = 0
|
|
|
|
self.plugin.config['sound_' + model.get_value(iter, 0) + '_file'] = \
|
|
|
|
model.get_value(iter, 2)
|
2005-02-10 01:07:55 +01:00
|
|
|
iter = model.iter_next(iter)
|
2004-05-15 18:50:38 +02:00
|
|
|
#autopopup
|
2004-10-12 00:57:29 +02:00
|
|
|
if self.chk_autopp.get_active():
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.config['autopopup'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['autopopup'] = 0
|
2004-06-10 04:54:07 +02:00
|
|
|
#autopopupaway
|
2004-10-12 00:57:29 +02:00
|
|
|
if self.chk_autoppaway.get_active():
|
2004-06-10 04:54:07 +02:00
|
|
|
self.plugin.config['autopopupaway'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['autopopupaway'] = 0
|
2004-05-15 18:50:38 +02:00
|
|
|
#autoaway
|
2004-10-12 00:57:29 +02:00
|
|
|
if self.chk_autoaway.get_active():
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.config['autoaway'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['autoaway'] = 0
|
|
|
|
aat = self.spin_autoawaytime.get_value_as_int()
|
|
|
|
self.plugin.config['autoawaytime'] = aat
|
|
|
|
#autoxa
|
2004-10-12 00:57:29 +02:00
|
|
|
if self.chk_autoxa.get_active():
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.config['autoxa'] = 1
|
|
|
|
else:
|
|
|
|
self.plugin.config['autoxa'] = 0
|
|
|
|
axt = self.spin_autoxatime.get_value_as_int()
|
|
|
|
self.plugin.config['autoxatime'] = axt
|
2004-10-21 00:53:15 +02:00
|
|
|
self.plugin.sleeper = common.sleepy.Sleepy(\
|
|
|
|
self.plugin.config['autoawaytime']*60, \
|
|
|
|
self.plugin.config['autoxatime']*60)
|
2004-10-26 00:02:16 +02:00
|
|
|
#Status messages
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.get_iter_first()
|
|
|
|
i = 0
|
|
|
|
while iter:
|
|
|
|
self.plugin.config['msg%i_name' % i] = model.get_value(iter, 0)
|
|
|
|
self.plugin.config['msg%i' % i] = model.get_value(iter, 1)
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
i += 1
|
|
|
|
while self.plugin.config.has_key('msg%s_name' % i):
|
|
|
|
del self.plugin.config['msg%i_name' % i]
|
|
|
|
del self.plugin.config['msg%i' % i]
|
|
|
|
i += 1
|
2004-06-21 22:22:10 +02:00
|
|
|
#trayicon
|
2004-10-12 00:57:29 +02:00
|
|
|
if self.chk_trayicon.get_active():
|
2004-06-21 22:22:10 +02:00
|
|
|
self.plugin.config['trayicon'] = 1
|
2004-12-14 13:57:45 +01:00
|
|
|
self.plugin.show_systray()
|
2004-06-21 22:22:10 +02:00
|
|
|
else:
|
|
|
|
self.plugin.config['trayicon'] = 0
|
2004-12-14 13:57:45 +01:00
|
|
|
self.plugin.hide_systray()
|
2004-11-04 02:03:17 +01:00
|
|
|
self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui'))
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.roster.draw_roster()
|
2004-11-04 02:03:17 +01:00
|
|
|
#log presences in user file
|
|
|
|
if self.xml.get_widget('chk_log_pres_usr').get_active():
|
|
|
|
self.config_logger['lognotusr'] = 1
|
|
|
|
else:
|
|
|
|
self.config_logger['lognotusr'] = 0
|
|
|
|
#log presences in external file
|
|
|
|
if self.xml.get_widget('chk_log_pres_ext').get_active():
|
|
|
|
self.config_logger['lognotsep'] = 1
|
|
|
|
else:
|
|
|
|
self.config_logger['lognotsep'] = 0
|
|
|
|
self.plugin.send('CONFIG', None, ('Logger', self.config_logger, 'GtkGui'))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_ok(self, widget):
|
|
|
|
"""When Ok button is clicked"""
|
|
|
|
self.write_cfg()
|
|
|
|
self.xml.get_widget('Preferences').destroy()
|
|
|
|
|
2004-11-01 14:41:00 +01:00
|
|
|
def on_apply(self, widget):
|
|
|
|
"""When Apply button is clicked"""
|
|
|
|
self.write_cfg()
|
|
|
|
|
2004-10-26 00:02:16 +02:00
|
|
|
def fill_msg_treeview(self):
|
|
|
|
i = 0
|
|
|
|
self.xml.get_widget('delete_msg_button').set_sensitive(False)
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
model.clear()
|
|
|
|
while self.plugin.config.has_key('msg%s_name' % i):
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, self.plugin.config['msg%s_name' % i], 1, self.plugin.config['msg%s' % i])
|
|
|
|
i += 1
|
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
def on_msg_cell_edited(self, cell, row, new_text):
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
|
|
|
model.set_value(iter, 0, new_text)
|
|
|
|
|
|
|
|
def on_msg_treeview_cursor_changed(self, widget, data=None):
|
|
|
|
self.xml.get_widget('delete_msg_button').set_sensitive(True)
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
|
|
|
name = model.get_value(iter, 0)
|
|
|
|
msg = model.get_value(iter, 1)
|
|
|
|
buf.set_text(msg)
|
|
|
|
|
|
|
|
def on_new_msg_button_clicked(self, widget, data=None):
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, 'msg', 1, 'message')
|
|
|
|
|
|
|
|
def on_delete_msg_button_clicked(self, widget, data=None):
|
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
model.remove(iter)
|
|
|
|
buf.set_text('')
|
|
|
|
self.xml.get_widget('delete_msg_button').set_sensitive(False)
|
|
|
|
|
|
|
|
def on_msg_textview_changed(self, widget, data=None):
|
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
first_iter, end_iter = buf.get_bounds()
|
|
|
|
name = model.get_value(iter, 0)
|
|
|
|
model.set_value(iter, 1, buf.get_text(first_iter, end_iter))
|
|
|
|
|
|
|
|
def on_msg_treeview_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Delete:
|
|
|
|
self.on_delete_msg_button_clicked(widget)
|
|
|
|
|
2005-01-20 13:09:26 +01:00
|
|
|
def image_is_ok(self, image):
|
|
|
|
if not os.path.exists(image):
|
|
|
|
return 0
|
|
|
|
img = gtk.Image()
|
|
|
|
try:
|
|
|
|
img.set_from_file(image)
|
|
|
|
except:
|
|
|
|
return 0
|
|
|
|
if img.get_storage_type() == gtk.IMAGE_PIXBUF:
|
|
|
|
pix = img.get_pixbuf()
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
if pix.get_width() > 24 or pix.get_height() > 24:
|
|
|
|
return 0
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def load_emots(self):
|
|
|
|
emots = {}
|
|
|
|
split_line = string.split(self.plugin.config['emoticons'], '\t')
|
|
|
|
for i in range(0, len(split_line)/2):
|
|
|
|
if not self.image_is_ok(split_line[2*i+1]):
|
|
|
|
continue
|
|
|
|
emots[split_line[2*i]] = split_line[2*i+1]
|
|
|
|
return emots
|
|
|
|
|
|
|
|
def fill_emot_treeview(self):
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
model.clear()
|
|
|
|
emots = self.load_emots()
|
|
|
|
for i in emots:
|
2005-02-14 13:19:49 +01:00
|
|
|
file = emots[i]
|
|
|
|
iter = model.append((i, file, None))
|
|
|
|
if not os.path.exists(file):
|
|
|
|
continue
|
|
|
|
img = gtk.Image()
|
|
|
|
img.show()
|
|
|
|
if file.find('.gif') != -1:
|
|
|
|
pix = gtk.gdk.PixbufAnimation(file)
|
|
|
|
img.set_from_animation(pix)
|
|
|
|
else:
|
|
|
|
pix = gtk.gdk.pixbuf_new_from_file(file)
|
|
|
|
img.set_from_pixbuf(pix)
|
|
|
|
model.set(iter, 2, img)
|
2005-01-20 13:09:26 +01:00
|
|
|
|
|
|
|
def on_emot_cell_edited(self, cell, row, new_text):
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
|
|
|
model.set_value(iter, 0, new_text)
|
|
|
|
|
2005-02-14 13:19:49 +01:00
|
|
|
def on_button_set_image_clicked(self, widget, data=None):
|
2005-01-20 13:09:26 +01:00
|
|
|
(model, iter) = self.emot_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
file = model.get_value(iter, 1)
|
|
|
|
dialog = gtk.FileChooserDialog("Choose image",
|
|
|
|
None,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name("All files")
|
|
|
|
filter.add_pattern("*")
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name("Images")
|
|
|
|
filter.add_mime_type("image/png")
|
|
|
|
filter.add_mime_type("image/jpeg")
|
|
|
|
filter.add_mime_type("image/gif")
|
|
|
|
filter.add_pattern("*.png")
|
|
|
|
filter.add_pattern("*.jpg")
|
|
|
|
filter.add_pattern("*.gif")
|
|
|
|
filter.add_pattern("*.tif")
|
|
|
|
filter.add_pattern("*.xpm")
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
|
|
|
|
|
|
|
file = os.path.join(os.getcwd(), file)
|
|
|
|
dialog.set_filename(file)
|
|
|
|
file = ''
|
|
|
|
ok = 0
|
|
|
|
while(ok == 0):
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file = dialog.get_filename()
|
|
|
|
if self.image_is_ok(file):
|
|
|
|
ok = 1
|
|
|
|
else:
|
|
|
|
ok = 1
|
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
|
|
|
model.set_value(iter, 1, file)
|
2005-02-14 13:19:49 +01:00
|
|
|
img = gtk.Image()
|
|
|
|
img.show()
|
|
|
|
if file.find('.gif') != -1:
|
|
|
|
pix = gtk.gdk.PixbufAnimation(file)
|
|
|
|
img.set_from_animation(pix)
|
|
|
|
else:
|
|
|
|
pix = gtk.gdk.pixbuf_new_from_file(file)
|
|
|
|
img.set_from_pixbuf(pix)
|
|
|
|
model.set(iter, 2, img)
|
2005-01-20 13:09:26 +01:00
|
|
|
|
|
|
|
def on_button_new_emoticon_clicked(self, widget, data=None):
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, 'smeiley', 1, '')
|
2005-02-14 13:19:49 +01:00
|
|
|
col = self.emot_tree.get_column(0)
|
|
|
|
self.emot_tree.set_cursor(model.get_path(iter), col, True)
|
2005-01-20 13:09:26 +01:00
|
|
|
|
|
|
|
def on_button_remove_emoticon_clicked(self, widget, data=None):
|
|
|
|
(model, iter) = self.emot_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
model.remove(iter)
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2004-11-01 14:41:00 +01:00
|
|
|
def on_chk_toggled(self, widget, widgets):
|
|
|
|
"""set or unset sensitivity of widgets when widget is toggled"""
|
|
|
|
for w in widgets:
|
|
|
|
w.set_sensitive(widget.get_active())
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-02-02 22:16:24 +01:00
|
|
|
def on_treeview_emoticons_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Delete:
|
|
|
|
self.on_button_remove_emoticon_clicked(widget)
|
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
def sound_is_ok(self, sound):
|
|
|
|
if not os.path.exists(sound):
|
|
|
|
return 0
|
|
|
|
return 1
|
|
|
|
|
2005-02-14 23:30:04 +01:00
|
|
|
def sound_toggled_cb(self, cell, path):
|
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model[path][1] = not model[path][1]
|
|
|
|
return
|
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
def fill_sound_treeview(self):
|
|
|
|
events = {}
|
2005-02-14 23:30:04 +01:00
|
|
|
#events = {name : [use_it, file], name2 : [., .], ...}
|
|
|
|
for key in self.plugin.config.keys():
|
|
|
|
if key.find('sound_') == 0:
|
|
|
|
if not self.plugin.config.has_key(key + '_file'):
|
|
|
|
continue
|
|
|
|
ev = key.replace('sound_', '')
|
|
|
|
events[ev] = [self.plugin.config[key], self.plugin.config[key + \
|
|
|
|
'_file']]
|
2005-02-10 01:07:55 +01:00
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model.clear()
|
2005-02-14 23:30:04 +01:00
|
|
|
for ev in events:
|
|
|
|
iter = model.append((ev, events[ev][0], events[ev][1]))
|
2005-02-10 01:07:55 +01:00
|
|
|
|
|
|
|
def on_treeview_sounds_cursor_changed(self, widget, data=None):
|
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
self.xml.get_widget('entry_sounds').set_text('')
|
|
|
|
return
|
2005-02-14 23:30:04 +01:00
|
|
|
str = model.get_value(iter, 2)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.xml.get_widget('entry_sounds').set_text(str)
|
|
|
|
|
|
|
|
def on_button_sounds_clicked(self, widget, data=None):
|
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-02-14 23:30:04 +01:00
|
|
|
file = model.get_value(iter, 2)
|
2005-02-10 01:07:55 +01:00
|
|
|
dialog = gtk.FileChooserDialog("Choose sound",
|
|
|
|
None,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name("All files")
|
|
|
|
filter.add_pattern("*")
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name("Wav Sounds")
|
|
|
|
filter.add_pattern("*.wav")
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
|
|
|
|
|
|
|
file = os.path.join(os.getcwd(), file)
|
|
|
|
dialog.set_filename(file)
|
2005-02-14 23:30:04 +01:00
|
|
|
file = ''
|
2005-02-10 01:07:55 +01:00
|
|
|
ok = 0
|
|
|
|
while(ok == 0):
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file = dialog.get_filename()
|
|
|
|
if self.sound_is_ok(file):
|
|
|
|
ok = 1
|
|
|
|
else:
|
|
|
|
ok = 1
|
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
|
|
|
self.xml.get_widget('entry_sounds').set_text(file)
|
2005-02-14 23:30:04 +01:00
|
|
|
model.set_value(iter, 2, file)
|
|
|
|
model.set_value(iter, 1, 1)
|
2005-02-10 01:07:55 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def __init__(self, plugin):
|
|
|
|
"""Initialize Preference window"""
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Preferences', APP)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.window = self.xml.get_widget('Preferences')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
2005-01-18 11:17:03 +01:00
|
|
|
self.xml.get_widget('image_emoticons').set_from_file(\
|
|
|
|
'plugins/gtkgui/pixmaps/smile.png')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.combo_iconstyle = self.xml.get_widget('combo_iconstyle')
|
|
|
|
self.chk_autopp = self.xml.get_widget('chk_autopopup')
|
2004-06-10 04:54:07 +02:00
|
|
|
self.chk_autoppaway = self.xml.get_widget('chk_autopopupaway')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.chk_autoaway = self.xml.get_widget('chk_autoaway')
|
|
|
|
self.spin_autoawaytime = self.xml.get_widget('spin_autoawaytime')
|
|
|
|
self.chk_autoxa = self.xml.get_widget('chk_autoxa')
|
|
|
|
self.spin_autoxatime = self.xml.get_widget('spin_autoxatime')
|
2004-06-21 22:22:10 +02:00
|
|
|
self.chk_trayicon = self.xml.get_widget('chk_trayicon')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.notebook = self.xml.get_widget('preferences_notebook')
|
|
|
|
|
|
|
|
#Color for incomming messages
|
|
|
|
colSt = self.plugin.config['inmsgcolor']
|
2004-10-12 00:57:29 +02:00
|
|
|
self.xml.get_widget('colorbutton_in').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Color for outgoing messages
|
|
|
|
colSt = self.plugin.config['outmsgcolor']
|
2004-10-12 00:57:29 +02:00
|
|
|
self.xml.get_widget('colorbutton_out').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Color for status messages
|
|
|
|
colSt = self.plugin.config['statusmsgcolor']
|
2004-10-12 00:57:29 +02:00
|
|
|
self.xml.get_widget('colorbutton_status').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#iconStyle
|
|
|
|
list_style = os.listdir('plugins/gtkgui/icons/')
|
|
|
|
l = []
|
|
|
|
for i in list_style:
|
|
|
|
if i != 'CVS' and i[0] != '.':
|
|
|
|
l.append(i)
|
|
|
|
if l.count == 0:
|
|
|
|
l.append(" ")
|
|
|
|
self.combo_iconstyle.set_popdown_strings(l)
|
|
|
|
if self.plugin.config['iconstyle'] in l:
|
|
|
|
self.combo_iconstyle.entry.set_text(self.plugin.config['iconstyle'])
|
2004-10-13 23:46:10 +02:00
|
|
|
|
|
|
|
#Save position
|
|
|
|
st = self.plugin.config['saveposition']
|
|
|
|
self.xml.get_widget('save_position_checkbutton').set_active(st)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-01-17 14:43:15 +01:00
|
|
|
#Merge accounts
|
|
|
|
st = self.plugin.config['mergeaccounts']
|
|
|
|
self.xml.get_widget('merge_checkbutton').set_active(st)
|
2005-01-18 11:17:03 +01:00
|
|
|
|
2005-02-05 18:18:49 +01:00
|
|
|
#use tabbed chat window
|
|
|
|
st = self.plugin.config['usetabbedchat']
|
|
|
|
self.xml.get_widget('checkbutton_tabbed').set_active(st)
|
|
|
|
|
2005-01-18 11:17:03 +01:00
|
|
|
#Use emoticons
|
|
|
|
st = self.plugin.config['useemoticons']
|
|
|
|
self.xml.get_widget('use_emoticons_checkbutton').set_active(st)
|
2005-01-20 13:09:26 +01:00
|
|
|
self.xml.get_widget('button_new_emoticon').set_sensitive(st)
|
|
|
|
self.xml.get_widget('button_remove_emoticon').set_sensitive(st)
|
|
|
|
self.xml.get_widget('treeview_emoticons').set_sensitive(st)
|
2005-02-14 13:19:49 +01:00
|
|
|
self.xml.get_widget('button_set_image').set_sensitive(st)
|
2005-01-20 13:09:26 +01:00
|
|
|
|
|
|
|
#emoticons
|
|
|
|
self.emot_tree = self.xml.get_widget('treeview_emoticons')
|
2005-02-14 13:19:49 +01:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.Image)
|
2005-01-20 13:09:26 +01:00
|
|
|
self.emot_tree.set_model(model)
|
|
|
|
col = gtk.TreeViewColumn('name')
|
|
|
|
self.emot_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.connect('edited', self.on_emot_cell_edited)
|
|
|
|
renderer.set_property('editable', True)
|
|
|
|
col.pack_start(renderer, True)
|
|
|
|
col.set_attributes(renderer, text=0)
|
2005-02-14 13:19:49 +01:00
|
|
|
|
|
|
|
col = gtk.TreeViewColumn('Image')
|
|
|
|
self.emot_tree.append_column(col)
|
|
|
|
renderer = gtkgui.ImageCellRenderer()
|
|
|
|
col.pack_start(renderer, expand = False)
|
|
|
|
col.add_attribute(renderer, 'image', 2)
|
|
|
|
|
2005-01-20 13:09:26 +01:00
|
|
|
self.fill_emot_treeview()
|
2005-02-10 01:07:55 +01:00
|
|
|
|
|
|
|
#sound player
|
|
|
|
self.xml.get_widget('entry_soundplayer').set_text(\
|
|
|
|
self.plugin.config['soundplayer'])
|
|
|
|
|
|
|
|
#sounds
|
|
|
|
self.sound_tree = self.xml.get_widget('treeview_sounds')
|
2005-02-14 23:30:04 +01:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \
|
|
|
|
gobject.TYPE_STRING)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.sound_tree.set_model(model)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
|
|
|
col = gtk.TreeViewColumn('Active')
|
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererToggle()
|
|
|
|
renderer.set_property('activatable', True)
|
|
|
|
renderer.connect("toggled", self.sound_toggled_cb)
|
|
|
|
col.pack_start(renderer)
|
|
|
|
col.set_attributes(renderer, active=1)
|
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
col = gtk.TreeViewColumn('Event')
|
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
|
|
|
col.set_attributes(renderer, text=0)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
col = gtk.TreeViewColumn('Sound')
|
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
2005-02-14 23:30:04 +01:00
|
|
|
col.set_attributes(renderer, text=2)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.fill_sound_treeview()
|
2005-02-16 01:24:36 +01:00
|
|
|
|
|
|
|
if not os.name == 'posix':
|
|
|
|
self.xml.get_widget('entry_soundplayer').set_sensitive(False)
|
|
|
|
self.sound_tree.set_sensitive(False)
|
|
|
|
self.xml.get_widget('entry_sounds').set_sensitive(False)
|
|
|
|
self.xml.get_widget('button_sounds').set_sensitive(False)
|
2005-01-17 14:43:15 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
#Autopopup
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autopopup']
|
2004-05-15 18:50:38 +02:00
|
|
|
self.chk_autopp.set_active(st)
|
|
|
|
|
2004-06-10 04:54:07 +02:00
|
|
|
#Autopopupaway
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autopopupaway']
|
2004-06-10 04:54:07 +02:00
|
|
|
self.chk_autoppaway.set_active(st)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.chk_autoppaway.set_sensitive(self.plugin.config['autopopup'])
|
2004-06-10 04:54:07 +02:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
#Autoaway
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autoaway']
|
2004-05-15 18:50:38 +02:00
|
|
|
self.chk_autoaway.set_active(st)
|
|
|
|
|
|
|
|
#Autoawaytime
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autoawaytime']
|
2004-05-15 18:50:38 +02:00
|
|
|
self.spin_autoawaytime.set_value(st)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.spin_autoawaytime.set_sensitive(self.plugin.config['autoaway'])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Autoxa
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autoxa']
|
2004-05-15 18:50:38 +02:00
|
|
|
self.chk_autoxa.set_active(st)
|
|
|
|
|
|
|
|
#Autoxatime
|
2004-06-21 20:17:21 +02:00
|
|
|
st = self.plugin.config['autoxatime']
|
2004-05-15 18:50:38 +02:00
|
|
|
self.spin_autoxatime.set_value(st)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.spin_autoxatime.set_sensitive(self.plugin.config['autoxa'])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2004-10-26 00:02:16 +02:00
|
|
|
#Status messages
|
|
|
|
self.msg_tree = self.xml.get_widget('msg_treeview')
|
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
self.msg_tree.set_model(model)
|
|
|
|
col = gtk.TreeViewColumn('name')
|
|
|
|
self.msg_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, True)
|
|
|
|
col.set_attributes(renderer, text=0)
|
|
|
|
renderer.connect('edited', self.on_msg_cell_edited)
|
|
|
|
renderer.set_property('editable', True)
|
|
|
|
self.fill_msg_treeview()
|
2004-11-01 14:30:56 +01:00
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
buf.connect('changed', self.on_msg_textview_changed)
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2004-06-21 22:22:10 +02:00
|
|
|
#trayicon
|
|
|
|
st = self.plugin.config['trayicon']
|
|
|
|
self.chk_trayicon.set_active(st)
|
2004-12-14 17:13:58 +01:00
|
|
|
if isinstance(self.plugin.systray, gtkgui.systrayDummy):
|
2004-10-26 00:02:16 +02:00
|
|
|
self.chk_trayicon.set_sensitive(False)
|
2004-06-21 22:22:10 +02:00
|
|
|
|
2004-10-12 00:57:29 +02:00
|
|
|
#Color for account text
|
|
|
|
colSt = self.plugin.config['accounttextcolor']
|
|
|
|
self.xml.get_widget('colorbutton_account_text').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for group text
|
|
|
|
colSt = self.plugin.config['grouptextcolor']
|
|
|
|
self.xml.get_widget('colorbutton_group_text').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for user text
|
|
|
|
colSt = self.plugin.config['usertextcolor']
|
|
|
|
self.xml.get_widget('colorbutton_user_text').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for background account
|
|
|
|
colSt = self.plugin.config['accountbgcolor']
|
|
|
|
self.xml.get_widget('colorbutton_account_bg').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for background group
|
|
|
|
colSt = self.plugin.config['groupbgcolor']
|
|
|
|
self.xml.get_widget('colorbutton_group_bg').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for background user
|
|
|
|
colSt = self.plugin.config['userbgcolor']
|
|
|
|
self.xml.get_widget('colorbutton_user_bg').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
2004-10-12 12:13:47 +02:00
|
|
|
|
|
|
|
#font for account
|
|
|
|
fontStr = self.plugin.config['accountfont']
|
|
|
|
self.xml.get_widget('fontbutton_account_text').set_font_name(fontStr)
|
|
|
|
|
|
|
|
#font for group
|
|
|
|
fontStr = self.plugin.config['groupfont']
|
|
|
|
self.xml.get_widget('fontbutton_group_text').set_font_name(fontStr)
|
|
|
|
|
|
|
|
#font for account
|
|
|
|
fontStr = self.plugin.config['userfont']
|
|
|
|
self.xml.get_widget('fontbutton_user_text').set_font_name(fontStr)
|
2004-10-12 00:57:29 +02:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.xml.signal_connect('on_apply_clicked', self.on_apply)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.signal_connect('on_ok_clicked', self.on_ok)
|
|
|
|
self.xml.signal_connect('on_cancel_clicked', self.on_cancel)
|
2004-10-26 00:02:16 +02:00
|
|
|
self.xml.signal_connect('on_msg_treeview_cursor_changed', \
|
|
|
|
self.on_msg_treeview_cursor_changed)
|
|
|
|
self.xml.signal_connect('on_new_msg_button_clicked', \
|
|
|
|
self.on_new_msg_button_clicked)
|
|
|
|
self.xml.signal_connect('on_delete_msg_button_clicked', \
|
|
|
|
self.on_delete_msg_button_clicked)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.xml.signal_connect('on_msg_treeview_key_press_event', \
|
|
|
|
self.on_msg_treeview_key_press_event)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.xml.signal_connect('on_chk_autopopup_toggled', \
|
|
|
|
self.on_chk_toggled, [self.chk_autoppaway])
|
|
|
|
self.xml.signal_connect('on_chk_autoaway_toggled', \
|
|
|
|
self.on_chk_toggled, [self.spin_autoawaytime])
|
|
|
|
self.xml.signal_connect('on_chk_autoxa_toggled', \
|
|
|
|
self.on_chk_toggled, [self.spin_autoxatime])
|
2005-01-20 13:09:26 +01:00
|
|
|
self.xml.signal_connect('on_use_emoticons_checkbutton_toggled', \
|
|
|
|
self.on_chk_toggled, [self.xml.get_widget('button_new_emoticon'),
|
|
|
|
self.xml.get_widget('button_remove_emoticon'),
|
|
|
|
self.xml.get_widget('treeview_emoticons'),
|
|
|
|
self.xml.get_widget('entry_emoticons'),
|
|
|
|
self.xml.get_widget('button_emoticons'),
|
|
|
|
self.xml.get_widget('image_emoticon')])
|
2005-02-14 13:19:49 +01:00
|
|
|
self.xml.signal_connect('on_button_set_image_clicked', \
|
|
|
|
self.on_button_set_image_clicked)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.xml.signal_connect('on_button_new_emoticon_clicked', \
|
|
|
|
self.on_button_new_emoticon_clicked)
|
|
|
|
self.xml.signal_connect('on_button_remove_emoticon_clicked', \
|
|
|
|
self.on_button_remove_emoticon_clicked)
|
2005-02-02 22:16:24 +01:00
|
|
|
self.xml.signal_connect('on_treeview_emoticons_key_press_event', \
|
|
|
|
self.on_treeview_emoticons_key_press_event)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.xml.signal_connect('on_treeview_sounds_cursor_changed', \
|
|
|
|
self.on_treeview_sounds_cursor_changed)
|
|
|
|
self.xml.signal_connect('on_button_sounds_clicked', \
|
|
|
|
self.on_button_sounds_clicked)
|
2004-11-04 02:03:17 +01:00
|
|
|
|
|
|
|
self.plugin.send('ASK_CONFIG', None, ('GtkGui', 'Logger', {'lognotsep':1,\
|
|
|
|
'lognotusr':1}))
|
|
|
|
self.config_logger = self.plugin.wait('CONFIG')
|
|
|
|
|
|
|
|
#log presences in user file
|
|
|
|
st = self.config_logger['lognotusr']
|
|
|
|
self.xml.get_widget('chk_log_pres_usr').set_active(st)
|
|
|
|
|
|
|
|
#log presences in external file
|
|
|
|
st = self.config_logger['lognotsep']
|
|
|
|
self.xml.get_widget('chk_log_pres_ext').set_active(st)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
class accountPreference_Window:
|
|
|
|
"""Class for account informations"""
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows['accountPreference']
|
|
|
|
|
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2004-07-01 21:49:26 +02:00
|
|
|
def destroy(self):
|
|
|
|
self.xml.get_widget("Account").destroy()
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def init_account(self, infos):
|
|
|
|
"""Initialize window with defaults values"""
|
2004-10-10 20:44:38 +02:00
|
|
|
if infos.has_key('accname'):
|
|
|
|
self.xml.get_widget("entry_name").set_text(infos['accname'])
|
2004-05-15 18:50:38 +02:00
|
|
|
if infos.has_key('jid'):
|
|
|
|
self.xml.get_widget("entry_jid").set_text(infos['jid'])
|
2004-11-01 14:41:00 +01:00
|
|
|
if infos.has_key('savepass'):
|
|
|
|
self.xml.get_widget('chk_password').set_active(\
|
|
|
|
infos['savepass'])
|
|
|
|
if infos['savepass']:
|
|
|
|
self.xml.get_widget('entry_password').set_sensitive(True)
|
|
|
|
if infos.has_key('password'):
|
|
|
|
self.xml.get_widget("entry_password").set_text(infos['password'])
|
2004-05-15 18:50:38 +02:00
|
|
|
if infos.has_key('ressource'):
|
|
|
|
self.xml.get_widget("entry_ressource").set_text(infos['ressource'])
|
2004-06-06 17:54:30 +02:00
|
|
|
if infos.has_key('priority'):
|
|
|
|
self.xml.get_widget("entry_priority").set_text(str(infos['priority']))
|
2004-05-15 18:50:38 +02:00
|
|
|
if infos.has_key('use_proxy'):
|
|
|
|
self.xml.get_widget("checkbutton_proxy").set_active(infos['use_proxy'])
|
|
|
|
if infos.has_key('proxyhost'):
|
|
|
|
self.xml.get_widget("entry_proxyhost").set_text(infos['proxyhost'])
|
|
|
|
if infos.has_key('proxyport'):
|
2004-06-06 21:35:10 +02:00
|
|
|
self.xml.get_widget("entry_proxyport").set_text(str(\
|
|
|
|
infos['proxyport']))
|
2004-11-01 15:11:22 +01:00
|
|
|
if not self.plugin.config.has_key('usegpg'):
|
2004-10-16 11:37:32 +02:00
|
|
|
self.xml.get_widget('gpg_key_label').set_text('GPG is not usable on this computer')
|
|
|
|
self.xml.get_widget('gpg_choose_key_button').set_sensitive(False)
|
2004-11-01 15:11:22 +01:00
|
|
|
if infos.has_key('keyid') and self.plugin.config.has_key('usegpg'):
|
|
|
|
if infos['keyid'] and self.plugin.config['usegpg']:
|
2004-10-10 20:44:38 +02:00
|
|
|
self.xml.get_widget('gpg_key_label').set_text(infos['keyid'])
|
|
|
|
if infos.has_key('keyname'):
|
|
|
|
self.xml.get_widget('gpg_name_label').set_text(infos['keyname'])
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_sensitive(True)
|
|
|
|
if infos.has_key('savegpgpass'):
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_active(\
|
|
|
|
infos['savegpgpass'])
|
2004-10-11 18:42:56 +02:00
|
|
|
if infos['savegpgpass']:
|
|
|
|
self.xml.get_widget('gpg_pass_entry').set_sensitive(True)
|
2005-01-06 13:44:50 +01:00
|
|
|
if infos.has_key('gpgpassword'):
|
2004-10-11 18:42:56 +02:00
|
|
|
self.xml.get_widget('gpg_pass_entry').set_text(\
|
2005-01-06 13:44:50 +01:00
|
|
|
infos['gpgpassword'])
|
2004-11-01 14:41:00 +01:00
|
|
|
if infos.has_key('autoconnect'):
|
|
|
|
self.xml.get_widget('chk_autoconnect').set_active(\
|
|
|
|
infos['autoconnect'])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_save_clicked(self, widget):
|
|
|
|
"""When save button is clicked : Save informations in config file"""
|
2004-11-01 14:41:00 +01:00
|
|
|
savepass = 0
|
|
|
|
if self.xml.get_widget("chk_password").get_active():
|
|
|
|
savepass = 1
|
2004-05-15 18:50:38 +02:00
|
|
|
entryPass = self.xml.get_widget("entry_password")
|
|
|
|
entryRessource = self.xml.get_widget("entry_ressource")
|
2004-06-06 17:54:30 +02:00
|
|
|
entryPriority = self.xml.get_widget("entry_priority")
|
|
|
|
prio = entryPriority.get_text()
|
2004-05-15 18:50:38 +02:00
|
|
|
check = self.xml.get_widget("checkbutton")
|
|
|
|
entryName = self.xml.get_widget("entry_name")
|
|
|
|
entryJid = self.xml.get_widget("entry_jid")
|
2004-11-01 14:41:00 +01:00
|
|
|
autoconnect = 0
|
|
|
|
if self.xml.get_widget("chk_autoconnect").get_active():
|
|
|
|
autoconnect = 1
|
2004-05-15 18:50:38 +02:00
|
|
|
checkProxy = self.xml.get_widget("checkbutton_proxy")
|
|
|
|
if checkProxy.get_active():
|
|
|
|
useProxy = 1
|
|
|
|
else:
|
|
|
|
useProxy = 0
|
|
|
|
entryProxyhost = self.xml.get_widget("entry_proxyhost")
|
|
|
|
entryProxyport = self.xml.get_widget("entry_proxyport")
|
|
|
|
proxyPort = entryProxyport.get_text()
|
2004-07-01 21:49:26 +02:00
|
|
|
proxyHost = entryProxyhost.get_text()
|
2004-05-15 18:50:38 +02:00
|
|
|
name = entryName.get_text()
|
|
|
|
jid = entryJid.get_text()
|
|
|
|
if (name == ''):
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("You must enter a name for this account"))
|
2004-05-15 18:50:38 +02:00
|
|
|
return 0
|
2004-05-15 18:52:07 +02:00
|
|
|
if name.find(' ') != -1:
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("Spaces are not permited in account name"))
|
2004-05-15 18:52:07 +02:00
|
|
|
return 0
|
2004-05-15 18:50:38 +02:00
|
|
|
if (jid == '') or (string.count(jid, '@') != 1):
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("You must enter a Jabber ID for this account\nFor example : login@hostname"))
|
2004-05-15 18:50:38 +02:00
|
|
|
return 0
|
2005-02-24 23:16:21 +01:00
|
|
|
if check.get_active() and entryPass.get_text() == "":
|
|
|
|
warning_Window(_("You must enter a password to register a new account"))
|
|
|
|
return 0
|
2004-07-01 21:49:26 +02:00
|
|
|
if useProxy:
|
|
|
|
if proxyPort != '':
|
|
|
|
try:
|
|
|
|
proxyPort = string.atoi(proxyPort)
|
|
|
|
except ValueError:
|
|
|
|
warning_Window(_("Proxy Port must be a port number"))
|
|
|
|
return 0
|
|
|
|
if proxyHost == '':
|
|
|
|
warning_Window(_("You must enter a proxy host to use proxy"))
|
2004-06-06 17:54:30 +02:00
|
|
|
if prio != '':
|
|
|
|
try:
|
|
|
|
prio = string.atoi(prio)
|
|
|
|
except ValueError:
|
|
|
|
warning_Window(_("Priority must be a number"))
|
|
|
|
return 0
|
2004-05-15 18:50:38 +02:00
|
|
|
(login, hostname) = string.split(jid, '@')
|
2004-10-10 20:44:38 +02:00
|
|
|
keyName = self.xml.get_widget('gpg_name_label').get_text()
|
|
|
|
if keyName == '': #no key selected
|
|
|
|
keyID = ''
|
|
|
|
save_gpg_pass = 0
|
|
|
|
gpg_pass = ''
|
|
|
|
else:
|
|
|
|
keyID = self.xml.get_widget('gpg_key_label').get_text()
|
|
|
|
save_gpg_pass = 0
|
|
|
|
if self.xml.get_widget('gpg_pass_checkbutton').get_active():
|
|
|
|
save_gpg_pass = 1
|
|
|
|
gpg_pass = self.xml.get_widget('gpg_pass_entry').get_text()
|
2004-05-15 18:50:38 +02:00
|
|
|
#if we are modifying an account
|
|
|
|
if self.modify:
|
|
|
|
#if we modify the name of the account
|
|
|
|
if name != self.account:
|
|
|
|
#update variables
|
|
|
|
self.plugin.windows[name] = self.plugin.windows[self.account]
|
|
|
|
self.plugin.queues[name] = self.plugin.queues[self.account]
|
|
|
|
self.plugin.connected[name] = self.plugin.connected[self.account]
|
|
|
|
self.plugin.nicks[name] = self.plugin.nicks[self.account]
|
|
|
|
self.plugin.roster.groups[name] = \
|
|
|
|
self.plugin.roster.groups[self.account]
|
|
|
|
self.plugin.roster.contacts[name] = \
|
|
|
|
self.plugin.roster.contacts[self.account]
|
|
|
|
del self.plugin.windows[self.account]
|
|
|
|
del self.plugin.queues[self.account]
|
|
|
|
del self.plugin.connected[self.account]
|
|
|
|
del self.plugin.nicks[self.account]
|
|
|
|
del self.plugin.roster.groups[self.account]
|
|
|
|
del self.plugin.roster.contacts[self.account]
|
|
|
|
del self.plugin.accounts[self.account]
|
|
|
|
self.plugin.send('ACC_CHG', self.account, name)
|
2004-12-05 19:23:46 +01:00
|
|
|
active = 1
|
|
|
|
if self.plugin.accounts[self.account].has_key('active'):
|
|
|
|
active = self.plugin.accounts[self.account]['active']
|
2004-06-06 21:35:10 +02:00
|
|
|
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\
|
2004-11-01 14:41:00 +01:00
|
|
|
'savepass': savepass, 'password': entryPass.get_text(), \
|
|
|
|
'ressource': entryRessource.get_text(), 'priority' : prio, \
|
|
|
|
'autoconnect': autoconnect, 'use_proxy': useProxy, 'proxyhost': \
|
|
|
|
entryProxyhost.get_text(), 'proxyport': proxyPort, 'keyid': keyID, \
|
|
|
|
'keyname': keyName, 'savegpgpass': save_gpg_pass, \
|
2005-01-06 13:44:50 +01:00
|
|
|
'gpgpassword': gpg_pass, 'active': active}
|
2004-11-04 02:03:17 +01:00
|
|
|
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
|
|
|
|
'GtkGui'))
|
2004-06-06 21:35:10 +02:00
|
|
|
#refresh accounts window
|
|
|
|
if self.plugin.windows.has_key('accounts'):
|
|
|
|
self.plugin.windows['accounts'].init_accounts()
|
|
|
|
#refresh roster
|
|
|
|
self.plugin.roster.draw_roster()
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
#if it's a new account
|
2004-10-10 20:44:38 +02:00
|
|
|
if name in self.plugin.accounts.keys():
|
|
|
|
warning_Window(_("An account already has this name"))
|
|
|
|
return
|
|
|
|
#if we neeed to register a new account
|
|
|
|
if check.get_active():
|
|
|
|
self.plugin.send('NEW_ACC', None, (hostname, login, \
|
|
|
|
entryPass.get_text(), name, entryRessource.get_text(), prio, \
|
|
|
|
useProxy, proxyHost, proxyPort))
|
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\
|
2004-11-01 14:41:00 +01:00
|
|
|
'savepass': savepass, 'password': entryPass.get_text(), 'ressource': \
|
|
|
|
entryRessource.get_text(), 'priority' : prio, 'autoconnect': \
|
|
|
|
autoconnect, 'use_proxy': useProxy, 'proxyhost': \
|
|
|
|
entryProxyhost.get_text(), 'proxyport': proxyPort, 'keyid': keyID, \
|
2005-01-06 13:44:50 +01:00
|
|
|
'keyname': keyName, 'savegpgpass': save_gpg_pass, 'gpgpassword': gpg_pass,\
|
2004-12-05 19:23:46 +01:00
|
|
|
'active': 1}
|
2004-11-04 02:03:17 +01:00
|
|
|
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
|
|
|
|
'GtkGui'))
|
2004-11-23 15:42:47 +01:00
|
|
|
if savepass:
|
|
|
|
self.plugin.send('PASSPHRASE', name, entryPass.get_text())
|
2004-05-15 18:50:38 +02:00
|
|
|
#update variables
|
2004-10-21 17:12:46 +02:00
|
|
|
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}}
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.queues[name] = {}
|
|
|
|
self.plugin.connected[name] = 0
|
|
|
|
self.plugin.roster.groups[name] = {}
|
|
|
|
self.plugin.roster.contacts[name] = {}
|
2004-07-17 17:31:47 +02:00
|
|
|
self.plugin.nicks[name] = login
|
2004-07-28 20:17:26 +02:00
|
|
|
self.plugin.sleeper_state[name] = 0
|
2004-05-15 18:50:38 +02:00
|
|
|
#refresh accounts window
|
|
|
|
if self.plugin.windows.has_key('accounts'):
|
|
|
|
self.plugin.windows['accounts'].init_accounts()
|
|
|
|
#refresh roster
|
|
|
|
self.plugin.roster.draw_roster()
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-02-24 23:16:21 +01:00
|
|
|
def account_is_ok(self, acct):
|
|
|
|
"""When the account has been created with sucess"""
|
|
|
|
self.xml.get_widget("checkbutton").set_active(False)
|
|
|
|
self.modify = True
|
|
|
|
self.account = acct
|
|
|
|
#TODO:
|
|
|
|
# self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\
|
|
|
|
# 'savepass': savepass, 'password': entryPass.get_text(), 'ressource': \
|
|
|
|
# entryRessource.get_text(), 'priority' : prio, 'autoconnect': \
|
|
|
|
# autoconnect, 'use_proxy': useProxy, 'proxyhost': \
|
|
|
|
# entryProxyhost.get_text(), 'proxyport': proxyPort, 'keyid': keyID, \
|
|
|
|
# 'keyname': keyName, 'savegpgpass': save_gpg_pass, 'gpgpassword': gpg_pass,\
|
|
|
|
# 'active': 1}
|
|
|
|
# self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
|
|
|
|
# 'GtkGui'))
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def on_edit_details_clicked(self, widget):
|
|
|
|
entryJid = self.xml.get_widget("entry_jid")
|
|
|
|
if not self.plugin.windows.has_key('vcard'):
|
|
|
|
self.plugin.windows[self.account]['infos'][entryJid.get_text()] = \
|
|
|
|
vCard_Window(entryJid.get_text(), self.plugin, self.account)
|
|
|
|
if self.plugin.connected[self.account]:
|
|
|
|
self.plugin.send('ASK_VCARD', self.account, entryJid.get_text())
|
|
|
|
else:
|
2004-05-17 01:47:14 +02:00
|
|
|
warning_Window(_("You must be connected to get your informations"))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2004-10-10 20:44:38 +02:00
|
|
|
def on_choose_gpg(self, widget, data=None):
|
|
|
|
w = choose_gpg_Window()
|
|
|
|
self.plugin.windows['gpg_keys'] = w
|
|
|
|
self.plugin.send('GPG_SECRETE_KEYS', None, ())
|
|
|
|
keyID = w.run()
|
|
|
|
if keyID == -1:
|
|
|
|
return
|
|
|
|
if keyID[0] == 'None':
|
|
|
|
self.xml.get_widget('gpg_key_label').set_text(_('No key selected'))
|
|
|
|
self.xml.get_widget('gpg_name_label').set_text('')
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_sensitive(False)
|
|
|
|
self.xml.get_widget('gpg_pass_entry').set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('gpg_key_label').set_text(keyID[0])
|
|
|
|
self.xml.get_widget('gpg_name_label').set_text(keyID[1])
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_sensitive(True)
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_active(False)
|
|
|
|
self.xml.get_widget('gpg_pass_entry').set_text('')
|
|
|
|
|
2004-11-01 14:41:00 +01:00
|
|
|
def on_chk_toggled(self, widget, widgets):
|
|
|
|
"""set or unset sensitivity of widgets when widget is toggled"""
|
|
|
|
for w in widgets:
|
|
|
|
w.set_sensitive(widget.get_active())
|
|
|
|
|
|
|
|
def on_chk_toggled_and_clear(self, widget, widgets):
|
|
|
|
self.on_chk_toggled(widget, widgets)
|
|
|
|
for w in widgets:
|
|
|
|
if not widget.get_active():
|
|
|
|
w.set_text('')
|
2004-10-10 20:44:38 +02:00
|
|
|
|
2005-02-24 23:16:21 +01:00
|
|
|
def on_chk_pass_toggled(self, widget):
|
|
|
|
if self.xml.get_widget('checkbutton').get_active():
|
|
|
|
return
|
2005-02-27 00:18:57 +01:00
|
|
|
self.on_chk_toggled_and_clear(widget, \
|
2005-02-24 23:16:21 +01:00
|
|
|
[self.xml.get_widget('entry_password')])
|
|
|
|
|
2005-02-16 01:16:00 +01:00
|
|
|
def on_chk_new_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
self.xml.get_widget('entry_password').set_sensitive(True)
|
2005-02-24 23:16:21 +01:00
|
|
|
elif not self.xml.get_widget('chk_password').get_active():
|
|
|
|
self.xml.get_widget('entry_password').set_sensitive(False)
|
|
|
|
self.xml.get_widget('entry_password').set_text('')
|
2005-02-16 01:16:00 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
#info must be a dictionnary
|
|
|
|
def __init__(self, plugin, infos = {}):
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Account', APP)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.window = self.xml.get_widget("Account")
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.account = ''
|
|
|
|
self.modify = False
|
2004-10-10 20:44:38 +02:00
|
|
|
self.xml.get_widget('gpg_key_label').set_text('No key selected')
|
|
|
|
self.xml.get_widget('gpg_name_label').set_text('')
|
|
|
|
self.xml.get_widget('gpg_pass_checkbutton').set_sensitive(False)
|
|
|
|
self.xml.get_widget('gpg_pass_entry').set_sensitive(False)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.xml.get_widget('entry_password').set_sensitive(False)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
self.xml.signal_connect('on_save_clicked', self.on_save_clicked)
|
|
|
|
self.xml.signal_connect('on_edit_details_clicked', \
|
|
|
|
self.on_edit_details_clicked)
|
|
|
|
self.xml.signal_connect('on_close_clicked', self.on_close)
|
2004-10-10 20:44:38 +02:00
|
|
|
self.xml.signal_connect('on_choose_gpg_clicked', self.on_choose_gpg)
|
|
|
|
self.xml.signal_connect('on_gpg_pass_checkbutton_toggled', \
|
2004-11-01 14:41:00 +01:00
|
|
|
self.on_chk_toggled_and_clear, [self.xml.get_widget('gpg_pass_entry')])
|
|
|
|
self.xml.signal_connect('on_pass_checkbutton_toggled', \
|
2005-02-24 23:16:21 +01:00
|
|
|
self.on_chk_pass_toggled)
|
2005-02-16 01:16:00 +01:00
|
|
|
self.xml.signal_connect('on_checkbutton_toggled', self.on_chk_new_toggled)
|
|
|
|
if infos:
|
|
|
|
self.modify = True
|
|
|
|
self.account = infos['accname']
|
|
|
|
self.init_account(infos)
|
2005-02-16 15:54:22 +01:00
|
|
|
self.xml.get_widget("checkbutton").set_sensitive(FALSE)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
class accounts_Window:
|
|
|
|
"""Class for accounts window : lists of accounts"""
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows['accounts']
|
|
|
|
|
2004-11-01 14:41:00 +01:00
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def init_accounts(self):
|
|
|
|
"""initialize listStore with existing accounts"""
|
|
|
|
self.xml.get_widget("modify_button").set_sensitive(False)
|
|
|
|
self.xml.get_widget("delete_button").set_sensitive(False)
|
|
|
|
model = self.treeview.get_model()
|
|
|
|
model.clear()
|
|
|
|
for account in self.plugin.accounts:
|
2004-09-28 23:31:26 +02:00
|
|
|
activ = 1
|
|
|
|
if self.plugin.accounts[account].has_key("active"):
|
|
|
|
activ = self.plugin.accounts[account]["active"]
|
2004-05-15 18:50:38 +02:00
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, account, 1, \
|
2004-09-28 23:31:26 +02:00
|
|
|
self.plugin.accounts[account]["hostname"], 2, activ)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_row_activated(self, widget):
|
|
|
|
"""Activate delete and modify buttons when a row is selected"""
|
|
|
|
self.xml.get_widget("modify_button").set_sensitive(True)
|
|
|
|
self.xml.get_widget("delete_button").set_sensitive(True)
|
|
|
|
|
|
|
|
def on_new_clicked(self, widget):
|
|
|
|
"""When new button is clicked : open an account information window"""
|
|
|
|
if not self.plugin.windows.has_key('accountPreference'):
|
|
|
|
self.plugin.windows['accountPreference'] = \
|
|
|
|
accountPreference_Window(self.plugin)
|
|
|
|
|
|
|
|
def on_delete_clicked(self, widget):
|
|
|
|
"""When delete button is clicked :
|
|
|
|
Remove an account from the listStore and from the config file"""
|
|
|
|
sel = self.treeview.get_selection()
|
|
|
|
(model, iter) = sel.get_selected()
|
|
|
|
account = model.get_value(iter, 0)
|
2004-05-17 01:47:14 +02:00
|
|
|
window = confirm_Window(_("Are you sure you want to remove this account (%s) ?") % account)
|
2004-05-15 18:50:38 +02:00
|
|
|
if window.wait() == gtk.RESPONSE_OK:
|
|
|
|
if self.plugin.connected[account]:
|
|
|
|
self.plugin.send('STATUS', account, ('offline', 'offline'))
|
|
|
|
del self.plugin.accounts[account]
|
2004-11-04 02:03:17 +01:00
|
|
|
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
|
|
|
|
'GtkGui'))
|
2004-05-15 18:50:38 +02:00
|
|
|
del self.plugin.windows[account]
|
|
|
|
del self.plugin.queues[account]
|
|
|
|
del self.plugin.connected[account]
|
|
|
|
del self.plugin.roster.groups[account]
|
|
|
|
del self.plugin.roster.contacts[account]
|
|
|
|
self.plugin.roster.draw_roster()
|
|
|
|
self.init_accounts()
|
|
|
|
|
|
|
|
def on_modify_clicked(self, widget):
|
|
|
|
"""When modify button is clicked :
|
|
|
|
open the account information window for this account"""
|
|
|
|
if not self.plugin.windows.has_key('accountPreference'):
|
2004-10-10 20:44:38 +02:00
|
|
|
# infos = {}
|
2004-05-15 18:50:38 +02:00
|
|
|
sel = self.treeview.get_selection()
|
|
|
|
(model, iter) = sel.get_selected()
|
|
|
|
account = model.get_value(iter, 0)
|
2004-10-10 20:44:38 +02:00
|
|
|
infos = self.plugin.accounts[account]
|
|
|
|
infos['accname'] = account
|
|
|
|
infos['jid'] = self.plugin.accounts[account]["name"] + \
|
|
|
|
'@' + self.plugin.accounts[account]["hostname"]
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.windows['accountPreference'] = \
|
|
|
|
accountPreference_Window(self.plugin, infos)
|
2004-09-28 23:31:26 +02:00
|
|
|
|
|
|
|
def on_toggled(self, cell, path, model=None):
|
|
|
|
iter = model.get_iter(path)
|
|
|
|
model.set_value(iter, 2, not cell.get_active())
|
|
|
|
account = model.get_value(iter, 0)
|
|
|
|
if cell.get_active():
|
|
|
|
self.plugin.accounts[account]["active"] = 0
|
|
|
|
else:
|
|
|
|
self.plugin.accounts[account]["active"] = 1
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def __init__(self, plugin):
|
|
|
|
self.plugin = plugin
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Accounts', APP)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.window = self.xml.get_widget("Accounts")
|
2004-05-15 18:50:38 +02:00
|
|
|
self.treeview = self.xml.get_widget("treeview")
|
2004-09-28 23:31:26 +02:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, \
|
|
|
|
gobject.TYPE_BOOLEAN)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.treeview.set_model(model)
|
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
2004-09-28 23:31:26 +02:00
|
|
|
self.treeview.insert_column_with_attributes(-1, _('Name'), renderer, \
|
|
|
|
text=0)
|
2004-05-15 18:50:38 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
2004-05-19 22:14:06 +02:00
|
|
|
self.treeview.insert_column_with_attributes(-1, _('Server'), \
|
2004-05-15 18:50:38 +02:00
|
|
|
renderer, text=1)
|
2004-09-28 23:31:26 +02:00
|
|
|
renderer = gtk.CellRendererToggle()
|
|
|
|
renderer.set_property('activatable', True)
|
|
|
|
renderer.connect('toggled', self.on_toggled, model)
|
|
|
|
self.treeview.insert_column_with_attributes(-1, _('Active'), \
|
|
|
|
renderer, active=2)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
self.xml.signal_connect('on_row_activated', self.on_row_activated)
|
|
|
|
self.xml.signal_connect('on_new_clicked', self.on_new_clicked)
|
|
|
|
self.xml.signal_connect('on_delete_clicked', self.on_delete_clicked)
|
|
|
|
self.xml.signal_connect('on_modify_clicked', self.on_modify_clicked)
|
2004-11-01 14:41:00 +01:00
|
|
|
self.xml.signal_connect('on_close_clicked', self.on_close)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.init_accounts()
|
|
|
|
|
|
|
|
|
|
|
|
class agentRegistration_Window:
|
|
|
|
"""Class for agent registration window :
|
|
|
|
window that appears when we want to subscribe to an agent"""
|
|
|
|
def on_cancel(self, widget):
|
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def draw_table(self):
|
|
|
|
"""Draw the table in the window"""
|
|
|
|
nbrow = 0
|
|
|
|
table = self.xml.get_widget('table')
|
|
|
|
for name in self.infos.keys():
|
|
|
|
if name != 'key' and name != 'instructions' and name != 'x':
|
|
|
|
nbrow = nbrow + 1
|
|
|
|
table.resize(rows=nbrow, columns=2)
|
|
|
|
label = gtk.Label(name)
|
|
|
|
table.attach(label, 0, 1, nbrow-1, nbrow, 0, 0, 0, 0)
|
|
|
|
entry = gtk.Entry()
|
|
|
|
entry.set_text(self.infos[name])
|
|
|
|
table.attach(entry, 1, 2, nbrow-1, nbrow, 0, 0, 0, 0)
|
|
|
|
self.entries[name] = entry
|
|
|
|
if nbrow == 1:
|
|
|
|
entry.grab_focus()
|
|
|
|
table.show_all()
|
|
|
|
|
|
|
|
def on_ok(self, widget):
|
|
|
|
"""When Ok button is clicked :
|
|
|
|
send registration info to the core"""
|
|
|
|
for name in self.entries.keys():
|
|
|
|
self.infos[name] = self.entries[name].get_text()
|
2004-06-21 19:06:43 +02:00
|
|
|
user1 = gtkgui.user(self.agent, self.agent, ['Agents'], 'offline', 'offline', \
|
2004-11-18 18:15:15 +01:00
|
|
|
'from', '', '', 0, '')
|
2004-06-21 19:06:43 +02:00
|
|
|
self.plugin.roster.contacts[self.account][self.agent] = [user1]
|
|
|
|
self.plugin.roster.add_user_to_roster(self.agent, self.account)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.send('REG_AGENT', self.account, self.agent)
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def __init__(self, agent, infos, plugin, account):
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_reg', APP)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.agent = agent
|
|
|
|
self.infos = infos
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2004-05-17 01:47:14 +02:00
|
|
|
self.xml.get_widget('agent_reg').set_title(_("Register to %s") % agent)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.get_widget('label').set_text(infos['instructions'])
|
|
|
|
self.entries = {}
|
|
|
|
self.draw_table()
|
|
|
|
self.xml.signal_connect('on_cancel_clicked', self.on_cancel)
|
|
|
|
self.xml.signal_connect('on_button_ok_clicked', self.on_ok)
|
|
|
|
|
|
|
|
|
|
|
|
class browseAgent_Window:
|
|
|
|
"""Class for bowser agent window :
|
|
|
|
to know the agents on the selected server"""
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows[self.account]['browser']
|
|
|
|
|
|
|
|
def on_cancel(self, widget):
|
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def browse(self):
|
|
|
|
"""Send a request to the core to know the available agents"""
|
|
|
|
self.plugin.send('REQ_AGENTS', self.account, None)
|
|
|
|
|
|
|
|
def agents(self, agents):
|
|
|
|
"""When list of available agent arrive :
|
|
|
|
Fill the treeview with it"""
|
|
|
|
model = self.treeview.get_model()
|
2004-09-06 16:55:10 +02:00
|
|
|
for agent in agents:
|
|
|
|
iter = model.append(None, (agent['name'], agent['jid']))
|
|
|
|
self.agent_infos[agent['jid']] = {'features' : []}
|
|
|
|
|
|
|
|
def agent_info(self, agent, identities, features, items):
|
|
|
|
"""When we recieve informations about an agent"""
|
|
|
|
model = self.treeview.get_model()
|
|
|
|
iter = model.get_iter_root()
|
2004-11-15 20:23:43 +01:00
|
|
|
expand = 0
|
|
|
|
while (iter):
|
2004-09-06 16:55:10 +02:00
|
|
|
if agent == model.get_value(iter, 1):
|
|
|
|
break
|
|
|
|
if model.iter_has_child(iter):
|
|
|
|
iter = model.iter_children(iter)
|
|
|
|
else:
|
|
|
|
if not model.iter_next(iter):
|
|
|
|
iter = model.iter_parent(iter)
|
|
|
|
iter = model.iter_next(iter)
|
2004-11-15 20:23:43 +01:00
|
|
|
if not iter:
|
|
|
|
iter = model.append(None, (agent, agent))
|
|
|
|
self.agent_infos[agent] = {'features' : []}
|
|
|
|
expand = 1
|
2004-09-06 16:55:10 +02:00
|
|
|
self.agent_infos[agent]['features'] = features
|
|
|
|
if len(identities):
|
|
|
|
self.agent_infos[agent]['identities'] = identities
|
|
|
|
if identities[0].has_key('name'):
|
|
|
|
model.set_value(iter, 0, identities[0]['name'])
|
|
|
|
for item in items:
|
|
|
|
model.append(iter, (item['name'], item['jid']))
|
|
|
|
self.agent_infos[item['jid']] = {'identities': [item]}
|
2004-11-15 20:23:43 +01:00
|
|
|
if expand:
|
|
|
|
self.treeview.expand_row((model.get_path(iter)), False)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_refresh(self, widget):
|
|
|
|
"""When refresh button is clicked :
|
|
|
|
refresh list : clear and rerequest it"""
|
|
|
|
self.treeview.get_model().clear()
|
|
|
|
self.browse()
|
|
|
|
|
|
|
|
def on_row_activated(self, widget, path, col=0):
|
|
|
|
"""When a row is activated :
|
2004-09-06 16:55:10 +02:00
|
|
|
Register or join the selected agent"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_join_button_clicked(self, widget):
|
|
|
|
"""When we want to join a conference :
|
2004-05-15 18:50:38 +02:00
|
|
|
Ask specific informations about the selected agent and close the window"""
|
2004-09-06 16:55:10 +02:00
|
|
|
model, iter = self.treeview.get_selection().get_selected()
|
2004-12-23 14:28:00 +01:00
|
|
|
if not iter:
|
|
|
|
return
|
2004-09-06 16:55:10 +02:00
|
|
|
service = model.get_value(iter, 1)
|
|
|
|
room = ''
|
|
|
|
if string.find(service, '@') > -1:
|
|
|
|
services = string.split(service, '@')
|
|
|
|
room = services[0]
|
|
|
|
service = services[1]
|
|
|
|
if not self.plugin.windows.has_key('join_gc'):
|
|
|
|
self.plugin.windows['join_gc'] = join_gc(self.plugin, self.account, service, room)
|
|
|
|
|
|
|
|
def on_register_button_clicked(self, widget):
|
|
|
|
"""When we want to register an agent :
|
|
|
|
Ask specific informations about the selected agent and close the window"""
|
|
|
|
model, iter = self.treeview.get_selection().get_selected()
|
2004-12-23 14:28:00 +01:00
|
|
|
if not iter :
|
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
service = model.get_value(iter, 1)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.plugin.send('REG_AGENT_INFO', self.account, service)
|
2004-05-15 18:50:38 +02:00
|
|
|
widget.get_toplevel().destroy()
|
2004-09-06 16:55:10 +02:00
|
|
|
|
|
|
|
def on_cursor_changed(self, widget):
|
|
|
|
"""When we select a row :
|
|
|
|
activate buttons if needed"""
|
|
|
|
model, iter = self.treeview.get_selection().get_selected()
|
|
|
|
jid = model.get_value(iter, 1)
|
|
|
|
self.register_button.set_sensitive(False)
|
|
|
|
if self.agent_infos[jid].has_key('features'):
|
|
|
|
if common.jabber.NS_REGISTER in self.agent_infos[jid]['features']:
|
|
|
|
self.register_button.set_sensitive(True)
|
|
|
|
self.join_button.set_sensitive(False)
|
|
|
|
if self.agent_infos[jid].has_key('identities'):
|
|
|
|
if len(self.agent_infos[jid]['identities']):
|
|
|
|
if self.agent_infos[jid]['identities'][0].has_key('category'):
|
|
|
|
if self.agent_infos[jid]['identities'][0]['category'] == 'conference':
|
|
|
|
self.join_button.set_sensitive(True)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def __init__(self, plugin, account):
|
2005-02-07 23:26:17 +01:00
|
|
|
if not plugin.connected[account]:
|
2005-02-07 23:24:07 +01:00
|
|
|
warning_Window(_("You must be connected to view Agents"))
|
|
|
|
return
|
2004-05-17 01:47:14 +02:00
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'browser', APP)
|
2004-09-06 16:55:10 +02:00
|
|
|
self.window = xml.get_widget('browser')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.treeview = xml.get_widget('treeview')
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2004-09-06 16:55:10 +02:00
|
|
|
self.agent_infos = {}
|
|
|
|
model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.treeview.set_model(model)
|
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_data('column', 0)
|
|
|
|
self.treeview.insert_column_with_attributes(-1, 'Name', renderer, text=0)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_data('column', 1)
|
|
|
|
self.treeview.insert_column_with_attributes(-1, 'Service', \
|
|
|
|
renderer, text=1)
|
|
|
|
|
2004-09-06 16:55:10 +02:00
|
|
|
self.register_button = xml.get_widget('register_button')
|
|
|
|
self.register_button.set_sensitive(False)
|
|
|
|
self.join_button = xml.get_widget('join_button')
|
|
|
|
self.join_button.set_sensitive(False)
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
xml.signal_connect('on_refresh_clicked', self.on_refresh)
|
|
|
|
xml.signal_connect('on_row_activated', self.on_row_activated)
|
2004-09-06 16:55:10 +02:00
|
|
|
xml.signal_connect('on_join_button_clicked', self.on_join_button_clicked)
|
|
|
|
xml.signal_connect('on_register_button_clicked', self.on_register_button_clicked)
|
|
|
|
xml.signal_connect('on_cursor_changed', self.on_cursor_changed)
|
2004-05-15 18:50:38 +02:00
|
|
|
xml.signal_connect('on_close_clicked', self.on_close)
|
2005-02-07 23:24:07 +01:00
|
|
|
self.browse()
|
2004-09-06 16:55:10 +02:00
|
|
|
|
|
|
|
class join_gc:
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
|
|
|
del self.plugin.windows['join_gc']
|
|
|
|
|
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def on_join(self, widget):
|
|
|
|
"""When Join button is clicked"""
|
|
|
|
nick = self.xml.get_widget('entry_nick').get_text()
|
|
|
|
room = self.xml.get_widget('entry_room').get_text()
|
|
|
|
server = self.xml.get_widget('entry_server').get_text()
|
|
|
|
passw = self.xml.get_widget('entry_pass').get_text()
|
|
|
|
jid = '%s@%s' % (room, server)
|
|
|
|
self.plugin.windows[self.account]['gc'][jid] = gtkgui.gc(jid, nick, \
|
|
|
|
self.plugin, self.account)
|
|
|
|
#TODO: verify entries
|
|
|
|
self.plugin.send('GC_JOIN', self.account, (nick, room, server, passw))
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def __init__(self, plugin, account, server='', room = ''):
|
2005-02-07 23:27:54 +01:00
|
|
|
if not plugin.connected[account]:
|
|
|
|
warning_Window(_("You must be connected to join a group chat on this serveur"))
|
|
|
|
return
|
2004-09-06 16:55:10 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Join_gc', APP)
|
|
|
|
self.window = self.xml.get_widget('Join_gc')
|
|
|
|
self.xml.get_widget('entry_server').set_text(server)
|
|
|
|
self.xml.get_widget('entry_room').set_text(room)
|
|
|
|
self.xml.get_widget('entry_nick').set_text(self.plugin.nicks[self.account])
|
|
|
|
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
self.xml.signal_connect('on_cancel_clicked', self.on_close)
|
|
|
|
self.xml.signal_connect('on_join_clicked', self.on_join)
|