From 34cbd78b9c29737177a568c10c12bc42e49528d7 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Sat, 23 Apr 2005 23:57:02 +0000 Subject: [PATCH] add advanced window as a new dialog. the position of the button is probably not the final position. modify config to support boolean value embedded in string because the treestore store/edit all value with a string. --- src/advanced.py | 113 ++++++++++++++++++++++ src/common/config.py | 5 + src/config.py | 3 + src/dialogs.py | 1 + src/gtkgui.glade | 219 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 337 insertions(+), 4 deletions(-) create mode 100644 src/advanced.py diff --git a/src/advanced.py b/src/advanced.py new file mode 100644 index 000000000..3cc4e6c4a --- /dev/null +++ b/src/advanced.py @@ -0,0 +1,113 @@ +## Advanced configuration window +## +## Gajim Team: +## - Yann Le Boulanger +## - Vincent Hanquez +## +## 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 + + def on_close(self): + window = self.xml.get_widget('advanced_window') + window.destroy() + + def on_advanced_window_delete_event(self, widget, data = None): + self.on_close() + + def on_advanced_window_destroy_event(self, widget, data = None): + self.on_close() + + def on_advanced_close_button_clicked(self, widget, data = None): + self.on_close() + + def find_iter(self, parent_iter, name): + if not parent_iter: + iter = self.model.get_iter_root() + else: + iter = self.model.iter_children(parent_iter) + while iter: + if self.model.get_value(iter, 0) == name: + break + iter = self.model.iter_next(iter) + return iter + + def fill(self, name, parents, val): + iter = None + if parents: + for p in parents: + iter2 = self.find_iter(iter, p) + if iter2: + iter = iter2 + + if not val: + self.model.append(iter, [name, "", ""]) + return + self.model.append(iter, [name, val[OPT_VAL], val[OPT_TYPE][0]]) + + def visible_func(self, model, iter, str): + name = model.get_value(iter, 0) + if str == None or str == "": + return 1 + if name.find(str) == -1: + return 1 + return 0 + + def filter(self, filterstr): + modelfilter = self.model.filter_new() + modelfilter.set_visible_func(self.visible_func, filterstr) + modelfilter.refilter() + + def __init__(self): + self.xml = gtk.glade.XML(GTKGUI_GLADE, 'advanced_window', None) + 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) + treeview.set_model(self.model) + + renderer_text = gtk.CellRendererText() + treeview.insert_column_with_attributes(-1, "Preference Name", + renderer_text, text = 0) + + renderer_text = gtk.CellRendererText() + renderer_text.set_property("editable", 1) + renderer_text.connect('edited', self.on_config_edited) + treeview.insert_column_with_attributes(-1, "Value", + renderer_text, text = 1) + + renderer_text = gtk.CellRendererText() + treeview.insert_column_with_attributes(-1, "Type", + renderer_text, text = 2) + + # add data to model + gajim.config.foreach(self.fill) + diff --git a/src/common/config.py b/src/common/config.py index 7411bd89d..100aa3333 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -244,6 +244,11 @@ class Config: # print 'error: option %s doesn\'t exist' % (optname) return -1 opt = self.__options[optname] + if opt[OPT_TYPE][0] == 'boolean': + if value == 'True': + value = True + elif value == 'False': + value = False if not self.is_valid(opt[OPT_TYPE], value): return -1 diff --git a/src/config.py b/src/config.py index 6182e5b37..baf200948 100644 --- a/src/config.py +++ b/src/config.py @@ -512,6 +512,9 @@ class Preferences_window: model.set_value(iter, 2, file) model.set_value(iter, 1, 1) + def on_open_advanced_editor_button_clicked(self, widget, data = None): + dialogs.Advanced_window() + def __init__(self, plugin): '''Initialize Preferences window''' self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP) diff --git a/src/dialogs.py b/src/dialogs.py index 01f55d269..83e1f5c58 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -24,6 +24,7 @@ from gajim import User from common import gajim from common import i18n from vcard import Vcard_window +from advanced import Advanced_window _ = i18n._ APP = i18n.APP gtk.glade.bindtextdomain (APP, i18n.DIR) diff --git a/src/gtkgui.glade b/src/gtkgui.glade index ee364127b..d5e96d95b 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -5909,10 +5909,6 @@ Custom False - - - - @@ -5947,6 +5943,65 @@ Custom True + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 0.230000004172 + 0 + 0 + 0 + 12 + 0 + + + + True + True + Open + True + GTK_RELIEF_NORMAL + True + + + + + + + + + True + <b>Advanced Configuration Editor</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + False @@ -11074,4 +11129,160 @@ send a chat message to + + 4 + 600 + 480 + True + Advanced Configuration Editor + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + + + + + + 5 + True + False + 10 + + + + True + 2 + 2 + False + 5 + 5 + + + + True + Filter: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + 2 + 1 + 2 + fill + + + + + 0 + True + True + + + + + + True + + + 0 + False + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + False + True + + + + + +