]> www.fi.muni.cz Git - evince.git/commitdiff
Autoraise toolbar on GoToPage action and fix keyboard accelerators in sidebar
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 16 Jun 2005 08:34:13 +0000 (08:34 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 16 Jun 2005 08:34:13 +0000 (08:34 +0000)
thumbnailer page

ChangeLog
shell/ev-sidebar-links.c
shell/ev-sidebar-links.h
shell/ev-sidebar-page.c
shell/ev-sidebar-page.h
shell/ev-sidebar-thumbnails.c
shell/ev-sidebar-thumbnails.h
shell/ev-view.c
shell/ev-window.c

index b88960cdd7d60ca586f5257655cfb8fa1828981e..a53082e9fc2591054d8cfe2614a424cdbf1017d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2005-06-16  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * 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  <chpe@cvs.gnome.org>
 
        * shell/ev-properties.c: (update_progress_label):
index 45719114a615d1c52de54dd019a20bf9f9466d8c..84b49dd292b47175aa5c0ac03df28e149082aba5 100644 (file)
@@ -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)
 {
index c6b212224cdfe2155d795c1acbd6b3523784b5cd..b9691e35a6bcf566ecf4136fd73de24990636d30 100644 (file)
@@ -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
 
index dfd21d3e4c8025b1a3d2ec2fc3bdfa1a002bbc03..af45413183864ee5d50b619dcdd4a86c68d0d463 100644 (file)
@@ -23,6 +23,9 @@
 #endif
 
 #include "ev-sidebar-page.h"
+#include <gtk/gtk.h>
+
+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));
+}
index e4d19ebe77bd32e8ae90998ab9a04d33f86ae81e..3739a0760ca15da9e95c439f1862767669fdbbbc 100644 (file)
@@ -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);
index 3a6eb0b598b491636661a159d58eb37fbb9e868e..d86d392aaf20430d04a0361c0cf214fbeb8fdc97 100644 (file)
@@ -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);
index dc5007c25b6be1009087fd9e71ec628211f0bc90..d3171b0cb6a26fe932d1ba11a13f8a9f0c387c94 100644 (file)
@@ -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
 
index 3e31d293448250094b2317bbcdc781aaea81e15b..6ae9ac6139b4ae217cbbaf4f2f4d24dab23d011c 100644 (file)
@@ -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);
index 1bb82bae017c332698181b6379d0f13dc59ae101..e9e1c4e65a6699e656aa059941e01fe525a7c3ac 100644 (file)
@@ -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);