+2007-05-09 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * shell/ev-history.c: (ev_history_class_init),
+ (ev_history_add_link):
+ * shell/ev-history.h:
+ * shell/ev-navigation-action.c:
+ (ev_navigation_action_history_changed),
+ (ev_navigation_action_set_history), (build_menu),
+ (ev_navigation_action_finalize):
+ * shell/ev-window.c: (ev_window_setup_action_sensitivity):
+
+ Make navigation action unsensitive instead of showing
+ menu with unsensitive word.
+
2007-05-08 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-application.[ch]: (ev_application_shutdown),
#include "ev-history.h"
+
+enum
+{
+ HISTORY_CHANGED,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = {0, };
+
struct _EvHistoryPrivate
{
GList *links;
object_class->finalize = ev_history_finalize;
+ signals[HISTORY_CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EvHistoryClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (object_class, sizeof (EvHistoryPrivate));
}
history->priv->links = g_list_delete_link (history->priv->links,
history->priv->links);
}
+
+ g_signal_emit (G_OBJECT (history), signals[HISTORY_CHANGED], 0);
}
EvLink *
struct _EvHistoryClass
{
GObjectClass parent_class;
+
+ void (*changed) (EvHistory *history);
};
GType ev_history_get_type (void);
#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)
g_object_add_weak_pointer (G_OBJECT (action->priv->history),
(gpointer) &action->priv->history);
+
+ g_signal_connect_object (history, "changed",
+ ev_navigation_action_history_changed,
+ action, 0);
}
static void
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)
{
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);
+ if (history == NULL) {
return GTK_WIDGET (menu);
}
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);
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
- ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, has_pages);
+ ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
ev_window_update_actions (ev_window);
}