diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/ephy-notebook.c | 53 | ||||
-rw-r--r-- | src/ephy-window.c | 64 | ||||
-rw-r--r-- | src/ephy-window.h | 4 |
4 files changed, 63 insertions, 69 deletions
@@ -1,5 +1,16 @@ 2004-12-24 Christian Persch <chpe@cvs.gnome.org> + * src/ephy-notebook.c: (ephy_notebook_get_type), + (notebook_drag_data_received_cb): + * src/ephy-window.c: (open_link_cb), (ephy_window_init), + (ephy_window_set_zoom): + * src/ephy-window.h: + + Remove obsolete ephy_window_load_in_tabs() and use generic + link opening framework instead. + +2004-12-24 Christian Persch <chpe@cvs.gnome.org> + * src/bookmarks/ephy-topic-action.c: (append_bookmarks_menu), (open_in_tabs_activate_cb): diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index e37e3cb7f..fe10ca09b 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -32,9 +32,10 @@ #include "ephy-embed.h" #include "ephy-window.h" #include "ephy-shell.h" -#include "ephy-debug.h" #include "ephy-favicon-cache.h" #include "ephy-spinner.h" +#include "ephy-link.h" +#include "ephy-debug.h" #include <glib-object.h> #include <gtk/gtkeventbox.h> @@ -56,6 +57,8 @@ #define AFTER_ALL_TABS -1 #define NOT_IN_APP_WINDOWS -2 +#define INSANE_NUMBER_OF_URLS 20 + #define EPHY_NOTEBOOK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_NOTEBOOK, EphyNotebookPrivate)) struct EphyNotebookPrivate @@ -103,11 +106,11 @@ static GObjectClass *parent_class = NULL; GType ephy_notebook_get_type (void) { - static GType type = 0; + static GType type = 0; - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo our_info = + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo our_info = { sizeof (EphyNotebookClass), NULL, /* base_init */ @@ -120,12 +123,22 @@ ephy_notebook_get_type (void) (GInstanceInitFunc) ephy_notebook_init }; - type = g_type_register_static (GTK_TYPE_NOTEBOOK, - "EphyNotebook", - &our_info, 0); - } + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; + + type = g_type_register_static (GTK_TYPE_NOTEBOOK, + "EphyNotebook", + &our_info, 0); + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); + } - return type; + return type; } static void @@ -575,6 +588,7 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, guint info, guint time, EphyTab *tab) { EphyWindow *window; + GtkWidget *notebook; g_signal_stop_emission_by_name (widget, "drag_data_received"); @@ -583,33 +597,36 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, if (selection_data->length <= 0 || selection_data->data == NULL) return; window = EPHY_WINDOW (gtk_widget_get_toplevel (widget)); + notebook = ephy_window_get_notebook (window); if (selection_data->target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) { - char *uris[2] = { NULL, NULL }; char **split; /* URL_TYPE has format: url \n title */ split = g_strsplit (selection_data->data, "\n", 2); - if (split != NULL && split[0] != NULL) + if (split != NULL && split[0] != NULL && split[0][0] != '\0') { - uris[0] = split[0]; - ephy_window_load_in_tabs (window, tab, uris); + ephy_link_open (EPHY_LINK (notebook), split[0], tab, + tab ? 0 : EPHY_LINK_NEW_TAB); } g_strfreev (split); } else if (selection_data->target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE)) { char **uris; + int i; uris = gtk_selection_data_get_uris (selection_data); + if (uris == NULL) return; - if (uris != NULL) + for (i = 0; uris[i] != NULL && i < INSANE_NUMBER_OF_URLS; i++) { - ephy_window_load_in_tabs (window, tab, uris); - - g_strfreev (uris); + tab = ephy_link_open (EPHY_LINK (notebook), uris[i], + tab, i == 0 ? 0 : EPHY_LINK_NEW_TAB); } + + g_strfreev (uris); } else { diff --git a/src/ephy-window.c b/src/ephy-window.c index 6d624ab54..58c1b4326 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -343,7 +343,6 @@ 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 BOOKMARKS_MENU_PATH "/menubar/BookmarksMenu" @@ -2418,6 +2417,11 @@ open_link_cb (EphyLink *link, g_return_val_if_fail (address != NULL, NULL); + if (tab == NULL) + { + tab = ephy_window_get_active_tab (window); + } + if (flags != 0) { EphyNewTabFlags ntflags = EPHY_NEW_TAB_OPEN_PAGE; @@ -2437,15 +2441,19 @@ open_link_cb (EphyLink *link, new_tab = ephy_shell_new_tab (ephy_shell, - tab ? EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))) - : window, - tab ? tab : ephy_window_get_active_tab (window), - address, ntflags); + EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), + tab, address, ntflags); } else { - ephy_window_load_url (window, address); - new_tab = ephy_window_get_active_tab (window); + EphyEmbed *embed; + + embed = ephy_tab_get_embed (tab); + + ephy_embed_load_url (embed, address); + ephy_embed_activate (embed); + + new_tab = tab; } return new_tab; @@ -2473,6 +2481,8 @@ ephy_window_init (EphyWindow *window) setup_ui_manager (window); window->priv->notebook = setup_notebook (window); + g_signal_connect (window->priv->notebook, "open-link", + G_CALLBACK (open_link_cb), window); gtk_box_pack_start (GTK_BOX (window->priv->main_vbox), GTK_WIDGET (window->priv->notebook), TRUE, TRUE, 0); @@ -3132,46 +3142,6 @@ ephy_window_set_zoom (EphyWindow *window, } } -void -ephy_window_load_in_tabs (EphyWindow *window, - EphyTab *tab, - char **uris) -{ - EphyEmbed *embed = NULL; - guint num; - - g_return_if_fail (uris != NULL); - - if (tab != NULL) - { - embed = ephy_tab_get_embed (tab); - g_return_if_fail (EPHY_IS_EMBED (embed)); - } - - for (num = 0; uris[num] != NULL && num < INSANE_NUMBER_OF_URLS; num++) - { - const char *url = uris[num]; - - 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)); - } - } -} - static void sync_prefs_with_chrome (EphyWindow *window) { diff --git a/src/ephy-window.h b/src/ephy-window.h index 73d95b80d..fb0a8180b 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -89,10 +89,6 @@ 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, - char **uris); - void ephy_window_set_zoom (EphyWindow *window, float zoom); |