X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=shell%2Fev-navigation-action.c;h=3aa1bea921840a63377b805c09e3ea07f5d2c1d4;hb=217797d63b2d3b1c9a7a0511af1bbf3d99f0d482;hp=cbed9fb8abd84bb946a5574c47de677b9d4e8251;hpb=531db966e66aa1b1c1638fc5260e49334b808e9e;p=evince.git diff --git a/shell/ev-navigation-action.c b/shell/ev-navigation-action.c index cbed9fb8..3aa1bea9 100644 --- a/shell/ev-navigation-action.c +++ b/shell/ev-navigation-action.c @@ -54,6 +54,17 @@ 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 (action, ev_history_get_n_links (history) > 0); + + return; +} + void ev_navigation_action_set_history (EvNavigationAction *action, EvHistory *history) @@ -61,7 +72,11 @@ ev_navigation_action_set_history (EvNavigationAction *action, action->priv->history = history; g_object_add_weak_pointer (G_OBJECT (action->priv->history), - (gpointer *) &action->priv->history); + (gpointer) &action->priv->history); + + g_signal_connect_object (history, "changed", + ev_navigation_action_history_changed, + action, 0); } static void @@ -110,18 +125,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 +134,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 +219,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);