[dots/remove-assistant: 7/38] Remove the notebook and make the app single-file
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 7/38] Remove the notebook and make the app single-file
- Date: Thu, 15 Jul 2010 21:07:34 +0000 (UTC)
commit 703bd1cf9853d1a19fa6261e34861d2ccb48ce58
Author: Fernando Herrera <fherrera onirica com>
Date: Thu Jul 8 18:18:16 2010 +0200
Remove the notebook and make the app single-file
dots/app_window.py | 61 ++++++++++++++++++----------------------------------
1 files changed, 21 insertions(+), 40 deletions(-)
---
diff --git a/dots/app_window.py b/dots/app_window.py
index b33f627..af67521 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -29,8 +29,6 @@ class AppWindow(object):
self.main_xml.add_from_file (
os.path.join(host_settings.gtkbuilder_dir, 'app_window.xml'))
self.window = self.main_xml.get_object('window1')
- self.main_notebook = gtk.Notebook()
- self.main_xml.get_object('main_alignment').add(self.main_notebook)
self.main_xml.connect_signals(self)
self.config_builder = ConfigBuilder()
self.client = gconf.client_get_default ()
@@ -40,6 +38,7 @@ class AppWindow(object):
os.path.join(host_settings.gtkbuilder_dir, 'config.xml'))
self.loadConfig()
+ self.project = None
def loadConfig(self):
self.config_builder['xml']['semanticFiles'] = self.client.get_string ("/apps/dots/semanticFiles")
@@ -189,66 +188,48 @@ class AppWindow(object):
def _OnBrailleViewToggle(self, ascii_item):
- current_project = self._getCurrentProject()
if ascii_item.get_active():
- current_project.view_ascii()
+ self.project.view_ascii()
else:
- current_project.view_braille()
-
- def _getCurrentProject(self):
- return self.main_notebook.get_nth_page(
- self.main_notebook.get_current_page())
+ self.project.view_braille()
def _onSave(self, action):
- curr_project = self._getCurrentProject()
- if curr_project.out_file is None:
+ if self.project.out_file is None:
self._onSaveAs(action)
else:
- fsave = open(curr_project.out_file, 'w')
- fsave.write(curr_project.buffer.get_text(
- curr_project.buffer.get_start_iter(),
- curr_project.buffer.get_end_iter()))
+ fsave = open(self.project.out_file, 'w')
+ fsave.write(self.project.buffer.get_text(
+ self.project.buffer.get_start_iter(),
+ self.project.buffer.get_end_iter()))
fsave.close()
- curr_project.buffer.set_modified(False)
+ self.project.buffer.set_modified(False)
def _onSaveAs(self, action):
- curr_project = self._getCurrentProject()
-
dialog = gtk.FileChooserDialog(
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
- if curr_project.out_file:
- dialog.set_filename(curr_project.out_file)
+ if self.project.out_file:
+ dialog.set_filename(self.project.out_file)
if (dialog.run() == gtk.RESPONSE_OK):
fsave = open(dialog.get_filename(), 'w')
- fsave.write(curr_project.buffer.get_text(
- curr_project.buffer.get_start_iter(),
- curr_project.buffer.get_end_iter()))
+ fsave.write(self.project.buffer.get_text(
+ self.project.buffer.get_start_iter(),
+ self.project.buffer.get_end_iter()))
fsave.close()
- curr_project.out_file = dialog.get_filename()
- curr_project.set_name(os.path.basename(curr_project.out_file))
- curr_project.buffer.set_modified(False)
+ self.project.out_file = dialog.get_filename()
+ self.project.set_name(os.path.basename(self.project.out_file))
+ self.project.buffer.set_modified(False)
dialog.destroy()
- def _getUnsavedNum(self):
- count = 0
- for i in xrange(self.main_notebook.get_n_pages()):
- page = self.main_notebook.get_nth_page(i)
- label_text = self.main_notebook.get_tab_label_text(page)
- if label_text.startswith("Unsaved Document "):
- count += 1
- return count + 1
-
def translate(self, document, config):
- dotsproj = DotsProject(
- document, "Unsaved Document %d" % self._getUnsavedNum())
- dotsproj.transcribeBraille(config)
- self.main_notebook.append_page(dotsproj, dotsproj.tab_label)
- dotsproj.show_all()
+ self.project = DotsProject(document, "Unsaved Document")
+ self.project.transcribeBraille(config)
+ self.main_xml.get_object('main_alignment').add(self.project)
+ self.project.show_all()
def run(self):
self.window.show_all()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]