diff options
author | Xan Lopez <xan@src.gnome.org> | 2003-07-17 21:20:10 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2003-07-17 21:20:10 +0800 |
commit | e8fbf999bcd5cc7bb8bf4e2b25885869a744ca43 (patch) | |
tree | d71c8ae37d29a5c2235e97bbb49872b02d6b8962 | |
parent | 3212871bff4999162a67e32c86990821e8c995ed (diff) | |
download | gsoc2013-epiphany-e8fbf999bcd5cc7bb8bf4e2b25885869a744ca43.tar.gz gsoc2013-epiphany-e8fbf999bcd5cc7bb8bf4e2b25885869a744ca43.tar.zst gsoc2013-epiphany-e8fbf999bcd5cc7bb8bf4e2b25885869a744ca43.zip |
Allow DND of URLs (from links or favicons or other apps...) to the
Allow DND of URLs (from links or favicons or other apps...) to the
bookmarks toolbar, fixes #116613 (HOORAY), thanks to marco and
chpe for the help.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | embed/ephy-history.c | 20 | ||||
-rw-r--r-- | embed/ephy-history.h | 2 | ||||
-rw-r--r-- | src/ephy-favicon-action.c | 8 | ||||
-rw-r--r-- | src/ephy-tab.c | 8 | ||||
-rwxr-xr-x | src/ephy-toolbars-model.c | 45 | ||||
-rwxr-xr-x | src/toolbar.c | 3 |
7 files changed, 93 insertions, 6 deletions
@@ -1,3 +1,16 @@ +2003-07-17 Xan Lopez <xan@masilla.org> + + * embed/ephy-history.c: (ephy_history_get_icon): + * embed/ephy-history.h: + * src/ephy-favicon-action.c: (each_url_get_data_binder): + * src/ephy-tab.c: (ephy_tab_get_type), (ephy_tab_open_uri_cb): + * src/ephy-toolbars-model.c: (impl_add_item): + * src/toolbar.c: + + Allow DND of URLs (from links or favicons or other apps...) to the + bookmarks toolbar, fixes #116613 (HOORAY), thanks to marco and chpe + for the help. + 2003-07-16 Marco Pesenti Gritti <marco@it.gnome.org> * src/prefs-dialog.c: (setup_font_menu): diff --git a/embed/ephy-history.c b/embed/ephy-history.c index 097b70d5c..8ead4fe01 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -823,6 +823,26 @@ ephy_history_set_page_title (EphyHistory *gh, g_value_unset (&value); } +const char* +ephy_history_get_icon (EphyHistory *gh, + const char *url) +{ + EphyNode *node, *host; + int host_id; + + node = ephy_history_get_page (gh, url); + if (node == NULL) return NULL; + + host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID); + g_return_val_if_fail (host_id >= 0, NULL); + + host = ephy_node_db_get_node_from_id (gh->priv->db, host_id); + g_return_val_if_fail (host != NULL, NULL); + + return ephy_node_get_property_string (host, EPHY_NODE_PAGE_PROP_ICON); +} + + void ephy_history_set_icon (EphyHistory *gh, const char *url, diff --git a/embed/ephy-history.h b/embed/ephy-history.h index 7d1d66ee4..5d89ce708 100644 --- a/embed/ephy-history.h +++ b/embed/ephy-history.h @@ -90,6 +90,8 @@ const char *ephy_history_get_last_page (EphyHistory *gh); void ephy_history_set_icon (EphyHistory *gh, const char *url, const char *icon); +const char *ephy_history_get_icon (EphyHistory *gh, + const char *url); void ephy_history_clear (EphyHistory *gh); diff --git a/src/ephy-favicon-action.c b/src/ephy-favicon-action.c index 418c11ab8..376794cba 100644 --- a/src/ephy-favicon-action.c +++ b/src/ephy-favicon-action.c @@ -84,7 +84,9 @@ static void each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee, gpointer iterator_context, gpointer data) { + const char *title; char *location; + char *netscape_url; EphyTab *tab; EphyEmbed *embed; EphyWindow *window = EPHY_WINDOW(iterator_context); @@ -92,9 +94,13 @@ each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee, tab = ephy_window_get_active_tab (window); embed = ephy_tab_get_embed (tab); ephy_embed_get_location (embed, TRUE, &location); + title = ephy_tab_get_title (tab); - iteratee (location, -1, -1, -1, -1, data); + netscape_url = g_strconcat (location, "\n", title, NULL); + iteratee (netscape_url, -1, -1, -1, -1, data); + + g_free (netscape_url); g_free (location); } diff --git a/src/ephy-tab.c b/src/ephy-tab.c index 5d2056dcd..270fd6cb3 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #ifdef HAVE_CONFIG_H @@ -136,8 +138,8 @@ ephy_tab_get_type (void) }; ephy_tab_type = g_type_register_static (G_TYPE_OBJECT, - "EphyTab", - &our_info, 0); + "EphyTab", + &our_info, 0); } return ephy_tab_type; @@ -820,7 +822,7 @@ ephy_tab_destroy_brsr_cb (EphyEmbed *embed, EphyTab *tab) static gint ephy_tab_open_uri_cb (EphyEmbed *embed, const char *uri, - EphyTab *tab) + EphyTab *tab) { LOG ("ephy_tab_open_uri_cb %s", uri) diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c index e8e733647..e587fde84 100755 --- a/src/ephy-toolbars-model.c +++ b/src/ephy-toolbars-model.c @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #include "ephy-toolbars-model.h" @@ -32,8 +34,8 @@ static void ephy_toolbars_model_finalize (GObject *object); enum { - ACTION_ADDED, - LAST_SIGNAL + ACTION_ADDED, + LAST_SIGNAL }; enum @@ -42,6 +44,12 @@ enum PROP_BOOKMARKS }; +enum +{ + URL, + NAME +}; + static GObjectClass *parent_class = NULL; struct EphyToolbarsModelPrivate @@ -148,6 +156,39 @@ impl_add_item (EggToolbarsModel *t, (EPHY_TOOLBARS_MODEL (t), FALSE, id); g_list_free (nodes); } + else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type) + { + EphyNode *node = NULL; + EphyBookmarks *bookmarks; + gchar **netscape_url; + + netscape_url = g_strsplit (name, "\n", 2); + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + node = ephy_bookmarks_find_bookmark (bookmarks, netscape_url[URL]); + + if (!node) + { + /* Create the bookmark, it does not exist */ + EphyHistory *gh; + const char *icon; + + node = ephy_bookmarks_add (bookmarks, netscape_url[NAME], netscape_url[URL]); + g_return_val_if_fail (node != NULL, NULL); + + gh = ephy_embed_shell_get_global_history (EPHY_EMBED_SHELL (ephy_shell)); + icon = ephy_history_get_icon (gh, netscape_url[URL]); + + if (icon) + { + ephy_bookmarks_set_icon (bookmarks, netscape_url[URL], icon); + } + } + + id = ephy_node_get_id (node); + action_name = ephy_toolbars_model_get_action_name + (EPHY_TOOLBARS_MODEL (t), FALSE, id); + g_strfreev (netscape_url); + } else { normal_item = TRUE; diff --git a/src/toolbar.c b/src/toolbar.c index 3d482f267..2c5fe6a51 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -15,6 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #ifdef HAVE_CONFIG_H @@ -66,6 +68,7 @@ static GtkTargetEntry drag_targets[] = { { EGG_TOOLBAR_ITEM_TYPE, 0, 0 }, { EPHY_DND_TOPIC_TYPE, 0, 1 }, { EPHY_DND_BOOKMARK_TYPE, 0, 2 }, + { EPHY_DND_URL_TYPE, 0, 3 }, }; static int n_drag_targets = G_N_ELEMENTS (drag_targets); |