aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-08-06 22:34:43 +0800
committerChristian Persch <chpe@src.gnome.org>2004-08-06 22:34:43 +0800
commit54f1919cae74d3551c23eef9d00975344d1c78a9 (patch)
tree817546aea8161746bcf5f1eb4aabfec0d4d0ec18
parent394409d0ccca365dd8d9e8a29752d2fb27cb7bbe (diff)
downloadgsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar.gz
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar.bz2
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar.lz
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar.xz
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.tar.zst
gsoc2013-epiphany-54f1919cae74d3551c23eef9d00975344d1c78a9.zip
Fix dragging of urls which gnome-vfs can't handle. Fix new tab positioning
2004-08-06 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-string.c: (ephy_string_parse_uri_list): * lib/ephy-string.h: * lib/widgets/ephy-node-view.c: (drag_data_received_cb), (ephy_node_view_class_init): * src/bookmarks/ephy-bookmarks-editor.c: * src/ephy-notebook.c: (notebook_drag_data_received_cb): * src/ephy-notebook.h: * src/ephy-session.c: * src/ephy-shell.c: (ephy_shell_new_tab): * src/ephy-tab.c: (ephy_tab_new_window_cb): * src/ephy-window.c: (ephy_window_load_in_tabs): Fix dragging of urls which gnome-vfs can't handle. Fix new tab positioning when opening tabs from drags.
-rw-r--r--ChangeLog17
-rw-r--r--lib/ephy-string.c52
-rw-r--r--lib/ephy-string.h2
-rw-r--r--lib/widgets/ephy-node-view.c57
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c1
-rw-r--r--src/ephy-notebook.c21
-rw-r--r--src/ephy-notebook.h5
-rw-r--r--src/ephy-session.c4
-rw-r--r--src/ephy-shell.c20
-rw-r--r--src/ephy-tab.c2
-rw-r--r--src/ephy-window.c12
11 files changed, 97 insertions, 96 deletions
diff --git a/ChangeLog b/ChangeLog
index 00aff9850..5e35abdfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2004-08-06 Christian Persch <chpe@cvs.gnome.org>
+ * lib/ephy-string.c: (ephy_string_parse_uri_list):
+ * lib/ephy-string.h:
+ * lib/widgets/ephy-node-view.c: (drag_data_received_cb),
+ (ephy_node_view_class_init):
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ * src/ephy-notebook.c: (notebook_drag_data_received_cb):
+ * src/ephy-notebook.h:
+ * src/ephy-session.c:
+ * src/ephy-shell.c: (ephy_shell_new_tab):
+ * src/ephy-tab.c: (ephy_tab_new_window_cb):
+ * src/ephy-window.c: (ephy_window_load_in_tabs):
+
+ Fix dragging of urls which gnome-vfs can't handle.
+ Fix new tab positioning when opening tabs from drags.
+
+2004-08-06 Christian Persch <chpe@cvs.gnome.org>
+
* src/ephy-session.c: (write_window_geometry), (write_tool_window),
(ephy_session_load):
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index dbda76275..daeac7d2b 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -191,3 +191,55 @@ ephy_string_double_underscores (const char *string)
return escaped;
}
+
+/* taken from libgnomevfs/gnome-vfs-uri.c */
+GList*
+ephy_string_parse_uri_list (const gchar* uri_list)
+{
+ /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */
+
+ const gchar *p, *q;
+ gchar *retval;
+ GList *result = NULL;
+
+ g_return_val_if_fail (uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p != NULL) {
+ if (*p != '#') {
+ while (g_ascii_isspace (*p))
+ p++;
+
+ q = p;
+ while ((*q != '\0')
+ && (*q != '\n')
+ && (*q != '\r'))
+ q++;
+
+ if (q > p) {
+ q--;
+ while (q > p
+ && g_ascii_isspace (*q))
+ q--;
+
+ retval = g_malloc (q - p + 2);
+ strncpy (retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ if (retval[0] != '\0')
+ result = g_list_prepend (result, retval);
+ }
+ }
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+
+ return g_list_reverse (result);
+}
diff --git a/lib/ephy-string.h b/lib/ephy-string.h
index f2907219f..bc844c09b 100644
--- a/lib/ephy-string.h
+++ b/lib/ephy-string.h
@@ -37,6 +37,8 @@ char *ephy_string_elide_underscores (const char *original);
char *ephy_string_double_underscores (const char *string);
+GList *ephy_string_parse_uri_list (const char *uri_list);
+
G_END_DECLS
#endif
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index 3681fe169..9b0f4a5d4 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -30,7 +30,6 @@
#include <gtk/gtktreemodelfilter.h>
#include <gtk/gtkwindow.h>
#include <gdk/gdkkeysyms.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include "ephy-node-view.h"
#include "ephy-tree-model-sort.h"
@@ -38,6 +37,7 @@
#include "ephy-dnd.h"
#include "ephy-gui.h"
#include "ephy-marshal.h"
+#include "ephy-string.h"
#include "string.h"
static void ephy_node_view_class_init (EphyNodeViewClass *klass);
@@ -360,58 +360,6 @@ drag_leave_cb (GtkWidget *widget,
remove_scroll_timeout (view);
}
-/* taken from libgnomevfs/gnome-vfs-uri.c */
-static GList*
-uri_list_parse (const gchar* uri_list)
-{
- /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */
-
- const gchar *p, *q;
- gchar *retval;
- GList *result = NULL;
-
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- p = uri_list;
-
- /* We don't actually try to validate the URI according to RFC
- * 2396, or even check for allowed characters - we just ignore
- * comments and trim whitespace off the ends. We also
- * allow LF delimination as well as the specified CRLF.
- */
- while (p != NULL) {
- if (*p != '#') {
- while (g_ascii_isspace (*p))
- p++;
-
- q = p;
- while ((*q != '\0')
- && (*q != '\n')
- && (*q != '\r'))
- q++;
-
- if (q > p) {
- q--;
- while (q > p
- && g_ascii_isspace (*q))
- q--;
-
- retval = g_malloc (q - p + 2);
- strncpy (retval, p, q - p + 1);
- retval[q - p + 1] = '\0';
-
- if (retval[0] != '\0')
- result = g_list_prepend (result, retval);
- }
- }
- p = strchr (p, '\n');
- if (p != NULL)
- p++;
- }
-
- return g_list_reverse (result);
-}
-
static void
drag_data_received_cb (GtkWidget *widget,
GdkDragContext *context,
@@ -452,7 +400,7 @@ drag_data_received_cb (GtkWidget *widget,
node = get_node_from_path (view, path);
- uris = uri_list_parse (selection_data->data);
+ uris = ephy_string_parse_uri_list (selection_data->data);
if (uris != NULL)
{
@@ -1716,4 +1664,3 @@ ephy_node_view_class_init (EphyNodeViewClass *klass)
g_type_class_add_private (object_class, sizeof (EphyNodeViewPrivate));
}
-
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 98b6adf63..74de22a34 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -44,7 +44,6 @@
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <libgnomeui/gnome-stock-icons.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <string.h>
#include "ephy-bookmarks-editor.h"
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index e55fdc03f..38c8a8c07 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -606,33 +606,32 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context,
{
/* URL_TYPE has format: url \n title */
tmp = g_strsplit (selection_data->data, "\n", 2);
- if (tmp)
+ if (tmp != NULL && tmp[0] != NULL)
{
- uri = gnome_vfs_uri_new (tmp[0]);
- if (uri)
- {
- uri_list = g_list_append (uri_list, uri);
- }
- g_strfreev (tmp);
+ uri_list = g_list_prepend (uri_list, g_strdup (tmp[0]));
}
+
+ g_strfreev (tmp);
}
else if (selection_data->target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE))
{
- uri_list = gnome_vfs_uri_list_parse (selection_data->data);
+ uri_list = ephy_string_parse_uri_list (selection_data->data);
}
else
{
- g_assert_not_reached ();
+ g_return_if_reached ();
}
- if (uri_list)
+ if (uri_list != NULL)
{
EphyWindow *window;
window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
ephy_window_load_in_tabs (window, tab, uri_list);
- gnome_vfs_uri_list_free (uri_list);
+
+ g_list_foreach (uri_list, (GFunc) g_free, NULL);
+ g_list_free (uri_list);
}
}
diff --git a/src/ephy-notebook.h b/src/ephy-notebook.h
index 5094dd842..60ede5616 100644
--- a/src/ephy-notebook.h
+++ b/src/ephy-notebook.h
@@ -41,11 +41,6 @@ typedef struct EphyNotebookClass EphyNotebookClass;
typedef struct EphyNotebook EphyNotebook;
typedef struct EphyNotebookPrivate EphyNotebookPrivate;
-enum
-{
- EPHY_NOTEBOOK_ADD_LAST = -1
-};
-
struct EphyNotebook
{
GtkNotebook parent;
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 78f4142bb..c82dccb96 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 Jorn Baayen
- * Copyright (C) 2003 Marco Pesenti Gritti
- * Copyright (C) 2003 Christian Persch
+ * Copyright (C) 2003, 2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 1d709d9eb..85edfaf21 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -549,7 +549,7 @@ ephy_shell_new_tab (EphyShell *shell,
gboolean jump_to;
EphyEmbed *previous_embed = NULL;
GtkWidget *nb;
- gint position;
+ int position = -1;
Toolbar *toolbar;
if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE;
@@ -557,7 +557,7 @@ ephy_shell_new_tab (EphyShell *shell,
in_new_window = in_new_window && !eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);
- jump_to = (flags & EPHY_NEW_TAB_JUMP);
+ jump_to = (flags & EPHY_NEW_TAB_JUMP) != 0;
if (!in_new_window && parent_window != NULL)
{
@@ -570,30 +570,24 @@ ephy_shell_new_tab (EphyShell *shell,
toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));
- if (previous_tab)
+ if (previous_tab != NULL)
{
previous_embed = ephy_tab_get_embed (previous_tab);
}
- if ((flags & EPHY_NEW_TAB_APPEND_AFTER) && previous_embed != NULL)
+ if ((flags & EPHY_NEW_TAB_APPEND_AFTER) && previous_tab != NULL)
{
nb = ephy_window_get_notebook (window);
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
- GTK_WIDGET (previous_embed)) + 1;
- }
- else
- {
- position = EPHY_NOTEBOOK_ADD_LAST;
+ GTK_WIDGET (previous_tab)) + 1;
}
tab = ephy_tab_new ();
gtk_widget_show (GTK_WIDGET (tab));
embed = ephy_tab_get_embed (tab);
- ephy_window_add_tab (window, tab,
- position,
- jump_to);
- gtk_widget_show (GTK_WIDGET(window));
+ ephy_window_add_tab (window, tab, position, jump_to);
+ gtk_window_present (GTK_WINDOW (window));
if (flags & EPHY_NEW_TAB_HOME_PAGE ||
flags & EPHY_NEW_TAB_NEW_PAGE)
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 078c7c9d7..82b80eab8 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -1262,7 +1262,7 @@ ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
new_tab = ephy_tab_new ();
gtk_widget_show (GTK_WIDGET (new_tab));
- ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_ADD_LAST, FALSE);
+ ephy_window_add_tab (window, new_tab, -1, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 7ec311d48..d24f13800 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2793,12 +2793,13 @@ ephy_window_set_zoom (EphyWindow *window,
}
void
-ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list)
+ephy_window_load_in_tabs (EphyWindow *window,
+ EphyTab *tab,
+ GList *uri_list)
{
EphyEmbed *embed = NULL;
GList *l;
guint num = 0;
- GnomeVFSURI *uri;
if (tab != NULL)
{
@@ -2809,10 +2810,7 @@ ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list)
l = uri_list;
while (l != NULL && num < INSANE_NUMBER_OF_URLS)
{
- gchar *url = NULL;
-
- uri = (GnomeVFSURI*) l->data;
- url = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ const char *url = l->data;
if (num == 0 && embed != NULL)
{
@@ -2832,8 +2830,6 @@ ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list)
EPHY_NEW_TAB_APPEND_LAST));
}
- g_free (url);
- url = NULL;
l = l->next;
++num;
}