]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-navigation-action.c
Use GTK_UNIT_POINTS instead of GTK_UNIT_PIXEL, since it's not supported by
[evince.git] / shell / ev-navigation-action.c
index dd4e38e83bf1e0d3c23749d71c85e0006b1eee58..6a5e3a522ddce0623b10baaf7123ad21539566d9 100644 (file)
@@ -54,6 +54,16 @@ G_DEFINE_TYPE (EvNavigationAction, ev_navigation_action, GTK_TYPE_ACTION)
 
 #define EV_NAVIGATION_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_NAVIGATION_ACTION, EvNavigationActionPrivate))
 
+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)
@@ -62,6 +72,10 @@ ev_navigation_action_set_history (EvNavigationAction *action,
 
        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
@@ -110,18 +124,6 @@ new_history_menu_item (EvNavigationAction *action,
        return item;
 }
 
-static GtkWidget *
-new_empty_history_menu_item (EvNavigationAction *action)
-{
-       GtkWidget *item;
-       
-       item = gtk_image_menu_item_new_with_label (_("Empty"));
-       gtk_widget_set_sensitive (item, FALSE);
-       gtk_widget_show (item);
-       
-       return item;
-}
-
 static GtkWidget *
 build_menu (EvNavigationAction *action)
 {
@@ -131,14 +133,12 @@ build_menu (EvNavigationAction *action)
        EvHistory *history = action->priv->history;
        int start, end, i;
 
-       menu = GTK_MENU_SHELL (gtk_menu_new ());
-
        if (history == NULL || ev_history_get_n_links (history) <= 0) {
-               item = new_empty_history_menu_item (action);
-               gtk_menu_shell_append (menu, item);             
-               return GTK_WIDGET (menu);
+               return NULL;
        }
 
+       menu = GTK_MENU_SHELL (gtk_menu_new ());
+
        start = 0;
        end = ev_history_get_n_links (history);
 
@@ -218,8 +218,9 @@ ev_navigation_action_finalize (GObject *object)
        EvNavigationAction *action = EV_NAVIGATION_ACTION (object);
 
        if (action->priv->history) {
-               g_object_add_weak_pointer (G_OBJECT (action->priv->history),
-                                          (gpointer) &action->priv->history);
+               g_object_remove_weak_pointer (G_OBJECT (action->priv->history),
+                                            (gpointer) &action->priv->history);
+               action->priv->history = NULL;
        }
 
        G_OBJECT_CLASS (ev_navigation_action_parent_class)->finalize (object);