+static void
+ev_navigation_action_history_changed (EvHistory *history,
+ gpointer data)
+{
+ EvNavigationAction *action = EV_NAVIGATION_ACTION (data);
+
+ gtk_action_set_sensitive (GTK_ACTION (action),
+ ev_history_get_n_links (history) > 0);
+}
+
+void
+ev_navigation_action_set_history (EvNavigationAction *action,
+ EvHistory *history)
+{
+ action->priv->history = history;
+
+ g_object_add_weak_pointer (G_OBJECT (action->priv->history),
+ (gpointer) &action->priv->history);
+
+ g_signal_connect_object (history, "changed",
+ G_CALLBACK (ev_navigation_action_history_changed),
+ action, 0);
+}
+
+static void
+activate_menu_item_cb (GtkWidget *widget, EvNavigationAction *action)
+{
+ int index;
+
+ g_return_if_fail (EV_IS_HISTORY (action->priv->history));
+
+ index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "index"));
+
+ if (action->priv->history) {
+ EvLink *link;
+
+ link = ev_history_get_link_nth (action->priv->history, index);
+
+ g_signal_emit (action, widget_signals[WIDGET_ACTIVATE_LINK], 0, link);
+ }
+}
+
+static GtkWidget *
+new_history_menu_item (EvNavigationAction *action,
+ EvLink *link,
+ int index)
+{
+ GtkLabel *label;
+ GtkWidget *item;
+ const char *title;
+
+ title = ev_link_get_title (link);
+ item = gtk_image_menu_item_new_with_label (title);
+ gtk_label_set_use_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (item))), TRUE);
+ g_object_set_data (G_OBJECT (item), "index",
+ GINT_TO_POINTER (index));
+
+ label = GTK_LABEL (GTK_BIN (item)->child);
+ gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (activate_menu_item_cb),
+ action);
+
+ gtk_widget_show (item);
+
+ return item;
+}
+