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
|
2004-05-28 06:20:30 +02:00
|
|
|
import common.sleepy
|
2005-04-18 16:05:30 +02:00
|
|
|
|
|
|
|
import dialogs
|
2005-04-18 18:40:10 +02:00
|
|
|
import cell_renderer_image
|
2005-04-18 18:54:49 +02:00
|
|
|
from gajim import User
|
2005-04-18 19:19:22 +02:00
|
|
|
import cell_renderer_image
|
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-03-26 22:09:49 +01:00
|
|
|
class Preferences_window:
|
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
|
|
|
|
|
|
|
def on_preferences_window_show(self, widget):
|
|
|
|
self.notebook.set_current_page(0)
|
2005-04-12 17:30:09 +02:00
|
|
|
if os.name == 'nt': # if windows, player must not be visible
|
|
|
|
self.xml.get_widget('soundplayer_hbox').set_property('visible', False)
|
|
|
|
self.trayicon_checkbutton.set_property('visible', False)
|
|
|
|
|
|
|
|
def on_preferences_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
|
|
|
self.window.hide()
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
def on_checkbutton_toggled(self, widget, config_name, \
|
2005-04-07 02:35:06 +02:00
|
|
|
change_sensitivity_widgets = None):
|
2005-04-20 20:10:37 +02:00
|
|
|
gajim.config.set(config_name, widget.get_active())
|
2005-04-06 20:51:54 +02:00
|
|
|
if change_sensitivity_widgets != None:
|
|
|
|
for w in change_sensitivity_widgets:
|
|
|
|
w.set_sensitive(widget.get_active())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-26 22:09:49 +01:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
def on_trayicon_checkbutton_toggled(self, widget):
|
2005-03-09 18:14:40 +01:00
|
|
|
if widget.get_active():
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('trayicon', True)
|
2005-03-08 15:08:46 +01:00
|
|
|
self.plugin.show_systray()
|
2005-04-03 11:21:26 +02:00
|
|
|
self.plugin.roster.update_status_comboxbox()
|
2005-03-08 15:08:46 +01:00
|
|
|
else:
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('trayicon', False)
|
2005-03-08 15:08:46 +01:00
|
|
|
self.plugin.hide_systray()
|
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
def on_save_position_checkbutton_toggled(self, widget):
|
2005-04-13 11:41:44 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'saveposition')
|
2005-03-08 15:08:46 +01:00
|
|
|
|
|
|
|
def on_merge_checkbutton_toggled(self, widget):
|
2005-04-13 11:41:44 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'mergeaccounts')
|
|
|
|
self.plugin.roster.regroup = gajim.config.get('mergeaccounts')
|
2005-03-28 18:15:50 +02:00
|
|
|
self.plugin.roster.draw_roster()
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-17 11:05:58 +02:00
|
|
|
def on_use_emoticons_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'useemoticons', \
|
|
|
|
[self.xml.get_widget('add_remove_emoticons_button')])
|
|
|
|
|
|
|
|
def on_add_remove_emoticons_button_clicked(self, widget):
|
2005-04-17 23:41:15 +02:00
|
|
|
window = self.plugin.windows['add_remove_emoticons'].window
|
2005-04-17 11:05:58 +02:00
|
|
|
if window.get_property('visible'):
|
|
|
|
window.present()
|
|
|
|
else:
|
|
|
|
window.show_all()
|
|
|
|
|
2005-03-30 14:29:48 +02:00
|
|
|
def on_iconset_combobox_changed(self, widget):
|
2005-03-08 15:08:46 +01:00
|
|
|
model = widget.get_model()
|
2005-03-30 01:52:26 +02:00
|
|
|
active = widget.get_active()
|
|
|
|
icon_string = model[active][0]
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('iconset', icon_string)
|
2005-04-23 03:37:05 +02:00
|
|
|
self.plugin.roster.reload_jabber_state_images()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
def on_roster_widget_color_set(self, widget, text):
|
2005-03-06 16:14:34 +01:00
|
|
|
color = widget.get_color()
|
2005-04-22 03:05:31 +02:00
|
|
|
color_string = mk_color_string(color)
|
|
|
|
gajim.config.set(text, color_string)
|
2005-03-06 19:28:42 +01:00
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-22 03:05:31 +02:00
|
|
|
|
|
|
|
def on_account_text_colorbutton_color_set(self, widget):
|
|
|
|
self.on_roster_widget_color_set(widget, 'accounttextcolor')
|
|
|
|
|
2005-04-27 02:19:07 +02:00
|
|
|
def on_group_text_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_roster_widget_color_set(widget, 'grouptextcolor')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-27 02:19:07 +02:00
|
|
|
def on_user_text_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_roster_widget_color_set(widget, 'usertextcolor')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-27 02:19:07 +02:00
|
|
|
def on_account_text_bg_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_roster_widget_color_set(widget, 'accountbgcolor')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-27 02:19:07 +02:00
|
|
|
def on_group_text_bg_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_roster_widget_color_set(widget, 'groupbgcolor')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-27 02:19:07 +02:00
|
|
|
def on_user_text_bg_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_roster_widget_color_set(widget, 'userbgcolor')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
def on_widget_font_set(self, widget, text):
|
2005-03-06 16:14:34 +01:00
|
|
|
font_string = widget.get_font_name()
|
2005-04-22 03:05:31 +02:00
|
|
|
gajim.config.set(text, font_string)
|
2005-03-06 19:28:42 +01:00
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
def on_account_text_fontbutton_font_set(self, widget):
|
|
|
|
self.on_widget_font_set(widget, 'accountfont')
|
|
|
|
|
2005-03-06 16:14:34 +01:00
|
|
|
def on_group_text_fontbutton_font_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_widget_font_set(widget, 'groupfont')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
|
|
|
def on_user_text_fontbutton_font_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_widget_font_set(widget, 'userfont')
|
2005-03-06 16:14:34 +01:00
|
|
|
|
2005-03-08 00:25:43 +01:00
|
|
|
def on_reset_colors_and_fonts_button_clicked(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
for i in ['accounttextcolor', 'grouptextcolor', \
|
|
|
|
'usertextcolor', 'accountbgcolor', 'groupbgcolor', \
|
|
|
|
'userbgcolor', 'accountfont', 'groupfont','userfont' ]:
|
|
|
|
|
|
|
|
gajim.config.set(i, gajim.config.get_default(i))
|
|
|
|
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('account_text_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('accounttextcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('group_text_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('grouptextcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('user_text_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('usertextcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('account_text_bg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('accountbgcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('group_text_bg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('groupbgcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('user_text_bg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('userbgcolor')))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('account_text_fontbutton').set_font_name(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get_default('accountfont'))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('group_text_fontbutton').set_font_name(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get_default('groupfont'))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.xml.get_widget('user_text_fontbutton').set_font_name(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get_default('userfont'))
|
2005-03-06 20:30:32 +01:00
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-06 20:30:32 +01:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
def on_use_tabbed_chat_window_checkbutton_toggled(self, widget):
|
2005-03-15 22:06:59 +01:00
|
|
|
buf1 = {}
|
|
|
|
buf2 = {}
|
|
|
|
jids = {}
|
2005-03-08 15:08:46 +01:00
|
|
|
if widget.get_active():
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('usetabbedchat', True)
|
2005-03-08 15:08:46 +01:00
|
|
|
else:
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('usetabbedchat', False)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-04-03 11:21:26 +02:00
|
|
|
def update_print_time(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Update time in Opened Chat Windows'''
|
2005-04-14 09:05:10 +02:00
|
|
|
for a in gajim.connections:
|
2005-04-22 03:05:31 +02:00
|
|
|
window = self.plugin.windows[a]['chats']
|
|
|
|
if window.has_key('tabbed'):
|
|
|
|
window['tabbed'].update_print_time()
|
2005-03-08 15:08:46 +01:00
|
|
|
else:
|
2005-04-22 03:05:31 +02:00
|
|
|
for jid in window.keys():
|
|
|
|
window[jid].update_print_time()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-04-03 11:21:26 +02:00
|
|
|
def on_time_never_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('print_time', 'never')
|
2005-04-03 11:21:26 +02:00
|
|
|
self.update_print_time()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_time_sometimes_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('print_time', 'sometimes')
|
2005-04-03 11:21:26 +02:00
|
|
|
self.update_print_time()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_time_always_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('print_time', 'always')
|
2005-04-03 11:21:26 +02:00
|
|
|
self.update_print_time()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_before_time_entry_focus_out_event(self, widget, event):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('before_time', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_after_time_entry_focus_out_event(self, widget, event):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('after_time', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_before_nickname_entry_focus_out_event(self, widget, event):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('before_nickname', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def on_after_nickname_entry_focus_out_event(self, widget, event):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('after_nickname', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-03 11:21:26 +02:00
|
|
|
|
|
|
|
def update_text_tags(self):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Update color tags in Opened Chat Windows'''
|
2005-04-14 09:05:10 +02:00
|
|
|
for a in gajim.connections:
|
2005-04-22 03:05:31 +02:00
|
|
|
window = self.plugin.windows[a]['chats']
|
|
|
|
if window.has_key('tabbed'):
|
|
|
|
window['tabbed'].update_tags()
|
2005-03-08 15:08:46 +01:00
|
|
|
else:
|
2005-04-22 03:05:31 +02:00
|
|
|
for jid in window.keys():
|
|
|
|
window[jid].update_tags()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
def on_preference_widget_color_set(self, widget, text):
|
2005-03-08 15:08:46 +01:00
|
|
|
color = widget.get_color()
|
2005-04-22 03:49:31 +02:00
|
|
|
color_string = mk_color_string(color)
|
2005-04-22 03:05:31 +02:00
|
|
|
gajim.config.set(text, color_string)
|
2005-03-08 15:08:46 +01:00
|
|
|
self.update_text_tags()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-22 03:05:31 +02:00
|
|
|
|
|
|
|
def on_incoming_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.on_preference_widget_color_set(widget, 'inmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
|
|
|
|
def on_outgoing_msg_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_preference_widget_color_set(widget, 'outmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
|
|
|
|
def on_status_msg_colorbutton_color_set(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_preference_widget_color_set(widget, 'statusmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
|
|
|
|
def on_reset_colors_button_clicked(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
for i in ['inmsgcolor', 'outmsgcolor', 'statusmsgcolor']:
|
|
|
|
gajim.config.set(i, gajim.config.get_default(i))
|
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('inmsgcolor')))
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('outgoing_msg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('outmsgcolor')))
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('status_msg_colorbutton').set_color(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gtk.gdk.color_parse(gajim.config.get_default('statusmsgcolor')))
|
2005-03-08 15:08:46 +01:00
|
|
|
self.update_text_tags()
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-04-17 01:15:03 +02:00
|
|
|
def on_notify_on_new_message_radiobutton_toggled(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_new_message',
|
|
|
|
[self.auto_popup_away_checkbutton])
|
2005-04-17 01:15:03 +02:00
|
|
|
|
|
|
|
def on_popup_new_message_radiobutton_toggled(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'autopopup',
|
|
|
|
[self.auto_popup_away_checkbutton])
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-04-17 01:15:03 +02:00
|
|
|
def on_only_in_roster_radiobutton_toggled(self, widget):
|
|
|
|
if widget.get_active():
|
|
|
|
self.auto_popup_away_checkbutton.set_sensitive(False)
|
|
|
|
|
|
|
|
def on_notify_on_online_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_online')
|
|
|
|
|
|
|
|
def on_notify_on_offline_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'notify_on_offline')
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
def on_auto_popup_away_checkbutton_toggled(self, widget):
|
2005-03-09 11:26:57 +01:00
|
|
|
self.on_checkbutton_toggled(widget, 'autopopupaway')
|
|
|
|
|
2005-03-11 00:45:10 +01:00
|
|
|
def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts')
|
|
|
|
|
2005-04-06 21:46:39 +02:00
|
|
|
def on_play_sounds_checkbutton_toggled(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
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')])
|
2005-04-06 21:46:39 +02:00
|
|
|
|
2005-03-09 11:26:57 +01:00
|
|
|
def on_soundplayer_entry_changed(self, widget):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('soundplayer', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-03-07 00:20:30 +01:00
|
|
|
def on_prompt_online_status_message_checkbutton_toggled(self, widget):
|
2005-03-09 11:26:57 +01:00
|
|
|
self.on_checkbutton_toggled(widget, 'ask_online_status')
|
2005-03-07 00:20:30 +01:00
|
|
|
|
|
|
|
def on_prompt_offline_status_message_checkbutton_toggled(self, widget):
|
2005-03-11 01:31:15 +01:00
|
|
|
self.on_checkbutton_toggled(widget, 'ask_offline_status')
|
2005-03-06 22:43:35 +01:00
|
|
|
|
2005-03-09 11:26:57 +01:00
|
|
|
def on_sounds_treemodel_row_changed(self, model, path, iter):
|
2005-04-16 16:50:26 +02:00
|
|
|
sound_event = model.get_value(iter, 0)
|
2005-04-20 20:13:12 +02:00
|
|
|
gajim.config.set_per('soundevents', sound_event, 'enabled',
|
2005-04-20 20:15:01 +02:00
|
|
|
bool(model[path][1]))
|
2005-04-22 03:05:31 +02:00
|
|
|
gajim.config.set_per('soundevents', sound_event, 'path',
|
|
|
|
model.get_value(iter, 2))
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_auto_away_checkbutton_toggled(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'autoaway',
|
|
|
|
[self.auto_away_time_spinbutton])
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_auto_away_time_spinbutton_value_changed(self, widget):
|
|
|
|
aat = widget.get_value_as_int()
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('autoawaytime', aat)
|
2005-04-22 03:05:31 +02:00
|
|
|
self.plugin.sleeper = common.sleepy.Sleepy(
|
|
|
|
gajim.config.get('autoawaytime') * 60,
|
|
|
|
gajim.config.get('autoxatime') * 60)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_auto_xa_checkbutton_toggled(self, widget):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_checkbutton_toggled(widget, 'autoxa',
|
|
|
|
[self.auto_xa_time_spinbutton])
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_auto_xa_time_spinbutton_value_changed(self, widget):
|
|
|
|
axt = widget.get_value_as_int()
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('autoxatime', axt)
|
2005-04-22 03:05:31 +02:00
|
|
|
self.plugin.sleeper = common.sleepy.Sleepy(
|
|
|
|
gajim.config.get('autoawaytime') * 60,
|
|
|
|
gajim.config.get('autoxatime') * 60)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-04-15 13:37:56 +02:00
|
|
|
def save_status_messages(self, model):
|
|
|
|
for msg in gajim.config.get_per('statusmsg'):
|
|
|
|
gajim.config.del_per('statusmsg', msg)
|
2004-10-26 00:02:16 +02:00
|
|
|
iter = model.get_iter_first()
|
|
|
|
while iter:
|
2005-04-22 03:05:31 +02:00
|
|
|
val = model.get_value(iter, 0)
|
|
|
|
gajim.config.add_per('statusmsg', val)
|
|
|
|
gajim.config.set_per('statusmsg', val, 'message',
|
|
|
|
model.get_value(iter, 1))
|
2004-10-26 00:02:16 +02:00
|
|
|
iter = model.iter_next(iter)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
2005-04-15 13:37:56 +02:00
|
|
|
def on_msg_treemodel_row_changed(self, model, path, iter):
|
|
|
|
self.save_status_messages(model)
|
|
|
|
|
2005-03-09 11:26:57 +01:00
|
|
|
def on_msg_treemodel_row_deleted(self, model, path, iter):
|
2005-04-15 13:37:56 +02:00
|
|
|
self.save_status_messages(model)
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_links_open_with_combobox_changed(self, widget):
|
|
|
|
if widget.get_active() == 2:
|
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('openwith', 'custom')
|
2005-03-09 11:26:57 +01:00
|
|
|
else:
|
|
|
|
if widget.get_active() == 0:
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('openwith', 'gnome-open')
|
2005-03-09 11:26:57 +01:00
|
|
|
if widget.get_active() == 1:
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('openwith', 'kfmclient exec')
|
2005-03-09 11:26:57 +01:00
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_custom_browser_entry_changed(self, widget):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('custombrowser', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_custom_mail_client_entry_changed(self, widget):
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('custommailapp', widget.get_text())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_log_in_contact_checkbutton_toggled(self, widget):
|
2005-04-20 20:10:37 +02:00
|
|
|
gajim.config.set('lognotusr', widget.get_active())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-03-09 11:26:57 +01:00
|
|
|
|
|
|
|
def on_log_in_extern_checkbutton_toggled(self, widget):
|
2005-04-20 20:10:37 +02:00
|
|
|
gajim.config.set('lognotsep', widget.get_active())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2004-11-01 14:41:00 +01:00
|
|
|
|
2005-04-24 02:31:48 +02:00
|
|
|
def on_send_os_info_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('send_os_info', widget.get_active())
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2005-04-24 02:31:48 +02:00
|
|
|
def on_check_for_new_version_checkbutton_toggled(self, widget):
|
|
|
|
gajim.config.set('check_for_new_version', widget.get_active())
|
2005-04-18 16:05:30 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2004-10-26 00:02:16 +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()
|
2005-04-15 13:37:56 +02:00
|
|
|
for msg in gajim.config.get_per('statusmsg'):
|
2004-10-26 00:02:16 +02:00
|
|
|
iter = model.append()
|
2005-04-22 03:05:31 +02:00
|
|
|
val = gajim.config.get_per('statusmsg', msg, 'message')
|
|
|
|
model.set(iter, 0, msg, 1, val)
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
def on_msg_cell_edited(self, cell, row, new_text):
|
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
|
|
|
model.set_value(iter, 0, new_text)
|
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_msg_treeview_cursor_changed(self, widget, data = None):
|
2005-04-18 11:25:12 +02:00
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
2005-04-22 03:05:31 +02:00
|
|
|
if not iter:
|
|
|
|
return
|
2005-02-10 01:07:55 +01:00
|
|
|
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)
|
|
|
|
msg = model.get_value(iter, 1)
|
|
|
|
buf.set_text(msg)
|
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_new_msg_button_clicked(self, widget, data = None):
|
2005-02-10 01:07:55 +01:00
|
|
|
model = self.msg_tree.get_model()
|
|
|
|
iter = model.append()
|
|
|
|
model.set(iter, 0, 'msg', 1, 'message')
|
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_delete_msg_button_clicked(self, widget, data = None):
|
2005-02-10 01:07:55 +01:00
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
2005-04-22 03:05:31 +02:00
|
|
|
if not iter:
|
|
|
|
return
|
2005-02-10 01:07:55 +01:00
|
|
|
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)
|
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_msg_textview_changed(self, widget, data = None):
|
2005-02-10 01:07:55 +01:00
|
|
|
(model, iter) = self.msg_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
first_iter, end_iter = buf.get_bounds()
|
|
|
|
name = model.get_value(iter, 0)
|
|
|
|
model.set_value(iter, 1, buf.get_text(first_iter, end_iter))
|
|
|
|
|
|
|
|
def on_msg_treeview_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Delete:
|
|
|
|
self.on_delete_msg_button_clicked(widget)
|
|
|
|
|
2005-02-14 23:30:04 +01:00
|
|
|
def sound_toggled_cb(self, cell, path):
|
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model[path][1] = not model[path][1]
|
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
def fill_sound_treeview(self):
|
2005-04-16 16:50:26 +02:00
|
|
|
sounds = gajim.config.get_per('soundevents')
|
2005-02-10 01:07:55 +01:00
|
|
|
model = self.sound_tree.get_model()
|
|
|
|
model.clear()
|
2005-04-16 16:50:26 +02:00
|
|
|
for sound in sounds:
|
2005-04-22 03:05:31 +02:00
|
|
|
val = gajim.config.get_per('soundevents', sound,
|
|
|
|
'enabled')
|
|
|
|
path = gajim.config.get_per('soundevents', sound,
|
|
|
|
'path')
|
|
|
|
iter = model.append((sound, val, path))
|
2005-02-10 01:07:55 +01:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_treeview_sounds_cursor_changed(self, widget, data = None):
|
2005-02-10 01:07:55 +01:00
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
2005-04-22 03:05:31 +02:00
|
|
|
sounds_entry = self.xml.get_widget('sounds_entry')
|
2005-02-10 01:07:55 +01:00
|
|
|
if not iter:
|
2005-04-22 03:05:31 +02:00
|
|
|
sounds_entry.set_text('')
|
2005-02-10 01:07:55 +01:00
|
|
|
return
|
2005-02-14 23:30:04 +01:00
|
|
|
str = model.get_value(iter, 2)
|
2005-04-22 03:05:31 +02:00
|
|
|
sounds_entry.set_text(str)
|
2005-02-10 01:07:55 +01:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_button_sounds_clicked(self, widget, data = None):
|
2005-02-10 01:07:55 +01:00
|
|
|
(model, iter) = self.sound_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-02-14 23:30:04 +01:00
|
|
|
file = model.get_value(iter, 2)
|
2005-04-22 03:05:31 +02:00
|
|
|
dialog = gtk.FileChooserDialog(_('Choose sound'), None,
|
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
2005-02-10 01:07:55 +01:00
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-04-22 03:05:31 +02:00
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
filter = gtk.FileFilter()
|
2005-03-13 00:14:00 +01:00
|
|
|
filter.set_name(_('All files'))
|
2005-04-14 19:07:55 +02:00
|
|
|
filter.add_pattern('*')
|
2005-02-10 01:07:55 +01:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
2005-03-13 00:14:00 +01:00
|
|
|
filter.set_name(_('Wav Sounds'))
|
2005-04-14 19:07:55 +02:00
|
|
|
filter.add_pattern('*.wav')
|
2005-02-10 01:07:55 +01:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
|
|
|
|
|
|
|
file = os.path.join(os.getcwd(), file)
|
|
|
|
dialog.set_filename(file)
|
2005-02-14 23:30:04 +01:00
|
|
|
file = ''
|
2005-04-23 14:51:14 +02:00
|
|
|
while True:
|
2005-02-10 01:07:55 +01:00
|
|
|
response = dialog.run()
|
2005-04-23 14:09:25 +02:00
|
|
|
if response != gtk.RESPONSE_OK:
|
|
|
|
break
|
|
|
|
file = dialog.get_filename()
|
|
|
|
if os.path.exists(file):
|
|
|
|
break
|
2005-02-10 01:07:55 +01:00
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
2005-03-09 21:43:22 +01:00
|
|
|
self.xml.get_widget('sounds_entry').set_text(file)
|
2005-02-14 23:30:04 +01:00
|
|
|
model.set_value(iter, 2, file)
|
|
|
|
model.set_value(iter, 1, 1)
|
2005-03-05 01:31:39 +01:00
|
|
|
|
2005-04-24 01:57:02 +02:00
|
|
|
def on_open_advanced_editor_button_clicked(self, widget, data = None):
|
2005-04-27 15:49:42 +02:00
|
|
|
dialogs.Advanced_window()
|
2005-04-24 01:57:02 +02:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def __init__(self, plugin):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Initialize Preferences window'''
|
2005-03-01 14:46:22 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP)
|
|
|
|
self.window = self.xml.get_widget('preferences_window')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
2005-03-30 14:29:48 +02:00
|
|
|
self.iconset_combobox = self.xml.get_widget('iconset_combobox')
|
2005-04-17 01:15:03 +02:00
|
|
|
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')
|
|
|
|
self.notify_on_online_checkbutton = self.xml.get_widget \
|
|
|
|
('notify_on_online_checkbutton')
|
|
|
|
self.notify_on_offline_checkbutton = self.xml.get_widget \
|
|
|
|
('notify_on_offline_checkbutton')
|
2005-04-06 20:51:54 +02:00
|
|
|
self.auto_popup_away_checkbutton = self.xml.get_widget \
|
|
|
|
('auto_popup_away_checkbutton')
|
2005-03-05 19:56:32 +01:00
|
|
|
self.auto_away_checkbutton = self.xml.get_widget('auto_away_checkbutton')
|
|
|
|
self.auto_away_time_spinbutton = self.xml.get_widget \
|
|
|
|
('auto_away_time_spinbutton')
|
|
|
|
self.auto_xa_checkbutton = self.xml.get_widget('auto_xa_checkbutton')
|
|
|
|
self.auto_xa_time_spinbutton = self.xml.get_widget \
|
|
|
|
('auto_xa_time_spinbutton')
|
2005-04-12 17:30:09 +02:00
|
|
|
self.trayicon_checkbutton = self.xml.get_widget('trayicon_checkbutton')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.notebook = self.xml.get_widget('preferences_notebook')
|
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
#trayicon
|
2005-03-29 18:16:42 +02:00
|
|
|
if self.plugin.systray_capabilities:
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('trayicon')
|
2005-04-12 17:30:09 +02:00
|
|
|
self.trayicon_checkbutton.set_active(st)
|
2005-03-29 18:16:42 +02:00
|
|
|
else:
|
2005-04-12 17:30:09 +02:00
|
|
|
self.trayicon_checkbutton.set_sensitive(False)
|
2005-03-29 18:37:59 +02:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
#Save position
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('saveposition')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('save_position_checkbutton').set_active(st)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
#Merge accounts
|
2005-04-14 09:05:10 +02:00
|
|
|
st = gajim.config.get('mergeaccounts')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('merge_checkbutton').set_active(st)
|
|
|
|
|
2005-04-17 11:05:58 +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-30 14:29:48 +02:00
|
|
|
#iconset
|
2005-04-21 00:30:04 +02:00
|
|
|
iconsets_list = os.listdir('../data/iconsets/')
|
2005-03-06 17:20:33 +01:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING)
|
2005-03-30 14:29:48 +02:00
|
|
|
self.iconset_combobox.set_model(model)
|
2005-03-06 19:28:42 +01:00
|
|
|
l = []
|
2005-04-21 00:30:04 +02:00
|
|
|
for dir in iconsets_list:
|
2005-04-21 18:25:05 +02:00
|
|
|
if dir != '.svn' and dir != 'transports':
|
2005-04-21 00:30:04 +02:00
|
|
|
l.append(dir)
|
2005-03-06 19:28:42 +01:00
|
|
|
if l.count == 0:
|
|
|
|
l.append(' ')
|
|
|
|
for i in range(len(l)):
|
|
|
|
model.append([l[i]])
|
2005-04-13 11:41:44 +02:00
|
|
|
if gajim.config.get('iconset') == l[i]:
|
2005-03-30 14:29:48 +02:00
|
|
|
self.iconset_combobox.set_active(i)
|
2004-10-13 23:46:10 +02:00
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
# update color widget(%2) = color(%1)
|
|
|
|
tab = { 'accounttextcolor': 'account_text_colorbutton', \
|
|
|
|
'grouptextcolor': 'group_text_colorbutton', \
|
|
|
|
'usertextcolor': 'user_text_colorbutton', \
|
|
|
|
'accountbgcolor': 'account_text_bg_colorbutton', \
|
|
|
|
'groupbgcolor': 'group_text_bg_colorbutton', \
|
|
|
|
'userbgcolor': 'user_text_bg_colorbutton', }
|
|
|
|
for i in tab:
|
|
|
|
col = gtk.gdk.color_parse(gajim.config.get(i))
|
|
|
|
self.xml.get_widget(tab[i]).set_color(col)
|
2005-03-08 15:08:46 +01:00
|
|
|
|
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
# update font widget(%2) = font(%1)
|
|
|
|
tab = { 'accountfont': 'account_text_fontbutton', \
|
|
|
|
'groupfont': 'group_text_fontbutton', \
|
|
|
|
'userfont': 'user_text_fontbutton', }
|
|
|
|
|
|
|
|
for i in tab:
|
|
|
|
font = gajim.config.get(i)
|
|
|
|
self.xml.get_widget(tab[i]).set_font_name(font)
|
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-02-05 18:18:49 +01:00
|
|
|
#use tabbed chat window
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('usetabbedchat')
|
2005-03-06 16:14:34 +01:00
|
|
|
self.xml.get_widget('use_tabbed_chat_window_checkbutton').set_active(st)
|
2005-04-02 21:52:00 +02:00
|
|
|
|
|
|
|
#Print time
|
2005-04-13 11:41:44 +02:00
|
|
|
if gajim.config.get('print_time') == 'never':
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('time_never_radiobutton').set_active(1)
|
2005-04-13 11:41:44 +02:00
|
|
|
elif gajim.config.get('print_time') == 'sometimes':
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('time_sometimes_radiobutton').set_active(1)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('time_always_radiobutton').set_active(1)
|
|
|
|
|
|
|
|
#before time
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('before_time')
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('before_time_entry').set_text(st)
|
|
|
|
|
|
|
|
#after time
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('after_time')
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('after_time_entry').set_text(st)
|
|
|
|
|
|
|
|
#before nickname
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('before_nickname')
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('before_nickname_entry').set_text(st)
|
|
|
|
|
|
|
|
#after nickanme
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('after_nickname')
|
2005-04-02 21:52:00 +02:00
|
|
|
self.xml.get_widget('after_nickname_entry').set_text(st)
|
2005-02-05 18:18:49 +01:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
#Color for incomming messages
|
2005-04-13 11:41:44 +02:00
|
|
|
colSt = gajim.config.get('inmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for outgoing messages
|
2005-04-13 11:41:44 +02:00
|
|
|
colSt = gajim.config.get('outmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('outgoing_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
|
|
|
#Color for status messages
|
2005-04-13 11:41:44 +02:00
|
|
|
colSt = gajim.config.get('statusmsgcolor')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('status_msg_colorbutton').set_color(\
|
|
|
|
gtk.gdk.color_parse(colSt))
|
|
|
|
|
2005-04-17 11:05:58 +02:00
|
|
|
# on new message
|
2005-04-17 15:10:45 +02:00
|
|
|
only_in_roster = True
|
2005-04-17 11:05:58 +02:00
|
|
|
if gajim.config.get('notify_on_new_message'):
|
|
|
|
self.xml.get_widget('notify_on_new_message_radiobutton').set_active(1)
|
2005-04-17 15:10:45 +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-17 01:15:03 +02:00
|
|
|
|
|
|
|
#notify on online statuses
|
|
|
|
st = gajim.config.get('notify_on_online')
|
|
|
|
self.notify_on_online_checkbutton.set_active(st)
|
|
|
|
|
|
|
|
#notify on offline statuses
|
|
|
|
st = gajim.config.get('notify_on_offline')
|
|
|
|
self.notify_on_offline_checkbutton.set_active(st)
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
#autopopupaway
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('autopopupaway')
|
2005-04-06 20:51:54 +02:00
|
|
|
self.auto_popup_away_checkbutton.set_active(st)
|
2005-03-08 15:08:46 +01:00
|
|
|
|
2005-03-21 22:01:03 +01:00
|
|
|
#Ignore messages from unknown contacts
|
|
|
|
self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
|
2005-04-13 11:41:44 +02:00
|
|
|
set_active(gajim.config.get('ignore_unknown_contacts'))
|
2005-03-21 22:01:03 +01:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
#sounds
|
2005-04-13 11:41:44 +02:00
|
|
|
if gajim.config.get('sounds_on'):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.xml.get_widget('play_sounds_checkbutton').set_active(True)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('soundplayer_hbox').set_sensitive(False)
|
2005-04-07 02:35:06 +02:00
|
|
|
self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False)
|
|
|
|
self.xml.get_widget('browse_sounds_hbox').set_sensitive(False)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-02-10 01:07:55 +01:00
|
|
|
#sound player
|
2005-03-09 11:26:57 +01:00
|
|
|
self.xml.get_widget('soundplayer_entry').set_text(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get('soundplayer'))
|
2005-02-10 01:07:55 +01:00
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
#sounds treeview
|
2005-03-09 11:26:57 +01:00
|
|
|
self.sound_tree = self.xml.get_widget('sounds_treeview')
|
2005-04-22 03:05:31 +02:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_BOOLEAN,
|
|
|
|
gobject.TYPE_STRING)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.sound_tree.set_model(model)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-03-13 00:14:00 +01:00
|
|
|
col = gtk.TreeViewColumn(_('Active'))
|
2005-02-14 23:30:04 +01:00
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererToggle()
|
|
|
|
renderer.set_property('activatable', True)
|
2005-03-13 00:14:00 +01:00
|
|
|
renderer.connect('toggled', self.sound_toggled_cb)
|
2005-02-14 23:30:04 +01:00
|
|
|
col.pack_start(renderer)
|
2005-04-22 01:20:18 +02:00
|
|
|
col.set_attributes(renderer, active = 1)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-03-13 00:14:00 +01:00
|
|
|
col = gtk.TreeViewColumn(_('Event'))
|
2005-02-10 01:07:55 +01:00
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
2005-04-22 01:20:18 +02:00
|
|
|
col.set_attributes(renderer, text = 0)
|
2005-02-14 23:30:04 +01:00
|
|
|
|
2005-03-13 00:14:00 +01:00
|
|
|
col = gtk.TreeViewColumn(_('Sound'))
|
2005-02-10 01:07:55 +01:00
|
|
|
self.sound_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer)
|
2005-04-22 01:20:18 +02:00
|
|
|
col.set_attributes(renderer, text = 2)
|
2005-02-10 01:07:55 +01:00
|
|
|
self.fill_sound_treeview()
|
2005-01-17 14:43:15 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
#Autoaway
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('autoaway')
|
2005-03-05 19:56:32 +01:00
|
|
|
self.auto_away_checkbutton.set_active(st)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Autoawaytime
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('autoawaytime')
|
2005-03-05 19:56:32 +01:00
|
|
|
self.auto_away_time_spinbutton.set_value(st)
|
2005-04-13 11:41:44 +02:00
|
|
|
self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Autoxa
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('autoxa')
|
2005-03-05 19:56:32 +01:00
|
|
|
self.auto_xa_checkbutton.set_active(st)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
#Autoxatime
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('autoxatime')
|
2005-03-05 19:56:32 +01:00
|
|
|
self.auto_xa_time_spinbutton.set_value(st)
|
2005-04-13 11:41:44 +02:00
|
|
|
self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-08 15:08:46 +01:00
|
|
|
#ask_status when online / offline
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('ask_online_status')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('prompt_online_status_message_checkbutton').\
|
|
|
|
set_active(st)
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('ask_offline_status')
|
2005-03-08 15:08:46 +01:00
|
|
|
self.xml.get_widget('prompt_offline_status_message_checkbutton').\
|
|
|
|
set_active(st)
|
|
|
|
|
2004-10-26 00:02:16 +02:00
|
|
|
#Status messages
|
|
|
|
self.msg_tree = self.xml.get_widget('msg_treeview')
|
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
self.msg_tree.set_model(model)
|
|
|
|
col = gtk.TreeViewColumn('name')
|
|
|
|
self.msg_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, True)
|
2005-04-22 01:20:18 +02:00
|
|
|
col.set_attributes(renderer, text = 0)
|
2004-10-26 00:02:16 +02:00
|
|
|
renderer.connect('edited', self.on_msg_cell_edited)
|
|
|
|
renderer.set_property('editable', True)
|
|
|
|
self.fill_msg_treeview()
|
2004-11-01 14:30:56 +01:00
|
|
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
|
|
|
buf.connect('changed', self.on_msg_textview_changed)
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-03-05 01:31:39 +01:00
|
|
|
#open links with
|
|
|
|
self.links_open_with_combobox = self.xml.get_widget('links_open_with_combobox')
|
2005-04-13 11:41:44 +02:00
|
|
|
if gajim.config.get('openwith') == 'gnome-open':
|
2005-03-05 01:31:39 +01:00
|
|
|
self.links_open_with_combobox.set_active(0)
|
2005-04-13 11:41:44 +02:00
|
|
|
elif gajim.config.get('openwith') == 'kfmclient exec':
|
2005-03-05 01:31:39 +01:00
|
|
|
self.links_open_with_combobox.set_active(1)
|
2005-04-13 11:41:44 +02:00
|
|
|
elif gajim.config.get('openwith') == 'custom':
|
2005-03-05 01:31:39 +01:00
|
|
|
self.links_open_with_combobox.set_active(2)
|
|
|
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
2005-03-08 21:59:29 +01:00
|
|
|
self.xml.get_widget('custom_browser_entry').set_text(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get('custombrowser'))
|
2005-03-08 21:59:29 +01:00
|
|
|
self.xml.get_widget('custom_mail_client_entry').set_text(\
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.get('custommailapp'))
|
2005-03-05 01:31:39 +01:00
|
|
|
|
2004-11-04 02:03:17 +01:00
|
|
|
#log presences in user file
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('lognotusr')
|
2005-03-09 11:26:57 +01:00
|
|
|
self.xml.get_widget('log_in_contact_checkbutton').set_active(st)
|
2004-11-04 02:03:17 +01:00
|
|
|
|
|
|
|
#log presences in external file
|
2005-04-13 11:41:44 +02:00
|
|
|
st = gajim.config.get('lognotsep')
|
2005-03-09 11:26:57 +01:00
|
|
|
self.xml.get_widget('log_in_extern_checkbutton').set_active(st)
|
2005-03-05 18:01:14 +01:00
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
# don't send os info
|
2005-04-24 02:31:48 +02:00
|
|
|
st = gajim.config.get('send_os_info')
|
|
|
|
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
|
2005-04-18 16:05:30 +02:00
|
|
|
|
|
|
|
# don't check for new version
|
2005-04-24 02:31:48 +02:00
|
|
|
st = gajim.config.get('check_for_new_version')
|
|
|
|
btn = self.xml.get_widget('check_for_new_version_checkbutton')
|
2005-04-18 16:05:30 +02:00
|
|
|
btn.set_active(st)
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
2005-04-22 03:05:31 +02:00
|
|
|
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)
|
2005-04-06 20:51:54 +02:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-07 18:01:56 +01:00
|
|
|
class Account_modification_window:
|
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-04-20 18:35:40 +02:00
|
|
|
if self.plugin.windows.has_key(self.account):
|
2005-04-20 19:48:49 +02:00
|
|
|
if self.plugin.windows[self.account].has_key('account_modification'):
|
2005-04-20 18:35:40 +02:00
|
|
|
del self.plugin.windows[self.account]['account_modification']
|
|
|
|
return
|
|
|
|
if self.plugin.windows.has_key('account_modification'):
|
|
|
|
del self.plugin.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-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-12 17:30:09 +02:00
|
|
|
def on_use_proxy_checkbutton_toggled(self, widget):
|
|
|
|
proxyhost_entry = self.xml.get_widget('proxyhost_entry')
|
|
|
|
proxyport_entry = self.xml.get_widget('proxyport_entry')
|
2005-04-22 03:05:31 +02:00
|
|
|
self.on_checkbutton_toggled(widget, [proxyhost_entry,
|
|
|
|
proxyport_entry])
|
|
|
|
|
|
|
|
def init_account_gpg(self):
|
|
|
|
keyid = gajim.config.get_per('accounts', self.account, 'keyid')
|
|
|
|
keyname = gajim.config.get_per('accounts', self.account,
|
|
|
|
'keyname')
|
|
|
|
savegpgpass = gajim.config.get_per('accounts', self.account,
|
|
|
|
'savegpgpass')
|
|
|
|
|
|
|
|
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-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',
|
|
|
|
self.account, 'hostname')
|
2005-04-15 01:00:25 +02:00
|
|
|
self.xml.get_widget('jid_entry').set_text(jid)
|
|
|
|
self.xml.get_widget('save_password_checkbutton').set_active( \
|
|
|
|
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-04-15 01:00:25 +02:00
|
|
|
self.xml.get_widget('resource_entry').set_text(gajim.config.get_per( \
|
|
|
|
'accounts', self.account, 'resource'))
|
|
|
|
self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\
|
|
|
|
get_per('accounts', self.account, 'priority'))
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-04-15 01:00:25 +02:00
|
|
|
use_proxy = gajim.config.get_per('accounts', self.account, 'use_proxy')
|
|
|
|
self.xml.get_widget('use_proxy_checkbutton').set_active(use_proxy)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-04-20 19:59:42 +02:00
|
|
|
entry = self.xml.get_widget('proxyhost_entry')
|
|
|
|
entry.set_sensitive(use_proxy)
|
|
|
|
entry.set_text(gajim.config.get_per('accounts', self.account,
|
|
|
|
'proxyhost'))
|
|
|
|
entry = self.xml.get_widget('proxyport_entry')
|
|
|
|
entry.set_sensitive(use_proxy)
|
|
|
|
entry.set_text(str(gajim.config.get_per('accounts',
|
|
|
|
self.account, 'proxyport')))
|
2005-04-12 17:30:09 +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-02-28 23:09:21 +01:00
|
|
|
gpg_key_label.set_text('GPG is not usable on this computer')
|
|
|
|
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'))
|
|
|
|
self.xml.get_widget('sync_with_global_status_checkbutton').set_active( \
|
|
|
|
gajim.config.get_per('accounts', self.account, \
|
|
|
|
'sync_with_global_status'))
|
|
|
|
list_no_log_for = gajim.config.get_per('accounts', self.account, \
|
|
|
|
'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-04-21 01:27:33 +02:00
|
|
|
save_password = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'save_password_checkbutton').get_active()
|
2005-02-28 23:09:21 +01:00
|
|
|
password = self.xml.get_widget('password_entry').get_text()
|
2005-03-07 18:01:56 +01:00
|
|
|
resource = self.xml.get_widget('resource_entry').get_text()
|
|
|
|
priority = self.xml.get_widget('priority_spinbutton').get_value_as_int()
|
2005-02-28 23:09:21 +01:00
|
|
|
new_account_checkbutton = self.xml.get_widget('new_account_checkbutton')
|
|
|
|
name = self.xml.get_widget('name_entry').get_text()
|
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-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must be offline to change the account\'s name'))
|
2005-03-31 14:17:07 +02:00
|
|
|
return
|
2005-02-28 23:09:21 +01:00
|
|
|
jid = self.xml.get_widget('jid_entry').get_text()
|
2005-04-21 01:20:26 +02:00
|
|
|
autoconnect = self.xml.get_widget('autoconnect_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-04-23 19:40:43 +02:00
|
|
|
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
|
|
|
|
|
|
|
use_proxy = self.xml.get_widget('use_proxy_checkbutton').get_active()
|
2005-02-28 23:09:21 +01:00
|
|
|
proxyhost = self.xml.get_widget('proxyhost_entry').get_text()
|
|
|
|
proxyport = self.xml.get_widget('proxyport_entry').get_text()
|
2004-05-15 18:50:38 +02:00
|
|
|
if (name == ''):
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must enter a name for this account'))
|
2005-03-16 02:27:37 +01:00
|
|
|
return
|
2004-05-15 18:52:07 +02:00
|
|
|
if name.find(' ') != -1:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('Spaces are not permited in account name'))
|
2005-03-16 02:27:37 +01:00
|
|
|
return
|
2005-04-22 03:05:31 +02:00
|
|
|
if jid == '' or jid.count('@') != 1:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
|
2005-03-16 02:27:37 +01:00
|
|
|
return
|
2005-02-28 23:09:21 +01:00
|
|
|
if new_account_checkbutton.get_active() and password == '':
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must enter a password to register a new account'))
|
2005-03-16 02:27:37 +01:00
|
|
|
return
|
2005-02-28 23:09:21 +01:00
|
|
|
if use_proxy:
|
|
|
|
if proxyport != '':
|
2004-07-01 21:49:26 +02:00
|
|
|
try:
|
2005-03-05 22:02:38 +01:00
|
|
|
proxyport = int(proxyport)
|
2004-07-01 21:49:26 +02:00
|
|
|
except ValueError:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('Proxy Port must be a port number'))
|
2005-03-16 02:27:37 +01:00
|
|
|
return
|
2005-04-12 17:30:09 +02:00
|
|
|
else:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must enter a proxy port to use proxy'))
|
2005-04-12 17:30:09 +02:00
|
|
|
return
|
2005-02-28 23:09:21 +01:00
|
|
|
if proxyhost == '':
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must enter a proxy host to use proxy'))
|
2005-04-12 17:30:09 +02:00
|
|
|
return
|
2005-03-11 02:10:30 +01:00
|
|
|
|
2005-03-05 22:02:38 +01:00
|
|
|
(login, hostname) = jid.split('@')
|
2005-02-28 23:09:21 +01:00
|
|
|
key_name = self.xml.get_widget('gpg_name_label').get_text()
|
|
|
|
if key_name == '': #no key selected
|
2004-10-10 20:44:38 +02:00
|
|
|
keyID = ''
|
2005-04-21 01:20:26 +02:00
|
|
|
save_gpg_password = False
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_password = ''
|
2004-10-10 20:44:38 +02:00
|
|
|
else:
|
|
|
|
keyID = self.xml.get_widget('gpg_key_label').get_text()
|
2005-04-22 01:20:18 +02:00
|
|
|
save_gpg_password = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'gpg_save_password_checkbutton').get_active()
|
2005-02-28 23:09:21 +01:00
|
|
|
gpg_password = self.xml.get_widget('gpg_password_entry').get_text()
|
2004-05-15 18:50:38 +02:00
|
|
|
#if we are modifying an account
|
|
|
|
if self.modify:
|
|
|
|
#if we modify the name of the account
|
|
|
|
if name != self.account:
|
|
|
|
#update variables
|
|
|
|
self.plugin.windows[name] = self.plugin.windows[self.account]
|
|
|
|
self.plugin.queues[name] = self.plugin.queues[self.account]
|
|
|
|
self.plugin.nicks[name] = self.plugin.nicks[self.account]
|
|
|
|
self.plugin.roster.groups[name] = \
|
|
|
|
self.plugin.roster.groups[self.account]
|
|
|
|
self.plugin.roster.contacts[name] = \
|
|
|
|
self.plugin.roster.contacts[self.account]
|
2005-04-05 01:03:26 +02:00
|
|
|
self.plugin.roster.newly_added[name] = \
|
|
|
|
self.plugin.roster.newly_added[self.account]
|
|
|
|
self.plugin.roster.to_be_removed[name] = \
|
|
|
|
self.plugin.roster.to_be_removed[self.account]
|
2005-03-09 22:01:31 +01:00
|
|
|
self.plugin.sleeper_state[name] = \
|
|
|
|
self.plugin.sleeper_state[self.account]
|
2005-03-21 23:41:30 +01:00
|
|
|
#upgrade account variable in opened windows
|
2005-04-20 12:21:33 +02:00
|
|
|
for kind in ['infos', 'chats', 'gc', 'gc_config']:
|
2005-03-21 23:41:30 +01:00
|
|
|
for j in self.plugin.windows[name][kind]:
|
|
|
|
self.plugin.windows[name][kind][j].account = name
|
|
|
|
#upgrade account in systray
|
|
|
|
for list in self.plugin.systray.jids:
|
|
|
|
if list[0] == self.account:
|
|
|
|
list[0] = name
|
2004-05-15 18:50:38 +02:00
|
|
|
del self.plugin.windows[self.account]
|
|
|
|
del self.plugin.queues[self.account]
|
|
|
|
del self.plugin.nicks[self.account]
|
|
|
|
del self.plugin.roster.groups[self.account]
|
|
|
|
del self.plugin.roster.contacts[self.account]
|
2005-03-09 22:01:31 +01:00
|
|
|
del self.plugin.sleeper_state[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)
|
|
|
|
|
|
|
|
gajim.config.set_per('accounts', name, 'name', login)
|
|
|
|
gajim.config.set_per('accounts', name, 'hostname', hostname)
|
|
|
|
gajim.config.set_per('accounts', name, 'savepass', save_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'password', password)
|
|
|
|
gajim.config.set_per('accounts', name, 'resource', resource)
|
|
|
|
gajim.config.set_per('accounts', name, 'priority', priority)
|
|
|
|
gajim.config.set_per('accounts', name, 'autoconnect', autoconnect)
|
|
|
|
gajim.config.set_per('accounts', name, 'use_proxy', use_proxy)
|
|
|
|
gajim.config.set_per('accounts', name, 'proxyhost', proxyhost)
|
|
|
|
gajim.config.set_per('accounts', name, 'proxyport', proxyport)
|
|
|
|
gajim.config.set_per('accounts', name, 'keyid', keyID)
|
|
|
|
gajim.config.set_per('accounts', name, 'keyname', key_name)
|
|
|
|
gajim.config.set_per('accounts', name, 'savegpgpass', \
|
|
|
|
save_gpg_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'sync_with_global_status', \
|
|
|
|
sync_with_global_status)
|
|
|
|
gajim.config.set_per('accounts', name, 'no_log_for', \
|
2005-04-15 01:00:25 +02:00
|
|
|
' '.join(list_no_log_for))
|
2005-02-28 23:09:21 +01:00
|
|
|
if save_password:
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[name].password = password
|
2004-06-06 21:35:10 +02:00
|
|
|
#refresh accounts window
|
2005-04-04 17:51:29 +02:00
|
|
|
if self.plugin.windows.has_key('accounts'):
|
|
|
|
self.plugin.windows['accounts'].init_accounts()
|
2004-06-06 21:35:10 +02:00
|
|
|
#refresh roster
|
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-21 01:20:26 +02:00
|
|
|
self.plugin.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-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('An account already has this name'))
|
2004-10-10 20:44:38 +02:00
|
|
|
return
|
2005-04-14 13:06:58 +02:00
|
|
|
gajim.config.add_per('accounts', name)
|
2005-04-19 15:14:41 +02:00
|
|
|
gajim.connections[name] = connection.Connection(name)
|
2005-04-14 09:58:54 +02:00
|
|
|
self.plugin.register_handlers(gajim.connections[name])
|
2004-10-10 20:44:38 +02:00
|
|
|
#if we neeed to register a new account
|
2005-02-28 23:09:21 +01:00
|
|
|
if new_account_checkbutton.get_active():
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[name].new_account(hostname, login, password, name, \
|
|
|
|
resource, priority, use_proxy, proxyhost, proxyport)
|
2004-10-10 20:44:38 +02:00
|
|
|
return
|
2005-04-14 09:05:10 +02:00
|
|
|
gajim.config.set_per('accounts', name, 'name', login)
|
|
|
|
gajim.config.set_per('accounts', name, 'hostname', hostname)
|
|
|
|
gajim.config.set_per('accounts', name, 'savepass', save_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'password', password)
|
|
|
|
gajim.config.set_per('accounts', name, 'resource', resource)
|
|
|
|
gajim.config.set_per('accounts', name, 'priority', priority)
|
|
|
|
gajim.config.set_per('accounts', name, 'autoconnect', autoconnect)
|
|
|
|
gajim.config.set_per('accounts', name, 'use_proxy', use_proxy)
|
|
|
|
gajim.config.set_per('accounts', name, 'proxyhost', proxyhost)
|
|
|
|
gajim.config.set_per('accounts', name, 'proxyport', proxyport)
|
|
|
|
gajim.config.set_per('accounts', name, 'keyid', keyID)
|
|
|
|
gajim.config.set_per('accounts', name, 'keyname', key_name)
|
|
|
|
gajim.config.set_per('accounts', name, 'savegpgpass', \
|
|
|
|
save_gpg_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password)
|
|
|
|
gajim.config.set_per('accounts', name, 'sync_with_global_status', True)
|
|
|
|
gajim.config.set_per('accounts', name, 'no_log_for', \
|
2005-04-15 01:00:25 +02:00
|
|
|
' '.join(list_no_log_for))
|
2005-02-28 23:09:21 +01:00
|
|
|
if save_password:
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[name].password = password
|
2004-05-15 18:50:38 +02:00
|
|
|
#update variables
|
2005-04-20 12:21:33 +02:00
|
|
|
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, \
|
|
|
|
'gc_config': {}}
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.queues[name] = {}
|
2005-04-14 09:42:26 +02:00
|
|
|
gajim.connections[name].connected = 0
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.roster.groups[name] = {}
|
|
|
|
self.plugin.roster.contacts[name] = {}
|
2005-04-05 01:03:26 +02:00
|
|
|
self.plugin.roster.newly_added[name] = []
|
|
|
|
self.plugin.roster.to_be_removed[name] = []
|
2004-07-17 17:31:47 +02:00
|
|
|
self.plugin.nicks[name] = login
|
2004-07-28 20:17:26 +02:00
|
|
|
self.plugin.sleeper_state[name] = 0
|
2004-05-15 18:50:38 +02:00
|
|
|
#refresh accounts window
|
2005-04-03 10:22:57 +02:00
|
|
|
if self.plugin.windows.has_key('accounts'):
|
|
|
|
self.plugin.windows['accounts'].init_accounts()
|
2004-05-15 18:50:38 +02:00
|
|
|
#refresh roster
|
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-21 01:20:26 +02:00
|
|
|
self.plugin.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-04-14 19:07:55 +02:00
|
|
|
dialog = dialogs.Change_password_dialog(self.plugin, self.account)
|
2005-03-04 14:10:00 +01:00
|
|
|
new_password = dialog.run()
|
|
|
|
if new_password != -1:
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].change_password(new_password, \
|
|
|
|
self.plugin.nicks[self.account])
|
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-04-18 14:17:43 +02:00
|
|
|
'''When the account has been created with sucess'''
|
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-03-07 21:41:28 +01:00
|
|
|
jid = self.xml.get_widget('jid_entry').get_text()
|
|
|
|
(login, hostname) = jid.split('@')
|
|
|
|
password = self.xml.get_widget('password_entry').get_text()
|
|
|
|
resource = self.xml.get_widget('resource_entry').get_text()
|
|
|
|
priority = self.xml.get_widget('priority_spinbutton').get_value_as_int()
|
2005-04-21 01:20:26 +02:00
|
|
|
autoconnect = self.xml.get_widget('autoconnect_checkbutton').get_active()
|
|
|
|
use_proxy = self.xml.get_widget('use_proxy_checkbutton').get_active()
|
2005-03-07 21:41:28 +01:00
|
|
|
proxyhost = self.xml.get_widget('proxyhost_entry').get_text()
|
|
|
|
proxyport = self.xml.get_widget('proxyport_entry').get_text()
|
|
|
|
key_name = self.xml.get_widget('gpg_name_label').get_text()
|
2005-04-21 01:27:33 +02:00
|
|
|
save_password = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'save_password_checkbutton').get_active()
|
2005-03-07 21:41:28 +01:00
|
|
|
if key_name == '': #no key selected
|
|
|
|
keyID = ''
|
2005-04-21 01:20:26 +02:00
|
|
|
save_gpg_password = False
|
2005-03-07 21:41:28 +01:00
|
|
|
gpg_password = ''
|
|
|
|
else:
|
|
|
|
keyID = self.xml.get_widget('gpg_key_label').get_text()
|
2005-04-22 01:20:18 +02:00
|
|
|
save_gpg_password = self.xml.get_widget(
|
2005-04-21 19:43:47 +02:00
|
|
|
'gpg_save_password_checkbutton').get_active()
|
2005-03-07 21:41:28 +01:00
|
|
|
gpg_password = self.xml.get_widget('gpg_password_entry').get_text()
|
|
|
|
no_log_for = ''
|
|
|
|
if self.xml.get_widget('log_history_checkbutton').get_active():
|
|
|
|
no_log_for = acct
|
2005-04-20 14:23:41 +02:00
|
|
|
gajim.config.set_per('accounts', acct, 'name', login)
|
|
|
|
gajim.config.set_per('accounts', acct, 'hostname', hostname)
|
|
|
|
gajim.config.set_per('accounts', acct, 'savepass', save_password)
|
|
|
|
gajim.config.set_per('accounts', acct, 'password', password)
|
|
|
|
gajim.config.set_per('accounts', acct, 'resource', resource)
|
|
|
|
gajim.config.set_per('accounts', acct, 'priority', priority)
|
|
|
|
gajim.config.set_per('accounts', acct, 'autoconnect', autoconnect)
|
|
|
|
gajim.config.set_per('accounts', acct, 'use_proxy', use_proxy)
|
|
|
|
gajim.config.set_per('accounts', acct, 'proxyhost', proxyhost)
|
|
|
|
gajim.config.set_per('accounts', acct, 'proxyport', proxyport)
|
|
|
|
gajim.config.set_per('accounts', acct, 'keyid', keyID)
|
|
|
|
gajim.config.set_per('accounts', acct, 'keyname', key_name)
|
|
|
|
gajim.config.set_per('accounts', acct, 'savegpgpass', \
|
2005-04-14 09:05:10 +02:00
|
|
|
save_gpg_password)
|
2005-04-20 14:23:41 +02:00
|
|
|
gajim.config.set_per('accounts', acct, 'gpgpassword', gpg_password)
|
|
|
|
gajim.config.set_per('accounts', acct, 'sync_with_global_status', True)
|
|
|
|
gajim.config.set_per('accounts', acct, 'no_log_for', no_log_for)
|
2005-02-24 23:16:21 +01:00
|
|
|
|
2005-02-28 23:09:21 +01:00
|
|
|
def on_edit_details_button_clicked(self, widget):
|
2005-03-07 22:03:48 +01:00
|
|
|
if not self.plugin.windows.has_key(self.account):
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must first create your account before editing your information'))
|
2005-03-07 22:03:48 +01:00
|
|
|
return
|
|
|
|
jid = self.xml.get_widget('jid_entry').get_text()
|
2005-04-14 09:20:14 +02:00
|
|
|
if gajim.connections[self.account].connected < 2:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('You must be connected to edit your information'))
|
2005-03-07 22:03:48 +01:00
|
|
|
return
|
|
|
|
if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
|
|
|
|
self.plugin.windows[self.account]['infos'][jid] = \
|
2005-04-22 03:47:03 +02:00
|
|
|
dialogs.Vcard_window(jid, self.plugin,
|
|
|
|
self.account, True)
|
2005-04-14 11:38:08 +02:00
|
|
|
gajim.connections[self.account].request_vcard(jid)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_gpg_choose_button_clicked(self, widget, data = None):
|
2005-04-14 09:05:10 +02:00
|
|
|
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
|
2005-04-12 23:09:06 +02:00
|
|
|
if not secret_keys:
|
2005-04-14 19:07:55 +02:00
|
|
|
dialogs.Error_dialog(_('error contacting %s') % service)
|
2005-04-12 23:09:06 +02:00
|
|
|
return
|
|
|
|
secret_keys['None'] = 'None'
|
2005-04-14 19:07:55 +02:00
|
|
|
w = dialogs.choose_gpg_key_dialog(secret_keys)
|
2004-10-10 20:44:38 +02:00
|
|
|
keyID = w.run()
|
|
|
|
if keyID == -1:
|
|
|
|
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-02-28 23:09:21 +01:00
|
|
|
def on_gpg_save_password_checkbutton_toggled(self, widget):
|
|
|
|
self.on_checkbutton_toggled_and_clear(widget, [\
|
|
|
|
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-02-28 23:09:21 +01:00
|
|
|
self.on_checkbutton_toggled_and_clear(widget, \
|
|
|
|
[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-04-15 01:00:25 +02:00
|
|
|
def __init__(self, plugin, account = ''):
|
2005-03-07 18:01:56 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'account_modification_window', APP)
|
|
|
|
self.window = self.xml.get_widget('account_modification_window')
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
2005-04-15 01:00:25 +02:00
|
|
|
self.account = account
|
2004-05-15 18:50:38 +02:00
|
|
|
self.modify = False
|
2004-10-10 20:44:38 +02:00
|
|
|
self.xml.get_widget('gpg_key_label').set_text('No key selected')
|
|
|
|
self.xml.get_widget('gpg_name_label').set_text('')
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.get_widget('gpg_save_password_checkbutton').set_sensitive(False)
|
|
|
|
self.xml.get_widget('gpg_password_entry').set_sensitive(False)
|
|
|
|
self.xml.get_widget('password_entry').set_sensitive(False)
|
2005-03-06 20:19:21 +01:00
|
|
|
self.xml.get_widget('log_history_checkbutton').set_active(1)
|
2005-04-12 17:30:09 +02:00
|
|
|
|
2005-03-12 19:21:49 +01:00
|
|
|
#default is checked
|
|
|
|
self.xml.get_widget('sync_with_global_status_checkbutton').set_active(1)
|
2005-02-28 23:09:21 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-15 01:00:25 +02:00
|
|
|
if account:
|
2005-02-16 01:16:00 +01:00
|
|
|
self.modify = True
|
2005-04-15 01:00:25 +02:00
|
|
|
self.init_account()
|
2005-03-01 14:46:22 +01:00
|
|
|
self.xml.get_widget('new_account_checkbutton').set_sensitive(False)
|
2005-03-23 15:25:56 +01:00
|
|
|
self.xml.get_widget('save_button').grab_focus()
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-07 18:01:56 +01:00
|
|
|
class Accounts_window:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for accounts window: lists of accounts'''
|
2005-04-02 22:35:33 +02:00
|
|
|
def on_accounts_window_destroy(self, widget):
|
|
|
|
del self.plugin.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
|
|
|
|
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-04-21 00:30:04 +02:00
|
|
|
model.set(iter, 0, account, 1, gajim.config.get_per('accounts',
|
2005-04-14 09:05:10 +02:00
|
|
|
account, 'hostname'))
|
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-04-18 14:17:43 +02:00
|
|
|
'''When new button is clicked : open an account information window'''
|
2005-04-17 23:31:18 +02:00
|
|
|
if self.plugin.windows.has_key('account_modification'):
|
2005-04-17 22:18:50 +02:00
|
|
|
self.plugin.windows['account_modification'].window.present()
|
|
|
|
else:
|
2005-04-04 17:51:29 +02:00
|
|
|
self.plugin.windows['account_modification'] = \
|
2005-04-15 01:00:25 +02:00
|
|
|
Account_modification_window(self.plugin, '')
|
2005-04-17 22:18:50 +02:00
|
|
|
|
2005-04-20 00:29:38 +02:00
|
|
|
def on_remove_button_clicked(self, widget):
|
2005-04-20 01:43:58 +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
|
2004-05-15 18:50:38 +02:00
|
|
|
account = model.get_value(iter, 0)
|
2005-04-20 01:43:58 +02:00
|
|
|
if self.plugin.windows[account].has_key('remove_account'):
|
|
|
|
self.plugin.windows[account]['remove_account'].window.present()
|
|
|
|
else:
|
|
|
|
self.plugin.windows[account]['remove_account'] = \
|
2005-04-21 00:30:04 +02:00
|
|
|
Remove_account_window(self.plugin, 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-04-17 22:18:50 +02:00
|
|
|
account = model.get_value(iter, 0)
|
2005-04-17 23:31:18 +02:00
|
|
|
if self.plugin.windows[account].has_key('account_modification'):
|
2005-04-17 22:18:50 +02:00
|
|
|
self.plugin.windows[account]['account_modification'].window.present()
|
2005-03-11 02:10:30 +01:00
|
|
|
else:
|
2005-04-17 22:18:50 +02:00
|
|
|
self.plugin.windows[account]['account_modification'] = \
|
|
|
|
Account_modification_window(self.plugin, account)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def __init__(self, plugin):
|
|
|
|
self.plugin = plugin
|
2005-03-07 18:01:56 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'accounts_window', APP)
|
|
|
|
self.window = self.xml.get_widget('accounts_window')
|
2005-03-02 13:05:56 +01:00
|
|
|
self.accounts_treeview = self.xml.get_widget('accounts_treeview')
|
2005-03-11 02:10:30 +01:00
|
|
|
self.modify_button = self.xml.get_widget('modify_button')
|
2005-04-20 00:29:38 +02:00
|
|
|
self.remove_button = self.xml.get_widget('remove_button')
|
2005-04-22 03:05:31 +02:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_BOOLEAN)
|
2005-02-28 18:45:06 +01:00
|
|
|
self.accounts_treeview.set_model(model)
|
2004-05-15 18:50:38 +02:00
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
2005-04-22 03:05:31 +02:00
|
|
|
self.accounts_treeview.insert_column_with_attributes(-1,
|
|
|
|
_('Name'), renderer, text = 0)
|
2004-05-15 18:50:38 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
2005-04-22 03:05:31 +02:00
|
|
|
self.accounts_treeview.insert_column_with_attributes(-1,
|
|
|
|
_('Server'), renderer, text = 1)
|
2005-03-01 19:00:34 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.init_accounts()
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-28 03:05:28 +02:00
|
|
|
class Service_registration_window:
|
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-18 14:17:43 +02:00
|
|
|
'''When Cancel button is clicked'''
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
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-04-20 20:04:26 +02:00
|
|
|
if name == 'key' or name == 'instructions' or name == 'x':
|
|
|
|
continue
|
|
|
|
|
|
|
|
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()
|
|
|
|
entry.set_text(self.infos[name])
|
|
|
|
table.attach(entry, 1, 2, nbrow - 1, nbrow, 0, 0, 0, 0)
|
|
|
|
self.entries[name] = entry
|
|
|
|
if nbrow == 1:
|
|
|
|
entry.grab_focus()
|
2004-05-15 18:50:38 +02:00
|
|
|
table.show_all()
|
|
|
|
|
2005-03-02 14:11:21 +01:00
|
|
|
def on_ok_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When Ok button is clicked :
|
|
|
|
send registration info to the core'''
|
2004-05-15 18:50:38 +02:00
|
|
|
for name in self.entries.keys():
|
|
|
|
self.infos[name] = self.entries[name].get_text()
|
2005-04-22 03:05:31 +02:00
|
|
|
user1 = User(self.service, self.service, ['Agents'], 'offline',
|
|
|
|
'offline', 'from', '', '', 0, '')
|
2005-03-28 03:05:28 +02:00
|
|
|
self.plugin.roster.contacts[self.account][self.service] = [user1]
|
|
|
|
self.plugin.roster.add_user_to_roster(self.service, self.account)
|
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()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-28 03:05:28 +02:00
|
|
|
def __init__(self, service, infos, plugin, account):
|
2005-04-22 03:05:31 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE,
|
|
|
|
'service_registration_window', APP)
|
2005-03-28 03:05:28 +02:00
|
|
|
self.service = service
|
2004-05-15 18:50:38 +02:00
|
|
|
self.infos = infos
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-04-18 14:17:43 +02:00
|
|
|
self.window = self.xml.get_widget('service_registration_window')
|
|
|
|
self.window.set_title(_('Register to %s') % service)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.xml.get_widget('label').set_text(infos['instructions'])
|
|
|
|
self.entries = {}
|
|
|
|
self.draw_table()
|
2005-03-02 14:11:21 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2005-04-04 17:51:29 +02:00
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
class Add_remove_emoticons_window:
|
|
|
|
def __init__(self, plugin):
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_remove_emoticons_window', APP)
|
|
|
|
self.window = self.xml.get_widget('add_remove_emoticons_window')
|
|
|
|
self.plugin = plugin
|
|
|
|
|
|
|
|
#emoticons
|
|
|
|
self.emot_tree = self.xml.get_widget('emoticons_treeview')
|
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.Image)
|
|
|
|
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()
|
|
|
|
self.emot_tree.get_model().connect('row-changed', \
|
|
|
|
self.on_emoticons_treemodel_row_changed)
|
|
|
|
self.emot_tree.get_model().connect('row-deleted', \
|
|
|
|
self.on_emoticons_treemodel_row_deleted)
|
|
|
|
|
|
|
|
self.plugin = plugin
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
|
|
|
def on_add_remove_emoticons_window_delete_event(self, widget, event):
|
|
|
|
self.window.hide()
|
|
|
|
return True # do NOT destroy the window
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.hide()
|
|
|
|
|
|
|
|
def on_emoticons_treemodel_row_deleted(self, model, path):
|
2005-04-16 16:50:26 +02:00
|
|
|
iter = model.get_iter(path)
|
|
|
|
gajim.config.get_per('emoticons', model.get_value(iter, 0))
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
def on_emoticons_treemodel_row_changed(self, model, path, iter):
|
2005-04-16 16:50:26 +02:00
|
|
|
emots = gajim.config.get_per('emoticons')
|
|
|
|
emot = model.get_value(iter, 0)
|
|
|
|
if not emot in emots:
|
|
|
|
gajim.config.add_per('emoticons', emot)
|
|
|
|
gajim.config.set_per('emoticons', emot, 'path', model.get_value(iter, 1))
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-06 20:51:54 +02:00
|
|
|
|
|
|
|
def image_is_ok(self, image):
|
|
|
|
if not os.path.exists(image):
|
|
|
|
return 0
|
|
|
|
img = gtk.Image()
|
|
|
|
try:
|
|
|
|
img.set_from_file(image)
|
|
|
|
except:
|
|
|
|
return 0
|
2005-04-22 03:05:31 +02:00
|
|
|
if img.get_storage_type() != gtk.IMAGE_PIXBUF:
|
2005-04-06 20:51:54 +02:00
|
|
|
return 0
|
2005-04-22 03:05:31 +02:00
|
|
|
pix = img.get_pixbuf()
|
|
|
|
|
2005-04-06 20:51:54 +02:00
|
|
|
if pix.get_width() > 24 or pix.get_height() > 24:
|
|
|
|
return 0
|
|
|
|
return 1
|
|
|
|
|
|
|
|
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):
|
|
|
|
model = self.emot_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
|
|
|
model.set_value(iter, 0, new_text)
|
|
|
|
|
2005-04-22 01:20:18 +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
|
|
|
|
file = model.get_value(iter, 1)
|
2005-04-22 03:05:31 +02:00
|
|
|
dialog = gtk.FileChooserDialog('Choose image', None,
|
|
|
|
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)
|
|
|
|
filter = gtk.FileFilter()
|
2005-04-18 14:17:43 +02:00
|
|
|
filter.set_name('All files')
|
|
|
|
filter.add_pattern('*')
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
2005-04-18 14:17:43 +02:00
|
|
|
filter.set_name('Images')
|
|
|
|
filter.add_mime_type('image/png')
|
|
|
|
filter.add_mime_type('image/jpeg')
|
|
|
|
filter.add_mime_type('image/gif')
|
|
|
|
filter.add_pattern('*.png')
|
|
|
|
filter.add_pattern('*.jpg')
|
|
|
|
filter.add_pattern('*.gif')
|
|
|
|
filter.add_pattern('*.tif')
|
|
|
|
filter.add_pattern('*.xpm')
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
|
|
|
|
|
|
|
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()
|
|
|
|
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-04-22 17:56:33 +02:00
|
|
|
ok = True
|
2005-04-06 20:51:54 +02:00
|
|
|
dialog.destroy()
|
|
|
|
if file:
|
|
|
|
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-04-22 01:20:18 +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()
|
|
|
|
model.set(iter, 0, 'emoticon', 1, '')
|
|
|
|
col = self.emot_tree.get_column(0)
|
|
|
|
self.emot_tree.set_cursor(model.get_path(iter), col, True)
|
|
|
|
|
2005-04-22 01:20:18 +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
|
|
|
|
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-03-23 14:25:48 +01:00
|
|
|
class Service_discovery_window:
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Class for Service Discovery Window:
|
|
|
|
to know the services on a server'''
|
2005-03-27 11:08:31 +02:00
|
|
|
def on_service_discovery_window_destroy(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''close window'''
|
2005-04-04 17:51:29 +02:00
|
|
|
del self.plugin.windows[self.account]['disco']
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 19:27:21 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2005-04-17 23:31:18 +02:00
|
|
|
|
|
|
|
def __init__(self, plugin, account):
|
2005-04-21 01:20:26 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
self.agent_infos = {}
|
2005-04-17 23:31:18 +02:00
|
|
|
if gajim.connections[account].connected < 2:
|
2005-04-18 14:17:43 +02:00
|
|
|
dialogs.Error_dialog(_('You must be connected to browse services'))
|
2005-04-17 23:31:18 +02:00
|
|
|
return
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'service_discovery_window', APP)
|
|
|
|
self.window = xml.get_widget('service_discovery_window')
|
|
|
|
self.services_treeview = xml.get_widget('services_treeview')
|
|
|
|
self.join_button = xml.get_widget('join_button')
|
|
|
|
self.register_button = xml.get_widget('register_button')
|
|
|
|
self.address_comboboxentry = xml.get_widget('address_comboboxentry')
|
|
|
|
self.address_comboboxentry_entry = self.address_comboboxentry.child
|
|
|
|
self.address_comboboxentry_entry.set_activates_default(True)
|
2005-04-21 01:20:26 +02:00
|
|
|
|
2005-04-23 23:54:12 +02:00
|
|
|
model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING)
|
2005-04-24 00:48:54 +02:00
|
|
|
model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
2005-04-17 23:31:18 +02:00
|
|
|
self.services_treeview.set_model(model)
|
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_data('column', 0)
|
2005-04-23 23:54:12 +02:00
|
|
|
self.services_treeview.insert_column_with_attributes(-1, _('Name'), \
|
2005-04-22 01:20:18 +02:00
|
|
|
renderer, text = 0)
|
2005-04-17 23:31:18 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_data('column', 1)
|
2005-04-23 23:54:12 +02:00
|
|
|
self.services_treeview.insert_column_with_attributes(-1, _('Service'), \
|
2005-04-22 01:20:18 +02:00
|
|
|
renderer, text = 1)
|
2005-04-23 23:54:12 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_data('column', 1)
|
|
|
|
self.services_treeview.insert_column_with_attributes(-1, _('Node'), \
|
|
|
|
renderer, text = 2)
|
2005-04-17 23:31:18 +02:00
|
|
|
|
|
|
|
self.address_comboboxentry = xml.get_widget('address_comboboxentry')
|
|
|
|
liststore = gtk.ListStore(str)
|
|
|
|
self.address_comboboxentry.set_model(liststore)
|
|
|
|
self.address_comboboxentry.set_text_column(0)
|
|
|
|
self.latest_addresses = gajim.config.get('latest_disco_addresses').split()
|
|
|
|
server_address = gajim.config.get_per('accounts', self.account, \
|
|
|
|
'hostname')
|
|
|
|
if server_address in self.latest_addresses:
|
|
|
|
self.latest_addresses.remove(server_address)
|
|
|
|
self.latest_addresses.insert(0, server_address)
|
|
|
|
if len(self.latest_addresses) > 10:
|
|
|
|
self.latest_addresses = self.latest_addresses[0:10]
|
|
|
|
for j in self.latest_addresses:
|
|
|
|
self.address_comboboxentry.append_text(j)
|
|
|
|
self.address_comboboxentry.child.set_text(server_address)
|
|
|
|
|
|
|
|
self.register_button = xml.get_widget('register_button')
|
|
|
|
self.register_button.set_sensitive(False)
|
|
|
|
self.join_button = xml.get_widget('join_button')
|
|
|
|
self.join_button.set_sensitive(False)
|
|
|
|
xml.signal_autoconnect(self)
|
|
|
|
self.browse(server_address)
|
|
|
|
self.window.show_all()
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-04-23 23:54:12 +02:00
|
|
|
def browse(self, jid, node = ''):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''Send a request to the core to know the available services'''
|
2005-03-28 03:05:28 +02:00
|
|
|
model = self.services_treeview.get_model()
|
2005-03-28 01:00:01 +02:00
|
|
|
if not model.get_iter_first():
|
|
|
|
# we begin to fill the treevier with the first line
|
2005-04-23 23:54:12 +02:00
|
|
|
iter = model.append(None, (jid, jid, node))
|
2005-03-28 01:00:01 +02:00
|
|
|
self.agent_infos[jid] = {'features' : []}
|
2005-04-23 23:54:12 +02:00
|
|
|
gajim.connections[self.account].request_agents(jid, node)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def agents(self, agents):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When list of available agent arrive :
|
|
|
|
Fill the treeview with it'''
|
2005-03-28 03:05:28 +02:00
|
|
|
model = self.services_treeview.get_model()
|
2004-09-06 16:55:10 +02:00
|
|
|
for agent in agents:
|
2005-04-23 23:54:12 +02:00
|
|
|
node = ''
|
|
|
|
if agent.has_key('node'):
|
|
|
|
node = agent['node']
|
|
|
|
iter = model.append(None, (agent['name'], agent['jid'], node))
|
|
|
|
self.agent_infos[agent['jid'] + node] = {'features' : []}
|
2005-03-27 11:08:31 +02:00
|
|
|
|
|
|
|
def iter_is_visible(self, iter):
|
|
|
|
if not iter:
|
|
|
|
return False
|
2005-03-28 03:05:28 +02:00
|
|
|
model = self.services_treeview.get_model()
|
2005-03-27 11:08:31 +02:00
|
|
|
iter = model.iter_parent(iter)
|
|
|
|
while iter:
|
2005-03-28 03:05:28 +02:00
|
|
|
if not self.services_treeview.row_expanded(model.get_path(iter)):
|
2005-03-27 11:08:31 +02:00
|
|
|
return False
|
|
|
|
iter = model.iter_parent(iter)
|
|
|
|
return True
|
|
|
|
|
2005-03-28 03:05:28 +02:00
|
|
|
def on_services_treeview_row_expanded(self, widget, iter, path):
|
|
|
|
model = self.services_treeview.get_model()
|
2005-03-27 11:08:31 +02:00
|
|
|
jid = model.get_value(iter, 1)
|
|
|
|
child = model.iter_children(iter)
|
|
|
|
while child:
|
|
|
|
child_jid = model.get_value(child, 1)
|
2005-04-23 23:54:12 +02:00
|
|
|
child_node = model.get_value(child, 2)
|
2005-03-27 11:08:31 +02:00
|
|
|
# We never requested its infos
|
2005-04-23 23:54:12 +02:00
|
|
|
if not self.agent_infos[child_jid + child_node].has_key('features'):
|
|
|
|
self.browse(child_jid, child_node)
|
2005-03-27 11:08:31 +02:00
|
|
|
child = model.iter_next(child)
|
2004-09-06 16:55:10 +02:00
|
|
|
|
2005-04-24 17:47:08 +02:00
|
|
|
def agent_info_info(self, agent, node, identities, features):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we recieve informations about an agent, but not its items'''
|
2005-04-24 17:47:08 +02:00
|
|
|
model = self.services_treeview.get_model()
|
|
|
|
iter = model.get_iter_root()
|
|
|
|
# We look if this agent is in the treeview
|
|
|
|
while (iter):
|
|
|
|
if agent == model.get_value(iter, 1) and node == model.get_value(
|
|
|
|
iter, 2):
|
|
|
|
break
|
|
|
|
if model.iter_has_child(iter):
|
|
|
|
iter = model.iter_children(iter)
|
|
|
|
else:
|
|
|
|
if not model.iter_next(iter):
|
|
|
|
iter = model.iter_parent(iter)
|
|
|
|
if iter:
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
if not iter: #If it is not we stop
|
|
|
|
return
|
|
|
|
self.agent_infos[agent + node]['features'] = features
|
|
|
|
if len(identities):
|
|
|
|
self.agent_infos[agent + node]['identities'] = identities
|
|
|
|
if identities[0].has_key('name'):
|
|
|
|
model.set_value(iter, 0, identities[0]['name'])
|
2005-03-27 12:31:26 +02:00
|
|
|
|
2005-04-23 23:54:12 +02:00
|
|
|
def agent_info_items(self, agent, node, items):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we recieve items about an agent'''
|
2005-03-28 03:05:28 +02:00
|
|
|
model = self.services_treeview.get_model()
|
2005-03-27 12:31:26 +02:00
|
|
|
iter = model.get_iter_root()
|
|
|
|
# We look if this agent is in the treeview
|
|
|
|
while (iter):
|
2005-04-23 23:54:12 +02:00
|
|
|
if agent == model.get_value(iter, 1) and node == model.get_value(
|
|
|
|
iter, 2):
|
2005-03-27 12:31:26 +02:00
|
|
|
break
|
|
|
|
if model.iter_has_child(iter):
|
|
|
|
iter = model.iter_children(iter)
|
|
|
|
else:
|
|
|
|
if not model.iter_next(iter):
|
|
|
|
iter = model.iter_parent(iter)
|
|
|
|
if iter:
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
if not iter: #If it is not, we stop
|
|
|
|
return
|
2005-03-27 20:02:23 +02:00
|
|
|
expand = False
|
|
|
|
if len(model.get_path(iter)) == 1:
|
|
|
|
expand = True
|
2005-03-27 12:31:26 +02:00
|
|
|
for item in items:
|
2005-03-30 22:06:01 +02:00
|
|
|
name = ''
|
|
|
|
if item.has_key('name'):
|
|
|
|
name = item['name']
|
2005-04-23 23:54:12 +02:00
|
|
|
node = ''
|
|
|
|
if item.has_key('node'):
|
|
|
|
node = item['node']
|
2005-03-27 12:31:26 +02:00
|
|
|
# We look if this item is already in the treeview
|
|
|
|
iter_child = model.iter_children(iter)
|
|
|
|
while iter_child:
|
2005-04-23 23:54:12 +02:00
|
|
|
if item['jid'] == model.get_value(iter_child, 1) and \
|
|
|
|
node == model.get_value(iter_child, 2):
|
2005-03-27 12:31:26 +02:00
|
|
|
break
|
|
|
|
iter_child = model.iter_next(iter_child)
|
|
|
|
if not iter_child: # If it is not we add it
|
2005-04-23 23:54:12 +02:00
|
|
|
iter_child = model.append(iter, (name, item['jid'], node))
|
|
|
|
self.agent_infos[item['jid'] + node] = {'identities': [item]}
|
2005-03-27 20:02:23 +02:00
|
|
|
if self.iter_is_visible(iter_child) or expand:
|
2005-04-23 23:54:12 +02:00
|
|
|
self.browse(item['jid'], node)
|
2005-03-27 20:02:23 +02:00
|
|
|
if expand:
|
2005-03-28 03:05:28 +02:00
|
|
|
self.services_treeview.expand_row((model.get_path(iter)), False)
|
2005-03-27 12:31:26 +02:00
|
|
|
|
2004-09-06 16:55:10 +02:00
|
|
|
def agent_info(self, agent, identities, features, items):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we recieve informations about an agent'''
|
2005-04-24 17:47:08 +02:00
|
|
|
self.agent_info_info(agent, '', identities, features)
|
|
|
|
self.agent_info_items(agent, '', items)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 19:27:21 +01:00
|
|
|
def on_refresh_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When refresh button is clicked: refresh list: clear and rerequest it'''
|
2005-03-28 03:05:28 +02:00
|
|
|
self.services_treeview.get_model().clear()
|
2005-03-27 11:08:31 +02:00
|
|
|
jid = self.address_comboboxentry.child.get_text()
|
|
|
|
self.browse(jid)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-29 23:28:58 +02:00
|
|
|
def on_address_comboboxentry_changed(self, widget):
|
|
|
|
return # not ready
|
|
|
|
'is executed on each keypress'
|
|
|
|
text = self.comboboxentry_entry.get_text()
|
|
|
|
self.on_go_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_address_comboboxentry_button_press_event(self, widget, event):
|
|
|
|
return # not ready
|
|
|
|
if event.click == 1: #Left click (user possibly selected sth)
|
|
|
|
pass
|
2005-04-07 00:03:12 +02:00
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_services_treeview_row_activated(self, widget, path, col = 0):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When a row is activated: Register or join the selected agent'''
|
2005-03-28 03:05:28 +02:00
|
|
|
#if both buttons are sensitive, it will register [default]
|
|
|
|
if self.register_button.get_property('sensitive'):
|
|
|
|
self.on_register_button_clicked(widget)
|
|
|
|
elif self.join_button.get_property('sensitive'):
|
|
|
|
self.on_join_button_clicked(widget)
|
2004-09-06 16:55:10 +02:00
|
|
|
|
|
|
|
def on_join_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we want to join a conference:
|
|
|
|
Ask specific informations about the selected agent and close the window'''
|
2005-03-28 03:05:28 +02:00
|
|
|
model, iter = self.services_treeview.get_selection().get_selected()
|
2004-12-23 14:28:00 +01:00
|
|
|
if not iter:
|
|
|
|
return
|
2004-09-06 16:55:10 +02:00
|
|
|
service = model.get_value(iter, 1)
|
|
|
|
room = ''
|
2005-03-05 22:02:38 +01:00
|
|
|
if service.find('@') > -1:
|
|
|
|
services = service.split('@')
|
2004-09-06 16:55:10 +02:00
|
|
|
room = services[0]
|
|
|
|
service = services[1]
|
2005-04-07 13:25:59 +02:00
|
|
|
if not self.plugin.windows[self.account].has_key('join_gc'):
|
2005-04-18 14:17:43 +02:00
|
|
|
dialogs.Join_groupchat_window(self.plugin, self.account, service, room)
|
2005-04-07 13:25:59 +02:00
|
|
|
else:
|
|
|
|
self.plugin.windows[self.account]['join_gc'].window.present()
|
2004-09-06 16:55:10 +02:00
|
|
|
|
|
|
|
def on_register_button_clicked(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we want to register an agent :
|
|
|
|
Ask specific informations about the selected agent and close the window'''
|
2005-03-28 03:05:28 +02:00
|
|
|
model, iter = self.services_treeview.get_selection().get_selected()
|
2004-12-23 14:28:00 +01:00
|
|
|
if not iter :
|
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
service = model.get_value(iter, 1)
|
2005-04-14 09:05:10 +02:00
|
|
|
infos = gajim.connections[self.account].ask_register_agent_info(service)
|
2005-04-21 23:06:33 +02:00
|
|
|
if infos.has_key('instructions'):
|
2005-04-21 23:14:53 +02:00
|
|
|
Service_registration_window(service, infos, self.plugin, self.account)
|
2005-04-12 23:09:06 +02:00
|
|
|
else:
|
2005-04-21 23:06:33 +02:00
|
|
|
dialogs.Error_dialog(_('error contacting %s') % service)
|
|
|
|
|
2005-04-12 17:30:09 +02:00
|
|
|
self.window.destroy()
|
2004-09-06 16:55:10 +02:00
|
|
|
|
2005-03-28 03:05:28 +02:00
|
|
|
def on_services_treeview_cursor_changed(self, widget):
|
2005-04-18 14:17:43 +02:00
|
|
|
'''When we select a row :
|
|
|
|
activate buttons if needed'''
|
2005-04-18 11:25:12 +02:00
|
|
|
self.join_button.set_sensitive(False)
|
|
|
|
self.register_button.set_sensitive(False)
|
2005-03-28 03:05:28 +02:00
|
|
|
model, iter = self.services_treeview.get_selection().get_selected()
|
2005-04-18 11:25:12 +02:00
|
|
|
if not iter: return
|
2004-09-06 16:55:10 +02:00
|
|
|
jid = model.get_value(iter, 1)
|
2005-04-23 23:54:12 +02:00
|
|
|
node = model.get_value(iter, 2)
|
|
|
|
if self.agent_infos[jid + node].has_key('features'):
|
2005-04-26 20:45:54 +02:00
|
|
|
if common.xmpp.NS_REGISTER in self.agent_infos[jid + node] \
|
2005-04-23 23:54:12 +02:00
|
|
|
['features']:
|
2004-09-06 16:55:10 +02:00
|
|
|
self.register_button.set_sensitive(True)
|
2005-04-23 23:54:12 +02:00
|
|
|
if self.agent_infos[jid + node].has_key('identities'):
|
|
|
|
if len(self.agent_infos[jid + node]['identities']):
|
|
|
|
if self.agent_infos[jid + node]['identities'][0].has_key(
|
|
|
|
'category'):
|
|
|
|
if self.agent_infos[jid + node]['identities'][0]['category'] == \
|
|
|
|
'conference':
|
2004-09-06 16:55:10 +02:00
|
|
|
self.join_button.set_sensitive(True)
|
2005-03-27 11:08:31 +02:00
|
|
|
|
|
|
|
def on_go_button_clicked(self, widget):
|
2005-03-29 23:28:58 +02:00
|
|
|
server_address = self.address_comboboxentry.child.get_text()
|
|
|
|
if server_address in self.latest_addresses:
|
|
|
|
self.latest_addresses.remove(server_address)
|
|
|
|
self.latest_addresses.insert(0, server_address)
|
2005-03-27 11:19:06 +02:00
|
|
|
if len(self.latest_addresses) > 10:
|
|
|
|
self.latest_addresses = self.latest_addresses[0:10]
|
2005-03-27 11:08:31 +02:00
|
|
|
self.address_comboboxentry.get_model().clear()
|
|
|
|
for j in self.latest_addresses:
|
|
|
|
self.address_comboboxentry.append_text(j)
|
2005-04-13 11:41:44 +02:00
|
|
|
gajim.config.set('latest_disco_addresses', \
|
|
|
|
' '.join(self.latest_addresses))
|
2005-03-28 03:05:28 +02:00
|
|
|
self.services_treeview.get_model().clear()
|
2005-03-29 23:28:58 +02:00
|
|
|
self.browse(server_address)
|
2005-04-12 17:30:09 +02:00
|
|
|
self.plugin.save_config()
|
2005-04-20 01:43:58 +02:00
|
|
|
|
2005-04-20 12:21:33 +02:00
|
|
|
class Groupchat_config_window:
|
|
|
|
'''Groupchat_config_window class'''
|
|
|
|
def __init__(self, plugin, account, room_jid, config):
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
self.room_jid = room_jid
|
|
|
|
self.config = config
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'groupchat_config_window', APP)
|
|
|
|
self.window = self.xml.get_widget('groupchat_config_window')
|
|
|
|
self.config_table = self.xml.get_widget('config_table')
|
|
|
|
self.fill_table()
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
|
|
|
def on_groupchat_config_window_destroy(self, widget):
|
|
|
|
del self.plugin.windows[self.account]['gc_config'][self.room_jid]
|
|
|
|
|
2005-04-21 00:30:04 +02:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-20 12:21:33 +02:00
|
|
|
self.window.destroy()
|
|
|
|
|
2005-04-21 00:30:04 +02:00
|
|
|
def on_change_button_clicked(self, widget):
|
2005-04-20 12:21:33 +02:00
|
|
|
gajim.connections[self.account].send_gc_config(self.room_jid, self.config)
|
2005-04-21 20:36:27 +02:00
|
|
|
self.window.destroy()
|
2005-04-20 12:21:33 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
widget.set_text(self.config[i]['values'][0])
|
|
|
|
max = 3
|
|
|
|
i += 1
|
|
|
|
if max < 4:
|
2005-04-22 03:05:31 +02:00
|
|
|
self.config_table.attach(widget, 1, max,
|
|
|
|
nbrows, nbrows + 1,
|
|
|
|
gtk.FILL | gtk.SHRINK)
|
2005-04-20 12:21:33 +02:00
|
|
|
widget = gtk.Label()
|
2005-04-22 03:05:31 +02:00
|
|
|
self.config_table.attach(widget, max, 4,
|
|
|
|
nbrows, nbrows + 1)
|
2005-04-20 12:21:33 +02:00
|
|
|
else:
|
2005-04-22 03:05:31 +02:00
|
|
|
self.config_table.attach(widget, 1, max,
|
|
|
|
nbrows, nbrows + 1)
|
2005-04-20 12:21:33 +02:00
|
|
|
self.config_table.show_all()
|
|
|
|
|
2005-04-20 01:43:58 +02:00
|
|
|
class Remove_account_window:
|
|
|
|
'''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):
|
|
|
|
'''close window'''
|
|
|
|
del self.plugin.windows[self.account]['remove_account']
|
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def __init__(self, plugin, account):
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'remove_account_window', APP)
|
|
|
|
self.window = xml.get_widget('remove_account_window')
|
|
|
|
self.remove_and_unregister_radiobutton = xml.get_widget(\
|
|
|
|
'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):
|
|
|
|
if gajim.connections[self.account].connected: #FIXME: user unfriendly??
|
|
|
|
gajim.connections[self.account].change_status('offline', 'offline')
|
|
|
|
|
|
|
|
unregister = False
|
|
|
|
if self.remove_and_unregister_radiobutton.get_active():
|
|
|
|
unregister = True
|
|
|
|
del gajim.connections[self.account]
|
|
|
|
gajim.config.del_per('accounts', self.account)
|
|
|
|
del self.plugin.windows[self.account]
|
|
|
|
del self.plugin.queues[self.account]
|
|
|
|
del self.plugin.roster.groups[self.account]
|
|
|
|
del self.plugin.roster.contacts[self.account]
|
|
|
|
del self.plugin.roster.to_be_removed[self.account]
|
2005-04-20 14:23:41 +02:00
|
|
|
del self.plugin.roster.newly_added[self.account]
|
2005-04-20 01:43:58 +02:00
|
|
|
self.plugin.roster.draw_roster()
|
2005-04-20 14:23:41 +02:00
|
|
|
if self.plugin.windows.has_key('accounts'):
|
|
|
|
self.plugin.windows['accounts'].init_accounts()
|
2005-04-20 01:43:58 +02:00
|
|
|
if unregister:
|
2005-04-20 14:23:41 +02:00
|
|
|
gajim.connections[self.account].remove_account()
|
2005-04-20 01:43:58 +02:00
|
|
|
self.window.destroy()
|