[turbine/implement-interface: 4/4] Implement "interfaces-model" manipulation
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [turbine/implement-interface: 4/4] Implement "interfaces-model" manipulation
- Date: Mon, 7 Sep 2009 15:40:19 +0000 (UTC)
commit b3e7865599209929f2811f191db535005848a53d
Author: Thomas Wood <thomas wood intel com>
Date: Mon Sep 7 16:40:41 2009 +0100
Implement "interfaces-model" manipulation
This allows users to add (or remove) interface classes that the object
should implement
src/turbine/__init__.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/turbine/__init__.py b/src/turbine/__init__.py
index 91cb05d..1f5120b 100755
--- a/src/turbine/__init__.py
+++ b/src/turbine/__init__.py
@@ -225,6 +225,38 @@ def about_button_clicked_cb (button, ui):
about.run ()
about.destroy ()
+def add_interface_cb (button, ui):
+ model = ui.get_object ("interfaces-model")
+ iter = model.append (["G_TYPE_OBJECT"])
+ treeview = ui.get_object ("interfaces-treeview")
+
+ column = treeview.get_column (0)
+ path = model.get_path (iter)
+
+ treeview.set_cursor (path, column, True)
+
+def remove_interface_cb (button, ui):
+ selection = ui.get_object ("interfaces-treeview").get_selection ()
+ (model, iter) = selection.get_selected ()
+ if (iter == None):
+ return
+ # move selection forward
+ newiter = model.iter_next (iter)
+ # or backward ...
+ if (newiter == None):
+ path = model.get_path (iter)
+ path = (path[0] - 1,)
+ if (path[0] >= 0):
+ newiter = model.get_iter (path)
+
+ if (newiter):
+ selection.select_iter (newiter)
+ if (iter):
+ model.remove (iter);
+
+def interface_edited_cb (cellrenderertext, path, new_text, ui):
+ model = ui.get_object ("interfaces-model")
+ model.set (model.get_iter (path), 0, new_text)
def main(argv = sys.argv, stdout=sys.stdout, stderr=sys.stderr):
ui = gtk.Builder()
@@ -244,5 +276,13 @@ def main(argv = sys.argv, stdout=sys.stdout, stderr=sys.stderr):
ui.get_object ('class_camel').connect ('changed', guess_class_params, ui)
ui.get_object ('parent_camel').connect ('changed', guess_parent_params, ui)
+ # implemented interfaces
+ ui.get_object ('add-interface-button').connect ('clicked',
+ add_interface_cb, ui)
+ ui.get_object ('remove-interface-button').connect ('clicked',
+ remove_interface_cb, ui)
+ ui.get_object ('interfaces-treeviewcell').connect ('edited',
+ interface_edited_cb, ui)
+
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]