]> www.fi.muni.cz Git - evince.git/commitdiff
History finally works as expected.
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Sun, 28 Jan 2007 13:29:10 +0000 (13:29 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 28 Jan 2007 13:29:10 +0000 (13:29 +0000)
2007-01-28  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>

* shell/ev-navigation-action.c: (activate_menu_item_cb),
(ev_navigation_action_class_init):
* shell/ev-navigation-action.h:
* shell/ev-page-action.c: (activate_cb):
* shell/ev-page-cache.c: (ev_page_cache_class_init),
(ev_page_cache_set_current_page_history):
* shell/ev-page-cache.h:
* shell/ev-sidebar-thumbnails.c:
(ev_sidebar_tree_selection_changed),
(ev_sidebar_icon_selection_changed), (page_changed_cb):
* shell/ev-view-private.h:
* shell/ev-view.c: (ev_view_handle_link), (ev_view_class_init):
* shell/ev-view.h:
* shell/ev-window.c: (page_changed_cb), (history_changed_cb),
(ev_window_setup_document), (ev_window_load_job_cb):
* shell/ev-window.h:

History finally works as expected.

svn path=/trunk/; revision=2259

12 files changed:
ChangeLog
shell/ev-navigation-action.c
shell/ev-navigation-action.h
shell/ev-page-action.c
shell/ev-page-cache.c
shell/ev-page-cache.h
shell/ev-sidebar-thumbnails.c
shell/ev-view-private.h
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c
shell/ev-window.h

index 8367a5e394bb93d2f89b1c0b6e0344cea499b27b..867c2fd0723ab1247dd33d3a1ac467e5e87c6c30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-01-28  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * shell/ev-navigation-action.c: (activate_menu_item_cb),
+       (ev_navigation_action_class_init):
+       * shell/ev-navigation-action.h:
+       * shell/ev-page-action.c: (activate_cb):
+       * shell/ev-page-cache.c: (ev_page_cache_class_init),
+       (ev_page_cache_set_current_page_history):
+       * shell/ev-page-cache.h:
+       * shell/ev-sidebar-thumbnails.c:
+       (ev_sidebar_tree_selection_changed),
+       (ev_sidebar_icon_selection_changed), (page_changed_cb):
+       * shell/ev-view-private.h:
+       * shell/ev-view.c: (ev_view_handle_link), (ev_view_class_init):
+       * shell/ev-view.h:
+       * shell/ev-window.c: (page_changed_cb), (history_changed_cb),
+       (ev_window_setup_document), (ev_window_load_job_cb):
+       * shell/ev-window.h:
+       
+       History finally works as expected.
+
 2007-01-28  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-sidebar-links.c: (ev_sidebar_links_map):
index 490b5f92bbfb06c0828346c7fe96fe10ec96a24e..88fe67b6de01bbadca11021d4876aa0568fa9fe5 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "ev-navigation-action.h"
 #include "ev-navigation-action-widget.h"
-#include "ev-window.h"
 
 #include <gtk/gtklabel.h>
 #include <gtk/gtkimage.h>
 #include <gtk/gtkmenutoolbutton.h>
 #include <glib/gi18n.h>
 
+enum
+{
+       WIDGET_ACTIVATE_LINK,
+       WIDGET_N_SIGNALS
+};
+
+static guint widget_signals[WIDGET_N_SIGNALS] = {0, };
+
 struct _EvNavigationActionPrivate
 {
-       EvWindow *window;
        EvHistory *history;
 };
 
@@ -58,13 +64,6 @@ ev_navigation_action_set_history (EvNavigationAction *action,
                                   (gpointer *) &action->priv->history);
 }
 
-void
-ev_navigation_action_set_window (EvNavigationAction *action,
-                                EvWindow           *window)
-{
-       action->priv->window = window;
-}
-
 static void
 activate_menu_item_cb (GtkWidget *widget, EvNavigationAction *action)
 {
@@ -75,16 +74,12 @@ activate_menu_item_cb (GtkWidget *widget, EvNavigationAction *action)
        index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "index"));
        ev_history_set_current_index (action->priv->history, index);
        
-       if (action->priv->window) {
+       if (action->priv->history) {
                EvLink *link;
-               EvLinkAction *link_action;
-               EvLinkDest *dest;
 
                link = ev_history_get_link_nth (action->priv->history, index);
-               link_action = ev_link_get_action (link);
-               dest = ev_link_action_get_dest (link_action);
                
-               ev_window_goto_dest (action->priv->window, dest);
+               g_signal_emit (action, widget_signals[WIDGET_ACTIVATE_LINK], 0, link);
        }
 }
 
@@ -223,5 +218,14 @@ ev_navigation_action_class_init (EvNavigationActionClass *class)
        action_class->create_tool_item = create_tool_item;
        action_class->connect_proxy = connect_proxy;
 
+       widget_signals[WIDGET_ACTIVATE_LINK] = g_signal_new ("activate_link",
+                                              G_OBJECT_CLASS_TYPE (object_class),
+                                              G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                              G_STRUCT_OFFSET (EvNavigationActionClass, activate_link),
+                                              NULL, NULL,
+                                              g_cclosure_marshal_VOID__OBJECT,
+                                              G_TYPE_NONE, 1,
+                                              G_TYPE_OBJECT);
+
        g_type_class_add_private (object_class, sizeof (EvNavigationActionPrivate));
 }
index c801c3922c3ad176c3779267423c386b3a99d4c9..2ac58487c316165d61f2ae57237588dfdfbca8e0 100644 (file)
@@ -24,7 +24,7 @@
 #include <gtk/gtkaction.h>
 
 #include "ev-history.h"
-#include "ev-window.h"
+#include "ev-link.h"
 
 G_BEGIN_DECLS
 
@@ -50,13 +50,14 @@ struct _EvNavigationAction
 struct _EvNavigationActionClass
 {
        GtkActionClass parent_class;
+
+       void (* activate_link) (EvNavigationAction *action,
+                               EvLink             *link);
 };
 
 GType  ev_navigation_action_get_type           (void);
 void   ev_navigation_action_set_history        (EvNavigationAction *action,
                                                 EvHistory          *history);
-void   ev_navigation_action_set_window         (EvNavigationAction *action,
-                                                EvWindow           *window);
 
 G_END_DECLS
 
index 744729d789cacd03c24b0742c40a20e5d994e65c..0571b6d162d467fbce8b00b315d5e6c6281dcda4 100644 (file)
@@ -118,6 +118,7 @@ activate_cb (GtkWidget *entry, GtkAction *action)
        EvLinkDest *link_dest;
        EvLinkAction *link_action;
        EvLink *link;
+       gchar *link_text;
 
        text = gtk_entry_get_text (GTK_ENTRY (entry));
        page_cache = page->priv->page_cache;
@@ -125,11 +126,13 @@ activate_cb (GtkWidget *entry, GtkAction *action)
        
        link_dest = ev_link_dest_new_page_label (text);
        link_action = ev_link_action_new_dest (link_dest);
-       link = ev_link_new (text, link_action);
+       link_text = g_strdup_printf ("Page: %s", text);
+       link = ev_link_new (link_text, link_action);
 
        g_signal_emit (action, signals[ACTIVATE_LINK], 0, link);
 
        g_object_unref (link);
+       g_free (link_text);
        
        /* rest the entry to the current page if we were unable to
         * change it */
index c1af7d228efe52684030bd00aafeb9bde7af1fca..a6d7bd9e99fc713fe8ed2f1c1ff1270bd9da6678 100644 (file)
@@ -45,11 +45,13 @@ struct _EvPageCacheClass
        GObjectClass parent_class;
 
        void (* page_changed) (EvPageCache *page_cache, gint page);
+       void (* history_changed) (EvPageCache *page_cache, gint page);
 };
 
 enum
 {
        PAGE_CHANGED,
+       HISTORY_CHANGED,
        N_SIGNALS,
 };
 
@@ -87,6 +89,16 @@ ev_page_cache_class_init (EvPageCacheClass *class)
                              G_TYPE_NONE, 1,
                              G_TYPE_INT);
 
+       signals [HISTORY_CHANGED] =
+               g_signal_new ("history-changed",
+                             EV_TYPE_PAGE_CACHE,
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (EvPageCacheClass, history_changed),
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__INT,
+                             G_TYPE_NONE, 1,
+                             G_TYPE_INT);
+
 }
 
 static void
@@ -324,6 +336,16 @@ ev_page_cache_set_current_page (EvPageCache *page_cache,
        g_signal_emit (page_cache, signals[PAGE_CHANGED], 0, page);
 }
 
+void
+ev_page_cache_set_current_page_history (EvPageCache *page_cache,
+                                       int          page)
+{
+       if (page != page_cache->current_page)
+               g_signal_emit (page_cache, signals [HISTORY_CHANGED], 0, page);
+               
+       ev_page_cache_set_current_page (page_cache, page);
+}
+
 gboolean
 ev_page_cache_set_page_label (EvPageCache *page_cache,
                              const char  *page_label)
index 0ad20e84aadcb0a6184f3875deb9612987984f74..d0ee00216c2f675637bf4569915fc3a4502f1172 100644 (file)
@@ -66,6 +66,8 @@ gboolean       ev_page_cache_get_dual_even_left  (EvPageCache *page_cache);
 gint           ev_page_cache_get_current_page    (EvPageCache *page_cache);
 void           ev_page_cache_set_current_page    (EvPageCache *page_cache,
                                                  int          page);
+void           ev_page_cache_set_current_page_history  (EvPageCache *page_cache,
+                                                       int          page);
 gboolean       ev_page_cache_set_page_label      (EvPageCache *page_cache,
                                                  const char  *page_label);
 
index eac7073f916e6d2f613e72c9e71626b4b23bc927..aa83dee4a4dc370d123a246ff95133df37ae1ce5 100644 (file)
@@ -433,7 +433,7 @@ ev_sidebar_tree_selection_changed (GtkTreeSelection *selection,
        page = gtk_tree_path_get_indices (path)[0];
        gtk_tree_path_free (path);
 
-       ev_page_cache_set_current_page (priv->page_cache, page);
+       ev_page_cache_set_current_page_history (priv->page_cache, page);
 }
 
 static void
@@ -458,7 +458,7 @@ ev_sidebar_icon_selection_changed (GtkIconView         *icon_view,
        gtk_tree_path_free (path);
        g_list_free (selected);
 
-       ev_page_cache_set_current_page (priv->page_cache, page);
+       ev_page_cache_set_current_page_history (priv->page_cache, page);
 }
 
 static void
@@ -563,7 +563,17 @@ page_changed_cb (EvPageCache         *page_cache,
                gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
                gtk_tree_view_scroll_to_cell (tree_view, path, NULL, FALSE, 0.0, 0.0);
        } else if (sidebar->priv->icon_view) {
+
+               g_signal_handlers_block_by_func
+                       (sidebar->priv->icon_view,
+                        G_CALLBACK (ev_sidebar_icon_selection_changed), sidebar);
+
                gtk_icon_view_select_path (GTK_ICON_VIEW (sidebar->priv->icon_view), path);
+
+               g_signal_handlers_unblock_by_func
+                       (sidebar->priv->icon_view,
+                        G_CALLBACK (ev_sidebar_icon_selection_changed), sidebar);
+
                gtk_icon_view_set_cursor (GTK_ICON_VIEW (sidebar->priv->icon_view), path, NULL, FALSE);
        }
 
index cdc6a96cbc80b3165ebe9f904fff8144529978fc..cab09417fe6ad1f53bd292f650ea505fb3931fe2 100644 (file)
@@ -161,6 +161,8 @@ struct _EvViewClass {
                                           EvScrollType   scroll,
                                           gboolean        horizontal);
        void    (*zoom_invalid)           (EvView         *view);
+       void    (*handle_link)            (EvView         *view,
+                                          EvLink         *link);
        void    (*external_link)          (EvView         *view,
                                           EvLinkAction   *action);
        void    (*popup_menu)             (EvView         *view,
index fec6435a532e2b5f356f2467b497163d599c7651..37ab5366d2ef35ca2ebd655c1e3431a2d73ba39c 100644 (file)
@@ -66,6 +66,7 @@ enum {
 enum {
        SIGNAL_BINDING_ACTIVATED,
        SIGNAL_ZOOM_INVALID,
+       SIGNAL_HANDLE_LINK,
        SIGNAL_EXTERNAL_LINK,
        SIGNAL_POPUP_MENU,
        N_SIGNALS,
@@ -1312,7 +1313,7 @@ goto_dest (EvView *view, EvLinkDest *dest)
                                                view->current_page);
 }
 
-void
+static void
 ev_view_goto_dest (EvView *view, EvLinkDest *dest)
 {
        EvLinkDestType type;
@@ -1364,6 +1365,7 @@ ev_view_handle_link (EvView *view, EvLink *link)
                        g_signal_emit (view, signals[SIGNAL_EXTERNAL_LINK], 0, action);
                        break;
        }
+       g_signal_emit (view, signals[SIGNAL_HANDLE_LINK], 0, link);
 }
 
 static gchar *
@@ -3191,6 +3193,14 @@ ev_view_class_init (EvViewClass *class)
                         NULL, NULL,
                         ev_marshal_VOID__VOID,
                         G_TYPE_NONE, 0, G_TYPE_NONE);
+       signals[SIGNAL_HANDLE_LINK] = g_signal_new ("handle-link",
+                        G_TYPE_FROM_CLASS (object_class),
+                        G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                        G_STRUCT_OFFSET (EvViewClass, handle_link),
+                        NULL, NULL,
+                        g_cclosure_marshal_VOID__OBJECT,
+                        G_TYPE_NONE, 1,
+                        G_TYPE_OBJECT);
        signals[SIGNAL_EXTERNAL_LINK] = g_signal_new ("external-link",
                         G_TYPE_FROM_CLASS (object_class),
                         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
index ba736ca39d24054aea6898ae2a3c50bec7044a45..77a4ba37ebdc32cf0733d235b66de7d128d2dc87 100644 (file)
@@ -141,8 +141,6 @@ void               ev_view_scroll             (EvView         *view,
                                           gboolean        horizontal);
 void          ev_view_handle_link        (EvView         *view,
                                           EvLink         *link);
-void           ev_view_goto_dest          (EvView         *view,
-                                          EvLinkDest     *dest);
 gboolean       ev_view_next_page         (EvView         *view);
 gboolean       ev_view_previous_page     (EvView         *view);
 
index f14bd31e920f897d79a22c11a0e94695e957faeb..51b8abde930083f31f7db39b5ac0b5158f3d28c6 100644 (file)
@@ -263,6 +263,9 @@ static gboolean fullscreen_motion_notify_cb                 (GtkWidget *widget,
 static gboolean fullscreen_leave_notify_cb             (GtkWidget *widget,
                                                         GdkEventCrossing *event,
                                                         gpointer user_data);
+static void    view_handle_link_cb                     (EvView *view, 
+                                                        EvLink *link, 
+                                                        EvWindow *window);
 
 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
 
@@ -635,19 +638,20 @@ page_changed_cb (EvPageCache *page_cache,
                 gint         page,
                 EvWindow    *ev_window)
 {
-       gchar *label;
-       
        ev_window_update_actions (ev_window);
        
-       if (ev_window->priv->history) {
-               label = ev_page_cache_get_page_label (ev_window->priv->page_cache, page);
-               ev_history_add_page (ev_window->priv->history, page, label);
-               g_free (label);
-       }
-
        if (!ev_window_is_empty (ev_window))
                ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
 }
+static void
+history_changed_cb (EvPageCache *page_cache,
+                   gint         page,
+                   EvWindow    *ev_window)
+{
+       ev_history_add_page (ev_window->priv->history, page, 
+                            ev_page_cache_get_page_label (ev_window->priv->page_cache, page));
+       return;
+}
 
 static void
 update_document_mode (EvWindow *window, EvDocumentMode mode)
@@ -903,6 +907,7 @@ ev_window_setup_document (EvWindow *ev_window)
        document = ev_window->priv->document;
        ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
        g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
+       g_signal_connect (ev_window->priv->page_cache, "history-changed", G_CALLBACK (history_changed_cb), ev_window);
 
        if (EV_IS_DOCUMENT_FIND (document)) {
                g_signal_connect_object (G_OBJECT (document),
@@ -930,7 +935,6 @@ ev_window_setup_document (EvWindow *ev_window)
        ev_window->priv->history = ev_history_new ();
        action = gtk_action_group_get_action (ev_window->priv->action_group, NAVIGATION_ACTION);
         ev_navigation_action_set_history (EV_NAVIGATION_ACTION (action), ev_window->priv->history);
-        ev_navigation_action_set_window (EV_NAVIGATION_ACTION (action), ev_window);
        
        if (ev_window->priv->properties) {
                ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
@@ -1099,8 +1103,15 @@ ev_window_load_job_cb  (EvJobLoad *job,
 
                ev_window_setup_document (ev_window);
 
-               if (job->dest)
-                       ev_window_goto_dest (ev_window, job->dest);
+               if (job->dest) {
+                       EvLink *link;
+                       EvLinkAction *link_action;
+       
+                       link_action = ev_link_action_new_dest (g_object_ref (job->dest));
+                       link = ev_link_new (NULL, link_action);
+                       ev_view_handle_link (EV_VIEW (ev_window->priv->view), link);
+                       g_object_unref (link);
+               }
 
                switch (job->mode) {
                        case EV_WINDOW_MODE_FULLSCREEN:
@@ -1269,12 +1280,6 @@ ev_window_open_uri (EvWindow       *ev_window,
        ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
 }
 
-void
-ev_window_goto_dest (EvWindow *ev_window, EvLinkDest *dest)
-{
-       ev_view_goto_dest (EV_VIEW (ev_window->priv->view), dest);
-}
-
 static void
 file_open_dialog_response_cb (GtkWidget *chooser,
                              gint       response_id,
@@ -4023,6 +4028,12 @@ static const GtkActionEntry attachment_popup_entries [] = {
          NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
 };
 
+static void
+sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
+{
+       ev_view_handle_link (EV_VIEW (window->priv->view), link);
+}
+
 static void
 activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
 {
@@ -4030,6 +4041,18 @@ activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
        gtk_widget_grab_focus (window->priv->view);
 }
 
+static void
+navigation_action_activate_link_cb (EvNavigationAction *action, EvLink *link, EvWindow *window)
+{
+       
+       g_signal_handlers_block_by_func
+               (window->priv->view, G_CALLBACK (view_handle_link_cb), window);
+       ev_view_handle_link (EV_VIEW (window->priv->view), link);
+       g_signal_handlers_unblock_by_func
+               (window->priv->view, G_CALLBACK (view_handle_link_cb), window);
+       gtk_widget_grab_focus (window->priv->view);
+}
+
 static void
 register_custom_actions (EvWindow *window, GtkActionGroup *group)
 {
@@ -4066,6 +4089,8 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group)
                               "stock_id", GTK_STOCK_GO_DOWN,
                               "tooltip", _("Move across visited pages"),
                               NULL);
+       g_signal_connect (action, "activate_link",
+                         G_CALLBACK (navigation_action_activate_link_cb), window);
        gtk_action_group_add_action (group, action);
        g_object_unref (action);
 }
@@ -4223,12 +4248,6 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
        return FALSE;
 }
 
-static void
-sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
-{
-       ev_view_handle_link (EV_VIEW (window->priv->view), link);
-}
-
 static void
 launch_action (EvWindow *window, EvLinkAction *action)
 {
@@ -4318,6 +4337,12 @@ do_action_named (EvWindow *window, EvLinkAction *action)
        }
 }
 
+static void
+view_handle_link_cb (EvView *view, EvLink *link, EvWindow *window)
+{
+       ev_history_add_link (window->priv->history, link);
+}
+
 static void
 view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
 {
@@ -4768,6 +4793,10 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_object (ev_window->priv->view, "external-link",
                                 G_CALLBACK (view_external_link_cb),
                                 ev_window, 0);
+       g_signal_connect_object (ev_window->priv->view, "handle-link",
+                                G_CALLBACK (view_handle_link_cb),
+                                ev_window, 0);
+
        g_signal_connect_object (ev_window->priv->view,
                                 "popup",
                                 G_CALLBACK (view_menu_popup_cb),
index 667f1370b124417263cd8bf13216f7b4f4c0c5b0..a60b123dcc6e79b77248677e8102e3d801d6edba 100644 (file)
@@ -78,8 +78,6 @@ void          ev_window_open_uri        (EvWindow       *ev_window,
                                           EvLinkDest     *dest,
                                           EvWindowRunMode mode,
                                           gboolean        unlink_temp_file);
-void            ev_window_goto_dest       (EvWindow       *ev_window,
-                                          EvLinkDest     *dest);
 gboolean       ev_window_is_empty        (const EvWindow *ev_window);
 #ifdef WITH_PRINT
 void           ev_window_print_range     (EvWindow       *ev_window,