+2005-09-08 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * shell/ev-sidebar-links.c: (ev_sidebar_links_class_init),
+ (selection_changed_callback):
+ * shell/ev-sidebar-links.h:
+
+ Add a signal for link activation.
+
+ * shell/ev-view.c: (ev_view_goto_link),
+ (ev_view_button_release_event):
+ * shell/ev-view.h:
+ * shell/ev-window.c: (sidebar_links_link_activated_cb),
+ (ev_window_init):
+
+ Implement the signal so that we can handle all link types.
+
+ * shell/ev-page-cache.c:
+
+ Remove unused set_link function
+
2005-09-08 Marco Pesenti Gritti <mpg@redhat.com>
* lib/ev-tooltip.c: (ev_tooltip_set_position):
return FALSE;
}
-void
-ev_page_cache_set_link (EvPageCache *page_cache,
- EvLink *link)
-{
- g_return_if_fail (EV_IS_PAGE_CACHE (page_cache));
- g_return_if_fail (EV_IS_LINK (link));
-
- ev_page_cache_set_current_page (page_cache, ev_link_get_page (link));
-}
-
const char *
ev_page_cache_get_title (EvPageCache *page_cache)
{
int page);
gboolean ev_page_cache_set_page_label (EvPageCache *page_cache,
const char *page_label);
-void ev_page_cache_set_link (EvPageCache *page_cache,
- EvLink *link);
gboolean ev_page_cache_next_page (EvPageCache *page_cache);
gboolean ev_page_cache_prev_page (EvPageCache *page_cache);
PROP_WIDGET,
};
+enum {
+ LINK_ACTIVATED,
+ N_SIGNALS
+};
static void links_page_num_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
EvDocument *document);
static const gchar* ev_sidebar_links_get_label (EvSidebarPage *sidebar_page);
+static guint signals[N_SIGNALS];
G_DEFINE_TYPE_EXTENDED (EvSidebarLinks,
ev_sidebar_links,
g_object_class->get_property = ev_sidebar_links_get_property;
g_object_class->dispose = ev_sidebar_links_dispose;
+ signals[LINK_ACTIVATED] = g_signal_new ("link-activated",
+ G_TYPE_FROM_CLASS (g_object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EvSidebarLinksClass, link_activated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
g_object_class_install_property (g_object_class,
PROP_MODEL,
g_param_spec_object ("model",
g_signal_handler_block (ev_sidebar_links->priv->page_cache,
ev_sidebar_links->priv->page_changed_id);
- /* FIXME: we should handle this better. This breaks w/ URLs */
- ev_page_cache_set_link (ev_sidebar_links->priv->page_cache, link);
+ g_signal_emit (ev_sidebar_links, signals[LINK_ACTIVATED], 0, link);
g_signal_handler_unblock (ev_sidebar_links->priv->page_cache,
ev_sidebar_links->priv->page_changed_id);
struct _EvSidebarLinksClass {
GtkVBoxClass base_class;
+
+ void (* link_activated) (EvSidebarLinks *sidebar_links,
+ EvLink *link);
};
GType ev_sidebar_links_get_type (void);
static EvLink* get_link_at_location (EvView *view,
gdouble x,
gdouble y);
-static void go_to_link (EvView *view,
- EvLink *link);
static char* tip_from_link (EvView *view,
EvLink *link);
gtk_adjustment_set_value (view->vadjustment, view_point.y);
}
-static void
-go_to_link (EvView *view, EvLink *link)
+void
+ev_view_goto_link (EvView *view, EvLink *link)
{
EvLinkType type;
const char *uri;
link = get_link_at_location (view, event->x + view->scroll_x, event->y + view->scroll_y);
if (link) {
- go_to_link (view, link);
+ ev_view_goto_link (view, link);
}
}
void ev_view_hide_cursor (EvView *view);
void ev_view_show_cursor (EvView *view);
-/* Scrolling */
+/* Navigation */
void ev_view_scroll (EvView *view,
EvScrollType scroll);
+void ev_view_goto_link (EvView *view,
+ EvLink *link);
G_END_DECLS
{
g_return_if_fail (EV_IS_WINDOW (window));
- ev_page_cache_set_link (window->priv->page_cache, link);
+ ev_view_goto_link (EV_VIEW (window->priv->view), link);
gtk_widget_grab_focus (window->priv->view);
}
return FALSE;
}
+static void
+sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
+{
+ ev_view_goto_link (EV_VIEW (window->priv->view), link);
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
"notify::model",
G_CALLBACK (sidebar_widget_model_set),
ev_window);
+ g_signal_connect (sidebar_widget,
+ "link_activated",
+ G_CALLBACK (sidebar_links_link_activated_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),