]> www.fi.muni.cz Git - evince.git/commitdiff
Use signals to notify action activation. Hopefully I did not break
authorMarco Pesenti Gritti <mpg@redhat.com>
Wed, 11 May 2005 09:42:22 +0000 (09:42 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 11 May 2005 09:42:22 +0000 (09:42 +0000)
2005-05-11  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-marshal.list:
        * shell/ev-page-action.c: (ev_page_action_widget_class_init),
        (activate_cb), (match_selected_cb), (activate_link_cb),
        (connect_proxy), (ev_page_action_class_init):
        * shell/ev-page-action.h:

        Use signals to notify action activation. Hopefully
        I did not break completion since I cant test...

        * shell/ev-window.c: (activate_link_cb), (activate_label_cb),
        (register_custom_actions):

        Connect to page selector actions and also grab focus on
        the view when activated.

ChangeLog
shell/ev-marshal.list
shell/ev-page-action.c
shell/ev-page-action.h
shell/ev-window.c

index 60e03110b01b719bd3788ca5516e77505a63482c..b670751525356025a4ceae96177188b83c518533 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-05-11  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-marshal.list:
+       * shell/ev-page-action.c: (ev_page_action_widget_class_init),
+       (activate_cb), (match_selected_cb), (activate_link_cb),
+       (connect_proxy), (ev_page_action_class_init):
+       * shell/ev-page-action.h:
+
+       Use signals to notify action activation. Hopefully
+       I did not break completion since I cant test...
+
+       * shell/ev-window.c: (activate_link_cb), (activate_label_cb),
+       (register_custom_actions):
+
+       Connect to page selector actions and also grab focus on
+       the view when activated.
+
 Wed May 11 01:18:29 2005  Jonathan Blandford  <jrb@redhat.com>
 
        * pdf/ev-poppler.cc:
index c2a026bf2dd58e05e4386f63aeef73611d36e0bb..44b8bcbb16f35319525ef1c26a387a36a37f91da 100644 (file)
@@ -1,3 +1,4 @@
 VOID:NONE
 VOID:OBJECT,OBJECT
 VOID:ENUM,BOOLEAN
+BOOLEAN:STRING
index 2eed3763f13b01b731f08613ad9f1a32156d5c1a..864e5e39654b5a543e87f453bacb218cb78a2fe3 100644 (file)
@@ -24,6 +24,7 @@
 #include "ev-page-action.h"
 #include "ev-window.h"
 #include "ev-document-links.h"
+#include "ev-marshal.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtkentry.h>
@@ -49,6 +50,9 @@ struct _EvPageActionWidget
 struct _EvPageActionWidgetClass
 {
        GtkToolItemClass parent_class;
+
+       void (* activate_link) (EvPageActionWidget *page_action,
+                               EvLink             *link);
 };
 
 struct _EvPageActionPrivate
@@ -66,6 +70,14 @@ static void  ev_page_action_widget_class_init (EvPageActionWidgetClass *action_w
 #define EV_TYPE_PAGE_ACTION_WIDGET (ev_page_action_widget_get_type ())
 #define EV_PAGE_ACTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PAGE_ACTION_WIDGET, EvPageActionWidget))
 
+enum
+{
+       WIDGET_ACTIVATE_LINK,
+       WIDGET_N_SIGNALS
+};
+
+static guint widget_signals[WIDGET_N_SIGNALS] = {0, };
+
 G_DEFINE_TYPE (EvPageActionWidget, ev_page_action_widget, GTK_TYPE_TOOL_ITEM)
 
 static void
@@ -105,11 +117,30 @@ ev_page_action_widget_class_init (EvPageActionWidgetClass *class)
        GObjectClass *object_class = G_OBJECT_CLASS (class);
 
        object_class->finalize = ev_page_action_widget_finalize;
+
+       widget_signals[WIDGET_ACTIVATE_LINK] = g_signal_new ("activate_link",
+                                              G_OBJECT_CLASS_TYPE (object_class),
+                                              G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                              G_STRUCT_OFFSET (EvPageActionClass, activate_link),
+                                              NULL, NULL,
+                                              g_cclosure_marshal_VOID__OBJECT,
+                                              G_TYPE_NONE, 1,
+                                              G_TYPE_OBJECT);
+
 }
 
 static void ev_page_action_init       (EvPageAction *action);
 static void ev_page_action_class_init (EvPageActionClass *class);
 
+enum
+{
+       ACTIVATE_LINK,
+       ACTIVATE_LABEL,
+       N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = {0, };
+
 G_DEFINE_TYPE (EvPageAction, ev_page_action, GTK_TYPE_ACTION)
 
 #define EV_PAGE_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_PAGE_ACTION, EvPageActionPrivate))
@@ -166,11 +197,14 @@ activate_cb (GtkWidget *entry, GtkAction *action)
        EvPageAction *page = EV_PAGE_ACTION (action);
        EvPageCache *page_cache;
        const char *text;
+       gboolean changed;
 
        text = gtk_entry_get_text (GTK_ENTRY (entry));
        page_cache = page->priv->page_cache;
 
-       if (! ev_page_cache_set_page_label (page_cache, text)) {
+       g_signal_emit (action, signals[ACTIVATE_LABEL], 0, text, &changed);
+
+       if (!changed) {
                /* rest the entry to the current page if we were unable to
                 * change it */
                gchar *page_label =
@@ -302,7 +336,8 @@ match_selected_cb (GtkEntryCompletion *completion,
        gtk_tree_model_get (proxy->model, iter,
                            EV_DOCUMENT_LINKS_COLUMN_LINK, &link,
                            -1);
-       ev_page_cache_set_link (proxy->page_cache, link);
+
+       g_signal_emit (proxy, signals[ACTIVATE_LINK], 0, link);
        
        return TRUE;
 }
@@ -422,6 +457,12 @@ update_model (EvPageAction *page, GParamSpec *pspec, EvPageActionWidget *proxy)
        }
 }
 
+static void
+activate_link_cb (EvPageActionWidget *proxy, EvLink *link, EvPageAction *action)
+{
+       g_signal_emit (action, signals[ACTIVATE_LINK], 0, link);
+}
+
 static void
 connect_proxy (GtkAction *action, GtkWidget *proxy)
 {
@@ -429,6 +470,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
                g_signal_connect_object (action, "notify::page-cache",
                                         G_CALLBACK (update_page_cache),
                                         proxy, 0);
+               g_signal_connect (proxy, "activate_link",
+                                 G_CALLBACK (activate_link_cb),
+                                 action);
                update_page_cache (EV_PAGE_ACTION (action), NULL,
                                   EV_PAGE_ACTION_WIDGET (proxy));
                /* We only go through this whole rigmarole if we can set
@@ -570,6 +614,23 @@ ev_page_action_class_init (EvPageActionClass *class)
        action_class->create_tool_item = create_tool_item;
        action_class->connect_proxy = connect_proxy;
 
+       signals[ACTIVATE_LINK] = g_signal_new ("activate_link",
+                                              G_OBJECT_CLASS_TYPE (object_class),
+                                              G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                              G_STRUCT_OFFSET (EvPageActionClass, activate_link),
+                                              NULL, NULL,
+                                              g_cclosure_marshal_VOID__OBJECT,
+                                              G_TYPE_NONE, 1,
+                                              G_TYPE_OBJECT);
+       signals[ACTIVATE_LABEL] = g_signal_new ("activate_label",
+                                               G_OBJECT_CLASS_TYPE (object_class),
+                                               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                               G_STRUCT_OFFSET (EvPageActionClass, activate_link),
+                                               NULL, NULL,
+                                               ev_marshal_BOOLEAN__STRING,
+                                               G_TYPE_BOOLEAN, 1,
+                                               G_TYPE_STRING);
+
        g_object_class_install_property (object_class,
                                         PROP_PAGE_CACHE,
                                         g_param_spec_object ("page-cache",
index 8ac0d54cfa2c3441246882ba5e945b53a0a7d4ad..c8b30ba6d279cfbcb2d18b1ef1d914624ea9d84c 100644 (file)
@@ -51,8 +51,10 @@ struct _EvPageActionClass
 {
        GtkActionClass parent_class;
 
-       void (* goto_page) (EvPageAction *page_action,
-                           int           page_number);
+       void     (* activate_link) (EvPageAction *page_action,
+                                   EvLink       *link);
+       gboolean (*activate_label) (EvPageAction *page_action,
+                                   char         *label);
 };
 
 GType ev_page_action_get_type     (void);
index 2475de0af289d86378e74ce2ffd9ce9abe8370f8..fc1f0ca72e31f17dbae8d63dde25198f00b4f637 100644 (file)
@@ -2436,6 +2436,25 @@ drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
        }
 }
 
+static void
+activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
+{
+       g_return_if_fail (EV_IS_WINDOW (window));
+
+       ev_page_cache_set_link (window->priv->page_cache, link);
+       gtk_widget_grab_focus (window->priv->view);
+}
+
+static gboolean
+activate_label_cb (EvPageAction *page_action, char *label, EvWindow *window)
+{
+       g_return_val_if_fail (EV_IS_WINDOW (window), FALSE);
+
+       gtk_widget_grab_focus (window->priv->view);
+
+       return ev_page_cache_set_page_label (window->priv->page_cache, label);
+}
+
 static void
 register_custom_actions (EvWindow *window, GtkActionGroup *group)
 {
@@ -2447,6 +2466,10 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group)
                               "tooltip", _("Select Page"),
                               "visible_overflown", FALSE,
                               NULL);
+       g_signal_connect (action, "activate_link",
+                         G_CALLBACK (activate_link_cb), window);
+       g_signal_connect (action, "activate_label",
+                         G_CALLBACK (activate_label_cb), window);
        gtk_action_group_add_action (group, action);
        g_object_unref (action);