aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c78
-rw-r--r--src/bookmarks/ephy-bookmark-toolitem.c37
-rw-r--r--src/bookmarks/ephy-bookmark-toolitem.h3
3 files changed, 75 insertions, 43 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 119007818..1362b8d02 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -196,53 +196,45 @@ ephy_bookmark_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget
}
static void
-entry_activated_cb (GtkWidget *entry, EggAction *action)
+activate_cb (GtkWidget *widget, const char *text, EggAction *action)
{
- char *text;
- char *solved;
- char *smart_url;
- EphyBookmarks *bookmarks;
+ char *location = NULL;
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ if (text != NULL && text[0] != '\0')
+ {
+ char *smart_url;
+ EphyBookmarks *bookmarks;
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- if (text == NULL) return;
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- smart_url = EPHY_BOOKMARK_ACTION (action)->priv->location;
- solved = ephy_bookmarks_solve_smart_url (bookmarks,
- smart_url,
- text);
- g_signal_emit (action,
- ephy_bookmark_action_signals[GO_LOCATION],
- 0, solved);
+ smart_url = EPHY_BOOKMARK_ACTION (action)->priv->location;
+ location = ephy_bookmarks_solve_smart_url (bookmarks,
+ smart_url,
+ text);
+ }
+ else
+ {
+ EphyBookmarkAction *baction = EPHY_BOOKMARK_ACTION (action);
- g_free (text);
-}
+ if (baction->priv->smart_url)
+ {
+ GnomeVFSURI *uri;
-static void
-activate_cb (GtkWidget *widget, EggAction *action)
-{
- EphyBookmarkAction *baction = EPHY_BOOKMARK_ACTION (action);
- char *location = NULL;
+ uri = gnome_vfs_uri_new (baction->priv->location);
- if (baction->priv->smart_url)
- {
- GnomeVFSURI *uri;
-
- uri = gnome_vfs_uri_new (baction->priv->location);
+ if (uri)
+ {
+ location = g_strdup (gnome_vfs_uri_get_host_name (uri));
+ gnome_vfs_uri_unref (uri);
+ }
+ }
- if (uri)
+ if (location == NULL)
{
- location = g_strdup (gnome_vfs_uri_get_host_name (uri));
- gnome_vfs_uri_unref (uri);
+ location = g_strdup (baction->priv->location);
}
}
- if (location == NULL)
- {
- location = g_strdup (baction->priv->location);
- }
-
g_signal_emit (action,
ephy_bookmark_action_signals[GO_LOCATION],
0, location);
@@ -251,10 +243,14 @@ activate_cb (GtkWidget *widget, EggAction *action)
}
static void
-connect_proxy (EggAction *action, GtkWidget *proxy)
+menu_activate_cb (GtkWidget *widget, EggAction *action)
{
- GtkWidget *button, *entry;
+ activate_cb (widget, NULL, action);
+}
+static void
+connect_proxy (EggAction *action, GtkWidget *proxy)
+{
LOG ("Connecting action %p to proxy %p", action, proxy)
(* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
@@ -273,15 +269,11 @@ connect_proxy (EggAction *action, GtkWidget *proxy)
if (EGG_IS_TOOL_ITEM (proxy))
{
- button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button"));
- g_signal_connect (button, "clicked", G_CALLBACK (activate_cb), action);
-
- entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
- g_signal_connect (entry, "activate", G_CALLBACK (entry_activated_cb), action);
+ g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
}
else if (GTK_IS_MENU_ITEM (proxy))
{
- g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
+ g_signal_connect (proxy, "activate", G_CALLBACK (menu_activate_cb), action);
}
}
diff --git a/src/bookmarks/ephy-bookmark-toolitem.c b/src/bookmarks/ephy-bookmark-toolitem.c
index 1c21b8f1d..b4245de29 100644
--- a/src/bookmarks/ephy-bookmark-toolitem.c
+++ b/src/bookmarks/ephy-bookmark-toolitem.c
@@ -32,6 +32,13 @@ static GObjectClass *parent_class = NULL;
static void ephy_bookmark_toolitem_class_init (EphyBookmarkToolitemClass *klass);
static void ephy_bookmark_toolitem_init (EphyBookmarkToolitem *item);
+enum
+{
+ ACTIVATE,
+ LAST_SIGNAL
+};
+static guint EphyBookmarkToolitemSignals[LAST_SIGNAL];
+
#define MENU_ID "ephy-bookmark-toolitem-menu-id"
/**
@@ -66,6 +73,21 @@ ephy_bookmark_toolitem_get_type (void)
return ephy_bookmark_toolitem_type;
}
+static void
+activated_cb (GtkWidget *widget, EggToolItem *item)
+{
+ char *text = NULL;
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ }
+
+ g_signal_emit (item, EphyBookmarkToolitemSignals[ACTIVATE], 0, text);
+
+ g_free (text);
+}
+
static gboolean
ephy_bookmark_toolitem_create_menu_proxy (EggToolItem *item)
{
@@ -85,6 +107,8 @@ ephy_bookmark_toolitem_create_menu_proxy (EggToolItem *item)
menu_item = gtk_image_menu_item_new_with_mnemonic (text);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+ g_signal_connect (menu_item, "activate", G_CALLBACK (activated_cb), item);
+
egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
return TRUE;
@@ -125,6 +149,9 @@ ephy_bookmark_toolitem_init (EphyBookmarkToolitem *item)
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
g_object_set_data (G_OBJECT (item), "label", label);
+
+ g_signal_connect (button, "clicked", G_CALLBACK (activated_cb), item);
+ g_signal_connect (entry, "activate", G_CALLBACK (activated_cb), item);
}
static void
@@ -137,4 +164,14 @@ ephy_bookmark_toolitem_class_init (EphyBookmarkToolitemClass *klass)
tool_item_class = (EggToolItemClass *)klass;
tool_item_class->create_menu_proxy = ephy_bookmark_toolitem_create_menu_proxy;
+
+ EphyBookmarkToolitemSignals[ACTIVATE] = g_signal_new (
+ "activate", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyBookmarkToolitemClass, activated),
+ NULL, NULL,
+ ephy_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
}
diff --git a/src/bookmarks/ephy-bookmark-toolitem.h b/src/bookmarks/ephy-bookmark-toolitem.h
index 1e817b0b7..f8248637e 100644
--- a/src/bookmarks/ephy-bookmark-toolitem.h
+++ b/src/bookmarks/ephy-bookmark-toolitem.h
@@ -43,6 +43,9 @@ typedef struct _EphyBookmarkToolitemPrivate EphyBookmarkToolitemPrivate;
struct _EphyBookmarkToolitemClass
{
EggToolItemClass parent_class;
+
+ void (* activated) (EphyBookmarkToolitem *item,
+ const char *text);
};
struct _EphyBookmarkToolitem