[dots/remove-assistant: 6/38] Load/save conf from the dialog



commit 47174cc3de5ba2e3d3a2d3313ed2957e8602dd08
Author: Fernando Herrera <fherrera onirica com>
Date:   Thu Jul 8 17:53:49 2010 +0200

    Load/save conf from the dialog

 data/Makefile.am   |    2 +-
 dots/app_window.py |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index d123b7e..948d6e8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
 gtkbuilderdir = $(datadir)/dots
-gtkbuilder_DATA = dots_assist.xml app_window.xml
+gtkbuilder_DATA = dots_assist.xml app_window.xml config.xml
 
 schemasdir = $(GCONF_SCHEMA_FILE_DIR)
 schemas_DATA = dots.schemas
diff --git a/dots/app_window.py b/dots/app_window.py
index d12e8af..b33f627 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -35,6 +35,10 @@ class AppWindow(object):
         self.config_builder = ConfigBuilder()
 	self.client = gconf.client_get_default ()
 	self.client.add_dir ("/apps/dots", gconf.CLIENT_PRELOAD_NONE)
+        self.conf_xml = gtk.Builder()
+        self.conf_xml.add_from_file (
+            os.path.join(host_settings.gtkbuilder_dir, 'config.xml'))
+ 
 	self.loadConfig()
 
     def loadConfig(self):
@@ -57,19 +61,53 @@ class AppWindow(object):
     def saveConfig(self):
 	self.client.set_string ("/apps/dots/semanticFiles", self.config_builder['xml']['semanticFiles'])
 	if self.config_builder['xml']['internetAccess'] == 'yes':
-		self.client.set_bool ("/apps/dots/internetAccess", true)
+		self.client.set_bool ("/apps/dots/internetAccess", True)
 	else:
-		self.client.set_bool ("/apps/dots/internetAccess", false)
+		self.client.set_bool ("/apps/dots/internetAccess", False)
 	self.client.set_string ("/apps/dots/literaryTextTable", self.config_builder['translation']['literaryTextTable'])
 	self.client.set_int ("/apps/dots/cellsPerLine", self.config_builder['outputFormat']['cellsPerLine'])
 	if self.config_builder['outputFormat']['braillePages'] == 'yes':
-		self.client.set_bool ("/apps/dots/braillePages", true)
+		self.client.set_bool ("/apps/dots/braillePages", True)
 	else:
-		self.client.set_bool ("/apps/dots/braillePages", false)
+		self.client.set_bool ("/apps/dots/braillePages", False)
 	self.client.set_string ("/apps/dots/formatFor", self.config_builder['outputFormat']['formatFor'])
 	self.client.set_int ("/apps/dots/LinesPerPage", self.config_builder['outputFormat']['LinesPerPage'])
 	self.client.set_string ("/apps/dots/braillePageNumberAt", self.config_builder['outputFormat']['braillePageNumberAt'])
 
+    def _OnTranslationFormatActivate(self, item):
+	dialog = self.conf_xml.get_object('format_dialog')
+	radiotop = self.conf_xml.get_object('page_top')
+	radiobottom = self.conf_xml.get_object('page_bottom')
+	radionone = self.conf_xml.get_object('page_none')
+
+	if self.config_builder['outputFormat']['braillePages'] == "yes":
+		if self.config_builder['outputFormat']['braillePageNumberAt'] == "top":
+			radiotop.set_active(True)
+		else:
+			radiobottom.set_active(True)
+	else:
+		radionone.set_active(True)
+	lines = self.conf_xml.get_object('lines_entry')
+	lines.set_value (self.config_builder['outputFormat']['LinesPerPage'])
+	cells = self.conf_xml.get_object('cells_entry')
+	cells.set_value (self.config_builder['outputFormat']['cellsPerLine'])
+
+	response = dialog.run()
+	if response == 0:
+		self.config_builder['outputFormat']['cellsPerLine'] = cells.get_value_as_int()
+		self.config_builder['outputFormat']['LinesPerPage'] = lines.get_value_as_int()
+		if radiotop.get_active():
+			self.config_builder['outputFormat']['braillePages'] = "yes"
+			self.config_builder['outputFormat']['braillePageNumberAt'] = "top"
+		elif radiobottom.get_active():
+			self.config_builder['outputFormat']['braillePages'] = "yes"
+			self.config_builder['outputFormat']['braillePageNumberAt'] = "bottom"
+		else:
+			self.config_builder['outputFormat']['braillePages'] = "no"
+
+	dialog.hide()
+
+	
 
 
     def _addTable(self, submenu, group, table):
@@ -101,17 +139,19 @@ class AppWindow(object):
         menuitem = self.main_xml.get_object('tables_menuitem')
 	#Fixme, dont make this global, use get_menu at _onTableOtherActivate
 	self.submenu = gtk.Menu()
+	menuitem.set_submenu(self.submenu)
         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)
+		if table == self.config_builder['translation']['literaryTextTable']:
+			group.activate()
 
 	#othermenu = gtk.MenuItem("Other...")
 	#othermenu.connect_after("activate", self._onTableOtherActivate, group)
 	#self.submenu.append(othermenu)
-	#menuitem.set_submenu(self.submenu)
 
 
 



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