diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-02-06 21:38:02 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-02-06 21:38:02 +0800 |
commit | 931a5b0d35e13d0af0fa388e52a56caf513bb581 (patch) | |
tree | fe0af4c345b3ce40bd9229ea26ea508d347a243f | |
parent | 7caf37cc9de88a482c9c99572019d6ce6f17308a (diff) | |
download | gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar.gz gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar.bz2 gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar.lz gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar.xz gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.tar.zst gsoc2013-epiphany-931a5b0d35e13d0af0fa388e52a56caf513bb581.zip |
Fix opening of local files. Bug #330104.
2006-02-06 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-main.c: (open_urls), (queue_commands), (main):
Fix opening of local files. Bug #330104.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/ephy-main.c | 64 |
2 files changed, 41 insertions, 29 deletions
@@ -1,5 +1,11 @@ 2006-02-06 Christian Persch <chpe@cvs.gnome.org> + * src/ephy-main.c: (open_urls), (queue_commands), (main): + + Fix opening of local files. Bug #330104. + +2006-02-06 Christian Persch <chpe@cvs.gnome.org> + * configure.ac: Go back to AM_GLIB_GNU_GETTEXT for now, until diff --git a/src/ephy-main.c b/src/ephy-main.c index ce56277c5..a3d7f7f5d 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -65,7 +65,7 @@ static gboolean open_as_bookmarks_editor = FALSE; static char *session_filename = NULL; static char *bookmark_url = NULL; static char *bookmarks_file = NULL; -static char **extra_arguments = NULL; +static char **arguments = NULL; /* Only set from options in debug builds */ static gboolean private_instance = FALSE; @@ -86,7 +86,7 @@ static const GOptionEntry option_entries[] = N_("Load the given session file"), N_("FILE") }, { "add-bookmark", 't', 0, G_OPTION_ARG_STRING, &bookmark_url, N_("Add a bookmark"), N_("URL") }, - { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &extra_arguments, + { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &arguments, "", "" }, { NULL } }; @@ -241,23 +241,6 @@ shell_weak_notify (gpointer data, } } -#if 0 -static char * -path_from_command_line_arg (const char *arg) -{ - char path[PATH_MAX]; - - if (realpath (arg, path) != NULL) - { - return g_strdup (path); - } - else - { - return g_strdup (arg); - } -} -#endif - static void unref_proxy_reply_cb (DBusGProxy *proxy, GError *error, @@ -297,23 +280,23 @@ open_urls (DBusGProxy *proxy, g_string_append (options, "new-tab,"); } - if (extra_arguments == NULL) + if (arguments == NULL) { uris = (char **) empty_arguments; } else { - uris = (char **) extra_arguments; + uris = (char **) arguments; } org_gnome_Epiphany_load_ur_ilist_async (proxy, (const char **) uris, options->str, user_time, unref_proxy_reply_cb, NULL); - if (extra_arguments != NULL) + if (arguments != NULL) { - g_strfreev (extra_arguments); - extra_arguments = NULL; + g_strfreev (arguments); + arguments = NULL; } g_string_free (options, TRUE); @@ -395,7 +378,7 @@ queue_commands (guint32 user_time) /* Don't queue any window openings if no extra arguments given, * since session autoresume will open one for us. */ - else if (extra_arguments != NULL) + else if (arguments != NULL) { GString *options; @@ -413,11 +396,11 @@ queue_commands (guint32 user_time) ephy_session_queue_command (session, EPHY_SESSION_CMD_OPEN_URIS, options->str, - extra_arguments, + arguments, user_time, FALSE); - g_strfreev (extra_arguments); - extra_arguments = NULL; + g_strfreev (arguments); + arguments = NULL; } } @@ -559,12 +542,35 @@ main (int argc, #endif /* GNOME_PARAM_GOPTION_CONTEXT */ - if (extra_arguments != NULL && + if (arguments != NULL && eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL)) { exit (1); } + /* Make URIs from arguments, to support filename args */ + if (arguments != NULL) + { + guint i; + + for (i = 0; arguments[i] != NULL; ++i) + { + char *path = NULL; + + path = realpath (arguments[i], NULL); + if (path != NULL) + { + g_free (arguments[i]); + arguments[i] = g_strdup (path); + free (path); + } + /* FIXME: I'd use gnome_vfs_make_uri_from_shell_arg + * but then "epiphany www.gnome.org" would try to open + * a local file, not a web address. + */ + } + } + /* Get a timestamp manually if need be */ if (user_time == 0) { |