[dots/remove-assistant: 16/38] Make entries in the table editor editable



commit 8d2273fcf6f664b6c749e0383bfed6099d1a0b22
Author: Fernando Herrera <fherrera onirica com>
Date:   Fri Jul 9 14:37:46 2010 +0200

    Make entries in the table editor editable

 dots/table_editor.py |  162 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 160 insertions(+), 2 deletions(-)
---
diff --git a/dots/table_editor.py b/dots/table_editor.py
index cd50a7d..bd93dc6 100755
--- a/dots/table_editor.py
+++ b/dots/table_editor.py
@@ -21,6 +21,141 @@ import os
 from sys import exit
 import host_settings
 
+def cell_started_editing (cell, editable, path, model, col):
+	iter = model.get_iter(path)
+	op = model.get_value (iter, 0)
+	if op == "include" and col > 1 and col < 3:
+		editable.set_property("editable", False)
+	else:
+		editable.set_property("editable", True)
+
+	
+def cell_edited (cell, path, text, model, col):
+	iter = model.get_iter(path)
+	model.set_value (iter, col, text)
+
+opcodes = {
+  "include": ["filename"],
+  "locale": ["characters"],
+  "capsign": ["dots"],
+  "begcaps": ["dots"],
+  "lenbegcaps": [],
+  "endcaps": ["dots"],
+  "firstwordcaps": [],
+  "lastwordaftercaps": [],
+  "lencapsphrase": [],
+  "letsign": ["dots"],
+  "noletsignbefore": ["characters"],
+  "noletsign": ["letters"],
+  "noletsignafter": ["characters"],
+  "numsign": ["dots"],
+  "firstwordital": ["dots"],
+  "italsign": ["dots"],
+  "lastworditalbefore": ["dots"],
+  "lastworditalafter": ["dots"],
+  "begital": ["dots"],
+  "firstletterital": ["dots"],
+  "endital": ["dots"],
+  "lastletterital": ["dots"],
+  "singleletterital": ["dots"],
+  "italword": [],
+  "lenitalphrase": ["number"],
+  "firstwordbold": ["dots"],
+  "boldsign": ["dots"],
+  "lastwordboldbefore": ["dots"],
+  "lastwordboldafter": ["dots"],
+  "begbold": ["dots"],
+  "firstletterbold": ["dots"],
+  "endbold": ["dots"],
+  "lastletterbold": ["dots"],
+  "singleletterbold": ["dots"],
+  "boldword": [],
+  "lenboldphrase": ["number"],
+  "firstwordunder": ["dots"],
+  "undersign": ["dots"],
+  "lastwordunderbefore": ["dots"],
+  "lastwordunderafter": ["dots"],
+  "begunder": ["dots"],
+  "firstletterunder": ["dots"],
+  "endunder": ["dots"],
+  "lastletterunder": ["dots"],
+  "singleletterunder": ["dots"],
+  "underword": [],
+  "lenunderphrase": ["number"],
+  "begcomp": ["dots"],
+  "compbegemph1": [],
+  "compendemph1": [],
+  "compbegemph2": [],
+  "compendemph2": [],
+  "compbegemph3": [],
+  "compendemph3": [],
+  "compcapsign": [],
+  "compbegcaps": [],
+  "compendcaps": [],
+  "endcomp": ["dots"],
+  "multind": ["dots" ,"opcode..."],
+  "compdots": [],
+  "comp6": ["character", "dots"],
+  "class": ["name", "character"],
+#Special ons using opcode!
+  "after": ["after", "class", "opcode"],
+  "before": ["after", "class", "opcode"],
+  "noback": ["opcode"],
+  "nofor": ["opcode"],
+  "swapcc": ["name", "characters", "dots,..."],
+  "swapcd": ["name", "dots...", "dotpattern..."],
+  "swapdd": ["name", "characters", "characters"],
+  "space": ["character", "dots"],
+  "digit": ["character", "dots"],
+  "punctuation": ["character", "dots"],
+  "math": ["character", "dots"],
+  "sign": ["character", "dots"],
+  "letter": ["characters", "dots"],
+  "uppercase": ["characters", "dots"],
+  "lowercase": ["character", "dots"],
+  "grouping": ["name", "characters", "dots,dots"],
+  "uplow": ["characters", "dots[,dots]"],
+  "litdigit": ["character", "dots"],
+  "display": ["character", "dots"],
+  "replace": ["characters", "{characters}"],
+  "context": ["test", "action"],
+  "correct": ["test", "action"],
+  "pass2": ["test", "action"],
+  "pass3": ["test", "action"],
+  "pass4": ["test", "action"],
+  "repeated": ["characters", "dots"],
+  "repword": ["characters", "dots"],
+  "capsnocont": [],
+  "always": ["characters", "dots"],
+  "exactdots": ["characters", "dots"],
+  "nocross": ["characters", "dots"],
+  "syllable": ["characters", "dots"],
+  "nocont": ["characters"],
+  "compbrl": ["characters"],
+  "literal": ["characters"],
+  "largesign": ["characters", "dots"],
+  "word": ["characters", "dots"],
+  "partword": ["characters", "dots"],
+  "joinnum": ["characters", "dots"],
+  "joinword": ["characters", "dots"],
+  "lowword": ["characters", "dots"],
+  "contraction": ["characters"],
+  "sufword": ["characters", "dots"],
+  "prfword": ["characters", "dots"],
+  "begword": ["characters", "dots"],
+  "begmidword": ["characters", "dots"],
+  "midword": ["characters", "dots"],
+  "midendword": ["characters", "dots"],
+  "endword": ["characters", "dots"],
+  "prepunc": ["characters", "dots"],
+  "postpunc": ["characters", "dots"],
+  "begnum": ["characters", "dots"],
+  "midnum": ["characters", "dots"],
+  "endnum": ["characters", "dots"],
+  "decpoint": ["character", "dots"],
+  "hyphen": ["character", "dots"],
+  "nobreak": [] }
+
 
 filename = "/opt/gnome/share/liblouis/tables/Es-Es-g1.utb"
 lines = open(filename, 'r').readlines()
@@ -57,6 +192,8 @@ for e in entries:
 		print "\tcomment=" + e['comment']
 
 
+
+
 		
 import gtk
 
@@ -74,14 +211,35 @@ for e in entries:
 		liststore.set_value(iter, 4, e['comment'])
 
 treeview = gtk.TreeView(liststore)
-for i in range(4):
+tvcolumn = gtk.TreeViewColumn('Column 0')
+treeview.append_column(tvcolumn)
+cell = gtk.CellRendererCombo()
+combomodel = gtk.ListStore(str)
+for o in opcodes.keys():
+	combomodel.append ([o])
+cell.set_property ("editable", True)
+cell.set_property ("editable-set", True)
+cell.set_property ("model", combomodel)
+cell.set_property ("text-column", 0)
+cell.connect ("edited", cell_edited, liststore, 0)
+
+tvcolumn.pack_start(cell, True)
+tvcolumn.add_attribute(cell, 'text', 0)
+
+for i in [1,2,3]:
 	tvcolumn = gtk.TreeViewColumn('Column ' + str(i))
 	treeview.append_column(tvcolumn)
 	cell = gtk.CellRendererText()
+	cell.set_property ("editable", True)
+	cell.set_property ("editable-set", True)
+	cell.connect ("editing-started", cell_started_editing, liststore, i)
+	cell.connect ("edited", cell_edited, liststore, i)
 	tvcolumn.pack_start(cell, True)
 	tvcolumn.add_attribute(cell, 'text', i)
 
-window.add(treeview)
+scrolledwindow = gtk.ScrolledWindow ()
+scrolledwindow.add(treeview)
+window.add(scrolledwindow)
 window.show_all()
 gtk.main()
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]