2005-04-13 11:41:44 +02:00
|
|
|
## config.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
|
|
|
|
import os
|
2005-08-30 23:03:23 +02:00
|
|
|
import sys
|
2005-06-09 00:05:45 +02:00
|
|
|
import common.config
|
2004-05-28 06:20:30 +02:00
|
|
|
import common.sleepy
|
2005-04-18 16:05:30 +02:00
|
|
|
|
2005-07-25 16:38:21 +02:00
|
|
|
import gtkgui_helpers
|
2005-04-18 16:05:30 +02:00
|
|
|
import dialogs
|
2005-04-18 18:40:10 +02:00
|
|
|
import cell_renderer_image
|
2005-05-26 02:07:49 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
import gtkspell
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2005-06-24 16:28:00 +02:00
|
|
|
from gajim import Contact
|
2005-08-09 13:34:36 +02:00
|
|
|
from common import helpers
|
2005-04-14 19:07:55 +02:00
|
|
|
from common import gajim
|
2005-04-14 09:42:26 +02:00
|
|
|
from common import connection
|
2004-05-17 01:47:14 +02:00
|
|
|
from common import i18n
|
2005-04-18 16:05:30 +02:00
|
|
|
|
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-04-22 17:56:33 +02:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
# helper function to create #aabbcc color string
|
|
|
|
def mk_color_string(color):
|
|
|
|
return '#' + (hex(color.red) + '0')[2:4] + \
|
|
|
|
(hex(color.green) + '0')[2:4] + \
|
|
|
|
(hex(color.blue) + '0')[2:4]
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- PreferencesWindow class -------------#
|
|
|
|
class PreferencesWindow:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for Preferences window'''
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-03-30 01:52:26 +02:00
|
|
|
def on_preferences_window_delete_event(self, widget, event):
|
2005-03-26 22:09:49 +01:00
|
|
|
self.window.hide()
|
2005-03-30 01:52:26 +02:00
|
|
|
return True # do NOT destroy the window
|
2005-03-26 22:09:49 +01:00
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.hide()
|
2005-03-30 01:52:26 +02:00
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-05-10 17:39:35 +02:00
|
|
|
'''Initialize Preferences window'''
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP)
|
|
|
|
self.window = self.xml.get_widget('preferences_window')
|
|
|
|
self.iconset_combobox = self.xml.get_widget('iconset_combobox')
|
|
|
|
self.notify_on_new_message_radiobutton = self.xml.get_widget \
|
|
|
|
('notify_on_new_message_radiobutton')
|
|
|
|
self.popup_new_message_radiobutton = self.xml.get_widget \
|
|
|
|
('popup_new_message_radiobutton')
|
2005-05-21 15:46:23 +02:00
|
|
|
self.notify_on_signin_checkbutton = self.xml.get_widget \
|
|
|
|
('notify_on_signin_checkbutton')
|
|
|
|
self.notify_on_signout_checkbutton = self.xml.get_widget \
|
|
|
|
('notify_on_signout_checkbutton')
|
2005-05-10 17:39:35 +02:00
|
|
|
self.auto_popup_away_checkbutton = self.xml.get_widget \
|
|
|
|
('auto_popup_away_checkbutton')
|
|
|
|
self.auto_away_checkbutton = self.xml.get_widget('auto_away_checkbutton')
|
|
|
|
self.auto_away_time_spinbutton = self.xml.get_widget \
|
|
|
|
('auto_away_time_spinbutton')
|
2005-08-06 17:17:20 +02:00
|
|
|
self.auto_away_message_entry = self.xml.get_widget \
|
|
|
|
('auto_away_message_entry')
|
2005-05-10 17:39:35 +02:00
|
|
|
self.auto_xa_checkbutton = self.xml.get_widget('auto_xa_checkbutton')
|
2005-08-16 22:24:56 +02:00
|
|
|
self.auto_xa_time_spinbutton = self.xml.get_widget(
|
|
|
|
'auto_xa_time_spinbutton')
|
2005-08-06 17:17:20 +02:00
|
|
|
self.auto_xa_message_entry = self.xml.get_widget('auto_xa_message_entry')
|
2005-05-10 17:39:35 +02:00
|
|
|
self.trayicon_checkbutton = self.xml.get_widget('trayicon_checkbutton')
|
|
|
|
self.notebook = self.xml.get_widget('preferences_notebook')
|
2005-04-29 17:01:44 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#trayicon
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.systray_capabilities:
|
2005-05-10 17:39:35 +02:00
|
|
|
st = gajim.config.get('trayicon')
|
|
|
|
self.trayicon_checkbutton.set_active(st)
|
2005-04-29 17:01:44 +02:00
|
|
|
else:
|
2005-08-16 22:24:56 +02:00
|
|
|
self.trayicon_checkbutton.set_sensitive(False)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#Save position
|
|
|
|
st = gajim.config.get('saveposition')
|
|
|
|
self.xml.get_widget('save_position_checkbutton').set_active(st)
|
|
|
|
|
|
|
|
#Merge accounts
|
|
|
|
st = gajim.config.get('mergeaccounts')
|
|
|
|
self.xml.get_widget('merge_checkbutton').set_active(st)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-05-29 20:41:13 +02:00
|
|
|
# Sort contacts by show
|
|
|
|
st = gajim.config.get('sort_by_show')
|
|
|
|
self.xml.get_widget('sort_by_show_checkbutton').set_active(st)
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#Use emoticons
|
|
|
|
st = gajim.config.get('useemoticons')
|
|
|
|
self.xml.get_widget('use_emoticons_checkbutton').set_active(st)
|
|
|
|
self.xml.get_widget('add_remove_emoticons_button').set_sensitive(st)
|
2005-03-26 22:09:49 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#iconset
|
2005-06-10 00:29:06 +02:00
|
|
|
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
2005-06-21 17:54:18 +02:00
|
|
|
# new model, image in 0, string in 1
|
|
|
|
model = gtk.ListStore(gtk.Image, str)
|
|
|
|
renderer_image = cell_renderer_image.CellRendererImage()
|
|
|
|
renderer_text = gtk.CellRendererText()
|
2005-06-23 18:31:35 +02:00
|
|
|
renderer_text.set_property('xpad', 5)
|
2005-06-21 17:54:18 +02:00
|
|
|
self.iconset_combobox.pack_start(renderer_image, expand=False)
|
|
|
|
self.iconset_combobox.pack_start(renderer_text, expand=True)
|
|
|
|
self.iconset_combobox.set_attributes(renderer_text, text=1)
|
|
|
|
self.iconset_combobox.add_attribute(renderer_image, 'image', 0)
|
2005-05-10 17:39:35 +02:00
|
|
|
self.iconset_combobox.set_model(model)
|
|
|
|
l = []
|
|
|
|
for dir in iconsets_list:
|
|
|
|
if dir != '.svn' and dir != 'transports':
|
|
|
|
l.append(dir)
|
|
|
|
if l.count == 0:
|
|
|
|
l.append(' ')
|
2005-10-27 14:47:54 +02:00
|
|
|
for i in xrange(len(l)):
|
2005-06-21 17:54:18 +02:00
|
|
|
preview = gtk.Image()
|
|
|
|
files = []
|
|
|
|
files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16', 'online.png'))
|
|
|
|
files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16', 'online.gif'))
|
|
|
|
for file in files:
|
|
|
|
if os.path.exists(file):
|
|
|
|
preview.set_from_file(file)
|
|
|
|
model.append([preview, l[i]])
|
2005-05-10 17:39:35 +02:00
|
|
|
if gajim.config.get('iconset') == l[i]:
|
|
|
|
self.iconset_combobox.set_active(i)
|
|
|
|
|
2005-05-25 19:13:50 +02:00
|
|
|
# Use transports iconsets
|
|
|
|
st = gajim.config.get('use_transports_iconsets')
|
|
|
|
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
|
|
|
|
|
2005-08-07 17:32:35 +02:00
|
|
|
# Themes
|
2005-05-10 17:39:35 +02:00
|
|
|
theme_combobox = self.xml.get_widget('theme_combobox')
|
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
theme_combobox.pack_start(cell, True)
|
|
|
|
theme_combobox.add_attribute(cell, 'text', 0)
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str)
|
2005-05-10 17:39:35 +02:00
|
|
|
theme_combobox.set_model(model)
|
|
|
|
|
|
|
|
#use tabbed chat window
|
|
|
|
st = gajim.config.get('usetabbedchat')
|
|
|
|
self.xml.get_widget('use_tabbed_chat_window_checkbutton').set_active(st)
|
|
|
|
|
2005-05-26 02:07:49 +02:00
|
|
|
#use speller
|
2005-06-04 14:52:16 +02:00
|
|
|
if os.name == 'nt':
|
|
|
|
self.xml.get_widget('speller_checkbutton').set_no_show_all(True)
|
2005-05-26 02:07:49 +02:00
|
|
|
else:
|
2005-06-04 14:52:16 +02:00
|
|
|
if 'gtkspell' in globals():
|
|
|
|
st = gajim.config.get('use_speller')
|
|
|
|
self.xml.get_widget('speller_checkbutton').set_active(st)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('speller_checkbutton').set_sensitive(False)
|
2005-05-26 02:07:49 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#Print time
|
2005-07-24 22:29:32 +02:00
|
|
|
st = gajim.config.get('print_ichat_every_foo_minutes')
|
|
|
|
text = _('Every %s _minutes') % st
|
|
|
|
self.xml.get_widget('time_sometimes_radiobutton').set_label(text)
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
if gajim.config.get('print_time') == 'never':
|
|
|
|
self.xml.get_widget('time_never_radiobutton').set_active(True)
|
|
|
|
elif gajim.config.get('print_time') == 'sometimes':
|
|
|
|
self.xml.get_widget('time_sometimes_radiobutton').set_active(True)
|
2005-04-17 11:05:58 +02:00
|
|
|
else:
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.get_widget('time_always_radiobutton').set_active(True)
|
2005-04-17 11:05:58 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#before time
|
|
|
|
st = gajim.config.get('before_time')
|
|
|
|
self.xml.get_widget('before_time_entry').set_text(st)
|
|
|
|
|
|
|
|
#after time
|
|
|
|
st = gajim.config.get('after_time')
|
|
|
|
self.xml.get_widget('after_time_entry').set_text(st)
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#before nickname
|
|
|
|
st = gajim.config.get('before_nickname')
|
|
|
|
self.xml.get_widget('before_nickname_entry').set_text(st)
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#after nickanme
|
|
|
|
st = gajim.config.get('after_nickname')
|
|
|
|
self.xml.get_widget('after_nickname_entry').set_text(st)
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#Color for incomming messages
|
|
|
|
colSt = gajim.config.get('inmsgcolor')
|
2005-06-04 14:52:16 +02:00
|
|
|
self.xml.get_widget('incoming_msg_colorbutton').set_color(
|
2005-05-10 17:39:35 +02:00
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for outgoing messages
|
|
|
|
colSt = gajim.config.get('outmsgcolor')
|
2005-06-04 14:52:16 +02:00
|
|
|
self.xml.get_widget('outgoing_msg_colorbutton').set_color(
|
2005-05-10 17:39:35 +02:00
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for status messages
|
|
|
|
colSt = gajim.config.get('statusmsgcolor')
|
2005-06-04 14:52:16 +02:00
|
|
|
self.xml.get_widget('status_msg_colorbutton').set_color(
|
2005-05-10 17:39:35 +02:00
|
|
|
gtk.gdk.color_parse(colSt))
|
2005-04-22 03:05:31 +02:00
|
|
|
|
2005-08-07 20:58:36 +02:00
|
|
|
#Font for messages
|
|
|
|
font = gajim.config.get('conversation_font')
|
2005-08-12 00:06:26 +02:00
|
|
|
# try to set default font for the current desktop env
|
|
|
|
if font == '':
|
|
|
|
font = gtkgui_helpers.get_default_font()
|
|
|
|
if font is None:
|
|
|
|
font = 'Sans 10'
|
2005-08-26 14:08:14 +02:00
|
|
|
gajim.config.set('conversation_font', font)
|
2005-08-07 20:58:36 +02:00
|
|
|
self.xml.get_widget('conversation_fontbutton').set_font_name(font)
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
# on new message
|
|
|
|
only_in_roster = True
|
|
|
|
if gajim.config.get('notify_on_new_message'):
|
2005-07-21 23:03:36 +02:00
|
|
|
self.xml.get_widget('notify_on_new_message_radiobutton').set_active(
|
|
|
|
True)
|
2005-05-10 17:39:35 +02:00
|
|
|
only_in_roster = False
|
|
|
|
if gajim.config.get('autopopup'):
|
|
|
|
self.xml.get_widget('popup_new_message_radiobutton').set_active(True)
|
|
|
|
only_in_roster = False
|
|
|
|
if only_in_roster:
|
|
|
|
self.xml.get_widget('only_in_roster_radiobutton').set_active(True)
|
2005-04-29 17:01:44 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#notify on online statuses
|
2005-05-21 15:46:23 +02:00
|
|
|
st = gajim.config.get('notify_on_signin')
|
|
|
|
self.notify_on_signin_checkbutton.set_active(st)
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
#notify on offline statuses
|
2005-05-21 15:46:23 +02:00
|
|
|
st = gajim.config.get('notify_on_signout')
|
|
|
|
self.notify_on_signout_checkbutton.set_active(st)
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
#autopopupaway
|
|
|
|
st = gajim.config.get('autopopupaway')
|
|
|
|
self.auto_popup_away_checkbutton.set_active(st)
|
|
|
|
|
|
|
|
#Ignore messages from unknown contacts
|
|
|
|
self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
|
|
|
|
set_active(gajim.config.get('ignore_unknown_contacts'))
|
2005-07-20 00:57:37 +02:00
|
|
|
|
|
|
|
# send chat state notifications
|
2005-08-07 22:58:44 +02:00
|
|
|
st = gajim.config.get('chat_state_notifications')
|
|
|
|
combo = self.xml.get_widget('chat_states_combobox')
|
2005-08-09 15:27:31 +02:00
|
|
|
if st == 'all':
|
2005-08-08 23:12:58 +02:00
|
|
|
combo.set_active(0)
|
2005-08-09 15:27:31 +02:00
|
|
|
elif st == 'composing_only':
|
|
|
|
combo.set_active(1)
|
2005-08-07 22:58:44 +02:00
|
|
|
else: # disabled
|
2005-08-09 15:27:31 +02:00
|
|
|
combo.set_active(2)
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
#sounds
|
2005-05-17 17:04:54 +02:00
|
|
|
if os.name == 'nt': # if windows, player must not become visible on show_all
|
2005-05-29 00:42:08 +02:00
|
|
|
soundplayer_hbox = self.xml.get_widget('soundplayer_hbox')
|
|
|
|
soundplayer_hbox.set_no_show_all(True)
|
2005-05-10 17:39:35 +02:00
|
|
|
if gajim.config.get('sounds_on'):
|
|
|
|
self.xml.get_widget('play_sounds_checkbutton').set_active(True)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('soundplayer_hbox').set_sensitive(False)
|
|
|
|
self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False)
|
|
|
|
self.xml.get_widget('browse_sounds_hbox').set_sensitive(False)
|
|
|
|
|
2005-08-09 13:34:36 +02:00
|
|
|
# sound player
|
|
|
|
player = gajim.config.get('soundplayer')
|
2005-08-25 22:31:49 +02:00
|
|
|
self.xml.get_widget('soundplayer_entry').set_text(player)
|
2005-08-09 13:34:36 +02:00
|
|
|
if player == '': # only on first time Gajim starts
|
2005-09-06 17:55:27 +02:00
|
|
|
commands = ('aplay', 'play', 'esdplay', 'artsplay')
|
2005-08-09 13:34:36 +02:00
|
|
|
for command in commands:
|
|
|
|
if helpers.is_in_path(command):
|
|
|
|
self.xml.get_widget('soundplayer_entry').set_text(command)
|
2005-08-21 21:09:31 +02:00
|
|
|
gajim.config.set('soundplayer', command)
|
2005-08-09 13:34:36 +02:00
|
|
|
break
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
#sounds treeview
|
|
|
|
self.sound_tree = self.xml.get_widget('sounds_treeview')
|
2005-06-18 16:17:26 +02:00
|
|
|
model = gtk.ListStore(str, bool, str)
|
2005-05-10 17:39:35 +02:00
|
|
|
self.sound_tree.set_model(model)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
col = gtk.TreeViewColumn(_('Event'))
|
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
|
|
|
col.set_attributes(renderer, text = 0)
|
|
|
|
|
|
|
|
col = gtk.TreeViewColumn(_('Sound'))
|
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
|
|
|
col.set_attributes(renderer, text = 2)
|
|
|
|
self.fill_sound_treeview()
|
|
|
|
|
|
|
|
#Autoaway
|
|
|
|
st = gajim.config.get('autoaway')
|
|
|
|
self.auto_away_checkbutton.set_active(st)
|
|
|
|
|
|
|
|
#Autoawaytime
|
|
|
|
st = gajim.config.get('autoawaytime')
|
|
|
|
self.auto_away_time_spinbutton.set_value(st)
|
|
|
|
self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))
|
|
|
|
|
2005-08-06 17:17:20 +02:00
|
|
|
#autoaway message
|
|
|
|
st = gajim.config.get('autoaway_message')
|
|
|
|
self.auto_away_message_entry.set_text(st)
|
|
|
|
self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway'))
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#Autoxa
|
|
|
|
st = gajim.config.get('autoxa')
|
|
|
|
self.auto_xa_checkbutton.set_active(st)
|
|
|
|
|
|
|
|
#Autoxatime
|
|
|
|
st = gajim.config.get('autoxatime')
|
|
|
|
self.auto_xa_time_spinbutton.set_value(st)
|
|
|
|
self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))
|
|
|
|
|
2005-08-06 17:17:20 +02:00
|
|
|
#autoxa message
|
|
|
|
st = gajim.config.get('autoxa_message')
|
|
|
|
self.auto_xa_message_entry.set_text(st)
|
|
|
|
self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa'))
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#ask_status when online / offline
|
|
|
|
st = gajim.config.get('ask_online_status')
|
|
|
|
self.xml.get_widget('prompt_online_status_message_checkbutton').\
|
|
|
|
set_active(st)
|
|
|
|
st = gajim.config.get('ask_offline_status')
|
|
|
|
self.xml.get_widget('prompt_offline_status_message_checkbutton').\
|
|
|
|
set_active(st)
|
|
|
|
|
|
|
|
#Status messages
|
|
|
|
self.msg_tree = self.xml.get_widget('msg_treeview')
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str, str)
|
2005-05-10 17:39:35 +02:00
|
|
|
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()
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
buf.connect('changed', self.on_msg_textview_changed)
|
|
|
|
|
|
|
|
#open links with
|
2005-05-17 17:04:54 +02:00
|
|
|
if os.name == 'nt':
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_frame = self.xml.get_widget('applications_frame')
|
|
|
|
self.applications_frame.set_no_show_all(True)
|
2005-08-11 13:41:50 +02:00
|
|
|
self.applications_frame.hide()
|
2005-05-17 17:04:54 +02:00
|
|
|
else:
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_combobox = self.xml.get_widget('applications_combobox')
|
2005-07-25 16:38:21 +02:00
|
|
|
if gajim.config.get('autodetect_browser_mailer'):
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_combobox.set_active(0)
|
2005-08-05 01:11:55 +02:00
|
|
|
gtkgui_helpers.autodetect_browser_mailer()
|
2005-07-25 16:38:21 +02:00
|
|
|
# autodetect_browser_mailer is now False.
|
|
|
|
# so user has 'Always Use GNOME/KDE' or Custom
|
|
|
|
elif gajim.config.get('openwith') == 'gnome-open':
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_combobox.set_active(1)
|
2005-05-17 17:04:54 +02:00
|
|
|
elif gajim.config.get('openwith') == 'kfmclient exec':
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_combobox.set_active(2)
|
2005-07-25 16:38:21 +02:00
|
|
|
elif gajim.config.get('openwith') == 'custom':
|
2005-08-09 17:30:45 +02:00
|
|
|
self.applications_combobox.set_active(3)
|
2005-05-17 17:04:54 +02:00
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
2005-05-20 17:05:22 +02:00
|
|
|
self.xml.get_widget('custom_browser_entry').set_text(
|
2005-05-17 17:04:54 +02:00
|
|
|
gajim.config.get('custombrowser'))
|
2005-05-20 17:05:22 +02:00
|
|
|
self.xml.get_widget('custom_mail_client_entry').set_text(
|
2005-05-17 17:04:54 +02:00
|
|
|
gajim.config.get('custommailapp'))
|
2005-08-09 17:30:45 +02:00
|
|
|
self.xml.get_widget('custom_file_manager_entry').set_text(
|
2005-08-09 17:37:11 +02:00
|
|
|
gajim.config.get('custom_file_manager'))
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
#log presences in user file
|
|
|
|
st = gajim.config.get('log_notif_in_user_file')
|
|
|
|
self.xml.get_widget('log_in_contact_checkbutton').set_active(st)
|
|
|
|
|
|
|
|
#log presences in external file
|
|
|
|
st = gajim.config.get('log_notif_in_sep_file')
|
|
|
|
self.xml.get_widget('log_in_extern_checkbutton').set_active(st)
|
|
|
|
|
2005-07-18 00:52:15 +02:00
|
|
|
# send os info
|
2005-05-10 17:39:35 +02:00
|
|
|
st = gajim.config.get('send_os_info')
|
|
|
|
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
|
|
|
|
|
2005-07-18 00:52:15 +02:00
|
|
|
# check for new version
|
2005-05-10 17:39:35 +02:00
|
|
|
st = gajim.config.get('check_for_new_version')
|
|
|
|
btn = self.xml.get_widget('check_for_new_version_checkbutton')
|
|
|
|
btn.set_active(st)
|
2005-07-20 00:57:37 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
|
|
|
self.sound_tree.get_model().connect('row-changed',
|
|
|
|
self.on_sounds_treemodel_row_changed)
|
|
|
|
self.msg_tree.get_model().connect('row-changed',
|
|
|
|
self.on_msg_treemodel_row_changed)
|
|
|
|
self.msg_tree.get_model().connect('row-deleted',
|
|
|
|
self.on_msg_treemodel_row_deleted)
|
|
|
|
|
|
|
|
def on_preferences_window_show(self, widget):
|
2005-07-24 23:05:44 +02:00
|
|
|
self.update_preferences_window()
|
2005-05-10 17:39:35 +02:00
|
|
|
self.notebook.set_current_page(0)
|
2005-07-24 23:05:44 +02:00
|
|
|
|
|
|
|
def update_preferences_window(self):
|
2005-07-24 22:29:32 +02:00
|
|
|
st = gajim.config.get('print_ichat_every_foo_minutes')
|
|
|
|
text = _('Every %s _minutes') % st
|
|
|
|
self.xml.get_widget('time_sometimes_radiobutton').set_label(text)
|
2005-08-07 17:32:35 +02:00
|
|
|
|
|
|
|
#Themes
|
|
|
|
theme_combobox = self.xml.get_widget('theme_combobox')
|
|
|
|
model = theme_combobox.get_model()
|
|
|
|
model.clear()
|
|
|
|
i = 0
|
2005-09-01 15:47:50 +02:00
|
|
|
for config_theme in gajim.config.get_per('themes'):
|
|
|
|
theme = config_theme.replace('_', ' ')
|
|
|
|
model.append([theme])
|
|
|
|
if gajim.config.get('roster_theme') == config_theme:
|
2005-08-07 17:32:35 +02:00
|
|
|
theme_combobox.set_active(i)
|
|
|
|
i += 1
|
|
|
|
self.on_theme_combobox_changed(theme_combobox)
|
2005-07-24 23:05:44 +02:00
|
|
|
#FIXME: move code from __init__ here
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_preferences_window_key_press_event(self, widget, event):
|
2005-05-26 02:07:49 +02:00
|
|
|
if event.keyval == gtk.keysyms.Escape:
|
2005-05-10 17:39:35 +02:00
|
|
|
self.window.hide()
|
|
|
|
|
2005-10-29 18:56:33 +02:00
|
|
|
def on_checkbutton_toggled(self, widget, config_name,
|
2005-05-10 17:39:35 +02:00
|
|
|
change_sensitivity_widgets = None):
|
|
|
|
gajim.config.set(config_name, widget.get_active())
|
2005-05-26 02:07:49 +02:00
|
|
|
if change_sensitivity_widgets:
|
2005-05-10 17:39:35 +02:00
|
|
|
for w in change_sensitivity_widgets:
|
|
|
|
w.set_sensitive(widget.get_active())
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_trayicon_checkbutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
gajim.config.set('trayicon', True)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.show_systray()
|
|
|
|
gajim.interface.roster.update_status_comboxbox()
|
2005-05-10 17:39:35 +02:00
|
|
|
else:
|
|
|
|
gajim.config.set('trayicon', False)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.hide_systray()
|
2005-06-06 01:17:59 +02:00
|
|
|
gajim.config.set('show_roster_on_startup', True) # no tray, show roster!
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_save_position_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'saveposition')
|
|
|
|
|
|
|
|
def on_merge_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'mergeaccounts')
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
|
|
|
|
gajim.interface.roster.draw_roster()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
2005-05-29 20:41:13 +02:00
|
|
|
def on_sort_by_show_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'sort_by_show')
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
2005-05-29 20:41:13 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_use_emoticons_checkbutton_toggled(self, widget):
|
2005-05-20 17:05:22 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'useemoticons',
|
2005-05-10 17:39:35 +02:00
|
|
|
[self.xml.get_widget('add_remove_emoticons_button')])
|
|
|
|
|
|
|
|
def on_add_remove_emoticons_button_clicked(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
window = gajim.interface.windows['add_remove_emoticons'].window
|
2005-05-10 17:39:35 +02:00
|
|
|
if window.get_property('visible'):
|
|
|
|
window.present()
|
|
|
|
else:
|
|
|
|
window.show_all()
|
|
|
|
|
|
|
|
def on_iconset_combobox_changed(self, widget):
|
|
|
|
model = widget.get_model()
|
|
|
|
active = widget.get_active()
|
2005-08-26 02:52:44 +02:00
|
|
|
icon_string = model[active][1].decode('utf-8')
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.set('iconset', icon_string)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.reload_jabber_state_images()
|
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
2005-05-25 19:13:50 +02:00
|
|
|
def on_transports_iconsets_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'use_transports_iconsets')
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
2005-06-09 01:17:40 +02:00
|
|
|
|
2005-06-10 00:29:06 +02:00
|
|
|
def on_manage_theme_button_clicked(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
dialogs.GajimThemesWindow()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_theme_combobox_changed(self, widget):
|
|
|
|
model = widget.get_model()
|
|
|
|
active = widget.get_active()
|
2005-09-01 15:47:50 +02:00
|
|
|
config_theme = model[active][0].decode('utf-8').replace(' ', '_')
|
2005-04-29 15:04:06 +02:00
|
|
|
|
2005-09-01 15:47:50 +02:00
|
|
|
gajim.config.set('roster_theme', config_theme)
|
2005-06-10 21:31:38 +02:00
|
|
|
|
2005-06-07 23:28:21 +02:00
|
|
|
# begin repainting themed widgets throughout
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.repaint_themed_widgets()
|
|
|
|
gajim.interface.roster.change_roster_style(None)
|
|
|
|
gajim.interface.save_config()
|
2005-04-28 16:38:36 +02:00
|
|
|
|
|
|
|
def merge_windows(self, kind):
|
|
|
|
for acct in gajim.connections:
|
|
|
|
#save buffers and close windows
|
|
|
|
buf1 = {}
|
|
|
|
buf2 = {}
|
|
|
|
saved_var = {}
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[acct][kind]
|
2005-04-28 16:55:57 +02:00
|
|
|
jids = windows.keys()
|
2005-04-28 16:38:36 +02:00
|
|
|
for jid in jids:
|
2005-04-28 16:55:57 +02:00
|
|
|
window = windows[jid]
|
|
|
|
buf1[jid] = window.xmls[jid].get_widget('conversation_textview').\
|
|
|
|
get_buffer()
|
|
|
|
buf2[jid] = window.xmls[jid].get_widget('message_textview').\
|
|
|
|
get_buffer()
|
|
|
|
saved_var[jid] = window.save_var(jid)
|
|
|
|
window.window.destroy()
|
2005-04-28 16:38:36 +02:00
|
|
|
#open new tabbed chat windows
|
|
|
|
for jid in jids:
|
2005-04-28 16:55:57 +02:00
|
|
|
if kind == 'chats':
|
2005-08-06 12:20:04 +02:00
|
|
|
c = gajim.get_contact_instance_with_highest_priority(acct, jid)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.new_chat(c, acct)
|
2005-04-28 17:48:20 +02:00
|
|
|
if kind == 'gc':
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct)
|
2005-04-28 16:55:57 +02:00
|
|
|
window = windows[jid]
|
2005-05-26 02:07:49 +02:00
|
|
|
window.xmls[jid].get_widget('conversation_textview').set_buffer(
|
2005-04-28 16:55:57 +02:00
|
|
|
buf1[jid])
|
2005-05-26 02:07:49 +02:00
|
|
|
window.xmls[jid].get_widget('message_textview').set_buffer(
|
2005-04-28 16:55:57 +02:00
|
|
|
buf2[jid])
|
|
|
|
window.load_var(jid, saved_var[jid])
|
2005-04-28 16:38:36 +02:00
|
|
|
|
|
|
|
def split_windows(self, kind):
|
|
|
|
for acct in gajim.connections:
|
|
|
|
#save buffers and close tabbed chat windows
|
2005-05-10 17:39:35 +02:00
|
|
|
buf1 = {}
|
|
|
|
buf2 = {}
|
|
|
|
saved_var = {}
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[acct][kind]
|
2005-05-10 17:39:35 +02:00
|
|
|
jids = windows.keys()
|
|
|
|
if not 'tabbed' in jids:
|
|
|
|
continue
|
|
|
|
jids.remove('tabbed')
|
|
|
|
for jid in jids:
|
|
|
|
window = windows[jid]
|
|
|
|
buf1[jid] = window.xmls[jid].get_widget('conversation_textview').\
|
|
|
|
get_buffer()
|
|
|
|
buf2[jid] = window.xmls[jid].get_widget('message_textview').\
|
|
|
|
get_buffer()
|
|
|
|
saved_var[jid] = window.save_var(jid)
|
|
|
|
windows['tabbed'].window.destroy()
|
|
|
|
#open new tabbed chat windows
|
|
|
|
for jid in jids:
|
|
|
|
if kind == 'chats':
|
2005-08-06 12:20:04 +02:00
|
|
|
c = gajim.get_contact_instance_with_highest_priority(acct, jid)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.new_chat(c, acct)
|
2005-05-10 17:39:35 +02:00
|
|
|
if kind == 'gc':
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct)
|
2005-05-10 17:39:35 +02:00
|
|
|
window = windows[jid]
|
2005-05-26 02:07:49 +02:00
|
|
|
window.xmls[jid].get_widget('conversation_textview').set_buffer(
|
2005-05-10 17:39:35 +02:00
|
|
|
buf1[jid])
|
2005-05-26 02:07:49 +02:00
|
|
|
window.xmls[jid].get_widget('message_textview').set_buffer(
|
2005-05-10 17:39:35 +02:00
|
|
|
buf2[jid])
|
|
|
|
window.load_var(jid, saved_var[jid])
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_use_tabbed_chat_window_checkbutton_toggled(self, widget):
|
2005-11-01 16:35:00 +01:00
|
|
|
self.on_checkbutton_toggled(widget, 'usetabbedchat')
|
2005-09-04 14:28:15 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
if widget.get_active():
|
|
|
|
self.merge_windows('chats')
|
|
|
|
self.merge_windows('gc')
|
2005-03-09 11:26:57 +01:00
|
|
|
else:
|
2005-05-10 17:39:35 +02:00
|
|
|
self.split_windows('chats')
|
|
|
|
self.split_windows('gc')
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-26 02:07:49 +02:00
|
|
|
|
|
|
|
def apply_speller(self, kind):
|
|
|
|
for acct in gajim.connections:
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[acct][kind]
|
2005-05-26 02:07:49 +02:00
|
|
|
jids = windows.keys()
|
|
|
|
for jid in jids:
|
2005-05-26 02:29:22 +02:00
|
|
|
if jid == 'tabbed':
|
|
|
|
continue
|
2005-05-26 02:07:49 +02:00
|
|
|
window = windows[jid]
|
|
|
|
textview = window.xmls[jid].get_widget('message_textview')
|
|
|
|
gtkspell.Spell(textview)
|
|
|
|
|
|
|
|
def remove_speller(self, kind):
|
|
|
|
for acct in gajim.connections:
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[acct][kind]
|
2005-05-26 02:07:49 +02:00
|
|
|
jids = windows.keys()
|
|
|
|
for jid in jids:
|
2005-05-26 02:29:22 +02:00
|
|
|
if jid == 'tabbed':
|
|
|
|
continue
|
2005-05-26 02:07:49 +02:00
|
|
|
window = windows[jid]
|
|
|
|
textview = window.xmls[jid].get_widget('message_textview')
|
|
|
|
spell_obj = gtkspell.get_from_text_view(textview)
|
|
|
|
if spell_obj:
|
|
|
|
spell_obj.detach()
|
|
|
|
|
|
|
|
def on_speller_checkbutton_toggled(self, widget):
|
|
|
|
active = widget.get_active()
|
|
|
|
gajim.config.set('use_speller', active)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-26 02:07:49 +02:00
|
|
|
if active:
|
|
|
|
self.apply_speller('chats')
|
|
|
|
self.apply_speller('gc')
|
|
|
|
else:
|
|
|
|
self.remove_speller('chats')
|
|
|
|
self.remove_speller('gc')
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def update_print_time(self):
|
|
|
|
'''Update time in Opened Chat Windows'''
|
|
|
|
for a in gajim.connections:
|
2005-10-20 13:17:17 +02:00
|
|
|
window = gajim.interface.windows[a]['chats']
|
2005-05-10 17:39:35 +02:00
|
|
|
if window.has_key('tabbed'):
|
|
|
|
window['tabbed'].update_print_time()
|
|
|
|
else:
|
|
|
|
for jid in window.keys():
|
|
|
|
window[jid].update_print_time()
|
|
|
|
|
|
|
|
def on_time_never_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
gajim.config.set('print_time', 'never')
|
|
|
|
self.update_print_time()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_time_sometimes_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
gajim.config.set('print_time', 'sometimes')
|
|
|
|
self.update_print_time()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_time_always_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
gajim.config.set('print_time', 'always')
|
|
|
|
self.update_print_time()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_before_time_entry_focus_out_event(self, widget, event):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('before_time', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_after_time_entry_focus_out_event(self, widget, event):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('after_time', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_before_nickname_entry_focus_out_event(self, widget, event):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('before_nickname', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_after_nickname_entry_focus_out_event(self, widget, event):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('after_nickname', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-29 18:37:59 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def update_text_tags(self):
|
|
|
|
'''Update color tags in Opened Chat Windows'''
|
|
|
|
for a in gajim.connections:
|
2005-10-27 15:15:03 +02:00
|
|
|
for kind in ('chats', 'gc'):
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[a][kind]
|
2005-08-07 20:58:36 +02:00
|
|
|
if windows.has_key('tabbed'):
|
|
|
|
windows['tabbed'].update_tags()
|
|
|
|
else:
|
|
|
|
for jid in windows.keys():
|
|
|
|
windows[jid].update_tags()
|
|
|
|
|
|
|
|
def update_text_font(self):
|
|
|
|
'''Update text font in Opened Chat Windows'''
|
|
|
|
for a in gajim.connections:
|
2005-10-27 15:15:03 +02:00
|
|
|
for kind in ('chats', 'gc'):
|
2005-10-20 13:17:17 +02:00
|
|
|
windows = gajim.interface.windows[a][kind]
|
2005-08-07 20:58:36 +02:00
|
|
|
if windows.has_key('tabbed'):
|
|
|
|
windows['tabbed'].update_font()
|
|
|
|
else:
|
|
|
|
for jid in windows.keys():
|
|
|
|
windows[jid].update_font()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_preference_widget_color_set(self, widget, text):
|
|
|
|
color = widget.get_color()
|
|
|
|
color_string = mk_color_string(color)
|
|
|
|
gajim.config.set(text, color_string)
|
|
|
|
self.update_text_tags()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-08-07 20:58:36 +02:00
|
|
|
|
|
|
|
def on_preference_widget_font_set(self, widget, text):
|
|
|
|
font = widget.get_font_name()
|
2005-08-26 14:08:14 +02:00
|
|
|
gajim.config.set(text, font)
|
2005-08-07 20:58:36 +02:00
|
|
|
self.update_text_font()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_incoming_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.on_preference_widget_color_set(widget, 'inmsgcolor')
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_outgoing_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.on_preference_widget_color_set(widget, 'outmsgcolor')
|
|
|
|
|
|
|
|
def on_status_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.on_preference_widget_color_set(widget, 'statusmsgcolor')
|
|
|
|
|
2005-08-07 20:58:36 +02:00
|
|
|
def on_conversation_fontbutton_font_set(self, widget):
|
|
|
|
self.on_preference_widget_font_set(widget, 'conversation_font')
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_reset_colors_button_clicked(self, widget):
|
2005-10-27 15:15:03 +02:00
|
|
|
for i in ('inmsgcolor', 'outmsgcolor', 'statusmsgcolor'):
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.config.set(i, gajim.interface.default_values[i])
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(gajim.config.get('inmsgcolor')))
|
|
|
|
self.xml.get_widget('outgoing_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(gajim.config.get('outmsgcolor')))
|
|
|
|
self.xml.get_widget('status_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(gajim.config.get('statusmsgcolor')))
|
|
|
|
self.update_text_tags()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-17 11:05:58 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_notify_on_new_message_radiobutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_new_message',
|
|
|
|
[self.auto_popup_away_checkbutton])
|
2004-10-13 23:46:10 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_popup_new_message_radiobutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'autopopup',
|
|
|
|
[self.auto_popup_away_checkbutton])
|
2005-04-29 15:04:06 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_only_in_roster_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
self.auto_popup_away_checkbutton.set_sensitive(False)
|
2005-04-29 15:04:06 +02:00
|
|
|
|
2005-05-21 15:46:23 +02:00
|
|
|
def on_notify_on_signin_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_signin')
|
2005-04-02 21:52:00 +02:00
|
|
|
|
2005-05-21 15:46:23 +02:00
|
|
|
def on_notify_on_signout_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_signout')
|
2005-04-02 21:52:00 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_auto_popup_away_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'autopopupaway')
|
2005-04-02 21:52:00 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts')
|
2005-02-05 18:18:49 +01:00
|
|
|
|
2005-08-07 22:58:44 +02:00
|
|
|
def on_chat_states_combobox_changed(self, widget):
|
|
|
|
active = widget.get_active()
|
2005-08-09 15:27:31 +02:00
|
|
|
if active == 0: # all
|
2005-08-07 22:58:44 +02:00
|
|
|
gajim.config.set('chat_state_notifications', 'all')
|
2005-08-09 15:27:31 +02:00
|
|
|
elif active == 1: # only composing
|
|
|
|
gajim.config.set('chat_state_notifications', 'composing_only')
|
2005-08-07 22:58:44 +02:00
|
|
|
else: # disabled
|
|
|
|
gajim.config.set('chat_state_notifications', 'disabled')
|
|
|
|
|
2005-07-20 00:57:37 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_play_sounds_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'sounds_on',
|
|
|
|
[self.xml.get_widget('soundplayer_hbox'),
|
|
|
|
self.xml.get_widget('sounds_scrolledwindow'),
|
|
|
|
self.xml.get_widget('browse_sounds_hbox')])
|
|
|
|
|
|
|
|
def on_soundplayer_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('soundplayer', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_prompt_online_status_message_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'ask_online_status')
|
|
|
|
|
|
|
|
def on_prompt_offline_status_message_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'ask_offline_status')
|
|
|
|
|
|
|
|
def on_sounds_treemodel_row_changed(self, model, path, iter):
|
2005-08-26 02:52:44 +02:00
|
|
|
sound_event = model.get_value(iter, 0).decode('utf-8')
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.set_per('soundevents', sound_event, 'enabled',
|
|
|
|
bool(model[path][1]))
|
|
|
|
gajim.config.set_per('soundevents', sound_event, 'path',
|
2005-08-26 02:52:44 +02:00
|
|
|
model[iter][2].decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_auto_away_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'autoaway',
|
2005-08-06 17:17:20 +02:00
|
|
|
[self.auto_away_time_spinbutton, self.auto_away_message_entry])
|
2005-04-17 01:15:03 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_auto_away_time_spinbutton_value_changed(self, widget):
|
|
|
|
aat = widget.get_value_as_int()
|
|
|
|
gajim.config.set('autoawaytime', aat)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.sleeper = common.sleepy.Sleepy(
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.get('autoawaytime') * 60,
|
|
|
|
gajim.config.get('autoxatime') * 60)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-17 01:15:03 +02:00
|
|
|
|
2005-08-06 17:17:20 +02:00
|
|
|
def on_auto_away_message_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('autoaway_message', widget.get_text().decode('utf-8'))
|
2005-08-06 17:17:20 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_auto_xa_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'autoxa',
|
2005-08-06 17:17:20 +02:00
|
|
|
[self.auto_xa_time_spinbutton, self.auto_xa_message_entry])
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_auto_xa_time_spinbutton_value_changed(self, widget):
|
|
|
|
axt = widget.get_value_as_int()
|
|
|
|
gajim.config.set('autoxatime', axt)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.sleeper = common.sleepy.Sleepy(
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.get('autoawaytime') * 60,
|
|
|
|
gajim.config.get('autoxatime') * 60)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-08-06 17:17:20 +02:00
|
|
|
def on_auto_xa_message_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('autoxa_message', widget.get_text().decode('utf-8'))
|
2005-08-06 17:17:20 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def save_status_messages(self, model):
|
|
|
|
for msg in gajim.config.get_per('statusmsg'):
|
|
|
|
gajim.config.del_per('statusmsg', msg)
|
|
|
|
iter = model.get_iter_first()
|
|
|
|
while iter:
|
2005-08-26 02:52:44 +02:00
|
|
|
val = model.get_value(iter, 0).decode('utf-8')
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.add_per('statusmsg', val)
|
|
|
|
gajim.config.set_per('statusmsg', val, 'message',
|
2005-08-26 02:52:44 +02:00
|
|
|
model[iter][1].decode('utf-8'))
|
2005-05-10 17:39:35 +02:00
|
|
|
iter = model.iter_next(iter)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-03-21 22:01:03 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_msg_treemodel_row_changed(self, model, path, iter):
|
|
|
|
self.save_status_messages(model)
|
|
|
|
|
2005-06-01 22:01:11 +02:00
|
|
|
def on_msg_treemodel_row_deleted(self, model, path):
|
2005-05-10 17:39:35 +02:00
|
|
|
self.save_status_messages(model)
|
|
|
|
|
2005-08-09 17:30:45 +02:00
|
|
|
def on_applications_combobox_changed(self, widget):
|
2005-07-25 16:38:21 +02:00
|
|
|
gajim.config.set('autodetect_browser_mailer', False)
|
2005-07-27 14:22:17 +02:00
|
|
|
if widget.get_active() == 3:
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
|
|
|
gajim.config.set('openwith', 'custom')
|
2005-04-12 17:30:09 +02:00
|
|
|
else:
|
2005-05-10 17:39:35 +02:00
|
|
|
if widget.get_active() == 0:
|
2005-07-25 16:38:21 +02:00
|
|
|
gajim.config.set('autodetect_browser_mailer', True)
|
|
|
|
elif widget.get_active() == 1:
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.set('openwith', 'gnome-open')
|
2005-07-25 16:38:21 +02:00
|
|
|
elif widget.get_active() == 2:
|
2005-05-10 17:39:35 +02:00
|
|
|
gajim.config.set('openwith', 'kfmclient exec')
|
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_custom_browser_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('custombrowser', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_custom_mail_client_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('custommailapp', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
2005-08-09 17:30:45 +02:00
|
|
|
def on_custom_file_manager_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.set('custom_file_manager', widget.get_text().decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-08-09 17:30:45 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_log_in_contact_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('log_notif_in_user_file', widget.get_active())
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_log_in_extern_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('log_notif_in_sep_file', widget.get_active())
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-05-10 17:39:35 +02:00
|
|
|
|
|
|
|
def on_send_os_info_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('send_os_info', widget.get_active())
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_check_for_new_version_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('check_for_new_version', widget.get_active())
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-02-10 01:07:55 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def fill_msg_treeview(self):
|
|
|
|
self.xml.get_widget('delete_msg_button').set_sensitive(False)
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
model.clear()
|
|
|
|
for msg in gajim.config.get_per('statusmsg'):
|
|
|
|
iter = model.append()
|
|
|
|
val = gajim.config.get_per('statusmsg', msg, 'message')
|
|
|
|
model.set(iter, 0, msg, 1, val)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-05-10 17:39:35 +02: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)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_msg_treeview_cursor_changed(self, widget, data = None):
|
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
self.xml.get_widget('delete_msg_button').set_sensitive(True)
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
name = model.get_value(iter, 0)
|
2005-08-07 13:44:50 +02:00
|
|
|
msg = model[iter][1]
|
2005-05-10 17:39:35 +02:00
|
|
|
buf.set_text(msg)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_new_msg_button_clicked(self, widget, data = None):
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.append()
|
2005-07-29 19:47:37 +02:00
|
|
|
model.set(iter, 0, _('status message title'), 1, _('status message text'))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_delete_msg_button_clicked(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()
|
|
|
|
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)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def sound_toggled_cb(self, cell, path):
|
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model[path][1] = not model[path][1]
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def fill_sound_treeview(self):
|
|
|
|
sounds = gajim.config.get_per('soundevents')
|
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model.clear()
|
|
|
|
for sound in sounds:
|
|
|
|
val = gajim.config.get_per('soundevents', sound,
|
|
|
|
'enabled')
|
|
|
|
path = gajim.config.get_per('soundevents', sound,
|
|
|
|
'path')
|
|
|
|
iter = model.append((sound, val, path))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_treeview_sounds_cursor_changed(self, widget, data = None):
|
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
|
|
|
sounds_entry = self.xml.get_widget('sounds_entry')
|
|
|
|
if not iter:
|
|
|
|
sounds_entry.set_text('')
|
|
|
|
return
|
2005-08-07 13:44:50 +02:00
|
|
|
str = model[iter][2]
|
2005-05-10 17:39:35 +02:00
|
|
|
sounds_entry.set_text(str)
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_button_sounds_clicked(self, widget, data = None):
|
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
file = model[iter][2].decode('utf-8')
|
2005-05-17 13:55:30 +02:00
|
|
|
dialog = gtk.FileChooserDialog(_('Choose Sound'), None,
|
2005-05-10 17:39:35 +02:00
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-08-23 15:22:14 +02:00
|
|
|
last_sounds_dir = gajim.config.get('last_sounds_dir')
|
|
|
|
if last_sounds_dir and os.path.isdir('last_sounds_dir'):
|
|
|
|
dialog.set_current_folder(last_sounds_dir)
|
|
|
|
else:
|
|
|
|
home_dir = os.path.expanduser('~')
|
|
|
|
dialog.set_current_folder(home_dir)
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
filter = gtk.FileFilter()
|
|
|
|
filter.set_name(_('All files'))
|
|
|
|
filter.add_pattern('*')
|
|
|
|
dialog.add_filter(filter)
|
2004-11-04 02:03:17 +01:00
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
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)
|
|
|
|
file = ''
|
|
|
|
while True:
|
|
|
|
response = dialog.run()
|
|
|
|
if response != gtk.RESPONSE_OK:
|
|
|
|
break
|
|
|
|
file = dialog.get_filename()
|
2005-10-21 15:21:31 +02:00
|
|
|
try:
|
|
|
|
file = file.decode(sys.getfilesystemencoding())
|
|
|
|
except:
|
|
|
|
pass
|
2005-05-10 17:39:35 +02:00
|
|
|
if os.path.exists(file):
|
|
|
|
break
|
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
2005-08-23 15:22:14 +02:00
|
|
|
directory = os.path.dirname(file)
|
|
|
|
gajim.config.set('last_sounds_dir', directory)
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.get_widget('sounds_entry').set_text(file)
|
|
|
|
model.set_value(iter, 2, file)
|
|
|
|
model.set_value(iter, 1, 1)
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-06-06 17:03:41 +02:00
|
|
|
def on_sounds_entry_changed(self, widget):
|
|
|
|
path_to_file = widget.get_text()
|
|
|
|
model, iter = self.sound_tree.get_selection().get_selected()
|
|
|
|
model.set_value(iter, 2, path_to_file)
|
|
|
|
model.set_value(iter, 1, 1)
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
def on_open_advanced_editor_button_clicked(self, widget, data = None):
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('advanced_config'):
|
|
|
|
gajim.interface.windows['advanced_config'].window.present()
|
2005-05-10 17:39:35 +02:00
|
|
|
else:
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows['advanced_config'] = \
|
2005-10-21 19:49:35 +02:00
|
|
|
dialogs.AdvancedConfigurationWindow()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- AccountModificationWindow class -------------#
|
|
|
|
class AccountModificationWindow:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for account informations'''
|
2005-03-07 18:01:56 +01:00
|
|
|
def on_account_modification_window_destroy(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''close window'''
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key(self.account):
|
|
|
|
if gajim.interface.windows[self.account].has_key('account_modification'):
|
|
|
|
del gajim.interface.windows[self.account]['account_modification']
|
2005-04-20 18:35:40 +02:00
|
|
|
return
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('account_modification'):
|
|
|
|
del gajim.interface.windows['account_modification']
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-04-17 20:36:09 +02:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, account = ''):
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'account_modification_window', APP)
|
|
|
|
self.window = self.xml.get_widget('account_modification_window')
|
|
|
|
self.account = account
|
2005-06-18 16:17:26 +02:00
|
|
|
self.modify = False # if we 're modifying an existing or creating a new account
|
2005-06-09 11:32:19 +02:00
|
|
|
|
|
|
|
# init proxy list
|
|
|
|
self.update_proxy_list()
|
|
|
|
|
2005-05-10 17:39:35 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-06-18 16:17:26 +02:00
|
|
|
if account: # we modify an existing account
|
2005-05-10 17:39:35 +02:00
|
|
|
self.modify = True
|
|
|
|
self.init_account()
|
|
|
|
self.xml.get_widget('new_account_checkbutton').set_sensitive(False)
|
2005-06-18 23:53:53 +02:00
|
|
|
self.xml.get_widget('save_button').grab_focus()
|
2005-06-18 16:17:26 +02:00
|
|
|
else: # we create a new account
|
|
|
|
if len(gajim.connections) == 0: # is it the first accound we're creating?
|
2005-07-22 23:51:56 +02:00
|
|
|
# the first account *has* to sync by default
|
|
|
|
self.xml.get_widget('sync_with_global_status_checkbutton')\
|
|
|
|
.set_active(True)
|
|
|
|
# the first account *has* to autoconnect by default
|
|
|
|
self.xml.get_widget('autoconnect_checkbutton').set_active(True)
|
2005-06-18 23:53:53 +02:00
|
|
|
self.xml.get_widget('name_entry').set_text('Main')
|
|
|
|
self.xml.get_widget('jid_entry').grab_focus()
|
2005-05-10 17:39:35 +02:00
|
|
|
self.window.show_all()
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
def on_checkbutton_toggled(self, widget, widgets):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''set or unset sensitivity of widgets when widget is toggled'''
|
2005-04-06 20:51:54 +02:00
|
|
|
for w in widgets:
|
|
|
|
w.set_sensitive(widget.get_active())
|
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
def init_account_gpg(self):
|
|
|
|
keyid = gajim.config.get_per('accounts', self.account, 'keyid')
|
2005-05-09 21:52:43 +02:00
|
|
|
keyname = gajim.config.get_per('accounts', self.account, 'keyname')
|
2005-04-22 03:05:31 +02:00
|
|
|
savegpgpass = gajim.config.get_per('accounts', self.account,
|
2005-05-09 21:52:43 +02:00
|
|
|
'savegpgpass')
|
2005-04-22 03:05:31 +02:00
|
|
|
|
|
|
|
if not keyid or not gajim.config.get('usegpg'):
|
|
|
|
return
|
|
|
|
|
2005-04-24 17:47:53 +02:00
|
|
|
self.xml.get_widget('gpg_key_label').set_text(keyid)
|
2005-04-22 03:05:31 +02:00
|
|
|
self.xml.get_widget('gpg_name_label').set_text(keyname)
|
|
|
|
gpg_save_password_checkbutton = \
|
|
|
|
self.xml.get_widget('gpg_save_password_checkbutton')
|
|
|
|
gpg_save_password_checkbutton.set_sensitive(True)
|
|
|
|
gpg_save_password_checkbutton.set_active(savegpgpass)
|
|
|
|
|
|
|
|
if savegpgpass:
|
|
|
|
entry = self.xml.get_widget('gpg_password_entry')
|
|
|
|
entry.set_sensitive(True)
|
|
|
|
gpgpassword = gajim.config.get_per('accounts',
|
|
|
|
self.account, 'gpgpassword')
|
|
|
|
entry.set_text(gpgpassword)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-06-09 00:05:45 +02:00
|
|
|
def update_proxy_list(self):
|
2005-06-09 11:32:19 +02:00
|
|
|
if self.account:
|
|
|
|
our_proxy = gajim.config.get_per('accounts', self.account, 'proxy')
|
|
|
|
else:
|
|
|
|
our_proxy = ''
|
2005-06-09 00:05:45 +02:00
|
|
|
if not our_proxy:
|
|
|
|
our_proxy = 'None'
|
|
|
|
self.proxy_combobox = self.xml.get_widget('proxies_combobox')
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str)
|
2005-06-09 00:05:45 +02:00
|
|
|
self.proxy_combobox.set_model(model)
|
|
|
|
l = gajim.config.get_per('proxies')
|
|
|
|
l.insert(0, 'None')
|
2005-10-27 14:47:54 +02:00
|
|
|
for i in xrange(len(l)):
|
2005-06-09 00:05:45 +02:00
|
|
|
model.append([l[i]])
|
|
|
|
if our_proxy == l[i]:
|
|
|
|
self.proxy_combobox.set_active(i)
|
|
|
|
|
2005-04-15 01:00:25 +02:00
|
|
|
def init_account(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Initialize window with defaults values'''
|
2005-04-15 01:00:25 +02:00
|
|
|
self.xml.get_widget('name_entry').set_text(self.account)
|
2005-04-22 03:05:31 +02:00
|
|
|
jid = gajim.config.get_per('accounts', self.account, 'name') \
|
|
|
|
+ '@' + gajim.config.get_per('accounts',
|
2005-10-20 10:48:19 +02:00
|
|
|
self.account, 'hostname')
|
2005-04-15 01:00:25 +02:00
|
|
|
self.xml.get_widget('jid_entry').set_text(jid)
|
2005-06-18 16:17:26 +02:00
|
|
|
self.xml.get_widget('save_password_checkbutton').set_active(
|
2005-04-15 01:00:25 +02:00
|
|
|
gajim.config.get_per('accounts', self.account, 'savepass'))
|
|
|
|
if gajim.config.get_per('accounts', self.account, 'savepass'):
|
2005-04-22 03:05:31 +02:00
|
|
|
passstr = gajim.config.get_per('accounts',
|
|
|
|
self.account, 'password')
|
2005-04-15 01:00:25 +02:00
|
|
|
password_entry = self.xml.get_widget('password_entry')
|
|
|
|
password_entry.set_sensitive(True)
|
2005-04-22 03:05:31 +02:00
|
|
|
password_entry.set_text(passstr)
|
|
|
|
|
2005-06-18 16:17:26 +02:00
|
|
|
self.xml.get_widget('resource_entry').set_text(gajim.config.get_per(
|
2005-04-15 01:00:25 +02:00
|
|
|
'accounts', self.account, 'resource'))
|
|
|
|
self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\
|
|
|
|
get_per('accounts', self.account, 'priority'))
|
2005-06-08 17:48:53 +02:00
|
|
|
|
2005-05-30 13:01:08 +02:00
|
|
|
usessl = gajim.config.get_per('accounts', self.account, 'usessl')
|
|
|
|
self.xml.get_widget('use_ssl_checkbutton').set_active(usessl)
|
2005-07-25 02:31:20 +02:00
|
|
|
|
|
|
|
self.xml.get_widget('send_keepalive_checkbutton').set_active(
|
|
|
|
gajim.config.get_per('accounts', self.account,
|
|
|
|
'keep_alives_enabled'))
|
2005-05-09 21:52:43 +02:00
|
|
|
|
2005-06-14 12:26:01 +02:00
|
|
|
use_custom_host = gajim.config.get_per('accounts', self.account,
|
|
|
|
'use_custom_host')
|
|
|
|
self.xml.get_widget('custom_host_port_checkbutton').set_active(
|
|
|
|
use_custom_host)
|
|
|
|
custom_host = gajim.config.get_per('accounts', self.account,
|
2005-10-20 10:48:19 +02:00
|
|
|
'custom_host')
|
2005-06-14 12:26:01 +02:00
|
|
|
if not custom_host:
|
|
|
|
custom_host = gajim.config.get_per('accounts',
|
2005-10-20 10:48:19 +02:00
|
|
|
self.account, 'hostname')
|
2005-06-14 12:26:01 +02:00
|
|
|
self.xml.get_widget('custom_host_entry').set_text(custom_host)
|
|
|
|
custom_port = gajim.config.get_per('accounts', self.account,
|
2005-10-19 22:18:09 +02:00
|
|
|
'custom_port')
|
2005-06-14 12:26:01 +02:00
|
|
|
if not custom_port:
|
|
|
|
custom_port = 5222
|
2005-08-26 02:52:44 +02:00
|
|
|
self.xml.get_widget('custom_port_entry').set_text(unicode(custom_port))
|
2005-06-13 23:16:41 +02:00
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_key_label = self.xml.get_widget('gpg_key_label')
|
2005-04-22 03:05:31 +02:00
|
|
|
if gajim.config.get('usegpg'):
|
2005-04-23 19:40:43 +02:00
|
|
|
self.init_account_gpg()
|
2005-04-22 03:05:31 +02:00
|
|
|
else:
|
2005-05-30 16:16:41 +02:00
|
|
|
gpg_key_label.set_text(_('OpenPGP is not usable in this computer'))
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('gpg_choose_button').set_sensitive(False)
|
2005-04-15 01:00:25 +02:00
|
|
|
self.xml.get_widget('autoconnect_checkbutton').set_active(gajim.config.\
|
|
|
|
get_per('accounts', self.account, 'autoconnect'))
|
2005-09-05 15:28:09 +02:00
|
|
|
self.xml.get_widget('autoreconnect_checkbutton').set_active(gajim.config.\
|
|
|
|
get_per('accounts', self.account, 'autoreconnect'))
|
2005-06-18 16:17:26 +02:00
|
|
|
|
2005-07-22 23:51:56 +02:00
|
|
|
if len(gajim.connections) != 0:
|
|
|
|
# only if we already have one account already
|
2005-06-18 16:17:26 +02:00
|
|
|
# we check that so we avoid the first account to have sync=False
|
|
|
|
self.xml.get_widget('sync_with_global_status_checkbutton').set_active(
|
|
|
|
gajim.config.get_per('accounts', self.account,
|
|
|
|
'sync_with_global_status'))
|
2005-07-22 23:51:56 +02:00
|
|
|
self.xml.get_widget('autoconnect_checkbutton').set_active(
|
|
|
|
gajim.config.get_per('accounts', self.account, 'autoconnect'))
|
2005-06-07 03:10:24 +02:00
|
|
|
list_no_log_for = gajim.config.get_per('accounts', self.account,
|
2005-04-15 01:00:25 +02:00
|
|
|
'no_log_for').split()
|
|
|
|
if self.account in list_no_log_for:
|
|
|
|
self.xml.get_widget('log_history_checkbutton').set_active(0)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_save_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When save button is clicked: Save information in config file'''
|
2005-05-10 11:20:35 +02:00
|
|
|
config = {}
|
2005-08-26 02:52:44 +02:00
|
|
|
name = self.xml.get_widget('name_entry').get_text().decode('utf-8')
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections.has_key(self.account):
|
2005-04-22 03:05:31 +02:00
|
|
|
if name != self.account and \
|
|
|
|
gajim.connections[self.account].connected != 0:
|
2005-07-18 18:40:12 +02:00
|
|
|
dialogs.ErrorDialog(_('You are currently connected to the server'),
|
|
|
|
_('To change the account name, you must be disconnected.')).get_response()
|
2005-03-31 14:17:07 +02:00
|
|
|
return
|
2005-05-10 11:20:35 +02:00
|
|
|
if (name == ''):
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Invalid account name'),
|
2005-07-18 18:40:12 +02:00
|
|
|
_('Account name cannot be empty.')).get_response()
|
2005-05-10 11:20:35 +02:00
|
|
|
return
|
|
|
|
if name.find(' ') != -1:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Invalid account name'),
|
2005-07-18 18:40:12 +02:00
|
|
|
_('Account name cannot contain spaces.')).get_response()
|
2005-05-10 11:20:35 +02:00
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8')
|
2005-05-10 11:20:35 +02:00
|
|
|
if jid == '' or jid.count('@') != 1:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Invalid Jabber ID'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('A Jabber ID must be in the form "user@servername".')).get_response()
|
2005-05-10 11:20:35 +02:00
|
|
|
return
|
|
|
|
new_account = self.xml.get_widget('new_account_checkbutton').get_active()
|
|
|
|
config['savepass'] = self.xml.get_widget(
|
|
|
|
'save_password_checkbutton').get_active()
|
2005-08-26 02:52:44 +02:00
|
|
|
config['password'] = self.xml.get_widget('password_entry').get_text().decode('utf-8')
|
2005-05-10 11:20:35 +02:00
|
|
|
if new_account and config['password'] == '':
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Invalid password'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('You must enter a password for the new account.')).get_response()
|
2005-05-10 11:20:35 +02:00
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
config['resource'] = self.xml.get_widget('resource_entry').get_text().decode('utf-8')
|
2005-05-10 11:20:35 +02:00
|
|
|
config['priority'] = self.xml.get_widget('priority_spinbutton').\
|
|
|
|
get_value_as_int()
|
|
|
|
config['autoconnect'] = self.xml.get_widget('autoconnect_checkbutton').\
|
|
|
|
get_active()
|
2005-09-05 15:28:09 +02:00
|
|
|
config['autoreconnect'] = self.xml.get_widget('autoreconnect_checkbutton').\
|
|
|
|
get_active()
|
2005-03-06 20:19:21 +01:00
|
|
|
|
2005-04-15 01:00:25 +02:00
|
|
|
if self.account:
|
2005-04-22 03:05:31 +02:00
|
|
|
list_no_log_for = gajim.config.get_per('accounts',
|
|
|
|
self.account, 'no_log_for').split()
|
2005-04-15 01:00:25 +02:00
|
|
|
else:
|
|
|
|
list_no_log_for = []
|
2005-03-06 20:19:21 +01:00
|
|
|
if self.account in list_no_log_for:
|
|
|
|
list_no_log_for.remove(self.account)
|
|
|
|
if not self.xml.get_widget('log_history_checkbutton').get_active():
|
|
|
|
list_no_log_for.append(name)
|
2005-05-10 11:20:35 +02:00
|
|
|
config['no_log_for'] = ' '.join(list_no_log_for)
|
|
|
|
|
|
|
|
config['sync_with_global_status'] = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'sync_with_global_status_checkbutton').get_active()
|
2005-04-21 01:20:26 +02:00
|
|
|
|
2005-06-08 17:48:53 +02:00
|
|
|
active = self.proxy_combobox.get_active()
|
2005-08-26 02:52:44 +02:00
|
|
|
proxy = self.proxy_combobox.get_model()[active][0].decode('utf-8')
|
2005-06-08 17:48:53 +02:00
|
|
|
if proxy == 'None':
|
|
|
|
proxy = ''
|
|
|
|
config['proxy'] = proxy
|
2005-06-13 23:16:41 +02:00
|
|
|
|
2005-05-30 13:01:08 +02:00
|
|
|
config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active()
|
2005-10-19 20:47:09 +02:00
|
|
|
n, hn = jid.split('@')
|
|
|
|
config['name'] = n
|
2005-10-20 10:48:19 +02:00
|
|
|
config['hostname'] = hn
|
2005-06-14 12:26:01 +02:00
|
|
|
|
|
|
|
config['use_custom_host'] = self.xml.get_widget(
|
|
|
|
'custom_host_port_checkbutton').get_active()
|
|
|
|
custom_port = self.xml.get_widget('custom_port_entry').get_text()
|
|
|
|
try:
|
|
|
|
custom_port = int(custom_port)
|
|
|
|
except:
|
|
|
|
dialogs.ErrorDialog(_('Invalid entry'),
|
|
|
|
_('Custom port must be a port number.')).get_response()
|
|
|
|
return
|
|
|
|
config['custom_port'] = custom_port
|
|
|
|
config['custom_host'] = self.xml.get_widget(
|
2005-10-20 10:48:19 +02:00
|
|
|
'custom_host_entry').get_text().decode('utf-8')
|
2005-06-13 23:16:41 +02:00
|
|
|
|
2005-08-26 02:52:44 +02:00
|
|
|
config['keyname'] = self.xml.get_widget('gpg_name_label').get_text().decode('utf-8')
|
2005-05-10 11:20:35 +02:00
|
|
|
if config['keyname'] == '': #no key selected
|
|
|
|
config['keyid'] = ''
|
|
|
|
config['savegpgpass'] = False
|
|
|
|
config['gpgpassword'] = ''
|
2004-10-10 20:44:38 +02:00
|
|
|
else:
|
2005-08-26 02:52:44 +02:00
|
|
|
config['keyid'] = self.xml.get_widget('gpg_key_label').get_text().decode('utf-8')
|
2005-05-10 11:20:35 +02:00
|
|
|
config['savegpgpass'] = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'gpg_save_password_checkbutton').get_active()
|
2005-05-10 11:20:35 +02:00
|
|
|
config['gpgpassword'] = self.xml.get_widget('gpg_password_entry').\
|
2005-08-26 02:52:44 +02:00
|
|
|
get_text().decode('utf-8')
|
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
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows[name] = gajim.interface.windows[self.account]
|
2005-10-15 22:49:08 +02:00
|
|
|
gajim.awaiting_events[name] = gajim.awaiting_events[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
gajim.nicks[name] = gajim.nicks[self.account]
|
|
|
|
gajim.allow_notifications[name] = \
|
|
|
|
gajim.allow_notifications[self.account]
|
|
|
|
gajim.groups[name] = gajim.groups[self.account]
|
|
|
|
gajim.contacts[name] = gajim.contacts[self.account]
|
2005-07-25 22:04:24 +02:00
|
|
|
gajim.gc_contacts[name] = gajim.gc_contacts[self.account]
|
2005-08-03 11:23:36 +02:00
|
|
|
gajim.gc_connected[name] = gajim.gc_connected[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
gajim.newly_added[name] = gajim.newly_added[self.account]
|
|
|
|
gajim.to_be_removed[name] = gajim.to_be_removed[self.account]
|
|
|
|
gajim.sleeper_state[name] = gajim.sleeper_state[self.account]
|
2005-07-02 13:06:02 +02:00
|
|
|
gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account]
|
2005-07-03 17:27:41 +02:00
|
|
|
gajim.last_message_time[name] = \
|
|
|
|
gajim.last_message_time[self.account]
|
2005-07-22 23:27:04 +02:00
|
|
|
gajim.status_before_autoaway[name] = \
|
|
|
|
gajim.status_before_autoaway[self.account]
|
2005-08-09 19:21:35 +02:00
|
|
|
gajim.events_for_ui[name] = gajim.events_for_ui[self.account]
|
2005-07-15 19:10:03 +02:00
|
|
|
|
2005-03-21 23:41:30 +01:00
|
|
|
#upgrade account variable in opened windows
|
2005-10-30 10:58:13 +01:00
|
|
|
for kind in ('infos', 'disco', 'chats', 'gc', 'gc_config'):
|
2005-10-20 13:17:17 +02:00
|
|
|
for j in gajim.interface.windows[name][kind]:
|
|
|
|
gajim.interface.windows[name][kind][j].account = name
|
2005-07-15 19:10:03 +02:00
|
|
|
|
2005-03-21 23:41:30 +01:00
|
|
|
#upgrade account in systray
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.systray_enabled:
|
|
|
|
for list in gajim.interface.systray.jids:
|
2005-07-15 19:10:03 +02:00
|
|
|
if list[0] == self.account:
|
|
|
|
list[0] = name
|
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
del gajim.interface.windows[self.account]
|
2005-10-15 22:49:08 +02:00
|
|
|
del gajim.awaiting_events[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
del gajim.nicks[self.account]
|
|
|
|
del gajim.allow_notifications[self.account]
|
|
|
|
del gajim.groups[self.account]
|
|
|
|
del gajim.contacts[self.account]
|
2005-07-25 22:04:24 +02:00
|
|
|
del gajim.gc_contacts[self.account]
|
2005-08-03 11:23:36 +02:00
|
|
|
del gajim.gc_connected[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
del gajim.newly_added[self.account]
|
|
|
|
del gajim.to_be_removed[self.account]
|
|
|
|
del gajim.sleeper_state[self.account]
|
2005-07-02 13:06:02 +02:00
|
|
|
del gajim.encrypted_chats[self.account]
|
2005-07-07 19:40:52 +02:00
|
|
|
del gajim.last_message_time[self.account]
|
2005-07-22 23:27:04 +02:00
|
|
|
del gajim.status_before_autoaway[self.account]
|
2005-08-09 19:21:35 +02:00
|
|
|
del gajim.events_for_ui[self.account]
|
2005-04-14 09:05:10 +02:00
|
|
|
gajim.connections[self.account].name = name
|
|
|
|
gajim.connections[name] = gajim.connections[self.account]
|
|
|
|
del gajim.connections[self.account]
|
|
|
|
gajim.config.del_per('accounts', self.account)
|
|
|
|
gajim.config.add_per('accounts', name)
|
2005-05-14 13:01:09 +02:00
|
|
|
self.account = name
|
2005-04-14 09:05:10 +02:00
|
|
|
|
2005-05-10 11:20:35 +02:00
|
|
|
for opt in config:
|
|
|
|
gajim.config.set_per('accounts', name, opt, config[opt])
|
2005-05-10 16:35:21 +02:00
|
|
|
if config['savepass']:
|
|
|
|
gajim.connections[name].password = config['password']
|
2004-06-06 21:35:10 +02:00
|
|
|
#refresh accounts window
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('accounts'):
|
|
|
|
gajim.interface.windows['accounts'].init_accounts()
|
2004-06-06 21:35:10 +02:00
|
|
|
#refresh roster
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
|
|
|
gajim.interface.save_config()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-06-06 21:35:10 +02:00
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
#if it's a new account
|
2005-04-14 09:05:10 +02:00
|
|
|
if name in gajim.connections:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Account name is in use'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('You already have an account using this name.')).get_response()
|
2004-10-10 20:44:38 +02:00
|
|
|
return
|
2005-05-10 11:20:35 +02:00
|
|
|
con = connection.Connection(name)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.register_handlers(con)
|
2005-05-26 15:35:58 +02:00
|
|
|
#if we need to register a new account
|
2005-05-10 11:20:35 +02:00
|
|
|
if new_account:
|
2005-08-10 13:52:37 +02:00
|
|
|
gajim.events_for_ui[name] = []
|
2005-05-10 11:20:35 +02:00
|
|
|
con.new_account(name, config)
|
2004-10-10 20:44:38 +02:00
|
|
|
return
|
2005-05-10 11:20:35 +02:00
|
|
|
# The account we add already exists on the server
|
|
|
|
gajim.connections[name] = con
|
|
|
|
gajim.config.add_per('accounts', name)
|
|
|
|
for opt in config:
|
|
|
|
gajim.config.set_per('accounts', name, opt, config[opt])
|
|
|
|
if config['savepass']:
|
|
|
|
gajim.connections[name].password = config['password']
|
2004-05-15 18:50:38 +02:00
|
|
|
#update variables
|
2005-10-30 10:58:13 +01:00
|
|
|
gajim.interface.windows[name] = {'infos': {}, 'disco': {}, 'chats': {},
|
|
|
|
'gc': {}, 'gc_config': {}}
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows[name]['xml_console'] = \
|
|
|
|
dialogs.XMLConsoleWindow(name)
|
2005-10-15 22:49:08 +02:00
|
|
|
gajim.awaiting_events[name] = {}
|
2005-04-14 09:42:26 +02:00
|
|
|
gajim.connections[name].connected = 0
|
2005-07-18 23:08:31 +02:00
|
|
|
gajim.groups[name] = {}
|
|
|
|
gajim.contacts[name] = {}
|
2005-07-25 22:04:24 +02:00
|
|
|
gajim.gc_contacts[name] = {}
|
2005-08-03 23:27:26 +02:00
|
|
|
gajim.gc_connected[name] = {}
|
2005-07-18 23:08:31 +02:00
|
|
|
gajim.newly_added[name] = []
|
|
|
|
gajim.to_be_removed[name] = []
|
|
|
|
gajim.nicks[name] = config['name']
|
|
|
|
gajim.allow_notifications[name] = False
|
2005-07-22 01:47:27 +02:00
|
|
|
gajim.sleeper_state[name] = 'off'
|
2005-07-02 13:06:02 +02:00
|
|
|
gajim.encrypted_chats[name] = []
|
2005-07-03 17:27:41 +02:00
|
|
|
gajim.last_message_time[name] = {}
|
2005-07-22 23:27:04 +02:00
|
|
|
gajim.status_before_autoaway[name] = ''
|
2005-08-09 19:21:35 +02:00
|
|
|
gajim.events_for_ui[name] = []
|
2004-05-15 18:50:38 +02:00
|
|
|
#refresh accounts window
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('accounts'):
|
|
|
|
gajim.interface.windows['accounts'].init_accounts()
|
2004-05-15 18:50:38 +02:00
|
|
|
#refresh roster
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
|
|
|
gajim.interface.save_config()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-04 14:10:00 +01:00
|
|
|
def on_change_password_button_clicked(self, widget):
|
2005-07-18 13:03:53 +02:00
|
|
|
try:
|
2005-10-20 13:17:17 +02:00
|
|
|
dialog = dialogs.ChangePasswordDialog(self.account)
|
2005-07-18 13:03:53 +02:00
|
|
|
except RuntimeError:
|
2005-07-18 16:15:33 +02:00
|
|
|
#if we showed ErrorDialog, there will not be dialog instance
|
2005-07-18 13:03:53 +02:00
|
|
|
return
|
|
|
|
|
2005-03-04 14:10:00 +01:00
|
|
|
new_password = dialog.run()
|
|
|
|
if new_password != -1:
|
2005-10-30 17:50:05 +01:00
|
|
|
gajim.connections[self.account].change_password(new_password)
|
2005-03-04 14:10:00 +01:00
|
|
|
if self.xml.get_widget('save_password_checkbutton').get_active():
|
|
|
|
self.xml.get_widget('password_entry').set_text(new_password)
|
|
|
|
|
2005-02-24 23:16:21 +01:00
|
|
|
def account_is_ok(self, acct):
|
2005-09-08 01:55:40 +02:00
|
|
|
'''When the account has been created with success'''
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('new_account_checkbutton').set_active(False)
|
2005-02-24 23:16:21 +01:00
|
|
|
self.modify = True
|
|
|
|
self.account = acct
|
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_edit_details_button_clicked(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
if not gajim.interface.windows.has_key(self.account):
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('No such account available'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('You must create your account before editing your personal information.')).get_response()
|
2005-03-07 22:03:48 +01:00
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8')
|
2005-07-18 23:16:31 +02:00
|
|
|
|
2005-07-18 23:26:42 +02:00
|
|
|
# show error dialog if account is newly created (not in gajim.connections)
|
2005-07-18 23:16:31 +02:00
|
|
|
if not gajim.connections.has_key(self.account) or \
|
2005-07-18 23:26:42 +02:00
|
|
|
gajim.connections[self.account].connected < 2:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('You are not connected to the server'),
|
2005-07-18 23:26:42 +02:00
|
|
|
_('Without a connection, you can not edit your personal information.')
|
|
|
|
).get_response()
|
2005-03-07 22:03:48 +01:00
|
|
|
return
|
2005-10-20 13:17:17 +02:00
|
|
|
if not gajim.interface.windows[self.account]['infos'].has_key('vcard'):
|
|
|
|
gajim.interface.windows[self.account]['infos'][jid] = \
|
|
|
|
dialogs.VcardWindow(jid, self.account, True)
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].request_vcard(jid)
|
2005-06-09 00:05:45 +02:00
|
|
|
|
|
|
|
def on_manage_proxies_button_clicked(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('manage_proxies'):
|
|
|
|
gajim.interface.windows['manage_proxies'].window.present()
|
2005-06-09 00:05:45 +02:00
|
|
|
else:
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows['manage_proxies'] = \
|
|
|
|
ManageProxiesWindow()
|
2005-06-09 00:05:45 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_gpg_choose_button_clicked(self, widget, data = None):
|
2005-07-18 16:16:55 +02:00
|
|
|
if gajim.connections.has_key(self.account):
|
|
|
|
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
|
|
|
|
|
|
|
|
# self.account is None and/or gajim.connections is {}
|
|
|
|
else:
|
|
|
|
from common import GnuPG
|
|
|
|
if GnuPG.USE_GPG:
|
2005-07-20 15:55:50 +02:00
|
|
|
secret_keys = GnuPG.GnuPG().get_secret_keys()
|
2005-07-18 16:16:55 +02:00
|
|
|
else:
|
|
|
|
secret_keys = []
|
2005-04-12 23:09:06 +02:00
|
|
|
if not secret_keys:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Failed to get secret keys'),
|
2005-08-12 14:10:27 +02:00
|
|
|
_('There was a problem retrieving your OpenPGP secret keys.')).get_response()
|
2005-04-12 23:09:06 +02:00
|
|
|
return
|
|
|
|
secret_keys['None'] = 'None'
|
2005-07-23 00:49:03 +02:00
|
|
|
instance = dialogs.ChooseGPGKeyDialog(_('Passphrase'),
|
|
|
|
_('Choose your OpenPGP key'), secret_keys)
|
2005-08-02 18:27:25 +02:00
|
|
|
keyID = instance.run()
|
2005-07-23 00:49:03 +02:00
|
|
|
if keyID is None:
|
2004-10-10 20:44:38 +02:00
|
|
|
return
|
2005-04-22 03:05:31 +02:00
|
|
|
checkbutton = self.xml.get_widget('gpg_save_password_checkbutton')
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_key_label = self.xml.get_widget('gpg_key_label')
|
|
|
|
gpg_name_label = self.xml.get_widget('gpg_name_label')
|
2004-10-10 20:44:38 +02:00
|
|
|
if keyID[0] == 'None':
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_key_label.set_text(_('No key selected'))
|
|
|
|
gpg_name_label.set_text('')
|
2005-04-22 03:05:31 +02:00
|
|
|
checkbutton.set_sensitive(False)
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('gpg_password_entry').set_sensitive(False)
|
2004-10-10 20:44:38 +02:00
|
|
|
else:
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_key_label.set_text(keyID[0])
|
|
|
|
gpg_name_label.set_text(keyID[1])
|
2005-04-22 03:05:31 +02:00
|
|
|
checkbutton.set_sensitive(True)
|
|
|
|
checkbutton.set_active(False)
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('gpg_password_entry').set_text('')
|
2004-11-01 14:41:00 +01:00
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_checkbutton_toggled_and_clear(self, widget, widgets):
|
|
|
|
self.on_checkbutton_toggled(widget, widgets)
|
2004-11-01 14:41:00 +01:00
|
|
|
for w in widgets:
|
|
|
|
if not widget.get_active():
|
|
|
|
w.set_text('')
|
2004-10-10 20:44:38 +02:00
|
|
|
|
2005-06-13 23:16:41 +02:00
|
|
|
def on_use_ssl_checkbutton_toggled(self, widget):
|
|
|
|
isactive = widget.get_active()
|
|
|
|
if isactive:
|
|
|
|
self.xml.get_widget('custom_port_entry').set_text('5223')
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('custom_port_entry').set_text('5222')
|
|
|
|
|
2005-06-26 01:25:17 +02:00
|
|
|
def on_send_keepalive_checkbutton_toggled(self, widget):
|
|
|
|
isactive = widget.get_active()
|
|
|
|
gajim.config.set_per('accounts', self.account,
|
|
|
|
'keep_alives_enabled', isactive)
|
|
|
|
|
2005-06-13 12:57:49 +02:00
|
|
|
def on_custom_host_port_checkbutton_toggled(self, widget):
|
|
|
|
isactive = widget.get_active()
|
|
|
|
self.xml.get_widget('custom_host_port_hbox').set_sensitive(isactive)
|
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_gpg_save_password_checkbutton_toggled(self, widget):
|
2005-06-08 15:45:30 +02:00
|
|
|
self.on_checkbutton_toggled_and_clear(widget, [
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('gpg_password_entry')])
|
|
|
|
|
|
|
|
def on_save_password_checkbutton_toggled(self, widget):
|
|
|
|
if self.xml.get_widget('new_account_checkbutton').get_active():
|
2005-02-24 23:16:21 +01:00
|
|
|
return
|
2005-06-08 15:45:30 +02:00
|
|
|
self.on_checkbutton_toggled_and_clear(widget,
|
2005-02-28 23:09:21 +01:00
|
|
|
[self.xml.get_widget('password_entry')])
|
2005-03-11 01:32:41 +01:00
|
|
|
self.xml.get_widget('password_entry').grab_focus()
|
2005-02-24 23:16:21 +01:00
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_new_account_checkbutton_toggled(self, widget):
|
|
|
|
password_entry = self.xml.get_widget('password_entry')
|
2005-02-16 01:16:00 +01:00
|
|
|
if widget.get_active():
|
2005-02-28 23:09:21 +01:00
|
|
|
password_entry.set_sensitive(True)
|
|
|
|
elif not self.xml.get_widget('save_password_checkbutton').get_active():
|
|
|
|
password_entry.set_sensitive(False)
|
|
|
|
password_entry.set_text('')
|
2005-02-16 01:16:00 +01:00
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- ManageProxiesWindow class -------------#
|
|
|
|
class ManageProxiesWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-06-09 00:05:45 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_proxies_window', APP)
|
|
|
|
self.window = self.xml.get_widget('manage_proxies_window')
|
|
|
|
self.proxies_treeview = self.xml.get_widget('proxies_treeview')
|
|
|
|
self.proxyname_entry = self.xml.get_widget('proxyname_entry')
|
|
|
|
self.init_list()
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def fill_proxies_treeview(self):
|
|
|
|
model = self.proxies_treeview.get_model()
|
|
|
|
model.clear()
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, 'None')
|
|
|
|
for p in gajim.config.get_per('proxies'):
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, p)
|
|
|
|
|
|
|
|
def init_list(self):
|
|
|
|
self.xml.get_widget('remove_proxy_button').set_sensitive(False)
|
|
|
|
self.xml.get_widget('proxytype_combobox').set_sensitive(False)
|
|
|
|
self.xml.get_widget('proxy_table').set_sensitive(False)
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str)
|
2005-06-09 00:05:45 +02:00
|
|
|
self.proxies_treeview.set_model(model)
|
|
|
|
col = gtk.TreeViewColumn('Proxies')
|
|
|
|
self.proxies_treeview.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, True)
|
|
|
|
col.set_attributes(renderer, text = 0)
|
|
|
|
self.fill_proxies_treeview()
|
|
|
|
self.xml.get_widget('proxytype_combobox').set_active(0)
|
|
|
|
|
|
|
|
def on_manage_proxies_window_destroy(self, widget):
|
|
|
|
for account in gajim.connections:
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows[account].has_key('account_modification'):
|
|
|
|
gajim.interface.windows[account]['account_modification'].\
|
2005-06-09 00:05:45 +02:00
|
|
|
update_proxy_list()
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('account_modification'):
|
|
|
|
gajim.interface.windows['account_modification'].update_proxy_list()
|
|
|
|
del gajim.interface.windows['manage_proxies']
|
2005-06-09 00:05:45 +02:00
|
|
|
|
|
|
|
def on_add_proxy_button_clicked(self, widget):
|
|
|
|
model = self.proxies_treeview.get_model()
|
|
|
|
proxies = gajim.config.get_per('proxies')
|
|
|
|
i = 1
|
2005-08-26 02:52:44 +02:00
|
|
|
while ('proxy' + unicode(i)) in proxies:
|
2005-06-09 00:05:45 +02:00
|
|
|
i += 1
|
|
|
|
iter = model.append()
|
2005-08-26 02:52:44 +02:00
|
|
|
model.set(iter, 0, 'proxy' + unicode(i))
|
|
|
|
gajim.config.add_per('proxies', 'proxy' + unicode(i))
|
2005-06-09 00:05:45 +02:00
|
|
|
|
|
|
|
def on_remove_proxy_button_clicked(self, widget):
|
|
|
|
(model, iter) = self.proxies_treeview.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-10-07 15:37:04 +02:00
|
|
|
proxy = model[iter][0].decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
model.remove(iter)
|
|
|
|
gajim.config.del_per('proxies', proxy)
|
|
|
|
self.xml.get_widget('remove_proxy_button').set_sensitive(False)
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_useauth_checkbutton_toggled(self, widget):
|
|
|
|
act = widget.get_active()
|
|
|
|
self.xml.get_widget('proxyuser_entry').set_sensitive(act)
|
|
|
|
self.xml.get_widget('proxypass_entry').set_sensitive(act)
|
|
|
|
|
|
|
|
def on_proxies_treeview_cursor_changed(self, widget):
|
2005-10-07 15:37:04 +02:00
|
|
|
#FIXME: check if off proxy settings are correct (see http://trac.gajim.org/changeset/1921#file2 line 1221
|
2005-06-09 00:05:45 +02:00
|
|
|
(model, iter) = widget.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-10-07 15:37:04 +02:00
|
|
|
proxy = model[iter][0]
|
2005-06-09 00:05:45 +02:00
|
|
|
self.xml.get_widget('proxyname_entry').set_text(proxy)
|
|
|
|
proxyhost_entry = self.xml.get_widget('proxyhost_entry')
|
|
|
|
proxyport_entry = self.xml.get_widget('proxyport_entry')
|
|
|
|
proxyuser_entry = self.xml.get_widget('proxyuser_entry')
|
|
|
|
proxypass_entry = self.xml.get_widget('proxypass_entry')
|
|
|
|
useauth_checkbutton = self.xml.get_widget('useauth_checkbutton')
|
|
|
|
proxyhost_entry.set_text('')
|
|
|
|
proxyport_entry.set_text('')
|
|
|
|
proxyuser_entry.set_text('')
|
|
|
|
proxypass_entry.set_text('')
|
|
|
|
useauth_checkbutton.set_active(False)
|
|
|
|
self.on_useauth_checkbutton_toggled(useauth_checkbutton)
|
2005-10-07 15:37:04 +02:00
|
|
|
if proxy == 'None': # special proxy None
|
2005-06-09 00:05:45 +02:00
|
|
|
self.proxyname_entry.set_editable(False)
|
2005-10-07 15:37:04 +02:00
|
|
|
self.xml.get_widget('remove_proxy_button').set_sensitive(False)
|
2005-06-09 00:05:45 +02:00
|
|
|
self.xml.get_widget('proxytype_combobox').set_sensitive(False)
|
|
|
|
self.xml.get_widget('proxy_table').set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.proxyname_entry.set_editable(True)
|
2005-10-07 15:37:04 +02:00
|
|
|
self.xml.get_widget('remove_proxy_button').set_sensitive(True)
|
2005-06-09 00:05:45 +02:00
|
|
|
self.xml.get_widget('proxytype_combobox').set_sensitive(True)
|
|
|
|
self.xml.get_widget('proxy_table').set_sensitive(True)
|
|
|
|
proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy,
|
|
|
|
'host'))
|
2005-08-26 02:52:44 +02:00
|
|
|
proxyport_entry.set_text(unicode(gajim.config.get_per('proxies',
|
|
|
|
proxy, 'port')))
|
2005-06-09 00:05:45 +02:00
|
|
|
proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy,
|
|
|
|
'user'))
|
|
|
|
proxypass_entry.set_text(gajim.config.get_per('proxies', proxy,
|
|
|
|
'pass'))
|
2005-10-07 15:37:04 +02:00
|
|
|
#FIXME: if we have several proxy types, set the combobox
|
2005-06-09 00:05:45 +02:00
|
|
|
if gajim.config.get_per('proxies', proxy, 'user'):
|
|
|
|
useauth_checkbutton.set_active(True)
|
|
|
|
|
|
|
|
def on_proxies_treeview_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Delete:
|
|
|
|
self.on_remove_proxy_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_proxyname_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.proxies_treeview.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
old_name = model.get_value(iter, 0).decode('utf-8')
|
|
|
|
new_name = widget.get_text().decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
if new_name == '':
|
|
|
|
return
|
|
|
|
if new_name == old_name:
|
|
|
|
return
|
|
|
|
config = gajim.config.get_per('proxies', old_name)
|
|
|
|
gajim.config.del_per('proxies', old_name)
|
|
|
|
gajim.config.add_per('proxies', new_name)
|
|
|
|
for option in config:
|
|
|
|
gajim.config.set_per('proxies', new_name, option,
|
|
|
|
config[option][common.config.OPT_VAL])
|
|
|
|
model.set_value(iter, 0, new_name)
|
|
|
|
|
|
|
|
def on_proxytype_combobox_changed(self, widget):
|
2005-10-07 15:37:04 +02:00
|
|
|
#FIXME: if we have several proxy types take them into account
|
2005-06-09 00:05:45 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
def on_proxyhost_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
value = widget.get_text().decode('utf-8')
|
|
|
|
proxy = self.proxyname_entry.get_text().decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
gajim.config.set_per('proxies', proxy, 'host', value)
|
|
|
|
|
|
|
|
def on_proxyport_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
value = widget.get_text().decode('utf-8')
|
|
|
|
proxy = self.proxyname_entry.get_text().decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
gajim.config.set_per('proxies', proxy, 'port', value)
|
|
|
|
|
|
|
|
def on_proxyuser_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
value = widget.get_text().decode('utf-8')
|
|
|
|
proxy = self.proxyname_entry.get_text().decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
gajim.config.set_per('proxies', proxy, 'user', value)
|
|
|
|
|
|
|
|
def on_proxypass_entry_changed(self, widget):
|
2005-08-26 02:52:44 +02:00
|
|
|
value = widget.get_text().decode('utf-8')
|
|
|
|
proxy = self.proxyname_entry.get_text().decode('utf-8')
|
2005-06-09 00:05:45 +02:00
|
|
|
gajim.config.set_per('proxies', proxy, 'pass', value)
|
|
|
|
|
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- AccountsWindow class -------------#
|
|
|
|
class AccountsWindow:
|
2005-05-26 02:07:49 +02:00
|
|
|
'''Class for accounts window: list of accounts'''
|
2005-04-02 22:35:33 +02:00
|
|
|
def on_accounts_window_destroy(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
del gajim.interface.windows['accounts']
|
2005-03-29 19:49:10 +02:00
|
|
|
|
2005-03-01 19:00:34 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-04-02 22:35:33 +02:00
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-05-26 02:07:49 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'accounts_window', APP)
|
|
|
|
self.window = self.xml.get_widget('accounts_window')
|
|
|
|
self.accounts_treeview = self.xml.get_widget('accounts_treeview')
|
|
|
|
self.modify_button = self.xml.get_widget('modify_button')
|
|
|
|
self.remove_button = self.xml.get_widget('remove_button')
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str, str,
|
|
|
|
bool)
|
2005-05-26 02:07:49 +02:00
|
|
|
self.accounts_treeview.set_model(model)
|
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
self.accounts_treeview.insert_column_with_attributes(-1,
|
|
|
|
_('Name'), renderer, text = 0)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
self.accounts_treeview.insert_column_with_attributes(-1,
|
|
|
|
_('Server'), renderer, text = 1)
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.init_accounts()
|
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def on_accounts_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape:
|
|
|
|
self.window.destroy()
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def init_accounts(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''initialize listStore with existing accounts'''
|
2005-03-11 02:10:30 +01:00
|
|
|
self.modify_button.set_sensitive(False)
|
2005-04-20 00:29:38 +02:00
|
|
|
self.remove_button.set_sensitive(False)
|
2005-02-28 18:45:06 +01:00
|
|
|
model = self.accounts_treeview.get_model()
|
2004-05-15 18:50:38 +02:00
|
|
|
model.clear()
|
2005-04-14 09:05:10 +02:00
|
|
|
for account in gajim.connections:
|
2004-05-15 18:50:38 +02:00
|
|
|
iter = model.append()
|
2005-09-11 02:32:58 +02:00
|
|
|
model.set(iter, 0, account, 1, gajim.get_hostname_from_account(account))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 19:27:21 +01:00
|
|
|
def on_accounts_treeview_cursor_changed(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Activate delete and modify buttons when a row is selected'''
|
2005-03-11 02:10:30 +01:00
|
|
|
self.modify_button.set_sensitive(True)
|
2005-04-20 00:29:38 +02:00
|
|
|
self.remove_button.set_sensitive(True)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 19:00:34 +01:00
|
|
|
def on_new_button_clicked(self, widget):
|
2005-05-26 02:07:49 +02:00
|
|
|
'''When new button is clicked: open an account information window'''
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('account_modification'):
|
|
|
|
gajim.interface.windows['account_modification'].window.present()
|
2005-04-17 22:18:50 +02:00
|
|
|
else:
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows['account_modification'] = \
|
|
|
|
AccountModificationWindow('')
|
2005-04-17 22:18:50 +02:00
|
|
|
|
2005-04-20 00:29:38 +02:00
|
|
|
def on_remove_button_clicked(self, widget):
|
2005-05-26 02:07:49 +02:00
|
|
|
'''When delete button is clicked:
|
2005-04-18 14:17:43 +02:00
|
|
|
Remove an account from the listStore and from the config file'''
|
2005-02-28 18:45:06 +01:00
|
|
|
sel = self.accounts_treeview.get_selection()
|
2004-05-15 18:50:38 +02:00
|
|
|
(model, iter) = sel.get_selected()
|
2005-04-22 03:05:31 +02:00
|
|
|
if not iter:
|
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
account = model.get_value(iter, 0).decode('utf-8')
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows[account].has_key('remove_account'):
|
|
|
|
gajim.interface.windows[account]['remove_account'].window.present()
|
2005-04-20 01:43:58 +02:00
|
|
|
else:
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows[account]['remove_account'] = \
|
|
|
|
RemoveAccountWindow(account)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 19:00:34 +01:00
|
|
|
def on_modify_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When modify button is clicked:
|
|
|
|
open/show the account modification window for this account'''
|
2005-04-17 22:18:50 +02:00
|
|
|
sel = self.accounts_treeview.get_selection()
|
|
|
|
(model, iter) = sel.get_selected()
|
2005-04-22 03:05:31 +02:00
|
|
|
if not iter:
|
|
|
|
return
|
2005-10-04 09:12:30 +02:00
|
|
|
account = model[iter][0].decode('utf-8')
|
|
|
|
self.show_modification_window(account)
|
|
|
|
|
|
|
|
def on_accounts_treeview_row_activated(self, widget, path, column):
|
|
|
|
model = widget.get_model()
|
|
|
|
iter = model.get_iter(path)
|
|
|
|
account = model[iter][0].decode('utf-8')
|
|
|
|
self.show_modification_window(account)
|
|
|
|
|
|
|
|
def show_modification_window(self, account):
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows[account].has_key('account_modification'):
|
|
|
|
gajim.interface.windows[account]['account_modification'].window.present()
|
2005-03-11 02:10:30 +01:00
|
|
|
else:
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows[account]['account_modification'] = \
|
|
|
|
AccountModificationWindow(account)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-10-05 12:13:31 +02:00
|
|
|
class DataFormWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, account, config):
|
2005-10-05 12:13:31 +02:00
|
|
|
self.account = account
|
|
|
|
self.config = config
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'data_form_window', APP)
|
|
|
|
self.window = self.xml.get_widget('data_form_window')
|
|
|
|
self.config_table = self.xml.get_widget('config_table')
|
|
|
|
self.fill_table()
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def on_data_form_window_destroy(self, widget):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_checkbutton_toggled(self, widget, index):
|
|
|
|
self.config[index]['values'][0] = widget.get_active()
|
|
|
|
|
|
|
|
def on_combobox_changed(self, widget, index):
|
|
|
|
self.config[index]['values'][0] = self.config[index]['options'][ \
|
|
|
|
widget.get_active()]['values'][0]
|
|
|
|
|
|
|
|
def on_entry_changed(self, widget, index):
|
|
|
|
self.config[index]['values'][0] = widget.get_text().decode('utf-8')
|
|
|
|
|
|
|
|
def on_textbuffer_changed(self, widget, index):
|
|
|
|
begin, end = widget.get_bounds()
|
|
|
|
self.config[index]['values'][0] = widget.get_text(begin, end)
|
|
|
|
|
|
|
|
def fill_table(self):
|
|
|
|
if self.config.has_key('title'):
|
|
|
|
self.window.set_title(self.config['title'])
|
|
|
|
if self.config.has_key('instructions'):
|
|
|
|
self.xml.get_widget('instructions_label').set_text(
|
|
|
|
self.config['instructions'])
|
|
|
|
i = 0
|
|
|
|
while self.config.has_key(i):
|
|
|
|
if not self.config[i].has_key('type'):
|
|
|
|
i += 1
|
|
|
|
continue
|
|
|
|
ctype = self.config[i]['type']
|
|
|
|
if ctype == 'hidden':
|
|
|
|
i += 1
|
|
|
|
continue
|
|
|
|
nbrows = self.config_table.get_property('n-rows')
|
|
|
|
self.config_table.resize(nbrows + 1, 2)
|
|
|
|
if self.config[i].has_key('label'):
|
|
|
|
label = gtk.Label(self.config[i]['label'])
|
|
|
|
label.set_alignment(0.0, 0.5)
|
|
|
|
self.config_table.attach(label, 0, 1, nbrows, nbrows + 1,
|
|
|
|
gtk.FILL | gtk.SHRINK)
|
|
|
|
desc = None
|
|
|
|
if self.config[i].has_key('desc'):
|
|
|
|
desc = self.config[i]['desc']
|
|
|
|
max = 1
|
|
|
|
if ctype == 'boolean':
|
|
|
|
widget = gtk.CheckButton(desc, False)
|
|
|
|
widget.set_active(self.config[i]['values'][0])
|
|
|
|
widget.connect('toggled', self.on_checkbutton_toggled, i)
|
|
|
|
max = 2
|
|
|
|
elif ctype == 'fixed':
|
|
|
|
widget = gtk.Label('\n'.join(self.config[i]['values']))
|
|
|
|
widget.set_alignment(0.0, 0.5)
|
|
|
|
max = 4
|
|
|
|
elif ctype == 'jid-multi':
|
|
|
|
#TODO
|
|
|
|
widget = gtk.Label('')
|
|
|
|
elif ctype == 'jid-single':
|
|
|
|
#TODO
|
|
|
|
widget = gtk.Label('')
|
|
|
|
elif ctype == 'list-multi':
|
|
|
|
#TODO
|
|
|
|
widget = gtk.Label('')
|
|
|
|
elif ctype == 'list-single':
|
|
|
|
widget = gtk.combo_box_new_text()
|
|
|
|
widget.connect('changed', self.on_combobox_changed, i)
|
|
|
|
index = 0
|
|
|
|
j = 0
|
|
|
|
while self.config[i]['options'].has_key(j):
|
|
|
|
if self.config[i]['options'][j]['values'][0] == \
|
|
|
|
self.config[i]['values'][0]:
|
|
|
|
index = j
|
|
|
|
widget.append_text(self.config[i]['options'][j]['label'])
|
|
|
|
j += 1
|
|
|
|
widget.set_active(index)
|
|
|
|
max = 3
|
|
|
|
elif ctype == 'text-multi':
|
|
|
|
widget = gtk.TextView()
|
|
|
|
widget.get_buffer().connect('changed', self.on_textbuffer_changed, \
|
|
|
|
i)
|
|
|
|
widget.get_buffer().set_text('\n'.join(self.config[i]['values']))
|
|
|
|
max = 4
|
|
|
|
elif ctype == 'text-private':
|
|
|
|
widget = gtk.Entry()
|
|
|
|
widget.connect('changed', self.on_entry_changed, i)
|
|
|
|
if not self.config[i].has_key('values'):
|
|
|
|
self.config[i]['values'] = ['']
|
|
|
|
widget.set_text(self.config[i]['values'][0])
|
|
|
|
widget.set_visibility(False)
|
|
|
|
max = 3
|
|
|
|
elif ctype == 'text-single':
|
|
|
|
widget = gtk.Entry()
|
|
|
|
widget.connect('changed', self.on_entry_changed, i)
|
|
|
|
if not self.config[i].has_key('values'):
|
|
|
|
self.config[i]['values'] = ['']
|
|
|
|
max = 3
|
|
|
|
i += 1
|
|
|
|
if max < 4:
|
|
|
|
self.config_table.attach(widget, 1, max,
|
|
|
|
nbrows, nbrows + 1,
|
|
|
|
gtk.FILL | gtk.SHRINK)
|
|
|
|
widget = gtk.Label()
|
|
|
|
self.config_table.attach(widget, max, 4,
|
|
|
|
nbrows, nbrows + 1)
|
|
|
|
else:
|
|
|
|
self.config_table.attach(widget, 1, max,
|
|
|
|
nbrows, nbrows + 1)
|
|
|
|
self.config_table.show_all()
|
|
|
|
|
|
|
|
class ServiceRegistrationWindow(DataFormWindow):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for Service registration window:
|
|
|
|
Window that appears when we want to subscribe to a service'''
|
2005-03-02 14:11:21 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-10-05 12:13:31 +02:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def draw_table(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Draw the table in the window'''
|
2004-05-15 18:50:38 +02:00
|
|
|
nbrow = 0
|
|
|
|
table = self.xml.get_widget('table')
|
|
|
|
for name in self.infos.keys():
|
2005-10-27 15:15:03 +02:00
|
|
|
if name in ('key', 'instructions', 'x', 'registered'):
|
2005-04-20 20:04:26 +02:00
|
|
|
continue
|
2005-06-09 00:08:53 +02:00
|
|
|
if not name:
|
|
|
|
continue
|
2005-04-20 20:04:26 +02:00
|
|
|
|
|
|
|
nbrow = nbrow + 1
|
|
|
|
table.resize(rows = nbrow, columns = 2)
|
|
|
|
label = gtk.Label(name.capitalize() + ':')
|
|
|
|
table.attach(label, 0, 1, nbrow - 1, nbrow, 0, 0, 0, 0)
|
|
|
|
entry = gtk.Entry()
|
2005-05-22 03:45:06 +02:00
|
|
|
entry.set_activates_default(True)
|
2005-06-12 23:22:54 +02:00
|
|
|
if self.infos[name]:
|
|
|
|
entry.set_text(self.infos[name])
|
2005-05-22 13:54:09 +02:00
|
|
|
if name == 'password':
|
|
|
|
entry.set_visibility(False)
|
2005-04-20 20:04:26 +02:00
|
|
|
table.attach(entry, 1, 2, nbrow - 1, nbrow, 0, 0, 0, 0)
|
|
|
|
self.entries[name] = entry
|
|
|
|
if nbrow == 1:
|
|
|
|
entry.grab_focus()
|
2004-05-15 18:50:38 +02:00
|
|
|
table.show_all()
|
2005-10-05 12:13:31 +02:00
|
|
|
|
|
|
|
def add_transport_to_roster(self):
|
|
|
|
user1 = Contact(jid = self.service, name = self.service,
|
|
|
|
groups = [_('Transports')], show = 'offline', status = 'offline',
|
|
|
|
sub = 'from')
|
|
|
|
gajim.contacts[self.account][self.service] = [user1]
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.add_contact_to_roster(self.service, self.account)
|
2005-10-05 12:13:31 +02:00
|
|
|
|
2005-03-02 14:11:21 +01:00
|
|
|
def on_ok_button_clicked(self, widget):
|
2005-05-20 17:05:22 +02:00
|
|
|
'''When Ok button is clicked:
|
2005-04-18 14:17:43 +02:00
|
|
|
send registration info to the core'''
|
2004-05-15 18:50:38 +02:00
|
|
|
for name in self.entries.keys():
|
2005-08-26 02:52:44 +02:00
|
|
|
self.infos[name] = self.entries[name].get_text().decode('utf-8')
|
2005-05-26 00:15:28 +02:00
|
|
|
if self.infos.has_key('instructions'):
|
|
|
|
del self.infos['instructions']
|
|
|
|
if self.infos.has_key('registered'):
|
|
|
|
del self.infos['registered']
|
|
|
|
else:
|
2005-10-05 12:13:31 +02:00
|
|
|
self.add_transport_to_roster()
|
2005-04-26 20:45:54 +02:00
|
|
|
gajim.connections[self.account].register_agent(self.service, self.infos)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-10-05 12:13:31 +02:00
|
|
|
|
|
|
|
def on_apply_button_clicked(self, widget):
|
|
|
|
# We press apply button of the FormDataWindow
|
|
|
|
if self.infos.has_key('registered'):
|
|
|
|
del self.infos['registered']
|
|
|
|
else:
|
|
|
|
self.add_transport_to_roster()
|
|
|
|
gajim.connections[self.account].register_agent(self.service, self.infos,
|
|
|
|
True) # True is for is_form
|
|
|
|
self.window.destroy()
|
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, service, infos, account, is_form):
|
2005-03-28 03:05:28 +02:00
|
|
|
self.service = service
|
2004-05-15 18:50:38 +02:00
|
|
|
self.infos = infos
|
|
|
|
self.account = account
|
2005-10-05 12:13:31 +02:00
|
|
|
if is_form:
|
2005-10-20 13:17:17 +02:00
|
|
|
DataFormWindow.__init__(self, account, infos)
|
2005-05-26 00:27:40 +02:00
|
|
|
else:
|
2005-10-05 12:13:31 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'service_registration_window', APP)
|
|
|
|
self.window = self.xml.get_widget('service_registration_window')
|
|
|
|
if infos.has_key('registered'):
|
|
|
|
self.window.set_title(_('Edit %s' % service))
|
|
|
|
else:
|
|
|
|
self.window.set_title(_('Register to %s' % service))
|
|
|
|
self.xml.get_widget('label').set_text(infos['instructions'])
|
|
|
|
self.entries = {}
|
|
|
|
self.draw_table()
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- ManageEmoticonsWindow class -------------#
|
|
|
|
class ManageEmoticonsWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-06-11 18:15:01 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_emoticons_window', APP)
|
|
|
|
self.window = self.xml.get_widget('manage_emoticons_window')
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
#emoticons
|
|
|
|
self.emot_tree = self.xml.get_widget('emoticons_treeview')
|
2005-06-18 15:48:43 +02:00
|
|
|
model = gtk.ListStore(str, str, gtk.Image)
|
2005-06-18 17:18:15 +02:00
|
|
|
model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
2005-04-06 20:51:54 +02:00
|
|
|
self.emot_tree.set_model(model)
|
2005-04-06 21:46:39 +02:00
|
|
|
col = gtk.TreeViewColumn(_('Text'))
|
2005-04-06 20:51:54 +02:00
|
|
|
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)
|
2005-04-22 01:20:18 +02:00
|
|
|
col.set_attributes(renderer, text = 0)
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
col = gtk.TreeViewColumn(_('Image'))
|
|
|
|
self.emot_tree.append_column(col)
|
2005-04-18 16:05:30 +02:00
|
|
|
renderer = cell_renderer_image.CellRendererImage()
|
2005-04-06 20:51:54 +02:00
|
|
|
col.pack_start(renderer, expand = False)
|
|
|
|
col.add_attribute(renderer, 'image', 2)
|
|
|
|
|
|
|
|
self.fill_emot_treeview()
|
2005-05-20 17:05:22 +02:00
|
|
|
self.emot_tree.get_model().connect('row-changed',
|
2005-04-06 20:51:54 +02:00
|
|
|
self.on_emoticons_treemodel_row_changed)
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
|
|
|
def on_add_remove_emoticons_window_delete_event(self, widget, event):
|
|
|
|
self.window.hide()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.init_regexp() # update regexp [emoticons included]
|
2005-04-06 20:51:54 +02:00
|
|
|
return True # do NOT destroy the window
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.hide()
|
|
|
|
|
|
|
|
def on_emoticons_treemodel_row_changed(self, model, path, iter):
|
2005-04-16 16:50:26 +02:00
|
|
|
emots = gajim.config.get_per('emoticons')
|
2005-08-26 02:52:44 +02:00
|
|
|
emot = model.get_value(iter, 0).decode('utf-8').upper()
|
2005-04-16 16:50:26 +02:00
|
|
|
if not emot in emots:
|
|
|
|
gajim.config.add_per('emoticons', emot)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.init_regexp() # update regexp [emoticons included]
|
2005-09-05 16:02:36 +02:00
|
|
|
image = model[iter][1]
|
|
|
|
if image:
|
|
|
|
image = image.decode('utf-8')
|
|
|
|
gajim.config.set_per('emoticons', emot, 'path', image)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
def image_is_ok(self, image):
|
|
|
|
if not os.path.exists(image):
|
2005-06-18 16:28:35 +02:00
|
|
|
return False
|
2005-04-06 20:51:54 +02:00
|
|
|
img = gtk.Image()
|
|
|
|
try:
|
|
|
|
img.set_from_file(image)
|
|
|
|
except:
|
2005-06-18 16:28:35 +02:00
|
|
|
return False
|
2005-06-18 17:57:06 +02:00
|
|
|
t = img.get_storage_type()
|
|
|
|
if t == gtk.IMAGE_PIXBUF:
|
|
|
|
pix = img.get_pixbuf()
|
|
|
|
elif t == gtk.IMAGE_ANIMATION:
|
|
|
|
pix = img.get_animation().get_static_image()
|
|
|
|
else:
|
2005-06-18 16:28:35 +02:00
|
|
|
return False
|
2005-04-22 03:05:31 +02:00
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
if pix.get_width() > 24 or pix.get_height() > 24:
|
2005-06-18 16:28:35 +02:00
|
|
|
dialogs.ErrorDialog(_('Image is too big'), _('Image for emoticon has to be less than or equal to 24 pixels in width and 24 in height.')).get_response()
|
|
|
|
return False
|
|
|
|
return True
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
def fill_emot_treeview(self):
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
model.clear()
|
2005-04-16 16:50:26 +02:00
|
|
|
emots = gajim.config.get_per('emoticons')
|
|
|
|
for emot in emots:
|
|
|
|
file = gajim.config.get_per('emoticons', emot, 'path')
|
|
|
|
iter = model.append((emot, file, None))
|
2005-04-06 20:51:54 +02:00
|
|
|
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)
|
|
|
|
|
|
|
|
def on_emot_cell_edited(self, cell, row, new_text):
|
2005-06-21 12:03:45 +02:00
|
|
|
emots = gajim.config.get_per('emoticons')
|
2005-04-06 20:51:54 +02:00
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
2005-08-26 02:52:44 +02:00
|
|
|
old_text = model.get_value(iter, 0).decode('utf-8')
|
2005-06-21 12:03:45 +02:00
|
|
|
if old_text in emots:
|
|
|
|
gajim.config.del_per('emoticons', old_text)
|
2005-09-05 23:48:39 +02:00
|
|
|
emots = gajim.config.get_per('emoticons')
|
2005-08-26 02:52:44 +02:00
|
|
|
emot = new_text.decode('utf-8').upper()
|
2005-06-21 12:03:45 +02:00
|
|
|
if emot in emots:
|
|
|
|
model.remove(iter)
|
|
|
|
else:
|
|
|
|
gajim.config.add_per('emoticons', emot)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.init_regexp() # update regexp (emoticons included)
|
2005-06-21 12:03:45 +02:00
|
|
|
gajim.config.set_per('emoticons', emot, 'path',
|
2005-08-26 02:52:44 +02:00
|
|
|
model[iter][1].decode('utf-8'))
|
2005-09-05 15:59:41 +02:00
|
|
|
model[iter][0] = emot
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-06-10 21:03:32 +02:00
|
|
|
def update_preview(self, widget):
|
|
|
|
path_to_file = widget.get_preview_filename()
|
2005-09-05 15:59:41 +02:00
|
|
|
if path_to_file is None or os.path.isdir(path_to_file):
|
|
|
|
# nothing to preview or directory
|
|
|
|
# make sure you clean image do show nothing
|
|
|
|
widget.get_preview_widget().set_from_file(None)
|
2005-09-05 15:35:45 +02:00
|
|
|
return
|
|
|
|
try:
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path_to_file, 32, 32)
|
|
|
|
except (gobject.GError, TypeError):
|
|
|
|
return
|
|
|
|
widget.get_preview_widget().set_from_pixbuf(pixbuf)
|
2005-06-10 21:03:32 +02:00
|
|
|
|
2005-06-21 10:58:45 +02:00
|
|
|
def on_set_image_button_clicked(self, widget, data=None):
|
2005-04-06 20:51:54 +02:00
|
|
|
(model, iter) = self.emot_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
file = model[iter][1].decode('utf-8')
|
2005-07-18 19:18:25 +02:00
|
|
|
dialog = gtk.FileChooserDialog(_('Choose Image'), None,
|
2005-04-22 03:05:31 +02:00
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-08-23 15:22:14 +02:00
|
|
|
last_emoticons_dir = gajim.config.get('last_emoticons_dir')
|
|
|
|
if last_emoticons_dir and os.path.isdir('last_emoticons_dir'):
|
|
|
|
dialog.set_current_folder(last_emoticons_dir)
|
|
|
|
else:
|
|
|
|
home_dir = os.path.expanduser('~')
|
|
|
|
dialog.set_current_folder(home_dir)
|
2005-04-06 20:51:54 +02:00
|
|
|
filter = gtk.FileFilter()
|
2005-06-10 21:03:32 +02:00
|
|
|
filter.set_name(_('All files'))
|
2005-04-18 14:17:43 +02:00
|
|
|
filter.add_pattern('*')
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
2005-06-10 21:03:32 +02:00
|
|
|
filter.set_name(_('Images'))
|
2005-04-18 14:17:43 +02:00
|
|
|
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')
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
2005-06-10 21:03:32 +02:00
|
|
|
dialog.set_use_preview_label(False)
|
|
|
|
dialog.set_preview_widget(gtk.Image())
|
|
|
|
dialog.connect('selection-changed', self.update_preview)
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
file = os.path.join(os.getcwd(), file)
|
|
|
|
dialog.set_filename(file)
|
|
|
|
file = ''
|
2005-04-22 17:56:33 +02:00
|
|
|
ok = False
|
|
|
|
while not ok:
|
2005-04-06 20:51:54 +02:00
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file = dialog.get_filename()
|
2005-10-21 15:21:31 +02:00
|
|
|
try:
|
|
|
|
file = file.decode(sys.getfilesystemencoding())
|
|
|
|
except:
|
|
|
|
pass
|
2005-04-06 20:51:54 +02:00
|
|
|
if self.image_is_ok(file):
|
2005-04-22 17:56:33 +02:00
|
|
|
ok = True
|
2005-04-06 20:51:54 +02:00
|
|
|
else:
|
2005-06-18 19:33:53 +02:00
|
|
|
file = None
|
2005-04-22 17:56:33 +02:00
|
|
|
ok = True
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
2005-08-23 15:22:14 +02:00
|
|
|
directory = os.path.dirname(file)
|
|
|
|
gajim.config.set('last_emoticons_dir', directory)
|
2005-04-06 20:51:54 +02:00
|
|
|
model.set_value(iter, 1, file)
|
|
|
|
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-06-21 12:03:45 +02:00
|
|
|
|
2005-06-21 10:58:45 +02:00
|
|
|
def on_button_new_emoticon_clicked(self, widget, data=None):
|
2005-04-06 20:51:54 +02:00
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.append()
|
2005-06-21 12:03:45 +02:00
|
|
|
model.set(iter, 0, 'EMOTICON', 1, '')
|
2005-04-06 20:51:54 +02:00
|
|
|
col = self.emot_tree.get_column(0)
|
|
|
|
self.emot_tree.set_cursor(model.get_path(iter), col, True)
|
|
|
|
|
2005-06-21 10:58:45 +02:00
|
|
|
def on_button_remove_emoticon_clicked(self, widget, data=None):
|
2005-04-06 20:51:54 +02:00
|
|
|
(model, iter) = self.emot_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
gajim.config.del_per('emoticons', model.get_value(iter, 0).decode('utf-8'))
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.init_regexp() # update regexp [emoticons included]
|
|
|
|
gajim.interface.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
model.remove(iter)
|
|
|
|
|
|
|
|
def on_emoticons_treeview_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Delete:
|
|
|
|
self.on_button_remove_emoticon_clicked(widget)
|
|
|
|
|
2005-10-05 11:18:32 +02:00
|
|
|
class GroupchatConfigWindow(DataFormWindow):
|
|
|
|
'''GroupchatConfigWindow class'''
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, account, room_jid, config):
|
|
|
|
DataFormWindow.__init__(self, account, config)
|
2005-10-05 11:18:32 +02:00
|
|
|
self.room_jid = room_jid
|
|
|
|
|
|
|
|
def on_data_form_window_destroy(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
del gajim.interface.windows[self.account]['gc_config'][self.room_jid]
|
2005-10-05 11:18:32 +02:00
|
|
|
|
|
|
|
def on_apply_button_clicked(self, widget):
|
|
|
|
gajim.connections[self.account].send_gc_config(self.room_jid, self.config)
|
|
|
|
self.window.destroy()
|
|
|
|
|
2005-06-10 23:14:16 +02:00
|
|
|
#---------- RemoveAccountWindow class -------------#
|
|
|
|
class RemoveAccountWindow:
|
2005-04-20 01:43:58 +02:00
|
|
|
'''ask for removing from gajim only or from gajim and server too
|
|
|
|
and do removing of the account given'''
|
|
|
|
|
|
|
|
def on_remove_account_window_destroy(self, widget):
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key(self.account):
|
|
|
|
del gajim.interface.windows[self.account]['remove_account']
|
2005-04-20 01:43:58 +02:00
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, account):
|
2005-04-20 01:43:58 +02:00
|
|
|
self.account = account
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'remove_account_window', APP)
|
|
|
|
self.window = xml.get_widget('remove_account_window')
|
2005-05-20 17:05:22 +02:00
|
|
|
self.remove_and_unregister_radiobutton = xml.get_widget(
|
2005-04-20 01:43:58 +02:00
|
|
|
'remove_and_unregister_radiobutton')
|
|
|
|
self.window.set_title(_('Removing %s account') % self.account)
|
|
|
|
xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def on_remove_button_clicked(self, widget):
|
2005-05-20 17:05:22 +02:00
|
|
|
if gajim.connections[self.account].connected:
|
2005-06-10 23:14:16 +02:00
|
|
|
dialog = dialogs.ConfirmationDialog(
|
2005-06-07 03:10:24 +02:00
|
|
|
_('Account "%s" is connected to the server' % self.account),
|
|
|
|
_('If you remove it, the connection will be lost.'))
|
|
|
|
if dialog.get_response() != gtk.RESPONSE_OK:
|
2005-05-20 17:05:22 +02:00
|
|
|
return
|
2005-04-20 01:43:58 +02:00
|
|
|
gajim.connections[self.account].change_status('offline', 'offline')
|
|
|
|
|
|
|
|
if self.remove_and_unregister_radiobutton.get_active():
|
2005-05-07 16:45:50 +02:00
|
|
|
gajim.connections[self.account].unregister_account()
|
2005-04-20 01:43:58 +02:00
|
|
|
del gajim.connections[self.account]
|
|
|
|
gajim.config.del_per('accounts', self.account)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.save_config()
|
|
|
|
del gajim.interface.windows[self.account]
|
2005-10-15 22:49:08 +02:00
|
|
|
del gajim.awaiting_events[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
del gajim.nicks[self.account]
|
|
|
|
del gajim.allow_notifications[self.account]
|
|
|
|
del gajim.groups[self.account]
|
|
|
|
del gajim.contacts[self.account]
|
2005-07-25 22:04:24 +02:00
|
|
|
del gajim.gc_contacts[self.account]
|
2005-08-03 11:23:36 +02:00
|
|
|
del gajim.gc_connected[self.account]
|
2005-07-18 23:08:31 +02:00
|
|
|
del gajim.to_be_removed[self.account]
|
|
|
|
del gajim.newly_added[self.account]
|
|
|
|
del gajim.sleeper_state[self.account]
|
|
|
|
del gajim.encrypted_chats[self.account]
|
|
|
|
del gajim.last_message_time[self.account]
|
2005-07-22 23:27:04 +02:00
|
|
|
del gajim.status_before_autoaway[self.account]
|
2005-08-09 19:21:35 +02:00
|
|
|
del gajim.events_for_ui[self.account]
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
|
|
|
if gajim.interface.windows.has_key('accounts'):
|
|
|
|
gajim.interface.windows['accounts'].init_accounts()
|
2005-04-20 01:43:58 +02:00
|
|
|
self.window.destroy()
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
#---------- ManageBookmarksWindow class -------------#
|
|
|
|
class ManageBookmarksWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-06-09 22:35:44 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_bookmarks_window', APP)
|
|
|
|
self.window = self.xml.get_widget('manage_bookmarks_window')
|
|
|
|
|
|
|
|
#Account-JID, RoomName, Room-JID, Autojoin, Passowrd, Nick
|
2005-06-11 16:14:50 +02:00
|
|
|
self.treestore = gtk.TreeStore(str, str, str, bool, str, str)
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
#Store bookmarks in treeview.
|
|
|
|
for account in gajim.connections:
|
2005-06-11 16:14:50 +02:00
|
|
|
if gajim.connections[account].connected <= 1:
|
|
|
|
continue
|
2005-06-09 22:35:44 +02:00
|
|
|
iter = self.treestore.append(None, [None, account,None,
|
|
|
|
None, None, None])
|
|
|
|
|
|
|
|
for bookmark in gajim.connections[account].bookmarks:
|
2005-06-11 18:15:01 +02:00
|
|
|
if bookmark['name'] == '':
|
2005-08-18 21:06:24 +02:00
|
|
|
# No name was given for this bookmark.
|
|
|
|
# Use the first part of JID instead...
|
2005-06-09 22:35:44 +02:00
|
|
|
name = bookmark['jid'].split("@")[0]
|
|
|
|
bookmark['name'] = name
|
2005-06-11 16:14:50 +02:00
|
|
|
|
2005-08-18 21:06:24 +02:00
|
|
|
# make '1', '0', 'true', 'false' (or other) to True/False
|
|
|
|
autojoin = helpers.from_xs_boolean_to_python_boolean(
|
|
|
|
bookmark['autojoin'])
|
2005-06-11 16:14:50 +02:00
|
|
|
|
2005-06-09 22:35:44 +02:00
|
|
|
self.treestore.append( iter, [
|
|
|
|
account,
|
|
|
|
bookmark['name'],
|
|
|
|
bookmark['jid'],
|
2005-06-11 16:14:50 +02:00
|
|
|
autojoin,
|
2005-06-09 22:35:44 +02:00
|
|
|
bookmark['password'],
|
|
|
|
bookmark['nick'] ])
|
|
|
|
|
|
|
|
self.view = self.xml.get_widget('bookmarks_treeview')
|
|
|
|
self.view.set_model(self.treestore)
|
2005-06-10 18:45:54 +02:00
|
|
|
self.view.expand_all()
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
renderer = gtk.CellRendererText()
|
2005-06-10 15:37:56 +02:00
|
|
|
column = gtk.TreeViewColumn('Bookmarks', renderer, text=1)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.view.append_column(column)
|
2005-06-12 18:39:04 +02:00
|
|
|
|
2005-06-09 22:35:44 +02:00
|
|
|
self.selection = self.view.get_selection()
|
2005-06-10 15:37:56 +02:00
|
|
|
self.selection.connect('changed', self.bookmark_selected)
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
#Prepare input fields
|
|
|
|
self.title_entry = self.xml.get_widget('title_entry')
|
2005-06-10 17:45:09 +02:00
|
|
|
self.title_entry.connect('changed', self.on_title_entry_changed)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.nick_entry = self.xml.get_widget('nick_entry')
|
2005-06-10 17:45:09 +02:00
|
|
|
self.nick_entry.connect('changed', self.on_nick_entry_changed)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.server_entry = self.xml.get_widget('server_entry')
|
2005-06-10 17:45:09 +02:00
|
|
|
self.server_entry.connect('changed', self.on_server_entry_changed)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.room_entry = self.xml.get_widget('room_entry')
|
2005-06-10 17:45:09 +02:00
|
|
|
self.room_entry.connect('changed', self.on_room_entry_changed)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.pass_entry = self.xml.get_widget('pass_entry')
|
2005-06-10 17:45:09 +02:00
|
|
|
self.pass_entry.connect('changed', self.on_pass_entry_changed)
|
2005-06-09 22:35:44 +02:00
|
|
|
self.autojoin_checkbutton = self.xml.get_widget('autojoin_checkbutton')
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
2005-06-12 18:39:04 +02:00
|
|
|
def on_bookmarks_treeview_button_press_event(self, widget, event):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if not iter:
|
2005-08-07 13:44:50 +02:00
|
|
|
# Removed a bookmark before
|
2005-06-12 18:39:04 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
if model.iter_parent(iter):
|
2005-08-07 13:44:50 +02:00
|
|
|
# The currently selected node is a bookmark
|
2005-06-12 19:33:38 +02:00
|
|
|
return not self.check_valid_bookmark()
|
2005-06-12 18:39:04 +02:00
|
|
|
|
|
|
|
def on_manage_bookmarks_window_destroy(self, widget, event):
|
2005-10-20 13:17:17 +02:00
|
|
|
del gajim.interface.windows['manage_bookmarks']
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
def on_add_bookmark_button_clicked(self,widget):
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
Add a new bookmark.
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-08-07 13:44:50 +02:00
|
|
|
# Get the account that is currently used
|
|
|
|
# (the parent of the currently selected item)
|
2005-06-09 22:35:44 +02:00
|
|
|
(model, iter) = self.selection.get_selected()
|
2005-08-07 13:44:50 +02:00
|
|
|
if not iter: # Nothing selected, do nothing
|
2005-06-09 23:05:58 +02:00
|
|
|
return
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
parent = model.iter_parent(iter)
|
|
|
|
|
2005-06-10 20:40:19 +02:00
|
|
|
if parent:
|
2005-08-07 13:44:50 +02:00
|
|
|
# We got a bookmark selected, so we add_to the parent
|
2005-06-10 20:40:19 +02:00
|
|
|
add_to = parent
|
|
|
|
else:
|
2005-08-07 13:44:50 +02:00
|
|
|
# No parent, so we got an account -> add to this.
|
2005-06-09 22:35:44 +02:00
|
|
|
add_to = iter
|
|
|
|
|
2005-06-10 15:37:56 +02:00
|
|
|
account = model.get_value(add_to, 1)
|
2005-06-11 16:14:50 +02:00
|
|
|
self.treestore.append(add_to, [account,_('New Room'), '', False, '', ''])
|
2005-06-10 18:45:54 +02:00
|
|
|
|
|
|
|
self.view.expand_row(model.get_path(add_to), True)
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
def on_remove_bookmark_button_clicked(self, widget):
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
Remove selected bookmark.
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
(model, iter) = self.selection.get_selected()
|
2005-08-07 13:44:50 +02:00
|
|
|
if not iter: # Nothing selected
|
2005-06-09 22:35:44 +02:00
|
|
|
return
|
2005-06-10 20:40:19 +02:00
|
|
|
|
2005-06-09 23:05:58 +02:00
|
|
|
if not model.iter_parent(iter):
|
2005-08-07 13:44:50 +02:00
|
|
|
# Don't remove account iters
|
2005-06-09 22:35:44 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
model.remove(iter)
|
|
|
|
self.clear_fields()
|
|
|
|
|
2005-06-12 18:39:04 +02:00
|
|
|
def check_valid_bookmark(self):
|
|
|
|
'''
|
|
|
|
Check if all neccessary fields are entered correctly.
|
|
|
|
'''
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
|
|
|
|
if not model.iter_parent(iter):
|
|
|
|
#Account data can't be changed
|
|
|
|
return
|
|
|
|
|
2005-08-26 02:52:44 +02:00
|
|
|
if self.server_entry.get_text().decode('utf-8') == '' or self.room_entry.get_text().decode('utf-8') == '':
|
2005-06-12 21:17:06 +02:00
|
|
|
dialogs.ErrorDialog(_('This bookmark has invalid data'),
|
|
|
|
_('Please be sure to fill out server and room fields or remove this bookmark.')).get_response()
|
2005-06-12 18:39:04 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2005-06-09 22:35:44 +02:00
|
|
|
def on_ok_button_clicked(self, widget):
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
Parse the treestore data into our new bookmarks array,
|
|
|
|
then send the new bookmarks to the server.
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-12 18:39:04 +02:00
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter and model.iter_parent(iter):
|
|
|
|
#bookmark selected, check it
|
|
|
|
if not self.check_valid_bookmark():
|
|
|
|
return
|
|
|
|
|
2005-06-10 17:45:09 +02:00
|
|
|
for account in self.treestore:
|
2005-08-27 01:03:22 +02:00
|
|
|
account_unicode = account[1].decode('utf-8')
|
|
|
|
gajim.connections[account_unicode].bookmarks = []
|
2005-06-10 20:40:19 +02:00
|
|
|
|
2005-06-10 17:45:09 +02:00
|
|
|
for bm in account.iterchildren():
|
2005-06-10 20:40:19 +02:00
|
|
|
#Convert True/False/None to '1' or '0'
|
2005-08-26 02:52:44 +02:00
|
|
|
autojoin = unicode(int(bm[3]))
|
2005-06-10 20:40:19 +02:00
|
|
|
|
|
|
|
#create the bookmark-dict
|
2005-06-11 16:14:50 +02:00
|
|
|
bmdict = { 'name': bm[1], 'jid': bm[2], 'autojoin': autojoin,
|
2005-06-12 18:39:04 +02:00
|
|
|
'password': bm[4], 'nick': bm[5] }
|
|
|
|
|
2005-08-27 01:03:22 +02:00
|
|
|
gajim.connections[account_unicode].bookmarks.append(bmdict)
|
2005-06-10 17:45:09 +02:00
|
|
|
|
2005-08-27 01:03:22 +02:00
|
|
|
gajim.connections[account_unicode].store_bookmarks()
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.make_menu()
|
2005-06-10 17:45:09 +02:00
|
|
|
self.window.destroy()
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-06-10 17:45:09 +02:00
|
|
|
self.window.destroy()
|
2005-06-09 22:35:44 +02:00
|
|
|
|
|
|
|
def bookmark_selected(self, selection):
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
Fill in the bookmark's data into the fields.
|
2005-06-10 15:37:56 +02:00
|
|
|
'''
|
2005-06-09 22:35:44 +02:00
|
|
|
(model, iter) = selection.get_selected()
|
|
|
|
|
|
|
|
if not iter:
|
|
|
|
#After removing the last bookmark for one account
|
|
|
|
#this will be None, so we will just:
|
|
|
|
return
|
2005-06-12 18:39:04 +02:00
|
|
|
|
2005-06-10 20:40:19 +02:00
|
|
|
widgets = [ self.title_entry, self.nick_entry, self.room_entry,
|
|
|
|
self.server_entry, self.pass_entry, self.autojoin_checkbutton ]
|
|
|
|
|
|
|
|
if model.iter_parent(iter):
|
|
|
|
#make the fields sensitive
|
|
|
|
for field in widgets:
|
|
|
|
field.set_sensitive(True)
|
|
|
|
else:
|
2005-06-09 22:35:44 +02:00
|
|
|
#Top-level has no data (it's the account fields)
|
2005-06-10 20:40:19 +02:00
|
|
|
#clear fields & make them insensitive
|
2005-06-09 22:35:44 +02:00
|
|
|
self.clear_fields()
|
2005-06-10 20:40:19 +02:00
|
|
|
for field in widgets:
|
|
|
|
field.set_sensitive(False)
|
2005-06-09 22:35:44 +02:00
|
|
|
return
|
2005-06-12 18:39:04 +02:00
|
|
|
|
2005-06-09 22:35:44 +02:00
|
|
|
#Fill in the data for childs
|
2005-08-07 13:44:50 +02:00
|
|
|
self.title_entry.set_text(model[iter][1])
|
2005-08-26 02:52:44 +02:00
|
|
|
room_jid = model[iter][2].decode('utf-8')
|
2005-06-09 22:35:44 +02:00
|
|
|
try:
|
2005-06-10 15:37:56 +02:00
|
|
|
(room, server) = room_jid.split('@')
|
2005-06-09 22:35:44 +02:00
|
|
|
except ValueError:
|
|
|
|
#We just added this one
|
|
|
|
room = ''
|
|
|
|
server = ''
|
|
|
|
self.room_entry.set_text(room)
|
|
|
|
self.server_entry.set_text(server)
|
2005-06-11 16:14:50 +02:00
|
|
|
|
2005-08-07 13:44:50 +02:00
|
|
|
self.autojoin_checkbutton.set_active(model[iter][3])
|
|
|
|
self.pass_entry.set_text(model[iter][4])
|
|
|
|
self.nick_entry.set_text(model[iter][5])
|
2005-06-09 22:35:44 +02:00
|
|
|
|
2005-06-10 17:45:09 +02:00
|
|
|
def on_title_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter: #After removing a bookmark, we got nothing selected
|
2005-06-10 18:45:54 +02:00
|
|
|
if model.iter_parent(iter):
|
|
|
|
#Don't clear the title field for account nodes
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][1] = self.title_entry.get_text()
|
2005-06-10 17:45:09 +02:00
|
|
|
|
|
|
|
def on_nick_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter:
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][5] = self.nick_entry.get_text()
|
2005-06-10 17:45:09 +02:00
|
|
|
|
|
|
|
def on_server_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter:
|
2005-08-26 02:52:44 +02:00
|
|
|
room_jid = self.room_entry.get_text().decode('utf-8') + '@' + \
|
|
|
|
self.server_entry.get_text().decode('utf-8')
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][2] = room_jid
|
2005-06-10 17:45:09 +02:00
|
|
|
|
|
|
|
def on_room_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter:
|
2005-08-26 02:52:44 +02:00
|
|
|
room_jid = self.room_entry.get_text().decode('utf-8') + '@' + \
|
|
|
|
self.server_entry.get_text().decode('utf-8')
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][2] = room_jid
|
2005-06-10 17:45:09 +02:00
|
|
|
|
|
|
|
def on_pass_entry_changed(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter:
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][4] = self.pass_entry.get_text()
|
2005-06-10 17:45:09 +02:00
|
|
|
|
|
|
|
def on_autojoin_checkbutton_toggled(self, widget):
|
|
|
|
(model, iter) = self.selection.get_selected()
|
|
|
|
if iter:
|
2005-08-07 13:44:50 +02:00
|
|
|
model[iter][3] = self.autojoin_checkbutton.get_active()
|
2005-06-10 17:45:09 +02:00
|
|
|
|
2005-06-09 22:35:44 +02:00
|
|
|
def clear_fields(self):
|
2005-06-10 20:40:19 +02:00
|
|
|
widgets = [ self.title_entry, self.nick_entry, self.room_entry,
|
|
|
|
self.server_entry, self.pass_entry ]
|
|
|
|
for field in widgets:
|
|
|
|
field.set_text('')
|
2005-06-09 23:05:58 +02:00
|
|
|
self.autojoin_checkbutton.set_active(False)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
|
|
|
class FirstTimeWizardWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-08-07 01:39:53 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'wizard_window', APP)
|
|
|
|
self.window = self.xml.get_widget('wizard_window')
|
2005-09-18 17:03:04 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
2005-08-07 01:39:53 +02:00
|
|
|
|
2005-09-18 20:30:16 +02:00
|
|
|
# Connect events from comboboxentry.child
|
2005-09-18 17:03:04 +02:00
|
|
|
server_comboboxentry = self.xml.get_widget('existing_server_comboboxentry')
|
|
|
|
server_comboboxentry.child.connect('key_press_event',
|
|
|
|
self.on_server_comboboxentry_key_press_event)
|
|
|
|
register_server_comboboxentry = self.xml.get_widget(
|
|
|
|
'register_server_comboboxentry')
|
|
|
|
register_server_comboboxentry.child.connect('key_press_event',
|
|
|
|
self.on_server_comboboxentry_key_press_event)
|
|
|
|
|
|
|
|
# parse servers.xml
|
2005-09-18 20:30:16 +02:00
|
|
|
servers_xml = os.path.join(gajim.DATA_DIR, 'other', 'servers.xml')
|
2005-09-18 17:03:04 +02:00
|
|
|
servers = gtkgui_helpers.parse_server_xml(servers_xml)
|
|
|
|
servers_model = gtk.ListStore(str, int)
|
|
|
|
for server in servers:
|
|
|
|
servers_model.append((str(server[0]), int(server[1])))
|
2005-08-07 13:33:34 +02:00
|
|
|
|
2005-09-18 20:30:16 +02:00
|
|
|
# Put servers into comboboxentries
|
2005-09-18 17:03:04 +02:00
|
|
|
server_comboboxentry.set_model(servers_model)
|
|
|
|
server_comboboxentry.set_text_column(0)
|
|
|
|
register_server_comboboxentry.set_model(servers_model)
|
|
|
|
register_server_comboboxentry.set_text_column(0)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
2005-09-18 17:03:04 +02:00
|
|
|
# Generic widgets
|
|
|
|
self.notebook = self.xml.get_widget('notebook')
|
2005-08-07 01:39:53 +02:00
|
|
|
self.back_button = self.xml.get_widget('back_button')
|
|
|
|
self.finish_button = self.xml.get_widget('finish_button')
|
|
|
|
self.finish_label = self.xml.get_widget('finish_label')
|
|
|
|
|
2005-09-18 20:34:14 +02:00
|
|
|
def on_register_server_features_button_clicked(self, widget):
|
2005-09-18 20:30:16 +02:00
|
|
|
helpers.launch_browser_mailer('url', 'http://www.jabber.org/network/')
|
2005-08-07 01:39:53 +02:00
|
|
|
|
|
|
|
def on_save_password_checkbutton_toggled(self, widget):
|
2005-10-02 15:12:23 +02:00
|
|
|
if widget.get_name() == 'existing_save_password_checkbutton':
|
2005-09-18 17:03:04 +02:00
|
|
|
widget2 = self.xml.get_widget('existing_pass_entry')
|
|
|
|
if widget2.get_property('sensitive'):
|
|
|
|
widget2.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
widget2.set_sensitive(True)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_back_button_clicked(self, widget):
|
|
|
|
if self.notebook.get_current_page() == 1:
|
|
|
|
self.notebook.set_current_page(0)
|
|
|
|
elif self.notebook.get_current_page() == 2:
|
|
|
|
self.notebook.set_current_page(0)
|
|
|
|
self.back_button.set_sensitive(False)
|
|
|
|
|
2005-09-18 17:03:04 +02:00
|
|
|
def get_widgets(self, prefix):
|
|
|
|
widgets = {}
|
2005-10-27 15:15:03 +02:00
|
|
|
for widget in (
|
|
|
|
'nick_entry',
|
2005-09-18 17:03:04 +02:00
|
|
|
'server_comboboxentry',
|
|
|
|
'pass_entry',
|
|
|
|
'save_password_checkbutton',
|
|
|
|
'proxyhost_entry',
|
|
|
|
'proxyport_entry',
|
|
|
|
'proxyuser_entry',
|
|
|
|
'proxypass_entry',
|
2005-10-27 15:15:03 +02:00
|
|
|
'jid_label'):
|
2005-09-18 17:03:04 +02:00
|
|
|
widgets[widget] = self.xml.get_widget(prefix + widget)
|
|
|
|
return widgets
|
|
|
|
|
|
|
|
def get_matching_widgets(self, widget):
|
|
|
|
if widget.get_name().startswith('existing_'):
|
|
|
|
return self.get_widgets('existing_')
|
|
|
|
elif widget.get_name().startswith('register_'):
|
|
|
|
return self.get_widgets('register_')
|
|
|
|
|
2005-08-07 01:39:53 +02:00
|
|
|
def on_forward_button_clicked(self, widget):
|
|
|
|
cur_page = self.notebook.get_current_page()
|
2005-09-18 17:03:04 +02:00
|
|
|
|
2005-08-07 01:39:53 +02:00
|
|
|
if cur_page == 0:
|
|
|
|
widget = self.xml.get_widget('use_existing_account_radiobutton')
|
|
|
|
if widget.get_active():
|
|
|
|
self.notebook.set_current_page(1)
|
|
|
|
else:
|
|
|
|
self.notebook.set_current_page(2)
|
|
|
|
self.back_button.set_sensitive(True)
|
2005-09-18 17:03:04 +02:00
|
|
|
return
|
2005-08-07 01:39:53 +02:00
|
|
|
|
|
|
|
else:
|
2005-09-18 17:03:04 +02:00
|
|
|
if cur_page == 1:
|
|
|
|
widgets = self.get_widgets('existing_')
|
|
|
|
register_new = False
|
2005-09-18 20:30:16 +02:00
|
|
|
#FIXME: pango me
|
2005-09-18 17:03:04 +02:00
|
|
|
finish_text = _('Account has been added successfully.\n'
|
2005-10-29 00:17:50 +02:00
|
|
|
'You can set advanced account options by clicking in Accounts menuitem under Edit menu from the main window.')
|
2005-09-18 17:03:04 +02:00
|
|
|
elif cur_page == 2:
|
|
|
|
widgets = self.get_widgets('register_')
|
|
|
|
register_new = True
|
2005-09-18 20:30:16 +02:00
|
|
|
#FIXME: pango me
|
|
|
|
finish_text = _('Your new account has been created successfully.\n'
|
2005-10-29 00:17:50 +02:00
|
|
|
'You can set advanced account options by clicking in Accounts menuitem under Edit menu from the main window.')
|
|
|
|
|
2005-10-29 19:02:59 +02:00
|
|
|
username = widgets['nick_entry'].get_text().decode('utf-8')
|
2005-09-18 17:03:04 +02:00
|
|
|
server = widgets['server_comboboxentry'].child.get_text()
|
|
|
|
savepass = widgets['save_password_checkbutton'].get_active()
|
|
|
|
password = widgets['pass_entry'].get_text()
|
2005-10-29 19:02:59 +02:00
|
|
|
if self.check_data(username, server):
|
2005-10-29 18:59:11 +02:00
|
|
|
self.save_account(_('Main'), server, savepass, password, register_new)
|
2005-09-18 17:03:04 +02:00
|
|
|
self.finish_label.set_text(finish_text)
|
|
|
|
self.xml.get_widget('cancel_button').hide()
|
|
|
|
self.back_button.hide()
|
|
|
|
self.xml.get_widget('forward_button').hide()
|
|
|
|
self.finish_button.set_sensitive(True)
|
|
|
|
self.notebook.set_current_page(3)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
|
|
|
def on_finish_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def check_data(self, username, server):
|
|
|
|
if len(username) == 0:
|
2005-09-18 20:30:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Username is missing'),
|
2005-09-18 20:34:14 +02:00
|
|
|
_('You need to enter a username to continue.')).get_response()
|
2005-08-07 01:39:53 +02:00
|
|
|
return False
|
|
|
|
elif len(server) == 0:
|
2005-09-18 20:30:16 +02:00
|
|
|
dialogs.ErrorDialog(_('Server address is missing'),
|
2005-09-18 20:34:14 +02:00
|
|
|
_('You need to enter a valid server address to continue.')).get_response()
|
2005-08-07 01:39:53 +02:00
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
|
|
|
def on_nick_entry_changed(self, widget):
|
2005-09-18 17:03:04 +02:00
|
|
|
self.update_jid(widget)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
2005-09-18 17:03:04 +02:00
|
|
|
def on_server_comboboxentry_changed(self, widget):
|
|
|
|
self.update_jid(widget)
|
2005-08-07 01:39:53 +02:00
|
|
|
|
2005-09-18 17:03:04 +02:00
|
|
|
def on_nick_entry_key_press_event(self, widget, event):
|
2005-09-18 20:30:16 +02:00
|
|
|
# Check for pressed @ and jump to combobox if found
|
2005-08-07 01:39:53 +02:00
|
|
|
if event.keyval == gtk.keysyms.at:
|
2005-09-18 17:03:04 +02:00
|
|
|
widgets = self.get_matching_widgets(widget)
|
|
|
|
widgets['server_comboboxentry'].grab_focus()
|
|
|
|
widgets['server_comboboxentry'].child.set_position(-1)
|
|
|
|
return True
|
|
|
|
|
|
|
|
def on_server_comboboxentry_key_press_event(self, widget, event):
|
2005-09-18 20:30:16 +02:00
|
|
|
# If backspace is pressed in empty field, return to the nick entry field
|
2005-09-18 17:03:04 +02:00
|
|
|
widgets = self.get_matching_widgets(widget.parent)
|
2005-10-21 23:50:44 +02:00
|
|
|
backspace = event.keyval == gtk.keysyms.BackSpace
|
2005-09-18 17:03:04 +02:00
|
|
|
empty = len(widgets['server_comboboxentry'].get_active_text()) == 0
|
2005-10-21 23:50:44 +02:00
|
|
|
if backspace and empty:
|
2005-09-18 17:03:04 +02:00
|
|
|
widgets['nick_entry'].grab_focus()
|
|
|
|
widgets['nick_entry'].set_position(-1)
|
2005-08-07 01:39:53 +02:00
|
|
|
return True
|
|
|
|
|
2005-09-18 17:03:04 +02:00
|
|
|
def update_jid(self,widget):
|
|
|
|
widgets = self.get_matching_widgets(widget)
|
|
|
|
name = widgets['nick_entry'].get_text().decode('utf-8')
|
|
|
|
server = widgets['server_comboboxentry'].get_active_text()
|
2005-08-07 01:39:53 +02:00
|
|
|
if len(name) == 0 or len(server) == 0:
|
2005-09-18 17:03:04 +02:00
|
|
|
widgets['jid_label'].set_label('')
|
2005-08-07 01:39:53 +02:00
|
|
|
else:
|
2005-10-21 23:50:44 +02:00
|
|
|
string = '<span background="lightyellow">%s@%s</span>' % (name, server)
|
|
|
|
widgets['jid_label'].set_label(string)
|
2005-09-18 17:03:04 +02:00
|
|
|
|
|
|
|
def save_account(self, name, server, savepass, password, new_account):
|
2005-09-18 20:30:16 +02:00
|
|
|
config = {}
|
2005-09-18 17:03:04 +02:00
|
|
|
config['name'] = name
|
|
|
|
config['hostname'] = server
|
|
|
|
config['savepass'] = savepass
|
|
|
|
config['password'] = password
|
|
|
|
if new_account and config['password'] == '':
|
|
|
|
dialogs.ErrorDialog(_('Invalid password'),
|
|
|
|
_('You must enter a password for the new account.')).get_response()
|
|
|
|
return
|
|
|
|
config['resource'] = 'Gajim'
|
|
|
|
config['priority'] = 5
|
|
|
|
config['autoconnect'] = True
|
|
|
|
config['no_log_for'] = ''
|
|
|
|
config['sync_with_global_status'] = True
|
|
|
|
config['proxy'] = ''
|
|
|
|
config['usessl'] = False
|
|
|
|
config['use_custom_host'] = False
|
|
|
|
config['custom_port'] = 0
|
|
|
|
config['custom_host'] = ''
|
|
|
|
config['keyname'] = ''
|
|
|
|
config['keyid'] = ''
|
|
|
|
config['savegpgpass'] = False
|
|
|
|
config['gpgpassword'] = ''
|
|
|
|
|
|
|
|
if name in gajim.connections:
|
|
|
|
dialogs.ErrorDialog(_('Account name is in use'),
|
|
|
|
_('You already have an account using this name.')).get_response()
|
|
|
|
return
|
|
|
|
con = connection.Connection(name)
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.register_handlers(con)
|
2005-09-18 17:03:04 +02:00
|
|
|
if new_account:
|
|
|
|
gajim.events_for_ui[name] = []
|
|
|
|
con.new_account(name, config)
|
|
|
|
return
|
2005-09-18 20:30:16 +02:00
|
|
|
# The account we add already exists on the server
|
2005-09-18 17:03:04 +02:00
|
|
|
gajim.connections[name] = con
|
|
|
|
gajim.config.add_per('accounts', name)
|
|
|
|
for opt in config:
|
|
|
|
gajim.config.set_per('accounts', name, opt, config[opt])
|
|
|
|
if config['savepass']:
|
|
|
|
gajim.connections[name].password = config['password']
|
2005-09-18 20:30:16 +02:00
|
|
|
# update variables
|
2005-10-30 10:58:13 +01:00
|
|
|
gajim.interface.windows[name] = {'infos': {}, 'disco': {}, 'chats': {},
|
|
|
|
'gc': {}, 'gc_config': {}}
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.windows[name]['xml_console'] = \
|
|
|
|
dialogs.XMLConsoleWindow(name)
|
2005-10-15 22:49:08 +02:00
|
|
|
gajim.awaiting_events[name] = {}
|
2005-09-18 17:03:04 +02:00
|
|
|
gajim.connections[name].connected = 0
|
|
|
|
gajim.groups[name] = {}
|
|
|
|
gajim.contacts[name] = {}
|
|
|
|
gajim.gc_contacts[name] = {}
|
|
|
|
gajim.gc_connected[name] = {}
|
|
|
|
gajim.newly_added[name] = []
|
|
|
|
gajim.to_be_removed[name] = []
|
|
|
|
gajim.nicks[name] = config['name']
|
|
|
|
gajim.allow_notifications[name] = False
|
|
|
|
gajim.sleeper_state[name] = 'off'
|
|
|
|
gajim.encrypted_chats[name] = []
|
|
|
|
gajim.last_message_time[name] = {}
|
|
|
|
gajim.status_before_autoaway[name] = ''
|
|
|
|
gajim.events_for_ui[name] = []
|
2005-09-18 20:30:16 +02:00
|
|
|
# refresh accounts window
|
2005-10-20 13:17:17 +02:00
|
|
|
if gajim.interface.windows.has_key('accounts'):
|
|
|
|
gajim.interface.windows['accounts'].init_accounts()
|
2005-09-18 20:30:16 +02:00
|
|
|
# refresh roster
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.draw_roster()
|
|
|
|
gajim.interface.save_config()
|