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.
This commit is contained in:
Vincent Hanquez 2005-04-23 23:57:02 +00:00
parent e0ac8948aa
commit 34cbd78b9c
5 changed files with 337 additions and 4 deletions

113
src/advanced.py Normal file
View File

@ -0,0 +1,113 @@
## Advanced configuration window
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
##
## 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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -5909,10 +5909,6 @@ Custom</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
@ -5947,6 +5943,65 @@ Custom</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame31">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkAlignment" id="alignment64">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0.230000004172</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkButton" id="open_advanced_editor_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Open</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_open_advanced_editor_button_clicked" last_modification_time="Sat, 23 Apr 2005 12:14:06 GMT"/>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label247">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Advanced Configuration Editor&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
@ -11074,4 +11129,160 @@ send a chat message to</property>
</child>
</widget>
<widget class="GtkWindow" id="advanced_window">
<property name="border_width">4</property>
<property name="width_request">600</property>
<property name="height_request">480</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Advanced Configuration Editor</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="delete_event" handler="on_advanced_window_delete_event" last_modification_time="Sat, 23 Apr 2005 23:46:31 GMT"/>
<signal name="destroy_event" handler="on_advanced_window_destroy_event" last_modification_time="Sat, 23 Apr 2005 23:46:44 GMT"/>
<child>
<widget class="GtkVBox" id="vbox70">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkTable" id="table26">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">5</property>
<property name="column_spacing">5</property>
<child>
<widget class="GtkLabel" id="label248">
<property name="visible">True</property>
<property name="label" translatable="yes">Filter:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="advanced_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow36">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="advanced_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator14">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox18">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="advanced_close_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_advanced_close_button_clicked" last_modification_time="Sat, 23 Apr 2005 12:20:30 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>