Updating branch refs/heads/master
         to 7aaf59ec9a75553ea081c9988bf03b6d3006bb3c (commit)
       from 19982199339aa083d8dc08d2c4dc95e02198485d (commit)

commit 7aaf59ec9a75553ea081c9988bf03b6d3006bb3c
Author: Christian Dywan <christ...@twotoasts.de>
Date:   Mon Oct 5 20:50:08 2009 +0200

    Format addresses nicely, with no percents and no punycode

 midori/midori-browser.c |    2 +-
 midori/midori-view.c    |    4 ++--
 midori/sokoke.c         |   36 ++++++++++++++++++++++++++++++++++++
 midori/sokoke.h         |    3 +++
 4 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 2d48f23..dc549a8 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -351,7 +351,7 @@ _midori_browser_set_statusbar_text (MidoriBrowser* browser,
     gboolean is_location = widget ?
         MIDORI_IS_LOCATION_ENTRY (gtk_widget_get_parent (widget)) : FALSE;
 
-    katze_assign (browser->statusbar_text, g_strdup (text));
+    katze_assign (browser->statusbar_text, sokoke_format_uri_for_display 
(text));
 
     if (!GTK_WIDGET_VISIBLE (browser->statusbar) && !is_location)
     {
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 35bcb69..01c743e 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -748,7 +748,7 @@ webkit_web_view_load_committed_cb (WebKitWebView*  web_view,
 
     uri = webkit_web_frame_get_uri (web_frame);
     g_return_if_fail (uri != NULL);
-    katze_assign (view->uri, g_strdup (uri));
+    katze_assign (view->uri, sokoke_format_uri_for_display (uri));
     if (view->item)
     {
         #if 0
@@ -2831,7 +2831,7 @@ midori_view_set_uri (MidoriView*  view,
         }
         else
         {
-            katze_assign (view->uri, g_strdup (uri));
+            katze_assign (view->uri, sokoke_format_uri_for_display (uri));
             g_object_notify (G_OBJECT (view), "uri");
             if (view->item)
                 katze_item_set_uri (view->item, uri);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 7d40e8d..a1fa336 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -358,6 +358,42 @@ sokoke_magic_uri (const gchar* uri,
     return search;
 }
 
+/**
+ * sokoke_format_uri_for_display:
+ * @uri: an URI string
+ *
+ * Formats an URI for display, for instance by converting
+ * percent encoded characters and by decoding punycode.
+ *
+ * Return value: a newly allocated URI
+ **/
+gchar*
+sokoke_format_uri_for_display (const gchar* uri)
+{
+    if (uri && g_str_has_prefix (uri, "http://";))
+    {
+        gchar* unescaped = g_uri_unescape_string (uri, NULL);
+        #ifdef HAVE_LIBSOUP_2_27_90
+        gchar* decoded = g_hostname_to_unicode (unescaped);
+        if (decoded)
+        {
+            g_free (unescaped);
+            return decoded;
+        }
+        return unescaped;
+        #elif HAVE_LIBIDN
+        gchar* decoded;
+        if (!idna_to_unicode_8z8z (unescaped, &decoded, 0) == IDNA_SUCCESS)
+            return unescaped;
+        g_free (unescaped);
+        return decoded;
+        #else
+        return unescaped;
+        #endif
+    }
+    return g_strdup (uri);
+}
+
 void
 sokoke_combo_box_add_strings (GtkComboBox* combobox,
                               const gchar* label_first, ...)
diff --git a/midori/sokoke.h b/midori/sokoke.h
index ea23caa..15f2c88 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -48,6 +48,9 @@ gchar*
 sokoke_magic_uri                        (const gchar*    uri,
                                          KatzeArray*     search_engines);
 
+gchar*
+sokoke_format_uri_for_display           (const gchar*    uri);
+
 typedef enum {
     SOKOKE_MENU_POSITION_CURSOR = 0,
     SOKOKE_MENU_POSITION_LEFT,
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to