[dots/remove-assistant: 25/38] table_editor: refactor TableEditor class
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 25/38] table_editor: refactor TableEditor class
- Date: Thu, 15 Jul 2010 21:09:05 +0000 (UTC)
commit 4abb9be3e2f3ea0131d1d8c30641c8b835605455
Author: Fernando Herrera <fherrera onirica com>
Date: Mon Jul 12 22:30:43 2010 +0200
table_editor: refactor TableEditor class
dots/table_editor.py | 109 ++++++++++++++++++++++++++------------------------
1 files changed, 57 insertions(+), 52 deletions(-)
---
diff --git a/dots/table_editor.py b/dots/table_editor.py
index b73e35c..acc9857 100755
--- a/dots/table_editor.py
+++ b/dots/table_editor.py
@@ -21,6 +21,8 @@
# * saving
# * translate non UTF-8 entries
# * check "=" in dots
+# * Hovers with intrustions (or label)
+# * i18n
import os
@@ -354,58 +356,61 @@ def remove_clicked(button, view):
model, iter = selection.get_selected()
model.remove(iter)
-
-
-window = gtk.Window(gtk.WINDOW_TOPLEVEL)
-window.set_title("Liblouis Table Editor")
-window.set_size_request(600, 600)
-liststore = gtk.ListStore(str, str)
-
-if argv[1]:
- parser = Parser (argv[1])
-else:
- parser = Parser ("/opt/gnome/share/liblouis/tables/Es-Es-g1.utb")
-entries = parser.get_entries()
-for e in entries:
- iter = liststore.append ([e['opcode'], e['operands']])
-
-treeview = gtk.TreeView(liststore)
-tvcolumn = gtk.TreeViewColumn('opcode')
-treeview.append_column(tvcolumn)
-cell = gtk.CellRendererText()
-tvcolumn.pack_start(cell, True)
-tvcolumn.add_attribute(cell, 'text', 0)
-
-tvcolumn = gtk.TreeViewColumn('operands')
-treeview.append_column(tvcolumn)
-cell = gtk.CellRendererText()
-tvcolumn.pack_start(cell, True)
-tvcolumn.add_attribute(cell, 'text', 1)
-
-treeview.connect("button-press-event", row_clicked)
-
-scrolledwindow = gtk.ScrolledWindow ()
-scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-scrolledwindow.add(treeview)
-
-vbox = gtk.VBox ()
-buttonbox = gtk.HButtonBox()
-buttonbox.set_layout(gtk.BUTTONBOX_START)
-button = gtk.Button("Add")
-button.connect("clicked", add_clicked, treeview)
-buttonbox.pack_start(button, False, False, 6)
-button = gtk.Button("Remove")
-button.connect("clicked", remove_clicked, treeview)
-buttonbox.pack_start(button, False, False, 6)
-vbox.pack_start(scrolledwindow, True, True, 6)
-vbox.pack_start(buttonbox, False, False, 6)
-
-
-window.add(vbox)
-window.show_all()
-gtk.main()
+class TableEditor(gtk.Window):
+ def __init__(self, table, type=gtk.WINDOW_TOPLEVEL):
+ gtk.Window.__init__(self, type)
+ self.set_title("Liblouis Table Editor")
+ self.set_size_request(600, 600)
+ liststore = gtk.ListStore(str, str)
+ parser = Parser (table)
+ entries = parser.get_entries()
+ for e in entries:
+ iter = liststore.append ([e['opcode'], e['operands']])
+
+ treeview = gtk.TreeView(liststore)
+ tvcolumn = gtk.TreeViewColumn('opcode')
+ treeview.append_column(tvcolumn)
+ cell = gtk.CellRendererText()
+ tvcolumn.pack_start(cell, True)
+ tvcolumn.add_attribute(cell, 'text', 0)
-
-
+ tvcolumn = gtk.TreeViewColumn('operands')
+ treeview.append_column(tvcolumn)
+ cell = gtk.CellRendererText()
+ tvcolumn.pack_start(cell, True)
+ tvcolumn.add_attribute(cell, 'text', 1)
+
+ treeview.connect("button-press-event", row_clicked)
+ scrolledwindow = gtk.ScrolledWindow ()
+ scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scrolledwindow.add(treeview)
+
+ vbox = gtk.VBox ()
+ buttonbox = gtk.HButtonBox()
+ buttonbox.set_layout(gtk.BUTTONBOX_START)
+ button = gtk.Button("Add")
+ button.connect("clicked", add_clicked, treeview)
+ buttonbox.pack_start(button, False, False, 6)
+ button = gtk.Button("Remove")
+ button.connect("clicked", remove_clicked, treeview)
+ buttonbox.pack_start(button, False, False, 6)
+ vbox.pack_start(scrolledwindow, True, True, 6)
+ vbox.pack_start(buttonbox, False, False, 6)
+
+
+ self.add(vbox)
+
+if __name__ == "__main__":
+
+ if argv[1]:
+ file = argv[1]
+ else:
+ file = "/opt/gnome/share/liblouis/tables/Es-Es-g1.utb"
+
+ te = TableEditor(file)
+ te.show_all()
+ gtk.main()
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]