From 12d49e36c266cd72b222da8661685e4042e3e05d Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 10 Apr 2012 21:54:38 +0200 Subject: [PATCH] List available about: URLs in about:version Strings are built with GString to avoid printf limits. --- midori/midori-view.c | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 35c08853..fb10fb59 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -3790,11 +3790,13 @@ midori_view_construct_web_view (MidoriView* view) NULL); } -static gchar* -list_netscape_plugins (JSContextRef js_context) +static void +list_netscape_plugins (GString* ns_plugins, + JSContextRef js_context) { - if (midori_web_settings_has_plugin_support ()) - { + if (!midori_web_settings_has_plugin_support ()) + return; + /* Joins available plugins like this: URI1|title1,URI2|title2 */ gchar* value = sokoke_js_script_eval (js_context, "function plugins (l) { var f = new Array (); for (var i in l) " @@ -3803,7 +3805,7 @@ list_netscape_plugins (JSContextRef js_context) "plugins (navigator.plugins)", NULL); gchar** items = g_strsplit (value, ",", 0); guint i = 0; - GString* ns_plugins = g_string_new ("

Netscape Plugins:

"); + g_string_append (ns_plugins, "

Netscape Plugins:

"); if (items != NULL) while (items[i] != NULL) { @@ -3824,16 +3826,12 @@ list_netscape_plugins (JSContextRef js_context) g_string_append (ns_plugins, "
"); g_strfreev (items); g_free (value); - return g_string_free (ns_plugins, FALSE); - } - else - return g_strdup (""); } -static const gchar* -list_geolocation () +static void +list_geolocation (GString* markup) { - return + g_string_append (markup, "" "" ""; + ""); } static gchar* @@ -3885,6 +3883,23 @@ list_video_formats (JSContextRef js_context) return value; } +static const gchar* valid_about_uris[] = { + "about:widgets", + "about:private", + "error:nodocs", + "http://.invalid", +}; + +static void +list_about_uris (GString* markup) +{ + g_string_append (markup, "

"); + guint i; + for (i = 0; i < G_N_ELEMENTS (valid_about_uris); i++) + g_string_append_printf (markup, "%s  ", + valid_about_uris[i], valid_about_uris[i]); +} + static gchar* prepare_speed_dial_html (MidoriView* view, gboolean load_missing) @@ -4168,8 +4183,11 @@ midori_view_set_uri (MidoriView* view, gchar* ident = katze_object_get_string (view->settings, "user-agent"); WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); - gchar* netscape_plugins = list_netscape_plugins (js_context); gchar* video_formats = list_video_formats (js_context); + GString* more = g_string_new (""); + list_netscape_plugins (more, js_context); + list_geolocation (more); + list_about_uris (more); katze_assign (view->uri, g_strdup (uri)); data = g_strdup_printf ( @@ -4193,7 +4211,7 @@ midori_view_set_uri (MidoriView* view, "Identification%s" "Video Formats%s" "" - "%s %s" + "%s" "", _("Version numbers in brackets show the version used at runtime."), command_line, @@ -4220,12 +4238,12 @@ midori_view_set_uri (MidoriView* view, "Sockets", #endif platform, sys_name, architecture ? architecture : "", ident, - video_formats, list_geolocation (), netscape_plugins); + video_formats, (gchar*)(more->str)); g_free (command_line); g_free (arguments); g_free (ident); - g_free (netscape_plugins); g_free (video_formats); + g_string_free (more, TRUE); } else { -- 2.39.5