+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):
#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;
};
(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)
{
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);
}
}
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));
}
#include <gtk/gtkaction.h>
#include "ev-history.h"
-#include "ev-window.h"
+#include "ev-link.h"
G_BEGIN_DECLS
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
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;
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 */
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,
};
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
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)
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);
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
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
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);
}
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,
enum {
SIGNAL_BINDING_ACTIVATED,
SIGNAL_ZOOM_INVALID,
+ SIGNAL_HANDLE_LINK,
SIGNAL_EXTERNAL_LINK,
SIGNAL_POPUP_MENU,
N_SIGNALS,
view->current_page);
}
-void
+static void
ev_view_goto_dest (EvView *view, EvLinkDest *dest)
{
EvLinkDestType type;
g_signal_emit (view, signals[SIGNAL_EXTERNAL_LINK], 0, action);
break;
}
+ g_signal_emit (view, signals[SIGNAL_HANDLE_LINK], 0, link);
}
static gchar *
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,
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);
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)
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)
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),
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),
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:
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,
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)
{
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)
{
"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);
}
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)
{
}
}
+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)
{
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),
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,