[dots/remove-assistant: 3/38] Table selector
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 3/38] Table selector
- Date: Thu, 15 Jul 2010 21:07:14 +0000 (UTC)
commit 99389e0dc5782a8c2e097cfd44ca3f0bb74f4bd5
Author: Fernando Herrera <fherrera onirica com>
Date: Thu Jul 8 04:58:39 2010 +0200
Table selector
data/app_window.xml | 39 +++++++++++++++++++++++----
dots/Makefile.am | 1 -
dots/app_window.py | 72 +++++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 94 insertions(+), 18 deletions(-)
---
diff --git a/data/app_window.xml b/data/app_window.xml
index 0fb4ebb..3b25a58 100644
--- a/data/app_window.xml
+++ b/data/app_window.xml
@@ -24,8 +24,8 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_open</property>
+ <property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -33,8 +33,8 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem3">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_save</property>
+ <property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -42,8 +42,8 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem4">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_save_as</property>
+ <property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -56,8 +56,8 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem5">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_quit</property>
+ <property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -142,6 +142,33 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="menuitem5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Translation</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu5">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuItem" id="tables_menuitem">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Table</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Format...</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="_OnTranslationFormatActivate"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
@@ -173,8 +200,8 @@
<child>
<object class="GtkToolButton" id="toolbutton1">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_open</property>
+ <property name="use_action_appearance">True</property>
<property name="label" translatable="yes">toolbutton1</property>
<property name="use_underline">True</property>
</object>
@@ -186,8 +213,8 @@
<child>
<object class="GtkToolButton" id="toolbutton2">
<property name="visible">True</property>
- <property name="use_action_appearance">True</property>
<property name="related_action">action_save</property>
+ <property name="use_action_appearance">True</property>
<property name="label" translatable="yes">toolbutton2</property>
<property name="use_underline">True</property>
</object>
diff --git a/dots/Makefile.am b/dots/Makefile.am
index 5a196ee..e0c9f1b 100644
--- a/dots/Makefile.am
+++ b/dots/Makefile.am
@@ -5,7 +5,6 @@ dots_PYTHON = \
ascii_braille.py \
app_window.py \
dots_project.py \
- import_assistant.py \
host_settings.py \
config_builder.py \
document.py \
diff --git a/dots/app_window.py b/dots/app_window.py
index b319fda..a8a7ecf 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -32,6 +32,66 @@ class AppWindow(object):
self.main_xml.get_object('main_alignment').add(self.main_notebook)
self.main_xml.connect_signals(self)
self.config_builder = ConfigBuilder()
+ self.loadConfig()
+
+ def loadConfig(self):
+ #FIXME Load this from gconf. Populate to UI
+ self.config_builder['xml']['semanticFiles'] = '*'
+ self.config_builder['xml']['semanticFiles'] += ',nemeth.sem'
+ self.config_builder['xml']['internetAccess'] = 'yes'
+ self.config_builder['translation']['literaryTextTable'] = "Es-Es-g1.utb"
+ self.config_builder['outputFormat']['cellsPerLine'] = 40
+ self.config_builder['outputFormat']['braillePages'] = 'yes'
+ self.config_builder['outputFormat']['formatFor'] = 'textDevice'
+ self.config_builder['outputFormat']['LinesPerPage'] = 25
+ self.config_builder['outputFormat']['braillePageNumberAt'] = 'bottom'
+ self._populateTablesMenu()
+
+
+ def _addTable(self, submenu, group, table):
+ print "Adding table %s to menu %s with group %s submenu" % (table, submenu, group)
+ tableitem = gtk.RadioMenuItem(group, table[:-4])
+ tableitem.connect("activate", self._onTableActivate, table)
+ submenu.append (tableitem)
+ return tableitem
+
+ def _onTableOtherActivate(self, item, group):
+
+ eitem = self._addTable(self.submenu, group, "CHOCHOCHO.txt")
+ chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
+ response = chooser.run()
+ filename = chooser.get_filename()
+ chooser.destroy()
+ if response == gtk.RESPONSE_OK:
+ eitem = self._addTable (self.submenu, group, filename)
+ eitem.activate()
+
+ def _onTableActivate(self, item, table):
+ print table
+ self.config_builder['translation']['literaryTextTable']
+
+
+
+ def _populateTablesMenu(self):
+ def _sepatatorFunc(model, itr):
+ return model[itr][0] == None
+ menuitem = self.main_xml.get_object('tables_menuitem')
+ #Fixme, dont make this global, use get_menu at _onTableOtherActivate
+ self.submenu = gtk.Menu()
+ table_list = filter(lambda x: x.endswith('ctb') or x.endswith('utb'),
+ os.listdir(host_settings.tablesdir))
+ table_list.sort()
+ group = None
+ for table in table_list:
+ group = self._addTable (self.submenu, group, table)
+
+ #othermenu = gtk.MenuItem("Other...")
+ #othermenu.connect_after("activate", self._onTableOtherActivate, group)
+ #self.submenu.append(othermenu)
+ #menuitem.set_submenu(self.submenu)
+
+
def _onOpen(self, action):
chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN,
@@ -62,17 +122,7 @@ class AppWindow(object):
if response == gtk.RESPONSE_OK:
print chooser.get_filename()
document = document_new (filename)
- config = ConfigBuilder()
- config['xml']['semanticFiles'] = '*'
- config['xml']['semanticFiles'] += ',nemeth.sem'
- config['xml']['internetAccess'] = 'yes'
- config['translation']['literaryTextTable'] = "Es-Es-g1.utb"
- config['outputFormat']['cellsPerLine'] = 40
- config['outputFormat']['braillePages'] = 'yes'
- config['outputFormat']['formatFor'] = 'textDevice'
- config['outputFormat']['LinesPerPage'] = 25
- config['outputFormat']['braillePageNumberAt'] = 'bottom'
- self.translate (document, config)
+ self.translate (document, self.config_builder)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]