diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 20 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.h | 3 | ||||
-rw-r--r-- | src/session.c | 2 | ||||
-rwxr-xr-x | src/toolbar.c | 94 |
4 files changed, 80 insertions, 39 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 5e9d539f3..7e1d2bdd5 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -659,6 +659,26 @@ ephy_bookmarks_add (EphyBookmarks *eb, return bm; } +guint +ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb, + const char *url) +{ + EphyNode *node; + + g_static_rw_lock_reader_lock (eb->priv->bookmarks_hash_lock); + node = g_hash_table_lookup (eb->priv->bookmarks_hash, url); + g_static_rw_lock_reader_unlock (eb->priv->bookmarks_hash_lock); + + if (node) + { + return ephy_node_get_id (node); + } + else + { + return -1; + } +} + void ephy_bookmarks_set_icon (EphyBookmarks *eb, const char *url, diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h index d2b1d7915..169e5a841 100644 --- a/src/bookmarks/ephy-bookmarks.h +++ b/src/bookmarks/ephy-bookmarks.h @@ -69,6 +69,9 @@ EphyNode *ephy_bookmarks_add (EphyBookmarks *eb, const char *smart_url, const char *keywords); +guint ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb, + const char *url); + void ephy_bookmarks_set_icon (EphyBookmarks *eb, const char *url, const char *icon); diff --git a/src/session.c b/src/session.c index d050a9dcd..431edef02 100644 --- a/src/session.c +++ b/src/session.c @@ -604,7 +604,7 @@ session_load (Session *session, { if (strcmp (child->name, "window") == 0) { - gint x = 0, y = 0, width = 0, height = 0; + gulong x = 0, y = 0, width = 0, height = 0; xmlChar *tmp; tmp = xmlGetProp (child, "x"); diff --git a/src/toolbar.c b/src/toolbar.c index ff5f9cba1..29ae4665f 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -100,17 +100,72 @@ toolbar_get_type (void) } static void +go_location_cb (EggAction *action, char *location, EphyWindow *window) +{ + EphyEmbed *embed; + + embed = ephy_window_get_active_embed (window); + g_return_if_fail (embed != NULL); + + ephy_embed_load_url (embed, location); +} + +static EggAction * +toolbar_get_action (EphyEditableToolbar *etoolbar, + const char *type, + const char *name) +{ + Toolbar *t = TOOLBAR (etoolbar); + EggAction *action = NULL; + EphyBookmarks *bookmarks; + gulong id = 0; + + if (type && (strcmp (type, EPHY_DND_URL_TYPE) == 0)) + { + char action_name[255]; + + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + id = ephy_bookmarks_get_bookmark_id (bookmarks, name); + + snprintf (action_name, 255, "GoBookmarkId%ld", id); + action = ephy_bookmark_action_new (name, id); + } + else if (g_str_has_prefix (name, "GoBookmarkId")) + { + ephy_str_to_int (name + strlen ("GoBookmarkId"), &id); + } + + if (action) + { + g_signal_connect (action, "go_location", + G_CALLBACK (go_location_cb), t->priv->window); + egg_action_group_add_action (t->priv->action_group, action); + g_object_unref (action); + } + else + { + action = EPHY_EDITABLE_TOOLBAR_CLASS + (parent_class)->get_action (etoolbar, type, name); + } + + return action; +} + +static void toolbar_class_init (ToolbarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + EphyEditableToolbarClass *eet_class; parent_class = g_type_class_peek_parent (klass); + eet_class = EPHY_EDITABLE_TOOLBAR_CLASS (klass); object_class->finalize = toolbar_finalize; - object_class->set_property = toolbar_set_property; object_class->get_property = toolbar_get_property; + eet_class->get_action = toolbar_get_action; + g_object_class_install_property (object_class, PROP_EPHY_WINDOW, g_param_spec_object ("EphyWindow", @@ -153,17 +208,6 @@ toolbar_get_property (GObject *object, } static void -go_location_cb (EggAction *action, char *location, EphyWindow *window) -{ - EphyEmbed *embed; - - embed = ephy_window_get_active_embed (window); - g_return_if_fail (embed != NULL); - - ephy_embed_load_url (embed, location); -} - -static void toolbar_setup_actions (Toolbar *t) { EggAction *action; @@ -246,28 +290,6 @@ toolbar_set_window (Toolbar *t, EphyWindow *window) } static void -editable_toolbar_request_action (Toolbar *t, - const char *name, - EphyEditableToolbar *etoolbar) -{ - guint id; - - if (g_str_has_prefix (name, "GoBookmark") && - ephy_str_to_int (name + strlen ("GoBookmark"), &id)) - { - EggAction *action; - - LOG ("Create an action for bookmark %d", id) - - action = ephy_bookmark_action_new (name, id); - g_signal_connect (action, "go_location", - G_CALLBACK (go_location_cb), t->priv->window); - egg_action_group_add_action (t->priv->action_group, action); - g_object_unref (action); - } -} - -static void toolbar_init (Toolbar *t) { t->priv = g_new0 (ToolbarPrivate, 1); @@ -275,10 +297,6 @@ toolbar_init (Toolbar *t) t->priv->window = NULL; t->priv->ui_merge = NULL; t->priv->visibility = TRUE; - - g_signal_connect (t, "request_action", - G_CALLBACK (editable_toolbar_request_action), - EPHY_EDITABLE_TOOLBAR (t)); } static void |