2005-04-24 01:57:02 +02:00
|
|
|
## Advanced configuration window
|
|
|
|
##
|
|
|
|
## Gajim Team:
|
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## - Vincent Hanquez <tab@snarc.org>
|
2005-04-27 17:16:40 +02:00
|
|
|
## - Nikos Kouremenos <kourem@gmail.com>
|
2005-04-24 01:57:02 +02:00
|
|
|
##
|
|
|
|
## Copyright (C) 2003-2005 Gajim Team
|
|
|
|
##
|
|
|
|
## 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
|
|
|
|
import gtk.glade
|
|
|
|
import gobject
|
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
|
|
|
|
OPT_TYPE = 0
|
|
|
|
OPT_VAL = 1
|
|
|
|
|
|
|
|
GTKGUI_GLADE = 'gtkgui.glade'
|
|
|
|
|
|
|
|
class Advanced_window:
|
|
|
|
def on_config_edited(self, cell, row, text):
|
|
|
|
modelrow = self.model[row]
|
|
|
|
if gajim.config.set(modelrow[0], text):
|
|
|
|
return
|
|
|
|
modelrow[1] = text
|
|
|
|
|
2005-04-27 17:16:40 +02:00
|
|
|
def on_advanced_window_destroy(self, widget):
|
|
|
|
del self.plugin.windows['advanced_config']
|
2005-04-24 01:57:02 +02:00
|
|
|
|
2005-04-27 17:16:40 +02:00
|
|
|
def on_advanced_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
2005-04-24 01:57:02 +02:00
|
|
|
|
2005-04-27 21:03:28 +02:00
|
|
|
def find_iter(self, model, parent_iter, name):
|
2005-04-24 01:57:02 +02:00
|
|
|
if not parent_iter:
|
2005-04-27 21:03:28 +02:00
|
|
|
iter = model.get_iter_root()
|
2005-04-24 01:57:02 +02:00
|
|
|
else:
|
2005-04-27 21:03:28 +02:00
|
|
|
iter = model.iter_children(parent_iter)
|
2005-04-24 01:57:02 +02:00
|
|
|
while iter:
|
2005-04-27 21:03:28 +02:00
|
|
|
if model.get_value(iter, 0) == name:
|
2005-04-24 01:57:02 +02:00
|
|
|
break
|
2005-04-27 21:03:28 +02:00
|
|
|
iter = model.iter_next(iter)
|
2005-04-24 01:57:02 +02:00
|
|
|
return iter
|
|
|
|
|
2005-04-27 21:03:28 +02:00
|
|
|
def fill(self, model, name, parents, val):
|
2005-04-24 01:57:02 +02:00
|
|
|
iter = None
|
|
|
|
if parents:
|
|
|
|
for p in parents:
|
2005-04-27 21:03:28 +02:00
|
|
|
iter2 = self.find_iter(model, iter, p)
|
2005-04-24 01:57:02 +02:00
|
|
|
if iter2:
|
|
|
|
iter = iter2
|
|
|
|
|
|
|
|
if not val:
|
2005-04-27 21:03:28 +02:00
|
|
|
model.append(iter, [name, '', ''])
|
2005-04-24 01:57:02 +02:00
|
|
|
return
|
2005-04-27 21:03:28 +02:00
|
|
|
model.append(iter, [name, val[OPT_VAL], val[OPT_TYPE][0]])
|
2005-04-24 01:57:02 +02:00
|
|
|
|
|
|
|
def visible_func(self, model, iter, str):
|
2005-04-27 17:16:40 +02:00
|
|
|
if str is None or str == '':
|
2005-04-29 10:00:06 +02:00
|
|
|
return True # show all
|
2005-04-24 01:57:02 +02:00
|
|
|
name = model.get_value(iter, 0)
|
2005-04-27 21:03:28 +02:00
|
|
|
if name.find(str) != -1:
|
2005-04-27 17:16:40 +02:00
|
|
|
return True
|
|
|
|
return False
|
2005-04-24 01:57:02 +02:00
|
|
|
|
2005-04-27 17:16:40 +02:00
|
|
|
def on_advanced_entry_changed(self, widget):
|
|
|
|
text = widget.get_text()
|
|
|
|
|
|
|
|
def __init__(self, plugin):
|
|
|
|
self.plugin = plugin
|
2005-04-24 01:57:02 +02:00
|
|
|
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'advanced_window', None)
|
2005-04-27 17:16:40 +02:00
|
|
|
self.window = self.xml.get_widget('advanced_window')
|
2005-04-24 01:57:02 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
|
|
|
|
treeview = self.xml.get_widget('advanced_treeview')
|
|
|
|
self.model = gtk.TreeStore(gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING)
|
2005-04-25 17:23:11 +02:00
|
|
|
self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
2005-04-24 01:57:02 +02:00
|
|
|
|
|
|
|
renderer_text = gtk.CellRendererText()
|
2005-04-25 17:23:11 +02:00
|
|
|
treeview.insert_column_with_attributes(-1, 'Preference Name',
|
2005-04-24 01:57:02 +02:00
|
|
|
renderer_text, text = 0)
|
|
|
|
|
|
|
|
renderer_text = gtk.CellRendererText()
|
2005-04-25 17:23:11 +02:00
|
|
|
renderer_text.set_property('editable', 1)
|
2005-04-24 01:57:02 +02:00
|
|
|
renderer_text.connect('edited', self.on_config_edited)
|
2005-04-27 17:16:40 +02:00
|
|
|
col = treeview.insert_column_with_attributes(-1, 'Value',
|
2005-04-24 01:57:02 +02:00
|
|
|
renderer_text, text = 1)
|
2005-04-27 17:16:40 +02:00
|
|
|
|
|
|
|
col.set_max_width(250)
|
2005-04-24 01:57:02 +02:00
|
|
|
|
|
|
|
renderer_text = gtk.CellRendererText()
|
2005-04-25 17:23:11 +02:00
|
|
|
treeview.insert_column_with_attributes(-1, 'Type',
|
2005-04-24 01:57:02 +02:00
|
|
|
renderer_text, text = 2)
|
|
|
|
|
|
|
|
# add data to model
|
2005-04-27 21:03:28 +02:00
|
|
|
gajim.config.foreach(self.fill, self.model)
|
2005-04-27 17:16:40 +02:00
|
|
|
|
2005-04-27 21:03:28 +02:00
|
|
|
treeview.set_model(self.model)
|
2005-04-27 17:16:40 +02:00
|
|
|
|
|
|
|
self.plugin.windows['advanced_config'] = self
|
|
|
|
self.window.show_all()
|