[dots/remove-assistant: 14/38] Add a review line
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 14/38] Add a review line
- Date: Thu, 15 Jul 2010 21:08:09 +0000 (UTC)
commit 17430379b16d224a0e608466792ffd34d449a6d2
Author: Fernando Herrera <fherrera onirica com>
Date: Thu Jul 8 21:02:05 2010 +0200
Add a review line
TODO | 1 -
data/app_window.xml | 52 +++++++++++++++++++++++++++++--------------------
dots/app_window.py | 14 +++++++++++++
dots/dots_project.py | 20 ++++++++++++++++++-
4 files changed, 64 insertions(+), 23 deletions(-)
---
diff --git a/TODO b/TODO
index 632814c..d8ce741 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
- Put cursor at beginning of textviews when they are exposed.
- Nice error handling when importing odt documents.
- Edit the text
-- Review line
- Custom table selection
- i18n
- .desktop file
diff --git a/data/app_window.xml b/data/app_window.xml
index 1399753..182b1fd 100644
--- a/data/app_window.xml
+++ b/data/app_window.xml
@@ -1,15 +1,14 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="2.15"/>
+ <requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<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>
- <property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
@@ -25,7 +24,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="visible">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>
@@ -34,7 +32,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem3">
<property name="visible">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>
@@ -43,7 +40,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem4">
<property name="visible">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>
@@ -52,7 +48,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem11">
<property name="visible">True</property>
<property name="related_action">action_print</property>
- <property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -66,7 +61,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem5">
<property name="visible">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>
@@ -134,7 +128,7 @@
<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>
@@ -146,6 +140,15 @@
<property name="group">ascii_radio</property>
</object>
</child>
+ <child>
+ <object class="GtkCheckMenuItem" id="line_check">
+ <property name="visible">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes">Revision line</property>
+ <property name="use_underline">True</property>
+ <signal name="toggled" handler="_OnRevisionLine" swapped="no"/>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -170,7 +173,7 @@
<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>
@@ -210,7 +213,6 @@
<object class="GtkToolButton" id="toolbutton1">
<property name="visible">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>
@@ -223,7 +225,6 @@
<object class="GtkToolButton" id="toolbutton2">
<property name="visible">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>
@@ -236,7 +237,6 @@
<object class="GtkToolButton" id="toolbutton3">
<property name="visible">True</property>
<property name="related_action">action_print</property>
- <property name="use_action_appearance">True</property>
<property name="label" translatable="yes">toolbutton3</property>
<property name="use_underline">True</property>
</object>
@@ -263,13 +263,24 @@
</packing>
</child>
<child>
+ <object class="GtkEntry" id="reviewentry">
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">â?¢</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="spacing">2</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
@@ -279,26 +290,25 @@
<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"/>
+ <signal name="activate" handler="_onOpen" 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"/>
+ <signal name="activate" handler="_onSave" 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"/>
+ <signal name="activate" handler="_onSaveAs" swapped="no"/>
</object>
<object class="GtkAction" id="action_quit">
<property name="stock_id">gtk-quit</property>
- <signal name="activate" handler="_onQuit"/>
+ <signal name="activate" handler="_onQuit" 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"/>
+ <signal name="activate" handler="_onPrint" swapped="no"/>
</object>
-
</interface>
diff --git a/dots/app_window.py b/dots/app_window.py
index f226bab..14ebbde 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -193,6 +193,13 @@ class AppWindow(object):
action.set_sensitive(True)
action = self.main_xml.get_object('action_print')
action.set_sensitive(True)
+
+ def _OnRevisionLine(self, item):
+ reviewentry = self.main_xml.get_object('reviewentry')
+ if item.get_active():
+ reviewentry.show()
+ else:
+ reviewentry.hide()
def _OnBrailleViewToggle(self, ascii_item):
@@ -201,6 +208,10 @@ class AppWindow(object):
else:
self.project.view_braille()
+ def _onLineChanged(self, view, project, line):
+ self.main_xml.get_object('reviewentry').set_text(line)
+
+
def _onSave(self, action):
if self.project.out_file is None:
self._onSaveAs(action)
@@ -266,12 +277,14 @@ class AppWindow(object):
self.project = DotsProject(document, "Unsaved Document")
container.add(self.project)
self.project.show_all()
+ self.project.connect("line-changed", self._onLineChanged)
def translate(self, document, config):
self.project.transcribeBraille(config)
def run(self):
self.window.show_all()
+ self.main_xml.get_object('reviewentry').hide()
gtk.main()
def _onQuit(self, window, event=None):
@@ -281,4 +294,5 @@ class AppWindow(object):
if __name__ == "__main__":
window = AppWindow()
window.show_all()
+ window.main_xml.get_object('reviewentry').hide()
gtk.main()
diff --git a/dots/dots_project.py b/dots/dots_project.py
index 1758a83..e1bacaa 100644
--- a/dots/dots_project.py
+++ b/dots/dots_project.py
@@ -16,7 +16,7 @@
# 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
+import gtksourceview2, pango, gobject
import mimetypes
class DotsProject(gtk.ScrolledWindow):
@@ -28,6 +28,7 @@ class DotsProject(gtk.ScrolledWindow):
self.view.set_left_margin(25)
self.view.set_editable(False)
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)
@@ -37,6 +38,8 @@ class DotsProject(gtk.ScrolledWindow):
self.set_name(name)
self.out_file = None
self.config = None
+ self.current_line = None
+ gobject.signal_new("line-changed", self, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gtk.ScrolledWindow, gobject.TYPE_STRING))
def set_name(self, name):
gtk.ScrolledWindow.set_name(self, name)
@@ -48,6 +51,21 @@ class DotsProject(gtk.ScrolledWindow):
else:
self.tab_label.set_text(self.name)
+ def _onMoved(self, view, step, count, extend_selection):
+ mark = view.get_buffer().get_mark("insert")
+ iter = view.get_buffer().get_iter_at_mark(mark)
+ line = iter.get_line()
+ start = self.buffer.get_iter_at_line(line)
+ end = start.copy()
+ end.forward_to_line_end()
+ text = self.buffer.get_text (start, end)
+ if text != self.current_line:
+ self.current_line = text
+ self.emit("line-changed", self, self.current_line)
+
+
+
+
def transcribeBraille(self, config):
self.config = config
self._transcribeBraille()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]