[Xfce4-commits] <midori:master> No temporary file for locally viewing source

Christian Dywan noreply at xfce.org
Fri Sep 28 20:16:02 CEST 2012


Updating branch refs/heads/master
         to 47df922547169395f60ef72676df3a1b91e45f2d (commit)
       from 6776bb960a04415e5d7e37e3e193d8e46e8d0d06 (commit)

commit 47df922547169395f60ef72676df3a1b91e45f2d
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Sep 28 19:06:25 2012 +0200

    No temporary file for locally viewing source

 midori/main.c           |    7 +++----
 midori/midori-browser.c |    4 +---
 midori/midori-view.c    |    3 +++
 tests/browser.c         |   11 +++++++++++
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index 1f4a13a..a23f274 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1468,10 +1468,9 @@ midori_prepare_uri (const gchar *uri)
     else if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)
          && !g_path_is_absolute (uri))
     {
-        gchar* current_dir = g_get_current_dir ();
-        uri_ready = g_strconcat ("file://", current_dir,
-                                 G_DIR_SEPARATOR_S, uri, NULL);
-        g_free (current_dir);
+        GFile* file = g_file_new_for_commandline_arg (uri);
+        uri_ready = g_file_get_uri (file);
+        g_object_unref (file);
         return uri_ready;
     }
 
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index aacacd5..26791da 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -3457,9 +3457,7 @@ _action_source_view_activate (GtkAction*     action,
     gchar* text_editor;
     gchar* filename = NULL;
 
-    if (!(view = midori_browser_get_current_tab (browser)))
-        return;
-
+    view = midori_browser_get_current_tab (browser);
     filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL);
     g_object_get (browser->settings, "text-editor", &text_editor, NULL);
     if (!(text_editor && *text_editor))
diff --git a/midori/midori-view.c b/midori/midori-view.c
index f3eddb2..cb392f0 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -5174,6 +5174,9 @@ midori_view_save_source (MidoriView* view,
     if (uri == NULL)
         uri = midori_view_get_display_uri (view);
 
+    if (g_str_has_prefix (uri, "file:///"))
+        return g_strdup (uri);
+
     if (!outfile)
     {
         gchar* extension = midori_download_get_extension_for_uri (uri, NULL);
diff --git a/tests/browser.c b/tests/browser.c
index 59dc076..e4db491 100644
--- a/tests/browser.c
+++ b/tests/browser.c
@@ -32,6 +32,8 @@ browser_create (void)
     gint n;
     gchar* temporary_downloads;
     GtkWidget* view;
+    GFile* file;
+    gchar* uri;
 
     g_test_log_set_fatal_handler (skip_gtk_bugs, NULL);
 
@@ -48,6 +50,15 @@ browser_create (void)
     midori_settings_set_download_folder (MIDORI_SETTINGS (settings), temporary_downloads);
     midori_browser_save_uri (browser, MIDORI_VIEW (view), NULL);
 
+    /* View source for local file: should NOT use temporary file */
+    file = g_file_new_for_commandline_arg ("./data/error.html");
+    uri = g_file_get_uri (file);
+    g_object_unref (file);
+    n = midori_browser_add_uri (browser, uri);
+    midori_browser_set_current_page (browser, n);
+    g_assert_cmpstr (uri, ==, midori_browser_get_current_uri (browser));
+    g_free (uri);
+
     gtk_widget_destroy (GTK_WIDGET (browser));
     g_object_unref (settings);
     g_object_unref (app);


More information about the Xfce4-commits mailing list