[Xfce4-commits] <midori:master> New extension to manage Netscape plugins like extensions
Christian Dywan
noreply at xfce.org
Thu Nov 29 02:46:03 CET 2012
Updating branch refs/heads/master
to 16897fc311ac1e286fd543029b96b72b44deae66 (commit)
from 62557d327cfbe450b82ce2b0c2ca989faa066b31 (commit)
commit 16897fc311ac1e286fd543029b96b72b44deae66
Author: André Stösel <andre at stoesel.de>
Date: Wed Nov 28 14:24:08 2012 +0100
New extension to manage Netscape plugins like extensions
Add WebKit.WebPlugin our webkitgtk-3.0.vapi.
Change WebKit.WebSettings.enable-plugins if nsplugin is de/ activated.
Omit "Enable Netscape plugins" from preferences for WebKit 1.3.8.
Use Pango markup and plugin icon for extension panel.
extensions/nsplugin-manager.vala | 71 ++++++++++++++++++++++++++++++++++++++
extensions/statusbar-features.c | 4 ++-
midori/midori-app.c | 2 +-
midori/midori-preferences.c | 17 +++------
midori/midori-stock.h | 2 +-
midori/midori.vapi | 3 ++
midori/webkitgtk-3.0.vapi | 21 +++++++++++
wscript | 2 +
8 files changed, 108 insertions(+), 14 deletions(-)
diff --git a/extensions/nsplugin-manager.vala b/extensions/nsplugin-manager.vala
new file mode 100644
index 0000000..a8154cd
--- /dev/null
+++ b/extensions/nsplugin-manager.vala
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2012 André Stösel <andre at stoesel.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#if HAVE_WEBKIT_1_3_8
+namespace NSPlugins {
+ private int active_plugins = 0;
+
+ private class Extension : Midori.Extension {
+ protected WebKit.WebPlugin plugin;
+
+ void activated (Midori.App app) {
+ active_plugins += 1;
+ this.plugin.set_enabled (true);
+ app.settings.enable_plugins = active_plugins > 0;
+ }
+
+ void deactivated () {
+ Midori.App app = this.get_app ();
+ active_plugins -= 1;
+ this.plugin.set_enabled (false);
+ app.settings.enable_plugins = active_plugins > 0;
+ }
+
+ internal Extension (WebKit.WebPlugin plugin) {
+ string desc = plugin.get_description ();
+ try {
+ var regex = new Regex ("<a.+href.+>(.+)</a>");
+ desc = regex.replace (desc, -1, 0, "<u>\\1</u>");
+ }
+ catch (Error error) { }
+ GLib.Object (stock_id: Midori.Stock.PLUGINS,
+ name: plugin.get_name (),
+ description: desc,
+ use_markup: true,
+ key: GLib.Path.get_basename (plugin.get_path ()),
+ version: "",
+ authors: "");
+
+ this.plugin = plugin;
+ this.plugin.set_enabled (false);
+
+ this.activate.connect (activated);
+ this.deactivate.connect (deactivated);
+ }
+ }
+}
+#endif
+
+public Katze.Array? extension_init () {
+#if HAVE_WEBKIT_1_3_8
+ var extensions = new Katze.Array( typeof (Midori.Extension));
+ WebKit.WebPluginDatabase pdb = WebKit.get_web_plugin_database ();
+ SList<WebKit.WebPlugin> plugins = pdb.get_plugins ();
+
+ foreach (WebKit.WebPlugin plugin in plugins) {
+ extensions.add_item (new NSPlugins.Extension (plugin));
+ }
+ return extensions;
+#else
+ return null;
+#endif
+}
+
diff --git a/extensions/statusbar-features.c b/extensions/statusbar-features.c
index e2210d7..a737561 100644
--- a/extensions/statusbar-features.c
+++ b/extensions/statusbar-features.c
@@ -172,7 +172,7 @@ statusbar_features_property_proxy (MidoriWebSettings* settings,
if (!midori_web_settings_has_plugin_support ())
gtk_widget_hide (button);
g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
- image = gtk_image_new_from_stock (STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
+ image = gtk_image_new_from_stock (MIDORI_STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button), image);
gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
@@ -220,8 +220,10 @@ statusbar_features_app_add_browser_cb (MidoriApp* app,
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
button = statusbar_features_property_proxy (settings, "enable-scripts", toolbar);
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
+ #if !WEBKIT_CHECK_VERSION (1, 3, 8)
button = statusbar_features_property_proxy (settings, "enable-plugins", toolbar);
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
+ #endif
button = statusbar_features_property_proxy (settings, "identify-as", toolbar);
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
button = statusbar_features_property_proxy (settings, "zoom-level", toolbar);
diff --git a/midori/midori-app.c b/midori/midori-app.c
index 3160915..d4ab919 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -1624,7 +1624,7 @@ midori_app_setup (gint *argc,
{ STOCK_STYLE, N_("User_styles") },
{ STOCK_TAB_NEW, N_("New _Tab") },
{ STOCK_TRANSFER, N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J },
- { STOCK_PLUGINS, N_("Netscape p_lugins") },
+ { MIDORI_STOCK_PLUGINS, N_("Netscape p_lugins") },
{ STOCK_USER_TRASH, N_("_Closed Tabs") },
{ STOCK_WINDOW_NEW, N_("New _Window") },
{ STOCK_FOLDER_NEW, N_("New _Folder") },
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index 1b072dd..3975c86 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -327,7 +327,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
/* Page "Appearance" */
PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Fonts"));
FRAME_NEW (NULL);
- #if !HAVE_HILDON
label = gtk_label_new (_("Proportional Font Family"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
INDENTED_ADD (label);
@@ -354,7 +353,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
SPANNED_ADD (entry);
button = katze_property_proxy (settings, "enforce-font-family", NULL);
INDENTED_ADD (button);
- #endif
label = gtk_label_new (_("Preferred Encoding"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
INDENTED_ADD (label);
@@ -364,7 +362,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
/* Page "Behavior" */
PAGE_NEW (GTK_STOCK_SELECT_COLOR, _("Behavior"));
FRAME_NEW (NULL);
- #if !HAVE_HILDON
button = katze_property_proxy (settings, "auto-load-images", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Load images automatically"));
INDENTED_ADD (button);
@@ -385,11 +382,15 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
button = katze_property_proxy (settings, "enable-scripts", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enable scripts"));
INDENTED_ADD (button);
+ #if WEBKIT_CHECK_VERSION (1, 3, 8)
+ button = katze_property_proxy (settings, "enable-webgl", NULL);
+ gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));
+ #else
button = katze_property_proxy (settings, "enable-plugins", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enable Netscape plugins"));
gtk_widget_set_sensitive (button, midori_web_settings_has_plugin_support ());
- SPANNED_ADD (button);
#endif
+ SPANNED_ADD (button);
button = katze_property_proxy (settings, "zoom-text-and-images", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images"));
INDENTED_ADD (button);
@@ -411,16 +412,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
gtk_widget_set_tooltip_text (button, _("Load an address from the selection via middle click"));
}
INDENTED_ADD (button);
- if (katze_object_has_property (settings, "enable-webgl"))
- {
- button = katze_property_proxy (settings, "enable-webgl", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));
- SPANNED_ADD (button);
- }
#ifndef G_OS_WIN32
button = katze_property_proxy (settings, "flash-window-on-new-bg-tabs", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Flash window on background tabs"));
- INDENTED_ADD (button);
+ SPANNED_ADD (button);
#endif
FRAME_NEW (NULL);
diff --git a/midori/midori-stock.h b/midori/midori-stock.h
index a28d3ed..fc8ce5c 100644
--- a/midori/midori-stock.h
+++ b/midori/midori-stock.h
@@ -21,7 +21,7 @@
#define STOCK_NEWS_FEED "internet-news-reader"
#define STOCK_STYLE "preferences-desktop-theme"
#define STOCK_TRANSFER "package"
-#define STOCK_PLUGINS "application-x-shockwave-flash"
+#define MIDORI_STOCK_PLUGINS "application-x-shockwave-flash"
#define STOCK_BOOKMARK_ADD "bookmark-new"
#define STOCK_IMAGE "image-x-generic"
#define STOCK_NETWORK_OFFLINE "network-offline"
diff --git a/midori/midori.vapi b/midori/midori.vapi
index a7ecf08..03d3cac 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -4,6 +4,9 @@
[CCode (cprefix = "Midori", lower_case_cprefix = "midori_")]
namespace Midori {
public const string VERSION_SUFFIX;
+ namespace Stock {
+ public const string PLUGINS;
+ }
[CCode (cheader_filename = "midori/midori.h")]
public class App : GLib.Object {
diff --git a/midori/webkitgtk-3.0.vapi b/midori/webkitgtk-3.0.vapi
index 16f3290..7ee599f 100644
--- a/midori/webkitgtk-3.0.vapi
+++ b/midori/webkitgtk-3.0.vapi
@@ -390,6 +390,25 @@ namespace WebKit {
public WebKit.WebNavigationReason reason { get; set construct; }
public string target_frame { get; construct; }
}
+ [CCode (cheader_filename = "webkit/webkit.h", type_id = "webkit_web_plugin_get_type ()")]
+ public class WebPlugin : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected WebPlugin ();
+ public unowned string get_description ();
+ public bool get_enabled ();
+ public unowned string get_name ();
+ public unowned string get_path ();
+ public void set_enabled (bool enabled);
+ public bool enabled { get; set; }
+ }
+ [CCode (cheader_filename = "webkit/webkit.h", type_id = "webkit_web_plugin_database_get_type ()")]
+ public class WebPluginDatabase : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected WebPluginDatabase ();
+ public WebKit.WebPlugin get_plugin_for_mimetype (string mime_type);
+ public GLib.SList<WebKit.WebPlugin> get_plugins ();
+ public void refresh ();
+ }
[CCode (cheader_filename = "webkit/webkit.h")]
public class WebPolicyDecision : GLib.Object {
[CCode (has_construct_function = false)]
@@ -779,6 +798,8 @@ namespace WebKit {
[CCode (cheader_filename = "webkit/webkit.h")]
public static unowned string get_web_database_directory_path ();
[CCode (cheader_filename = "webkit/webkit.h")]
+ public static unowned WebKit.WebPluginDatabase get_web_plugin_database ();
+ [CCode (cheader_filename = "webkit/webkit.h")]
public static uint major_version ();
[CCode (cheader_filename = "webkit/webkit.h")]
public static uint micro_version ();
diff --git a/wscript b/wscript
index 3c9ca5c..598ce1f 100644
--- a/wscript
+++ b/wscript
@@ -292,6 +292,8 @@ def configure (conf):
conf.env.append_value ('VALAFLAGS', '-D HAVE_LIBSOUP_2_34_0')
if check_version (conf.env['LIBSOUP_VERSION'], 2, 37, 1):
conf.define ('HAVE_LIBSOUP_2_37_1', 1)
+ if check_version (conf.env['WEBKIT_VERSION'], 1, 3, 8):
+ conf.env.append_value ('VALAFLAGS', '-D HAVE_WEBKIT_1_3_8')
check_pkg ('libxml-2.0', '2.6')
conf.undefine ('LIBXML_VERSION') # Defined in xmlversion.h
check_pkg ('sqlite3', '3.6.19', var='SQLITE')
More information about the Xfce4-commits
mailing list