[dots/remove-assistant: 31/38] Add an entry to choose an external table
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 31/38] Add an entry to choose an external table
- Date: Thu, 15 Jul 2010 21:09:35 +0000 (UTC)
commit 77990e390444d82d065ca0b000c7a6b110e701f5
Author: Fernando Herrera <fherrera onirica com>
Date: Wed Jul 14 22:01:20 2010 +0200
Add an entry to choose an external table
dots/app_window.py | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/dots/app_window.py b/dots/app_window.py
index 30b2264..d2ca4e8 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -35,9 +35,7 @@ class AppWindow(object):
self.project = None
self.document = None
self.main_xml = gtk.Builder()
- print host_settings.DOMAIN
self.main_xml.set_translation_domain(host_settings.DOMAIN)
- print host_settings.DOMAIN
self.main_xml.add_from_file (
os.path.join(host_settings.gtkbuilder_dir, 'app_window.xml'))
self.window = self.main_xml.get_object('window1')
@@ -122,12 +120,15 @@ class AppWindow(object):
dialog.hide()
- def _addTable(self, submenu, group, table):
+ def _addTable(self, submenu, group, table, prepend=False):
tableitem = gtk.RadioMenuItem(group, table[:-4])
tableitem.connect("activate", self._onTableActivate, table)
- submenu.append (tableitem)
+ if prepend:
+ submenu.prepend (tableitem)
+ else:
+ submenu.append (tableitem)
return tableitem
-
+
def _onTableOtherActivate(self, item, group):
chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
@@ -135,8 +136,9 @@ class AppWindow(object):
filename = chooser.get_filename()
chooser.destroy()
if response == gtk.RESPONSE_OK:
- eitem = self._addTable (self.submenu, group, filename)
+ eitem = self._addTable (self.submenu, group, filename, True)
eitem.activate()
+ eitem.show()
def _onTableActivate(self, item, table):
self.config_builder['translation']['literaryTextTable'] = table
@@ -156,14 +158,23 @@ class AppWindow(object):
os.listdir(host_settings.tablesdir))
table_list.sort()
group = None
+ found = False
for table in table_list:
group = self._addTable (self.submenu, group, table)
if table == self.config_builder['translation']['literaryTextTable']:
group.activate()
+ found = True
- #othermenu = gtk.MenuItem("Other...")
- #othermenu.connect_after("activate", self._onTableOtherActivate, group)
- #self.submenu.append(othermenu)
+ othermenu = gtk.MenuItem("Other...")
+ othermenu.connect_after("activate", self._onTableOtherActivate, group)
+ self.submenu.append(othermenu)
+
+ if not found:
+ if os.access (self.config_builder['translation']['literaryTextTable'], os.R_OK):
+ eitem = self._addTable (self.submenu, group, self.config_builder['translation']['literaryTextTable'], True)
+ eitem.activate()
+ else:
+ self.submenu.set_active(1)
@@ -177,7 +188,6 @@ class AppWindow(object):
filter = gtk.FileFilter()
filter.set_name(_("Documents"))
- print _("Documents")
filter.add_mime_type("application/pdf")
filter.add_mime_type("application/vnd.oasis.opendocument.text")
filter.add_mime_type("application/xhtml+xml")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]