+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:
#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>
struct _EvPageActionWidgetClass
{
GtkToolItemClass parent_class;
+
+ void (* activate_link) (EvPageActionWidget *page_action,
+ EvLink *link);
};
struct _EvPageActionPrivate
#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
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))
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 =
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;
}
}
}
+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)
{
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
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",
}
}
+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)
{
"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);