This commit is contained in:
Родитель
22087645ee
Коммит
21abc04361
|
@ -1,3 +1,24 @@
|
|||
# vim:set noet ts=4:
|
||||
#
|
||||
# ibus - The Input Bus
|
||||
#
|
||||
# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
# Boston, MA 02111-1307 USA
|
||||
|
||||
from os import path
|
||||
import gtk
|
||||
import gobject
|
||||
|
@ -9,8 +30,9 @@ import dbus.mainloop.glib
|
|||
NAME_COLUMN,
|
||||
ENABLE_COLUMN,
|
||||
VISIBLE_COLUMN,
|
||||
ICON_COLUMN,
|
||||
DATA_COLUMN,
|
||||
) = range (4)
|
||||
) = range (5)
|
||||
|
||||
class Setup:
|
||||
def __init__ (self):
|
||||
|
@ -22,22 +44,38 @@ class Setup:
|
|||
self._tree = self._xml.get_widget ("treeview_engines")
|
||||
model = self.__create_model ()
|
||||
self._tree.set_model (model)
|
||||
|
||||
|
||||
# add icon search path
|
||||
icon_theme = gtk.icon_theme_get_default ()
|
||||
dir = path.dirname (__file__)
|
||||
icondir = path.join (dir, "..", "icons")
|
||||
icon_theme.prepend_search_path (icondir)
|
||||
|
||||
# column for holiday names
|
||||
column = gtk.TreeViewColumn ()
|
||||
column.set_title ("Name")
|
||||
|
||||
renderer = gtk.CellRendererPixbuf()
|
||||
renderer.set_property("xalign", 0.0)
|
||||
|
||||
column.pack_start (renderer)
|
||||
column.set_attributes (renderer, icon_name = ICON_COLUMN, visible = VISIBLE_COLUMN)
|
||||
|
||||
renderer = gtk.CellRendererText()
|
||||
renderer.set_property("xalign", 0.0)
|
||||
|
||||
#col_offset = gtk.TreeViewColumn("Holiday", renderer, text=HOLIDAY_NAME_COLUMN)
|
||||
column = gtk.TreeViewColumn("Name", renderer, text = NAME_COLUMN)
|
||||
|
||||
# column.set_clickable(True)
|
||||
column.pack_start (renderer)
|
||||
column.set_attributes (renderer, text = NAME_COLUMN)
|
||||
|
||||
self._tree.append_column(column)
|
||||
|
||||
|
||||
# column for holiday names
|
||||
renderer = gtk.CellRendererToggle()
|
||||
renderer.set_data ('column', ENABLE_COLUMN)
|
||||
renderer.set_property("xalign", 0.0)
|
||||
renderer.connect("toggled", self.__item_toggled_cb, model)
|
||||
|
||||
|
||||
#col_offset = gtk.TreeViewColumn("Holiday", renderer, text=HOLIDAY_NAME_COLUMN)
|
||||
column = gtk.TreeViewColumn("Started", renderer, active = ENABLE_COLUMN, visible = VISIBLE_COLUMN)
|
||||
column.set_clickable(True)
|
||||
|
@ -48,11 +86,11 @@ class Setup:
|
|||
model = self.__create_model ()
|
||||
|
||||
def __item_toggled_cb (self, cell, path_str, model):
|
||||
|
||||
|
||||
# get toggled iter
|
||||
iter = model.get_iter_from_string(path_str)
|
||||
data = model.get_value (iter, DATA_COLUMN)
|
||||
|
||||
|
||||
# do something with the value
|
||||
if data[6] == False:
|
||||
try:
|
||||
|
@ -73,17 +111,18 @@ class Setup:
|
|||
dlg.run ()
|
||||
return
|
||||
data[6] = not data[6]
|
||||
|
||||
|
||||
# set new value
|
||||
model.set(iter, ENABLE_COLUMN, data[6])
|
||||
|
||||
|
||||
|
||||
|
||||
def __create_model (self):
|
||||
# create tree store
|
||||
model = gtk.TreeStore (
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN,
|
||||
gobject.TYPE_BOOLEAN,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_PYOBJECT)
|
||||
|
||||
langs = {}
|
||||
|
@ -102,6 +141,7 @@ class Setup:
|
|||
NAME_COLUMN, key,
|
||||
ENABLE_COLUMN, False,
|
||||
VISIBLE_COLUMN, False,
|
||||
ICON_COLUMN, None,
|
||||
DATA_COLUMN, None)
|
||||
langs[key].sort ()
|
||||
for name, lang, icon, author, credits, _exec, started in langs[key]:
|
||||
|
@ -110,6 +150,7 @@ class Setup:
|
|||
NAME_COLUMN, name,
|
||||
ENABLE_COLUMN, started,
|
||||
VISIBLE_COLUMN, True,
|
||||
ICON_COLUMN, icon,
|
||||
DATA_COLUMN,
|
||||
[name, lang, icon, author, credits, _exec, started])
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.4 on Thu Jul 10 13:36:06 2008 -->
|
||||
<!--Generated with glade3 3.4.4 on Thu Jul 10 15:52:05 2008 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkDialog" id="dialog_setup">
|
||||
<property name="border_width">5</property>
|
||||
|
|
Загрузка…
Ссылка в новой задаче