[PATCH] RFC: ReadActivity fullscreen, paging changes

Klaus Weidner kweidner at pobox.com
Sun Jan 27 03:36:55 EST 2008


Hello,

here's a patch to enhance the Read activity, unfortunately it needed
modification of the evince lib also.

By popular request, it adds a "fullscreen" button to the View tab. 

For the scroll/paging changes, my main motivation was that I think it's
important to be able to scroll page by page, especially if using "zoom to fit"
mode, instead of having to manually (and slowly) align the top of the
page with the top of the screen with the arrow keys.

- add "continuous pages" and "single pages" to the "zoom to width" menu
  (this should probably be a toggle instead).

- modify evince to map PageUp/PageDown buttons (Fn-Up, Fn-Down, or
  gamepad O/X) - without these buttons, "continuous pages" mode can't
  advance pages via keyboard.

I'm not sure what the best way to submit these is, please let me know in
case I should get in touch with maintainers directly, or if I should set
up a pull-able git repo.

I wanted to try fixing the nonrotated rocker switch in e-book mode also,
but haven't found a good place to do that yet. Apparently the rotation
happens directly via a shell call to xrandr from the Sugar keyboard
manager, and I'm not sure which signal (if any) the activity could catch
to be notified of the rotation.

Also, I'm not sure if this should be done on a per-application basis, or
if a lower level should always rotate the rocker switch to match the
screen rotation automatically. That may mess up apps that expect the
current behavior though - are there any? Should the game buttons stay
static even when rotating?

Is it intentional to keep the keyboard mapping hardcoded in the evince
lib?  The usual evince key binding mechanism appears not to work via the
activity (I think that's why PageUp/PageDown weren't responding). I think
it would be cleaner and more flexible to revive an interface to that and
do the mapping from the activity.

Please send me feedback if you have ideas or suggestions how this should
work.

-Klaus
-------------- next part --------------
diff --git a/readactivity.py b/readactivity.py
index 956e3b0..99b9244 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -95,7 +95,7 @@ class ReadActivity(activity.Activity):
         toolbox.add_toolbar(_('Read'), self._read_toolbar)
         self._read_toolbar.show()
 
-        self._view_toolbar = ViewToolbar(self._view)
+        self._view_toolbar = ViewToolbar(self._view, self)
         self._view_toolbar.connect('needs-update-size',
                 self.__view_toolbar_needs_update_size_cb)
         toolbox.add_toolbar(_('View'), self._view_toolbar)
diff --git a/readtoolbar.py b/readtoolbar.py
index 332e4fa..be475b2 100644
--- a/readtoolbar.py
+++ b/readtoolbar.py
@@ -258,9 +258,10 @@ class ViewToolbar(gtk.Toolbar):
                               ([]))
     }
 
-    def __init__(self, evince_view):
+    def __init__(self, evince_view, activity):
         gtk.Toolbar.__init__(self)
 
+        self._activity = activity
         self._evince_view = evince_view
         self._document = None
             
@@ -293,6 +294,16 @@ class ViewToolbar(gtk.Toolbar):
         palette.menu.append(menu_item)
         menu_item.show()
 
+        menu_item = MenuItem(_('Single pages'))
+        menu_item.connect('activate', self._continuous_false_menu_item_activate_cb)
+        palette.menu.append(menu_item)
+        menu_item.show()
+
+        menu_item = MenuItem(_('Continuous pages'))
+        menu_item.connect('activate', self._continuous_true_menu_item_activate_cb)
+        palette.menu.append(menu_item)
+        menu_item.show()
+
         tool_item = gtk.ToolItem()
         self.insert(tool_item, -1)
         tool_item.show()
@@ -313,6 +324,14 @@ class ViewToolbar(gtk.Toolbar):
         self.insert(tool_item_zoom_perc_label, -1)
         tool_item_zoom_perc_label.show()
 
+        self._view_fullscreen = ToolButton('view-fullscreen')
+        self._view_fullscreen.set_tooltip(_('Fullscreen mode'))
+        self._view_fullscreen.connect('clicked', self._view_fullscreen_cb)
+        self.insert(self._view_fullscreen, -1)
+        self._view_fullscreen.show()
+
+        self._zoom_to_width.show()
+
         self._view_notify_zoom_handler = self._evince_view.connect(
                 'notify::zoom', self._view_notify_zoom_cb)
 
@@ -364,3 +383,12 @@ class ViewToolbar(gtk.Toolbar):
         self._evince_view.props.zoom = 1.0
         self._update_zoom_buttons()
 
+    def _continuous_false_menu_item_activate_cb(self, menu_item):
+        self._evince_view.set_continuous(False)
+
+    def _continuous_true_menu_item_activate_cb(self, menu_item):
+        self._evince_view.set_continuous(True)
+
+    def _view_fullscreen_cb(self, button):
+        self._activity.fullscreen()
+
-------------- next part --------------
diff --git a/shell/ev-view.c b/shell/ev-view.c
index b464c3f..39fc0e7 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -3996,6 +3996,8 @@ ev_view_class_init (EvViewClass *class)
 
 	binding_set = gtk_binding_set_by_class (class);
 
+	add_scroll_binding_keypad (binding_set, GDK_Page_Up,  0, EV_SCROLL_PAGE_BACKWARD, TRUE);
+	add_scroll_binding_keypad (binding_set, GDK_Page_Down, 0, EV_SCROLL_PAGE_FORWARD,  TRUE);
 	add_scroll_binding_keypad (binding_set, GDK_Left,  0, EV_SCROLL_STEP_BACKWARD, TRUE);
 	add_scroll_binding_keypad (binding_set, GDK_Right, 0, EV_SCROLL_STEP_FORWARD,  TRUE);
 	add_scroll_binding_keypad (binding_set, GDK_Left,  GDK_MOD1_MASK, EV_SCROLL_STEP_DOWN, TRUE);


More information about the Devel mailing list