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)
{
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
}
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);
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, ...)
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,