aboutsummaryrefslogtreecommitdiffstats
path: root/src/toolbar.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-30 21:53:39 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-30 21:53:39 +0800
commitbd2108eb559d0538b59c6907b89f7aba137431dd (patch)
tree5a35409492af0c228f90a2e524a6db804c579992 /src/toolbar.c
parentc1008f8781b7940bb7096bc6e5fe250ec6ebcaf2 (diff)
downloadgsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar.gz
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar.bz2
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar.lz
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar.xz
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.tar.zst
gsoc2013-epiphany-bd2108eb559d0538b59c6907b89f7aba137431dd.zip
Allow to drag also normal urls in the toolbars. Commit some fixes I did to
2003-01-30 Marco Pesenti Gritti <marco@it.gnome.org> * data/ui/epiphany-toolbar.xml.in: * embed/mozilla/EphyWrapper.cpp: * embed/mozilla/Makefile.am: * lib/egg/egg-action.c: (disconnect_proxy): * lib/egg/egg-menu-merge.c: (update_node): * lib/ephy-dnd.c: (ephy_dnd_uri_list_extract_uris): * lib/ephy-dnd.h: * lib/ephy-string.c: (ephy_str_to_int): * lib/widgets/ephy-editable-toolbar.c: (item_node_new), (impl_get_action), (add_action), (parse_item_list), (toolbar_list_to_xml), (ephy_editable_toolbar_save), (do_merge), (free_node), (ephy_editable_toolbar_finalize): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_bookmark_id): * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add), (ephy_new_bookmark_response_cb), (ephy_new_bookmark_init), (ephy_new_bookmark_set_icon), (ephy_new_bookmark_get_id): * src/bookmarks/ephy-new-bookmark.h: * src/popup-commands.c: (popup_cmd_add_link_bookmark): * src/toolbar.c: (get_bookmark_action), (toolbar_get_action): * src/window-commands.c: (window_cmd_file_add_bookmark): Allow to drag also normal urls in the toolbars. Commit some fixes I did to the eggmenu stuff, now toolbar editor should work well, please start reporting bugs :)
Diffstat (limited to 'src/toolbar.c')
-rwxr-xr-xsrc/toolbar.c76
1 files changed, 63 insertions, 13 deletions
diff --git a/src/toolbar.c b/src/toolbar.c
index 826adc596..1df62677c 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -32,6 +32,7 @@
#include "window-commands.h"
#include "ephy-string.h"
#include "ephy-debug.h"
+#include "ephy-new-bookmark.h"
#include <string.h>
@@ -111,6 +112,25 @@ go_location_cb (EggAction *action, char *location, EphyWindow *window)
}
static EggAction *
+get_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id)
+{
+ char action_name[255];
+ EggAction *action;
+
+ LOG ("Creating action for bookmark id %ld", id)
+
+ snprintf (action_name, 255, "GoBookmarkId%ld", id);
+ action = ephy_bookmark_action_new (action_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);
+
+ return action;
+}
+
+static EggAction *
toolbar_get_action (EphyEditableToolbar *etoolbar,
const char *type,
const char *name)
@@ -120,22 +140,52 @@ toolbar_get_action (EphyEditableToolbar *etoolbar,
EphyBookmarks *bookmarks;
gulong id = 0;
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+
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);
-
- 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);
+ GtkWidget *new_bookmark;
+ const char *url;
+ const char *title = NULL;
+ GList *uris;
+
+ uris = ephy_dnd_uri_list_extract_uris (name);
+ g_return_val_if_fail (uris != NULL, NULL);
+ url = (const char *)uris->data;
+ if (uris->next)
+ {
+ title = (const char *)uris->next->data;
+ }
+
+ id = ephy_bookmarks_get_bookmark_id (bookmarks, url);
+
+ if (id == 0)
+ {
+ new_bookmark = ephy_new_bookmark_new
+ (bookmarks, GTK_WINDOW (t->priv->window), url);
+ ephy_new_bookmark_set_title (EPHY_NEW_BOOKMARK (new_bookmark),
+ title);
+ gtk_dialog_run (GTK_DIALOG (new_bookmark));
+ id = ephy_new_bookmark_get_id (EPHY_NEW_BOOKMARK (new_bookmark));
+ gtk_widget_destroy (new_bookmark);
+ }
+
+ g_return_val_if_fail (id != 0, NULL);
+
+ action = get_bookmark_action (t, bookmarks, id);
+
+ g_list_foreach (uris, (GFunc)g_free, NULL);
+ g_list_free (uris);
}
- else
+ else if (g_str_has_prefix (name, "GoBookmarkId"))
+ {
+ if (ephy_str_to_int (name + strlen ("GoBookmarkId"), &id))
+ {
+ action = get_bookmark_action (t, bookmarks, id);
+ }
+ }
+
+ if (action == NULL)
{
action = EPHY_EDITABLE_TOOLBAR_CLASS
(parent_class)->get_action (etoolbar, type, name);