]> www.fi.muni.cz Git - evince.git/commitdiff
Make navigation action unsensitive instead of showing menu with
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Wed, 9 May 2007 15:02:09 +0000 (15:02 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Wed, 9 May 2007 15:02:09 +0000 (15:02 +0000)
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.

svn path=/trunk/; revision=2443

ChangeLog
shell/ev-history.c
shell/ev-history.h
shell/ev-navigation-action.c
shell/ev-window.c

index 0a6a405000d18f38b96b0b2055c0d032024321ca..de2813110024994308c902b578893c51ff084fee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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),
index c06fa25fa8349b94c44dfcb52a82e49f2d481959..cb015ccba5694d45126dcdcfc0d558bd5c036d93 100644 (file)
 
 #include "ev-history.h"
 
+
+enum
+{
+       HISTORY_CHANGED,
+       N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = {0, };
+
 struct _EvHistoryPrivate
 {
        GList *links;
@@ -68,6 +77,15 @@ ev_history_class_init (EvHistoryClass *class)
 
        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));
 }
 
@@ -98,6 +116,8 @@ ev_history_add_link (EvHistory *history, EvLink *link)
                history->priv->links = g_list_delete_link (history->priv->links, 
                                                           history->priv->links);
        }
+       
+       g_signal_emit (G_OBJECT (history), signals[HISTORY_CHANGED], 0);
 }
 
 EvLink *
index 2d27bda615c6b341be6cdd7a97bb21335c44c6db..55eeb7c21e484b3fcd6043e8d9a136285e6d720f 100644 (file)
@@ -48,6 +48,8 @@ struct _EvHistory
 struct _EvHistoryClass
 {
        GObjectClass parent_class;
+       
+       void (*changed) (EvHistory *history);
 };
 
 GType          ev_history_get_type             (void);
index dd4e38e83bf1e0d3c23749d71c85e0006b1eee58..9da89f993c10149f9248799ecdecc8cbb51ef35a 100644 (file)
@@ -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)
@@ -62,6 +73,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",
+                                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)
 {
@@ -133,9 +136,7 @@ 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);
        }
 
@@ -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);
index c42864313306db3f2371ee40077a6dde40c352ab..939f510b14cbb199d877c14dda9dc943e127608e 100644 (file)
@@ -391,7 +391,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        /* 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);
 }