From: Nickolay V. Shmyrev Date: Thu, 16 Jun 2005 08:34:13 +0000 (+0000) Subject: Autoraise toolbar on GoToPage action and fix keyboard accelerators in sidebar X-Git-Tag: EVINCE_0_3_3~247 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=4f1722b0523879cd73ee936d483a735e163a6b54;p=evince.git Autoraise toolbar on GoToPage action and fix keyboard accelerators in sidebar thumbnailer page --- diff --git a/ChangeLog b/ChangeLog index b88960cd..a53082e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2005-06-16 Nickolay V. Shmyrev + + * shell/ev-sidebar-links.c: (ev_sidebar_links_get_property), + (ev_sidebar_links_class_init), (ev_sidebar_links_get_label): + * shell/ev-sidebar-links.h: + * shell/ev-sidebar-page.c: (ev_sidebar_page_get_type), + (ev_sidebar_page_iface_init): + * shell/ev-sidebar-page.h: + * shell/ev-sidebar-thumbnails.c: + (ev_sidebar_thumbnails_get_property), + (ev_sidebar_thumbnails_class_init), + (ev_sidebar_thumbnails_set_document): + * shell/ev-sidebar-thumbnails.h: + * shell/ev-view.c: (ev_view_motion_notify_event): + * shell/ev-window.c: (update_chrome_visibility), + (ev_window_cmd_focus_page_selector), + (ev_window_update_fullscreen_popup), (view_actions_focus_in_cb), + (sidebar_page_main_widget_update_cb), (ev_window_init): + + Autoraise toolbar on GoToPage binding and fix bindings in + EvSidebarThumbnails page. + 2005-06-15 Christian Persch * shell/ev-properties.c: (update_progress_label): diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index 45719114..84b49dd2 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -52,6 +52,7 @@ struct _EvSidebarLinksPrivate { enum { PROP_0, PROP_MODEL, + PROP_WIDGET, }; @@ -128,6 +129,9 @@ ev_sidebar_links_get_property (GObject *object, case PROP_MODEL: g_value_set_object (value, ev_sidebar_links->priv->model); break; + case PROP_WIDGET: + g_value_set_object (value, ev_sidebar_links->priv->tree_view); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -174,6 +178,9 @@ ev_sidebar_links_class_init (EvSidebarLinksClass *ev_sidebar_links_class) "Current Model", GTK_TYPE_TREE_MODEL, G_PARAM_READWRITE)); + g_object_class_override_property (g_object_class, + PROP_WIDGET, + "main-widget"); g_type_class_add_private (g_object_class, sizeof (EvSidebarLinksPrivate)); } @@ -630,12 +637,6 @@ ev_sidebar_links_get_label (EvSidebarPage *sidebar_page) 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) { diff --git a/shell/ev-sidebar-links.h b/shell/ev-sidebar-links.h index c6b21222..b9691e35 100644 --- a/shell/ev-sidebar-links.h +++ b/shell/ev-sidebar-links.h @@ -52,7 +52,6 @@ struct _EvSidebarLinksClass { GType ev_sidebar_links_get_type (void); GtkWidget *ev_sidebar_links_new (void); -GtkWidget *ev_sidebar_links_get_treeview (EvSidebarLinks *sidebar); G_END_DECLS diff --git a/shell/ev-sidebar-page.c b/shell/ev-sidebar-page.c index dfd21d3e..af454131 100644 --- a/shell/ev-sidebar-page.c +++ b/shell/ev-sidebar-page.c @@ -23,6 +23,9 @@ #endif #include "ev-sidebar-page.h" +#include + +static void ev_sidebar_page_iface_init (gpointer iface); GType ev_sidebar_page_get_type (void) @@ -33,10 +36,10 @@ ev_sidebar_page_get_type (void) { static const GTypeInfo sidebar_page_info = { - sizeof (EvDocumentIface), + sizeof (EvSidebarPageIface), NULL, NULL, - NULL + (GClassInitFunc)ev_sidebar_page_iface_init, }; type = g_type_register_static (G_TYPE_INTERFACE, @@ -96,3 +99,13 @@ ev_sidebar_page_get_label (EvSidebarPage *sidebar_page) return iface->get_label (sidebar_page); } + +static void ev_sidebar_page_iface_init (gpointer iface) +{ + g_object_interface_install_property (iface, + g_param_spec_object ("main-widget", + "Main Widget", + "Main page widget, used to handle focus", + GTK_TYPE_WIDGET, + G_PARAM_READABLE)); +} diff --git a/shell/ev-sidebar-page.h b/shell/ev-sidebar-page.h index e4d19ebe..3739a076 100644 --- a/shell/ev-sidebar-page.h +++ b/shell/ev-sidebar-page.h @@ -47,7 +47,7 @@ struct _EvSidebarPageIface EvDocument *document); void (* set_document) (EvSidebarPage *sidebar_page, EvDocument *document); - const gchar* (* get_label) (EvSidebarPage *sidebar_page); + const gchar*(* get_label) (EvSidebarPage *sidebar_page); }; GType ev_sidebar_page_get_type (void); diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 3a6eb0b5..d86d392a 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -68,6 +68,11 @@ enum { NUM_COLUMNS }; +enum { + PROP_0, + PROP_WIDGET, +}; + static void ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar); static gboolean ev_sidebar_thumbnails_support_document (EvSidebarPage *sidebar_page, EvDocument *document); @@ -101,6 +106,28 @@ ev_sidebar_thumbnails_dispose (GObject *object) G_OBJECT_CLASS (ev_sidebar_thumbnails_parent_class)->dispose (object); } +static void +ev_sidebar_thumbnails_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EvSidebarThumbnails *sidebar = EV_SIDEBAR_THUMBNAILS (object); + + switch (prop_id) + { + case PROP_WIDGET: + if (sidebar->priv->tree_view) + g_value_set_object (value, sidebar->priv->tree_view); + else + g_value_set_object (value, sidebar->priv->icon_view); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnails_class) { @@ -111,6 +138,11 @@ ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnail gtk_object_class = GTK_OBJECT_CLASS (ev_sidebar_thumbnails_class); g_object_class->dispose = ev_sidebar_thumbnails_dispose; + g_object_class->get_property = ev_sidebar_thumbnails_get_property; + + g_object_class_override_property (g_object_class, + PROP_WIDGET, + "main-widget"); g_type_class_add_private (g_object_class, sizeof (EvSidebarThumbnailsPrivate)); } @@ -349,16 +381,6 @@ ev_sidebar_icon_selection_changed (GtkIconView *icon_view, ev_page_cache_set_current_page (page_cache, page); } -GtkWidget * -ev_sidebar_thumbnails_get_treeview (EvSidebarThumbnails *sidebar) -{ - if (sidebar->priv->tree_view) - return sidebar->priv->tree_view; - else - return sidebar->priv->icon_view; -} - - static void ev_sidebar_init_tree_view (EvSidebarThumbnails *ev_sidebar_thumbnails) { @@ -552,19 +574,22 @@ ev_sidebar_thumbnails_set_document (EvSidebarPage *sidebar_page, priv->tree_view = NULL; } - if (! priv->icon_view) + if (! priv->icon_view) { ev_sidebar_init_icon_view (sidebar_thumbnails); + g_object_notify (G_OBJECT (sidebar_thumbnails), "main_widget"); + } } else { if (priv->icon_view) { gtk_container_remove (GTK_CONTAINER (priv->swindow), priv->icon_view); priv->icon_view = NULL; } - if (! priv->tree_view) + if (! priv->tree_view) { ev_sidebar_init_tree_view (sidebar_thumbnails); + g_object_notify (G_OBJECT (sidebar_thumbnails), "main_widget"); + } } - /* Connect to the signal and trigger a fake callback */ g_signal_connect (page_cache, "page-changed", G_CALLBACK (page_changed_cb), sidebar_thumbnails); adjustment_changed_cb (sidebar_thumbnails); diff --git a/shell/ev-sidebar-thumbnails.h b/shell/ev-sidebar-thumbnails.h index dc5007c2..d3171b0c 100644 --- a/shell/ev-sidebar-thumbnails.h +++ b/shell/ev-sidebar-thumbnails.h @@ -53,7 +53,6 @@ struct _EvSidebarThumbnailsClass { GType ev_sidebar_thumbnails_get_type (void); GtkWidget *ev_sidebar_thumbnails_new (void); -GtkWidget *ev_sidebar_thumbnails_get_treeview (EvSidebarThumbnails *sidebar); G_END_DECLS diff --git a/shell/ev-view.c b/shell/ev-view.c index 3e31d293..6ae9ac61 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -1322,6 +1322,9 @@ ev_view_motion_notify_event (GtkWidget *widget, { EvView *view = EV_VIEW (widget); + if (!view->document) + return FALSE; + if (view->pressed_button == 1) { GdkRectangle selection; @@ -1371,7 +1374,7 @@ ev_view_motion_notify_event (GtkWidget *widget, return TRUE; } - } else if (view->pressed_button <= 0 && view->document) { + } else if (view->pressed_button <= 0) { EvLink *link; link = get_link_at_location (view, event->x + view->scroll_x, event->y + view->scroll_y); diff --git a/shell/ev-window.c b/shell/ev-window.c index 1bb82bae..e9e1c4e6 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -46,6 +46,7 @@ #include "ev-job-queue.h" #include "ev-jobs.h" #include "ev-statusbar.h" +#include "ev-sidebar-page.h" #include "eggfindbar.h" #include "egg-recent-view-gtk.h" #include "egg-recent-view.h" @@ -80,6 +81,7 @@ typedef enum { EV_CHROME_SIDEBAR = 1 << 2, EV_CHROME_FINDBAR = 1 << 3, EV_CHROME_STATUSBAR = 1 << 4, + EV_CHROME_RAISE_TOOLBAR = 1 << 5, EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR | EV_CHROME_STATUSBAR } EvChrome; @@ -310,9 +312,11 @@ update_chrome_visibility (EvWindow *window) fullscreen_mode = fullscreen || presentation; menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode; - toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode; + toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 || + (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode; sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode; - fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0; + fullscreen_toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 || + (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0); statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode; findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0; @@ -361,6 +365,9 @@ ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window) { GtkAction *action; + update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, NULL, TRUE); + set_action_sensitive (window, "ViewToolbar", FALSE); + action = gtk_action_group_get_action (window->priv->action_group, PAGE_SELECTOR_ACTION); ev_page_action_grab_focus (EV_PAGE_ACTION (action)); @@ -1343,7 +1350,8 @@ ev_window_update_fullscreen_popup (EvWindow *window) g_return_if_fail (popup != NULL); - toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0; + toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0 || + (window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0; popup_width = popup->requisition.width; popup_height = popup->requisition.height; @@ -2843,6 +2851,9 @@ set_view_actions_sensitivity (EvWindow *window, gboolean sensitive) static void view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window) { + update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, NULL, FALSE); + set_action_sensitive (window, "ViewToolbar", TRUE); + set_view_actions_sensitivity (window, TRUE); } @@ -2853,14 +2864,22 @@ view_actions_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *wi } static void -enable_view_actions_for_widget (EvWindow *window, GtkWidget *widget) +sidebar_page_main_widget_update_cb (GObject *ev_sidebar_page, + GParamSpec *pspec, + EvWindow *ev_window) { + GtkWidget *widget; + + g_object_get (ev_sidebar_page, "main_widget", &widget, NULL); + + if (widget != NULL) { g_signal_connect_object (widget, "focus_in_event", G_CALLBACK (view_actions_focus_in_cb), - window, 0); + ev_window, 0); g_signal_connect_object (widget, "focus_out_event", G_CALLBACK (view_actions_focus_out_cb), - window, 0); + ev_window, 0); + } } static void @@ -2869,7 +2888,7 @@ ev_window_init (EvWindow *ev_window) GtkActionGroup *action_group; GtkAccelGroup *accel_group; GError *error = NULL; - GtkWidget *sidebar_widget, *toolbar_dock, *tree_view; + GtkWidget *sidebar_widget, *toolbar_dock; GConfValue *value; GConfClient *client; int sidebar_size; @@ -2995,21 +3014,22 @@ ev_window_init (EvWindow *ev_window) "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); + sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window); 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); + g_signal_connect (sidebar_widget, + "notify::main-widget", + G_CALLBACK (sidebar_page_main_widget_update_cb), + ev_window); + sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window); gtk_widget_show (sidebar_widget); ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), sidebar_widget); + ev_window->priv->scrolled_window = GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW, "shadow-type", GTK_SHADOW_IN, @@ -3025,10 +3045,16 @@ ev_window_init (EvWindow *ev_window) "unlock", G_CALLBACK (ev_window_popup_password_dialog), ev_window); - enable_view_actions_for_widget (ev_window, ev_window->priv->view); + g_signal_connect_object (ev_window->priv->view, "focus_in_event", + G_CALLBACK (view_actions_focus_in_cb), + ev_window, 0); + g_signal_connect_object (ev_window->priv->view, "focus_out_event", + G_CALLBACK (view_actions_focus_out_cb), + ev_window, 0); gtk_widget_show (ev_window->priv->view); gtk_widget_show (ev_window->priv->password_view); + /* We own a ref on these widgets, as we can swap them in and out */ g_object_ref (ev_window->priv->view); //g_object_ref (ev_window->priv->page_view);