[dots] Change the GtkSourceView into a plain TextView



commit 459c038bb1d975f4f387a913677babe98aa3199e
Author: Fernando Herrera <fherrera onirica com>
Date:   Wed Dec 1 20:51:23 2010 +0100

    Change the GtkSourceView into a plain TextView

 data/app_window.xml      |  135 ++++++++++++++++++++++++++-------------------
 dots/app_window.py       |   10 +---
 dots/document_builder.py |    1 -
 dots/dots_project.py     |   42 ++++-----------
 4 files changed, 90 insertions(+), 98 deletions(-)
---
diff --git a/data/app_window.xml b/data/app_window.xml
index c193a49..8e0ad86 100644
--- a/data/app_window.xml
+++ b/data/app_window.xml
@@ -1,25 +1,21 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkMessageDialog" id="table_error_dialog">
+  <object class="GtkMessageDialog" id="notext-dialog">
     <property name="border_width">5</property>
     <property name="type_hint">normal</property>
     <property name="skip_taskbar_hint">True</property>
-    <property name="message_type">error</property>
+    <property name="message_type">warning</property>
     <property name="buttons">ok</property>
-    <property name="text" translatable="yes">The selected table is not valid</property>
-    <property name="secondary_text" translatable="yes">The selected table cannot be used by
-liblouisxml. Please make sure that if you
-are using "include" directive, those files
-are placed in the same directory as the table</property>
-    <property name="secondary_use_markup">True</property>
+    <property name="text" translatable="yes">Cannot extract text from the document.</property>
+    <property name="secondary_text" translatable="yes">Make sure that the document is valid and does contain text</property>
     <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox3">
+      <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area3">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
             <property name="visible">True</property>
             <property name="layout_style">end</property>
             <child>
@@ -38,10 +34,43 @@ are placed in the same directory as the table</property>
       </object>
     </child>
   </object>
+  <object class="GtkAction" id="action_help">
+    <property name="stock_id">gtk-help</property>
+    <signal name="activate" handler="_onHelp" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_about">
+    <property name="stock_id">gtk-about</property>
+    <signal name="activate" handler="_onAbout" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_print">
+    <property name="stock_id">gtk-print</property>
+    <property name="sensitive">False</property>
+    <signal name="activate" handler="_onPrint" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_quit">
+    <property name="stock_id">gtk-quit</property>
+    <signal name="activate" handler="_onQuit" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_save_as">
+    <property name="stock_id">gtk-save-as</property>
+    <property name="sensitive">False</property>
+    <signal name="activate" handler="_onSaveAs" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_save">
+    <property name="stock_id">gtk-save</property>
+    <property name="sensitive">False</property>
+    <signal name="activate" handler="_onSave" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="action_open">
+    <property name="tooltip">Open a file</property>
+    <property name="stock_id">gtk-open</property>
+    <signal name="activate" handler="_onOpen" swapped="no"/>
+  </object>
+  <object class="GtkActionGroup" id="file_actions"/>
   <object class="GtkWindow" id="window1">
     <property name="default_width">480</property>
     <property name="default_height">360</property>
-    <signal name="delete_event" handler="_onQuit"/>
+    <signal name="delete-event" handler="_onQuit" swapped="no"/>
     <child>
       <object class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
@@ -164,7 +193,7 @@ are placed in the same directory as the table</property>
                         <property name="use_underline">True</property>
                         <property name="active">True</property>
                         <property name="draw_as_radio">True</property>
-                        <signal name="toggled" handler="_OnBrailleViewToggle"/>
+                        <signal name="toggled" handler="_OnBrailleViewToggle" swapped="no"/>
                       </object>
                     </child>
                     <child>
@@ -181,7 +210,7 @@ are placed in the same directory as the table</property>
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Revision line</property>
                         <property name="use_underline">True</property>
-                        <signal name="toggled" handler="_OnRevisionLine"/>
+                        <signal name="toggled" handler="_OnRevisionLine" swapped="no"/>
                       </object>
                     </child>
                   </object>
@@ -208,7 +237,7 @@ are placed in the same directory as the table</property>
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Edit current Table...</property>
                         <property name="use_underline">True</property>
-                        <signal name="activate" handler="_OnTranslationEditTableActivate"/>
+                        <signal name="activate" handler="_OnTranslationEditTableActivate" swapped="no"/>
                       </object>
                     </child>
                     <child>
@@ -216,7 +245,7 @@ are placed in the same directory as the table</property>
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Format...</property>
                         <property name="use_underline">True</property>
-                        <signal name="activate" handler="_OnTranslationFormatActivate"/>
+                        <signal name="activate" handler="_OnTranslationFormatActivate" swapped="no"/>
                       </object>
                     </child>
                   </object>
@@ -306,7 +335,22 @@ are placed in the same directory as the table</property>
           <object class="GtkAlignment" id="main_alignment">
             <property name="visible">True</property>
             <child>
-              <placeholder/>
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <object class="GtkTextView" id="textview1">
+                    <property name="visible">True</property>
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="editable">False</property>
+                    <property name="left_margin">25</property>
+                    <property name="right_margin">25</property>
+                  </object>
+                </child>
+              </object>
             </child>
           </object>
           <packing>
@@ -317,7 +361,13 @@ are placed in the same directory as the table</property>
           <object class="GtkEntry" id="reviewentry">
             <property name="can_focus">True</property>
             <property name="editable">False</property>
-            <property name="invisible_char">&#x2022;</property>
+            <property name="invisible_char">â?¢</property>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="reviewentry-atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes">Revision line</property>
+                <property name="AtkObject::accessible-description" translatable="yes">Line showing the ASCII representation for the currently selected line</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -337,53 +387,24 @@ are placed in the same directory as the table</property>
       </object>
     </child>
   </object>
-  <object class="GtkActionGroup" id="file_actions"/>
-  <object class="GtkAction" id="action_open">
-    <property name="tooltip">Open a file</property>
-    <property name="stock_id">gtk-open</property>
-    <signal name="activate" handler="_onOpen"/>
-  </object>
-  <object class="GtkAction" id="action_save">
-    <property name="stock_id">gtk-save</property>
-    <property name="sensitive">False</property>
-    <signal name="activate" handler="_onSave"/>
-  </object>
-  <object class="GtkAction" id="action_save_as">
-    <property name="stock_id">gtk-save-as</property>
-    <property name="sensitive">False</property>
-    <signal name="activate" handler="_onSaveAs"/>
-  </object>
-  <object class="GtkAction" id="action_quit">
-    <property name="stock_id">gtk-quit</property>
-    <signal name="activate" handler="_onQuit"/>
-  </object>
-  <object class="GtkAction" id="action_print">
-    <property name="stock_id">gtk-print</property>
-    <property name="sensitive">False</property>
-    <signal name="activate" handler="_onPrint"/>
-  </object>
-  <object class="GtkAction" id="action_about">
-    <property name="stock_id">gtk-about</property>
-    <signal name="activate" handler="_onAbout"/>
-  </object>
-  <object class="GtkAction" id="action_help">
-    <property name="stock_id">gtk-help</property>
-    <signal name="activate" handler="_onHelp"/>
-  </object>
-  <object class="GtkMessageDialog" id="notext-dialog">
+  <object class="GtkMessageDialog" id="table_error_dialog">
     <property name="border_width">5</property>
     <property name="type_hint">normal</property>
     <property name="skip_taskbar_hint">True</property>
-    <property name="message_type">warning</property>
+    <property name="message_type">error</property>
     <property name="buttons">ok</property>
-    <property name="text" translatable="yes">Cannot extract text from the document.</property>
-    <property name="secondary_text" translatable="yes">Make sure that the document is valid and does contain text</property>
+    <property name="text" translatable="yes">The selected table is not valid</property>
+    <property name="secondary_text" translatable="yes">The selected table cannot be used by
+liblouisxml. Please make sure that if you
+are using "include" directive, those files
+are placed in the same directory as the table</property>
+    <property name="secondary_use_markup">True</property>
     <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
+      <object class="GtkVBox" id="dialog-vbox3">
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
+          <object class="GtkHButtonBox" id="dialog-action_area3">
             <property name="visible">True</property>
             <property name="layout_style">end</property>
             <child>
diff --git a/dots/app_window.py b/dots/app_window.py
index a4acfd4..65090e6 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -313,7 +313,6 @@ class AppWindow(object):
                     self.project.buffer.get_end_iter()))
             fsave.close()
             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()
@@ -359,15 +358,10 @@ class AppWindow(object):
 
 
     def addDocument(self, document):
-	container = self.main_xml.get_object('main_alignment')
 	if self.project is not None:
-		container.remove (self.project)
-		self.project.destroy()
-
-        self.project = DotsProject(document, _("Unsaved Document"))
-	container.add(self.project)
+		del self.project
+        self.project = DotsProject(document, _("Unsaved Document"), self.main_xml.get_object("textview1"))
 	self.window.set_title(os.path.basename(document.input_file) + " - dots")
-        self.project.show_all()
 	self.project.connect("line-changed", self._onLineChanged)
 
     def translate(self, document, config):
diff --git a/dots/document_builder.py b/dots/document_builder.py
index ef34e0e..1f4144b 100644
--- a/dots/document_builder.py
+++ b/dots/document_builder.py
@@ -58,4 +58,3 @@ if __name__ == "__main__":
 
 	d.translate (config_builder)
 	print d.get_braille_text ()
-
diff --git a/dots/dots_project.py b/dots/dots_project.py
index 6c9423e..fe40f28 100644
--- a/dots/dots_project.py
+++ b/dots/dots_project.py
@@ -18,43 +18,23 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import os, tempfile, host_settings, sys, gtk
 import ascii_braille
-import gtksourceview2, pango, gobject
+import pango, gobject
 import mimetypes
 
-class DotsProject(gtk.ScrolledWindow):
-    def __init__(self, document, name):
-        gtk.ScrolledWindow.__init__(self)
-        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-        self.view = gtksourceview2.View()
-        self.view.set_right_margin(25)
-        self.view.set_left_margin(25)
-        self.view.set_editable(False)
-        self.view.modify_font(pango.FontDescription('Mono'))
+class DotsProject(gobject.GObject):
+    __gsignals__ = { 'line-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT, gobject.TYPE_STRING,)) }
+    def __init__(self, document, name, view):
+	gobject.GObject.__init__(self)
+        self.view = view
+	self.view.set_sensitive(True)
+        #self.view.modify_font(pango.FontDescription('Mono'))
 	self.view.connect_after("move-cursor", self._onMoved)
-        self.add(self.view)
         self.buffer = self.view.get_buffer()
-        self.buffer.connect("modified-changed", self._onModified)
-        self.braille_buffer = gtksourceview2.Buffer()
+        self.braille_buffer = gtk.TextBuffer()
         self.document = document
-        self.tab_label = gtk.Label()
-        self.set_name(name)
         self.out_file = None
         self.config = None
 	self.current_line = None
-	try:
-		gobject.signal_new("line-changed", self, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gtk.ScrolledWindow, gobject.TYPE_STRING))
-	except:
-		pass
-
-    def set_name(self, name):
-        gtk.ScrolledWindow.set_name(self, name)
-        self.tab_label.set_text(name)
-
-    def _onModified(self, textbuffer):
-        if textbuffer.get_modified():
-            self.tab_label.set_text('*'+self.name)
-        else:
-            self.tab_label.set_text(self.name)
 
     def _onMoved(self, view, step, count, extend_selection):
 	mark = view.get_buffer().get_mark("insert")
@@ -68,9 +48,6 @@ class DotsProject(gtk.ScrolledWindow):
 		self.current_line = text
 		self.emit("line-changed", self, self.current_line)
 
-
-
-
     def transcribeBraille(self, config):
         self.config = config
         return self._transcribeBraille()
@@ -103,3 +80,4 @@ class DotsProject(gtk.ScrolledWindow):
                         x, '') for x in braille_text]))
 	return True
 
+gobject.type_register(DotsProject) 



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