diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-06-24 02:28:31 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2004-06-24 02:28:31 +0800 |
commit | 96aedf7f4f19c494a549310b7c6e55b6fcd7668a (patch) | |
tree | 93c41ee9896977c52df9f03a5e3f81f36665d3ad | |
parent | d12bc3fbd3a34b8bcf8a6d7c23815f5a79dec49d (diff) | |
download | gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar.gz gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar.bz2 gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar.lz gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar.xz gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.tar.zst gsoc2013-epiphany-96aedf7f4f19c494a549310b7c6e55b6fcd7668a.zip |
Add EphyWindow API to open multiple uris in tabs, use it for dnd on the
2004-06-23 Marco Pesenti Gritti <marco@gnome.org>
* src/ephy-notebook.c: (notebook_drag_data_received_cb):
* src/ephy-window.c: (ephy_window_set_zoom),
(ephy_window_load_in_tabs):
* src/ephy-window.h:
Add EphyWindow API to open multiple uris in
tabs, use it for dnd on the notebook.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | src/ephy-notebook.c | 60 | ||||
-rw-r--r-- | src/ephy-window.c | 47 | ||||
-rw-r--r-- | src/ephy-window.h | 4 |
4 files changed, 72 insertions, 49 deletions
@@ -1,3 +1,13 @@ +2004-06-23 Marco Pesenti Gritti <marco@gnome.org> + + * src/ephy-notebook.c: (notebook_drag_data_received_cb): + * src/ephy-window.c: (ephy_window_set_zoom), + (ephy_window_load_in_tabs): + * src/ephy-window.h: + + Add EphyWindow API to open multiple uris in + tabs, use it for dnd on the notebook. + 2004-06-23 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/GlobalHistory.cpp: diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index 02389dd52..cd61994bc 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -584,20 +584,13 @@ ephy_notebook_switch_page_cb (GtkNotebook *notebook, child); } -#define INSANE_NUMBER_OF_URLS 20 - static void notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time, EphyTab *tab) { - EphyEmbed *embed = NULL; - EphyWindow *window = NULL; - GtkWidget *toplevel; - GList *uris = NULL, *l; + GList *uri_list = NULL; GnomeVFSURI *uri; - gchar *url = NULL; - guint num = 0; gchar **tmp; g_signal_stop_emission_by_name (widget, "drag_data_received"); @@ -613,62 +606,31 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, if (tmp) { uri = gnome_vfs_uri_new (tmp[0]); - if (uri) uris = g_list_append (uris, uri); + if (uri) + { + uri_list = g_list_append (uri_list, uri); + } g_strfreev (tmp); } } else if (selection_data->target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE)) { - uris = gnome_vfs_uri_list_parse (selection_data->data); + uri_list = gnome_vfs_uri_list_parse (selection_data->data); } else { g_assert_not_reached (); } - if (uris == NULL) return; - - toplevel = gtk_widget_get_toplevel (widget); - g_return_if_fail (EPHY_IS_WINDOW (toplevel)); - window = EPHY_WINDOW (toplevel); - - if (tab != NULL) + if (uri_list) { - embed = ephy_tab_get_embed (tab); - g_return_if_fail (EPHY_IS_EMBED (embed)); - } + EphyWindow *window; - l = uris; - while (l != NULL && num < INSANE_NUMBER_OF_URLS) - { - uri = (GnomeVFSURI*) l->data; - url = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); + window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))); - if (num == 0 && embed != NULL) - { - /** - * The first url is special: if the drag was to an - * existing tab, load it there - */ - ephy_embed_load_url (embed, url); - } - else - { - tab = ephy_shell_new_tab (ephy_shell, window, - tab, url, - EPHY_NEW_TAB_OPEN_PAGE | - EPHY_NEW_TAB_IN_EXISTING_WINDOW | - (tab ? EPHY_NEW_TAB_APPEND_AFTER : - EPHY_NEW_TAB_APPEND_LAST)); - } - - g_free (url); - url = NULL; - l = l->next; - ++num; + ephy_window_load_in_tabs (window, tab, uri_list); + gnome_vfs_uri_list_free (uri_list); } - - gnome_vfs_uri_list_free (uris); } /* diff --git a/src/ephy-window.c b/src/ephy-window.c index 5010ffc46..0ddf7f59c 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -304,6 +304,7 @@ static guint ephy_popups_n_entries = G_N_ELEMENTS (ephy_popups_entries); #define CONF_LOCKDOWN_HIDE_MENUBAR "/apps/epiphany/lockdown/hide_menubar" #define CONF_DESKTOP_BG_PICTURE "/desktop/gnome/background/picture_filename" +#define INSANE_NUMBER_OF_URLS 20 #define EPHY_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WINDOW, EphyWindowPrivate)) @@ -2620,6 +2621,52 @@ ephy_window_set_zoom (EphyWindow *window, } } +void +ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list) +{ + EphyEmbed *embed = NULL; + GList *l; + gchar *url = NULL; + guint num = 0; + GnomeVFSURI *uri; + + if (tab != NULL) + { + embed = ephy_tab_get_embed (tab); + g_return_if_fail (EPHY_IS_EMBED (embed)); + } + + l = uri_list; + while (l != NULL && num < INSANE_NUMBER_OF_URLS) + { + uri = (GnomeVFSURI*) l->data; + url = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); + + if (num == 0 && embed != NULL) + { + /** + * The first url is special: if the drag was to an + * existing tab, load it there + */ + ephy_embed_load_url (embed, url); + } + else + { + tab = ephy_shell_new_tab (ephy_shell, window, + tab, url, + EPHY_NEW_TAB_OPEN_PAGE | + EPHY_NEW_TAB_IN_EXISTING_WINDOW | + (tab ? EPHY_NEW_TAB_APPEND_AFTER : + EPHY_NEW_TAB_APPEND_LAST)); + } + + g_free (url); + url = NULL; + l = l->next; + ++num; + } +} + static void sync_prefs_with_chrome (EphyWindow *window) { diff --git a/src/ephy-window.h b/src/ephy-window.h index e1c6f4261..cace444f5 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -91,6 +91,10 @@ void ephy_window_jump_to_tab (EphyWindow *window, void ephy_window_load_url (EphyWindow *window, const char *url); +void ephy_window_load_in_tabs (EphyWindow *window, + EphyTab *first_tab, + GList *uri_list); + void ephy_window_set_zoom (EphyWindow *window, float zoom); |