+2005-05-10 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * data/evince-ui.xml:
+ * shell/ev-sidebar-links.c: (ev_sidebar_links_get_treeview):
+ * shell/ev-sidebar-links.h:
+ * shell/ev-sidebar-thumbnails.c:
+ (ev_sidebar_thumbnails_get_treeview):
+ * shell/ev-sidebar-thumbnails.h:
+ * shell/ev-view.c: (ev_view_scroll), (ev_view_scroll_view),
+ (ev_view_class_init):
+ * shell/ev-view.h:
+ * shell/ev-window.c: (update_action_sensitivity),
+ (ev_window_cmd_scroll_forward), (ev_window_cmd_scroll_backward),
+ (set_view_actions_sensitivity), (view_actions_focus_in_cb),
+ (view_actions_focus_out_cb), (enable_view_actions_for_widget),
+ (ev_window_init):
+
+ This is evil... Make space/backspace global accelerators but
+ enable them only for some widgets (sidebars and view).
+ I dont like it, but I dont know a better way... :/
+
2005-05-10 Marco Pesenti Gritti <mpg@redhat.com>
* shell/ev-page-action.c: (ev_page_action_widget_set_page_cache),
<accelerator name="EscapeAccel" action="Escape"/>
<accelerator name="SlashAccel" action="Slash"/>
+ <accelerator name="SpaceAccel" action="Space"/>
+ <accelerator name="BackSpaceAccel" action="BackSpace"/>
+ <accelerator name="ShiftSpaceAccel" action="ShiftSpace"/>
+ <accelerator name="ShiftBackSpaceAccel" action="ShiftBackSpace"/>
</ui>
return _("Index");
}
+GtkWidget *
+ev_sidebar_links_get_treeview (EvSidebarLinks *sidebar)
+{
+ return sidebar->priv->tree_view;
+}
+
static void
ev_sidebar_links_page_iface_init (EvSidebarPageIface *iface)
{
GType ev_sidebar_links_get_type (void);
GtkWidget *ev_sidebar_links_new (void);
+GtkWidget *ev_sidebar_links_get_treeview (EvSidebarLinks *sidebar);
G_END_DECLS
ev_page_cache_set_current_page (page_cache, page);
}
+GtkWidget *
+ev_sidebar_thumbnails_get_treeview (EvSidebarThumbnails *sidebar)
+{
+ return sidebar->priv->tree_view;
+}
+
static void
ev_sidebar_thumbnails_init (EvSidebarThumbnails *ev_sidebar_thumbnails)
{
GtkVBoxClass base_class;
};
-GType ev_sidebar_thumbnails_get_type (void);
-GtkWidget *ev_sidebar_thumbnails_new (void);
+GType ev_sidebar_thumbnails_get_type (void);
+GtkWidget *ev_sidebar_thumbnails_new (void);
+GtkWidget *ev_sidebar_thumbnails_get_treeview (EvSidebarThumbnails *sidebar);
G_END_DECLS
TARGET_TEXT_BUFFER_CONTENTS
};
-enum {
- EV_SCROLL_PAGE_FORWARD,
- EV_SCROLL_PAGE_BACKWARD
-};
-
static const GtkTargetEntry targets[] = {
{ "STRING", 0, TARGET_STRING },
{ "TEXT", 0, TARGET_TEXT },
G_TYPE_BOOLEAN, horizontal);
}
-static void
-add_scroll_binding_shifted (GtkBindingSet *binding_set,
- guint keyval,
- GtkScrollType scroll_normal,
- GtkScrollType scroll_shifted,
- gboolean horizontal)
-{
- gtk_binding_entry_add_signal (binding_set, keyval, 0,
- "scroll_view", 2,
- GTK_TYPE_SCROLL_TYPE, scroll_normal,
- G_TYPE_BOOLEAN, horizontal);
- gtk_binding_entry_add_signal (binding_set, keyval, GDK_SHIFT_MASK,
- "scroll_view", 2,
- GTK_TYPE_SCROLL_TYPE, scroll_shifted,
- G_TYPE_BOOLEAN, horizontal);
-}
-
-static void
-ev_view_jump (EvView *view,
- GtkScrollType scroll)
+void
+ev_view_scroll (EvView *view,
+ EvScrollType scroll)
{
GtkAdjustment *adjustment;
double value, increment;
ev_page_cache_prev_page (view->page_cache);
} else if (scroll == GTK_SCROLL_PAGE_FORWARD) {
ev_page_cache_next_page (view->page_cache);
- } else if (scroll == EV_SCROLL_PAGE_BACKWARD || scroll == EV_SCROLL_PAGE_FORWARD) {
- ev_view_jump (view, scroll);
} else {
GtkAdjustment *adjustment;
double value;
add_scroll_binding_keypad (binding_set, GDK_Page_Up, GTK_SCROLL_PAGE_BACKWARD, FALSE);
add_scroll_binding_keypad (binding_set, GDK_Page_Down, GTK_SCROLL_PAGE_FORWARD, FALSE);
-
- add_scroll_binding_shifted (binding_set, GDK_space, EV_SCROLL_PAGE_FORWARD, EV_SCROLL_PAGE_BACKWARD, FALSE);
- add_scroll_binding_shifted (binding_set, GDK_BackSpace, EV_SCROLL_PAGE_BACKWARD, EV_SCROLL_PAGE_FORWARD, FALSE);
}
static void
EV_SIZING_FREE,
} EvSizingMode;
-GType ev_view_get_type (void) G_GNUC_CONST;
-GType ev_sizing_mode_get_type (void) G_GNUC_CONST;
-GtkWidget* ev_view_new (void);
-void ev_view_set_document (EvView *view,
- EvDocument *document);
+typedef enum {
+ EV_SCROLL_PAGE_FORWARD,
+ EV_SCROLL_PAGE_BACKWARD
+} EvScrollType;
-/* Clipboard */
-void ev_view_copy (EvView *view);
-void ev_view_select_all (EvView *view);
+GType ev_view_get_type (void) G_GNUC_CONST;
+GType ev_sizing_mode_get_type (void) G_GNUC_CONST;
+GtkWidget* ev_view_new (void);
+void ev_view_set_document (EvView *view,
+ EvDocument *document);
+/* Clipboard */
+void ev_view_copy (EvView *view);
+void ev_view_select_all (EvView *view);
/* sizing and behavior */
/* These are all orthoganal to each other, except 'presentation' trumps all
* other behaviors
*/
-void ev_view_set_continuous (EvView *view,
- gboolean continuous);
-void ev_view_set_dual_page (EvView *view,
- gboolean dual_page);
-void ev_view_set_fullscreen (EvView *view,
- gboolean fullscreen);
-gboolean ev_view_get_fullscreen (EvView *view);
-void ev_view_set_presentation (EvView *view,
- gboolean presentation);
-gboolean ev_view_get_presentation (EvView *view);
-void ev_view_set_sizing_mode (EvView *view,
- EvSizingMode mode);
-EvSizingMode ev_view_get_sizing_mode (EvView *view);
+void ev_view_set_continuous (EvView *view,
+ gboolean continuous);
+void ev_view_set_dual_page (EvView *view,
+ gboolean dual_page);
+void ev_view_set_fullscreen (EvView *view,
+ gboolean fullscreen);
+gboolean ev_view_get_fullscreen (EvView *view);
+void ev_view_set_presentation (EvView *view,
+ gboolean presentation);
+gboolean ev_view_get_presentation (EvView *view);
+void ev_view_set_sizing_mode (EvView *view,
+ EvSizingMode mode);
+EvSizingMode ev_view_get_sizing_mode (EvView *view);
/* Page size */
-gboolean ev_view_can_zoom_in (EvView *view);
-void ev_view_zoom_in (EvView *view);
-gboolean ev_view_can_zoom_out (EvView *view);
-void ev_view_zoom_out (EvView *view);
-void ev_view_set_zoom (EvView *view,
- double factor,
- gboolean relative);
-double ev_view_get_zoom (EvView *view);
-
-void ev_view_set_zoom_for_size (EvView *view,
- int width,
- int height,
- int vsb_width,
- int hsb_height);
-void ev_view_zoom_normal (EvView *view);
-void ev_view_set_size (EvView *view,
- int width,
- int height);
+gboolean ev_view_can_zoom_in (EvView *view);
+void ev_view_zoom_in (EvView *view);
+gboolean ev_view_can_zoom_out (EvView *view);
+void ev_view_zoom_out (EvView *view);
+void ev_view_set_zoom (EvView *view,
+ double factor,
+ gboolean relative);
+double ev_view_get_zoom (EvView *view);
+
+void ev_view_set_zoom_for_size (EvView *view,
+ int width,
+ int height,
+ int vsb_width,
+ int hsb_height);
+void ev_view_zoom_normal (EvView *view);
/* Find */
-gboolean ev_view_can_find_next (EvView *view);
-void ev_view_find_next (EvView *view);
-void ev_view_find_previous (EvView *view);
+gboolean ev_view_can_find_next (EvView *view);
+void ev_view_find_next (EvView *view);
+void ev_view_find_previous (EvView *view);
/* Status */
-const char *ev_view_get_status (EvView *view);
-const char *ev_view_get_find_status (EvView *view);
+const char *ev_view_get_status (EvView *view);
+const char *ev_view_get_find_status (EvView *view);
/* Cursor */
-void ev_view_hide_cursor (EvView *view);
-void ev_view_show_cursor (EvView *view);
+void ev_view_hide_cursor (EvView *view);
+void ev_view_show_cursor (EvView *view);
+
+/* Scrolling */
+void ev_view_scroll (EvView *view,
+ EvScrollType scroll);
G_END_DECLS
set_action_sensitive (ev_window, "SinglePage", FALSE);
set_action_sensitive (ev_window, "ContinuousPage", FALSE);
}
- /* Help menu */
- /* "HelpContents": always sensitive */
- /* "HelpAbout": always sensitive */
/* Toolbar-specific actions: */
set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
update_chrome_visibility (window);
}
+static void
+ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD);
+}
+
+static void
+ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD);
+}
+
static void
ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
{
G_CALLBACK (ev_window_cmd_escape) },
{ "Slash", GTK_STOCK_FIND, NULL, "slash",
N_("Find a word or phrase in the document"),
- G_CALLBACK (ev_window_cmd_edit_find) }
+ G_CALLBACK (ev_window_cmd_edit_find) },
+ { "Space", GTK_STOCK_FIND, NULL, "space",
+ N_("Scroll one page forward"),
+ G_CALLBACK (ev_window_cmd_scroll_forward) },
+ { "ShiftSpace", GTK_STOCK_FIND, NULL, "<shift>space",
+ N_("Scroll one page backward"),
+ G_CALLBACK (ev_window_cmd_scroll_backward) },
+ { "BackSpace", GTK_STOCK_FIND, NULL, "BackSpace",
+ N_("Scroll one page backward"),
+ G_CALLBACK (ev_window_cmd_scroll_backward) },
+ { "ShiftBackSpace", GTK_STOCK_FIND, NULL, "<shift>BackSpace",
+ N_("Scroll one page forward"),
+ G_CALLBACK (ev_window_cmd_scroll_forward) }
};
/* Toggle items */
ev_page_action_set_model (EV_PAGE_ACTION (action), model);
}
+
+static void
+set_view_actions_sensitivity (EvWindow *window, gboolean sensitive)
+{
+ if (window->priv->action_group) {
+ set_action_sensitive (window, "Space", sensitive);
+ set_action_sensitive (window, "ShiftSpace", sensitive);
+ set_action_sensitive (window, "BackSpace", sensitive);
+ set_action_sensitive (window, "ShiftBackSpace", sensitive);
+ }
+}
+
+static void
+view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
+{
+ set_view_actions_sensitivity (window, TRUE);
+}
+
+static void
+view_actions_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
+{
+ set_view_actions_sensitivity (window, FALSE);
+}
+
+static void
+enable_view_actions_for_widget (EvWindow *window, GtkWidget *widget)
+{
+ g_signal_connect_object (widget, "focus_in_event",
+ G_CALLBACK (view_actions_focus_in_cb),
+ window, 0);
+ g_signal_connect_object (widget, "focus_out_event",
+ G_CALLBACK (view_actions_focus_out_cb),
+ window, 0);
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
GtkActionGroup *action_group;
GtkAccelGroup *accel_group;
GError *error = NULL;
- GtkWidget *sidebar_widget, *toolbar_dock;
+ GtkWidget *sidebar_widget, *toolbar_dock, *tree_view;
GConfValue *value;
GConfClient *client;
int sidebar_size;
gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
+ set_view_actions_sensitivity (ev_window, FALSE);
+
g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
G_CALLBACK (connect_proxy_cb), ev_window);
g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
"notify::model",
G_CALLBACK (sidebar_widget_model_set),
ev_window);
+ tree_view = ev_sidebar_links_get_treeview
+ (EV_SIDEBAR_LINKS (sidebar_widget));
+ enable_view_actions_for_widget (ev_window, tree_view);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
sidebar_widget = ev_sidebar_thumbnails_new ();
+ tree_view = ev_sidebar_thumbnails_get_treeview
+ (EV_SIDEBAR_THUMBNAILS (sidebar_widget));
+ enable_view_actions_for_widget (ev_window, tree_view);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
"unlock",
G_CALLBACK (ev_window_popup_password_dialog),
ev_window);
+ enable_view_actions_for_widget (ev_window, ev_window->priv->view);
gtk_widget_show (ev_window->priv->view);
- //gtk_widget_show (ev_window->priv->page_view);
gtk_widget_show (ev_window->priv->password_view);
/* We own a ref on these widgets, as we can swap them in and out */