aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe+gnomebugz@stud.uni-saarland.de>2003-05-06 19:59:09 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-05-06 19:59:09 +0800
commit6f4d431c2ea7384aec032c691cd0743755d364a7 (patch)
tree2272cf616ffd8777129bf8f0b6d573f609c87945
parent468c744c0c5efde0aa7bbc179bd0bba784c908a5 (diff)
downloadgsoc2013-epiphany-6f4d431c2ea7384aec032c691cd0743755d364a7.tar.gz
gsoc2013-epiphany-6f4d431c2ea7384aec032c691cd0743755d364a7.tar.zst
gsoc2013-epiphany-6f4d431c2ea7384aec032c691cd0743755d364a7.zip
Implement the EPHY_NEW_TAB_APPEND_AFTER flag.
2003-05-05 Christian Persch <chpe+gnomebugz@stud.uni-saarland.de> * src/ephy-shell.c: * src/ephy-shell.h: (ephy_shell_new_tab): Implement the EPHY_NEW_TAB_APPEND_AFTER flag. * src/ephy-window.c: * src/ephy-window.h: (ephy_window_add_tab): Changed parameter (gboolean) groupde to (gint) position, to support specifying the position in the notebook to insert the new tab into. * src/ephy-shell.c: (ephy_shell_new_window_cb): * src/ephy-tab.c: (ephy_tab_new_window_cb): Fix callers of ephy_window_add_tab for new parameter. * src/ephy-notebook.c: (notebook_drag_data_received_cb), (ephy_notebook_init), (ephy_notebook_insert_page): Implement drag-and-drop of links to tabs.
-rw-r--r--ChangeLog23
-rw-r--r--src/ephy-notebook.c118
-rw-r--r--src/ephy-shell.c17
-rw-r--r--src/ephy-shell.h3
-rw-r--r--src/ephy-tab.c2
-rw-r--r--src/ephy-window.c4
-rw-r--r--src/ephy-window.h2
7 files changed, 161 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 41a09c7fb..024f9c208 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-05-05 Christian Persch <chpe+gnomebugz@stud.uni-saarland.de>
+
+ * src/ephy-shell.c:
+ * src/ephy-shell.h: (ephy_shell_new_tab):
+
+ Implement the EPHY_NEW_TAB_APPEND_AFTER flag.
+
+ * src/ephy-window.c:
+ * src/ephy-window.h: (ephy_window_add_tab):
+
+ Changed parameter (gboolean) groupde to (gint) position, to support
+ specifying the position in the notebook to insert the new tab into.
+
+ * src/ephy-shell.c: (ephy_shell_new_window_cb):
+ * src/ephy-tab.c: (ephy_tab_new_window_cb):
+
+ Fix callers of ephy_window_add_tab for new parameter.
+
+ * src/ephy-notebook.c: (notebook_drag_data_received_cb),
+ (ephy_notebook_init), (ephy_notebook_insert_page):
+
+ Implement drag-and-drop of links to tabs.
+
2003-05-06 Christian Persch <chpe+gnomebugz@stud.uni-saarland.de>
* embed/mozilla/EphyWrapper.cpp: (EphyWrapper::SetZoomOnDocshell):
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 6ce34bb50..49b99f49e 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -21,10 +21,15 @@
#include "ephy-prefs.h"
#include "ephy-marshal.h"
#include "ephy-file-helpers.h"
+#include "ephy-dnd.h"
+#include "ephy-embed.h"
+#include "ephy-window.h"
+#include "ephy-shell.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#define AFTER_ALL_TABS -1
#define NOT_IN_APP_WINDOWS -2
@@ -55,6 +60,12 @@ static void ephy_notebook_finalize (GObject *object);
static GdkCursor *cursor = NULL;
static GList *notebooks = NULL;
+static GtkTargetEntry url_drag_types [] =
+{
+ { EPHY_DND_URI_LIST_TYPE, 0, 0 },
+ { EPHY_DND_URL_TYPE, 0, 1 }
+};
+static guint n_url_drag_types = G_N_ELEMENTS (url_drag_types);
/* Local functions */
static void drag_start (EphyNotebook *notebook,
@@ -585,6 +596,97 @@ ephy_notebook_switch_page_cb (GtkNotebook *notebook,
nb->priv->opened_tabs = NULL;
}
+#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, GtkWidget *child)
+{
+ EphyEmbed *embed = NULL;
+ EphyWindow *window = NULL;
+ EphyTab *tab = NULL;
+ GtkWidget *toplevel;
+ GList *uris = NULL, *l;
+ GnomeVFSURI *uri;
+ gchar *url = NULL;
+ guint num = 0;
+ gchar **tmp;
+
+ g_signal_stop_emission_by_name (widget, "drag_data_received");
+
+ if (selection_data->length <= 0 || selection_data->data == NULL) return;
+
+ if (selection_data->target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE))
+ {
+ /* URL_TYPE has format: url \n title */
+ tmp = g_strsplit (selection_data->data, "\n", 2);
+ if (tmp)
+ {
+ uri = gnome_vfs_uri_new (tmp[0]);
+ if (uri) uris = g_list_append (uris, 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);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ if (uris == NULL) return;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ g_return_if_fail (IS_EPHY_WINDOW (toplevel));
+ window = EPHY_WINDOW (toplevel);
+
+ if (child)
+ {
+ embed = EPHY_EMBED (child);
+ tab = EPHY_TAB (g_object_get_data (G_OBJECT (embed), "EphyTab"));
+ }
+
+ 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);
+
+ 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_IN_EXISTING_WINDOW |
+ EPHY_NEW_TAB_APPEND_LAST |
+ EPHY_NEW_TAB_APPEND_AFTER |
+ EPHY_NEW_TAB_DONT_JUMP_TO);
+ }
+
+ if (num == 0 && eel_gconf_get_boolean (CONF_TABS_TABBED_AUTOJUMP))
+ {
+ ephy_window_jump_to_tab (window, tab);
+ }
+
+ g_free (url);
+ url = NULL;
+ l = l->next;
+ ++num;
+ }
+
+ gnome_vfs_uri_list_free (uris);
+}
+
static void
ephy_notebook_init (EphyNotebook *notebook)
{
@@ -610,6 +712,15 @@ ephy_notebook_init (EphyNotebook *notebook)
g_signal_connect_after (G_OBJECT (notebook), "switch_page",
G_CALLBACK (ephy_notebook_switch_page_cb),
NULL);
+
+ /* Set up drag-and-drop target */
+ g_signal_connect (G_OBJECT(notebook), "drag_data_received",
+ G_CALLBACK(notebook_drag_data_received_cb),
+ NULL);
+ gtk_drag_dest_set (GTK_WIDGET(notebook), GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_DROP,
+ url_drag_types,n_url_drag_types,
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
}
static void
@@ -835,6 +946,13 @@ ephy_notebook_insert_page (EphyNotebook *nb,
child,
tab_hbox, position);
+ /* Set up drag-and-drop target */
+ g_signal_connect (G_OBJECT(tab_hbox), "drag_data_received",
+ G_CALLBACK(notebook_drag_data_received_cb), child);
+ gtk_drag_dest_set (tab_hbox, GTK_DEST_DEFAULT_ALL,
+ url_drag_types,n_url_drag_types,
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+
if (jump_to)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index c37aa8b31..56f31799e 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -238,7 +238,7 @@ ephy_shell_new_window_cb (EphyEmbedShell *shell,
}
new_tab = ephy_tab_new ();
- ephy_window_add_tab (window, new_tab, TRUE, FALSE);
+ ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_INSERT_GROUPED, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
}
@@ -491,6 +491,8 @@ ephy_shell_new_tab (EphyShell *shell,
gboolean grouped = FALSE;
gboolean jump_to;
EphyEmbed *previous_embed = NULL;
+ GtkWidget *nb;
+ gint position;
in_new_window = !eel_gconf_get_boolean (CONF_TABS_TABBED);
@@ -525,11 +527,22 @@ ephy_shell_new_tab (EphyShell *shell,
if (flags & EPHY_NEW_TAB_APPEND_GROUPED) grouped = TRUE;
if (flags & EPHY_NEW_TAB_APPEND_LAST) grouped = FALSE;
+ if ((flags & EPHY_NEW_TAB_APPEND_AFTER) && previous_embed != NULL)
+ {
+ nb = ephy_window_get_notebook (window);
+ position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
+ GTK_WIDGET (previous_embed)) + 1;
+ }
+ else
+ {
+ position = grouped ? EPHY_NOTEBOOK_INSERT_GROUPED : EPHY_NOTEBOOK_INSERT_LAST;
+ }
+
tab = ephy_tab_new ();
embed = ephy_tab_get_embed (tab);
gtk_widget_show (GTK_WIDGET(embed));
ephy_window_add_tab (window, tab,
- grouped,
+ position,
jump_to);
if (flags & EPHY_NEW_TAB_RAISE_WINDOW)
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index d4654a002..08fd7658a 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -62,7 +62,8 @@ typedef enum
EPHY_NEW_TAB_IN_NEW_WINDOW = 1 << 8,
EPHY_NEW_TAB_IN_EXISTING_WINDOW = 1 << 9,
EPHY_NEW_TAB_IS_A_COPY = 1 << 10,
- EPHY_NEW_TAB_VIEW_SOURCE = 1 << 11
+ EPHY_NEW_TAB_VIEW_SOURCE = 1 << 11,
+ EPHY_NEW_TAB_APPEND_AFTER = 1 << 12
} EphyNewTabFlags;
struct EphyShell
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 1c6800283..cbf981ebc 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -804,7 +804,7 @@ ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
}
new_tab = ephy_tab_new ();
- ephy_window_add_tab (window, new_tab, TRUE, FALSE);
+ ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_INSERT_GROUPED, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index ad40a5fb3..51d26f38a 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -857,11 +857,10 @@ ephy_window_get_notebook (EphyWindow *window)
void
ephy_window_add_tab (EphyWindow *window,
EphyTab *tab,
- gboolean grouped,
+ gint position,
gboolean jump_to)
{
GtkWidget *widget;
- int position;
g_return_if_fail (IS_EPHY_WINDOW (window));
g_return_if_fail (IS_EPHY_TAB (tab));
@@ -870,7 +869,6 @@ ephy_window_add_tab (EphyWindow *window,
widget = GTK_WIDGET(ephy_tab_get_embed (tab));
- position = grouped ? EPHY_NOTEBOOK_INSERT_GROUPED : EPHY_NOTEBOOK_INSERT_LAST;
ephy_notebook_insert_page (EPHY_NOTEBOOK (window->priv->notebook),
widget, position, jump_to);
}
diff --git a/src/ephy-window.h b/src/ephy-window.h
index a0e44269b..5a76383de 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -96,7 +96,7 @@ GtkWidget *ephy_window_get_notebook (EphyWindow *window);
void ephy_window_add_tab (EphyWindow *window,
EphyTab *tab,
- gboolean grouped,
+ gint position,
gboolean jump_to);
void ephy_window_remove_tab (EphyWindow *window,