[Xfce4-commits] <midori:master> Handle external, magic URIs from command line consistently
Christian Dywan
noreply at xfce.org
Thu Feb 11 02:00:01 CET 2010
Updating branch refs/heads/master
to f494ec090be051617a1532b998f773fc0e72e81c (commit)
from 532e84ea4f4dda8a6113d963d531c8802440559d (commit)
commit f494ec090be051617a1532b998f773fc0e72e81c
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Feb 10 23:59:03 2010 +0100
Handle external, magic URIs from command line consistently
midori/main.c | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index 87f877e..9c6848d 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1358,6 +1358,29 @@ midori_remove_config_file (gint clear_prefs,
}
}
+static gchar*
+midori_prepare_uri (const gchar *uri)
+{
+ gchar* uri_ready;
+
+ if (g_path_is_absolute (uri))
+ return g_filename_to_uri (uri, NULL, NULL);
+ else if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
+ {
+ gchar* current_dir = g_get_current_dir ();
+ uri_ready = g_strconcat ("file://", current_dir,
+ G_DIR_SEPARATOR_S, uri, NULL);
+ g_free (current_dir);
+ return uri_ready;
+ }
+
+ uri_ready = sokoke_magic_uri (uri);
+ if (uri_ready)
+ return sokoke_uri_to_ascii (uri_ready);
+
+ return sokoke_uri_to_ascii (uri);
+}
+
#ifdef HAVE_SIGNAL_H
static void
signal_handler (int signal_id)
@@ -1554,6 +1577,8 @@ main (int argc,
if (webapp)
{
MidoriBrowser* browser = midori_browser_new ();
+ gchar* tmp_uri = midori_prepare_uri (webapp);
+ katze_assign (webapp, tmp_uri);
midori_startup_timer ("Browser: \t%f");
settings = katze_object_get_object (browser, "settings");
g_object_set (settings,
@@ -1628,12 +1653,11 @@ main (int argc,
else if (uris)
{
/* TODO: Open a tab per URI, seperated by pipes */
- /* FIXME: Handle relative files or magic URI here */
/* Encode any IDN addresses because libUnique doesn't like them */
i = 0;
while (uris[i] != NULL)
{
- gchar* new_uri = sokoke_uri_to_ascii (uris[i]);
+ gchar* new_uri = midori_prepare_uri (uris[i]);
katze_assign (uris[i], new_uri);
i++;
}
@@ -1837,22 +1861,7 @@ main (int argc,
while (uri != NULL)
{
item = katze_item_new ();
- /* Construct an absolute path if the file is relative */
- if (g_path_is_absolute (uri))
- uri_ready = g_strconcat ("file://", uri, NULL);
- else if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
- {
- gchar* current_dir = g_get_current_dir ();
- uri_ready = g_strconcat ("file://", current_dir,
- G_DIR_SEPARATOR_S, uri, NULL);
- g_free (current_dir);
- }
- else
- {
- uri_ready = sokoke_magic_uri (uri);
- if (!uri_ready)
- uri_ready = g_strdup (uri_ready);
- }
+ uri_ready = midori_prepare_uri (uri);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
katze_array_add_item (_session, item);
More information about the Xfce4-commits
mailing list