Merge lp:~kalikiana/midori/beans into lp:midori

Proposed by Cris Dywan
Status: Work in progress
Proposed branch: lp:~kalikiana/midori/beans
Merge into: lp:midori
Diff against target: 220 lines (+97/-6)
7 files modified
CMakeLists.txt (+2/-1)
extensions/example.plugin (+9/-0)
extensions/example.py (+14/-0)
katze/midori-paths.vala (+16/-0)
midori/midori-app.c (+1/-1)
midori/midori-view.c (+51/-4)
midori/midori-websettings.c (+4/-0)
To merge this branch: bzr merge lp:~kalikiana/midori/beans
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+183371@code.launchpad.net

Commit message

Implement libpeas extension support and example plugin

Description of the change

TODO: sort out libpeas/ Python on Win32 - contact dieterv in #win32 on gimpnet

To post a comment you must log in.
lp:~kalikiana/midori/beans updated
6377. By Cris Dywan

Rename test extension to example to avoid confusion

Unmerged revisions

6377. By Cris Dywan

Rename test extension to example to avoid confusion

6376. By Cris Dywan

Implement libpeas extension support and example plugin

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-09-01 19:26:37 +0000
3+++ CMakeLists.txt 2013-09-01 23:16:32 +0000
4@@ -72,11 +72,12 @@
5 gmodule-2.0
6 gio-2.0>=2.32.3
7 libsoup-gnome-2.4>=2.27.90
8+ libpeas-1.0>=1.4
9 )
10 add_definitions("-DHAVE_LIBXML")
11 add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"")
12 add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-gnome-2.4_VERSION}\"")
13-set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4)
14+set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4 libpeas-1.0)
15 if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.34.0")
16 set(VALAFLAGS ${VALAFLAGS} "-D;HAVE_LIBSOUP_2_34_0")
17 endif ()
18
19=== added file 'extensions/example.plugin'
20--- extensions/example.plugin 1970-01-01 00:00:00 +0000
21+++ extensions/example.plugin 2013-09-01 23:16:32 +0000
22@@ -0,0 +1,9 @@
23+[Plugin]
24+Loader=python
25+Module=example
26+IAge=3
27+Name=Example
28+Name[de]=Beispiel
29+Authors=Christian Dywan <christian@twotoasts.de>
30+Copyright=Copyright © 2013 Christian Dywan
31+Website=http://www.twotoasts.de
32
33=== added file 'extensions/example.py'
34--- extensions/example.py 1970-01-01 00:00:00 +0000
35+++ extensions/example.py 2013-09-01 23:16:32 +0000
36@@ -0,0 +1,14 @@
37+# -*- coding: utf-8 py-indent-offset: 4 -*-
38+from gi.repository import GObject, Gtk, Peas
39+import os, gettext
40+
41+class ExamplePlugin(GObject.Object, Peas.Activatable):
42+ __gtype_name__ = "ExamplePlugin"
43+ object = GObject.property(type=GObject.Object)
44+
45+ def __init__(self):
46+ GObject.Object.__init__(self)
47+
48+ def do_activate(self):
49+ print('Current page is %s (%s)' \
50+ % (self.object.props.title, self.object.props.uri))
51
52=== modified file 'katze/midori-paths.vala'
53--- katze/midori-paths.vala 2013-08-02 18:35:37 +0000
54+++ katze/midori-paths.vala 2013-09-01 23:16:32 +0000
55@@ -161,6 +161,22 @@
56 stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
57 config_dir, cache_dir, user_data_dir, tmp_dir);
58 }
59+
60+ /* Fallback to build folder */
61+ string source_extensions = Path.build_path (Path.DIR_SEPARATOR_S,
62+ File.new_for_path (exec_path).get_parent ().get_path (), "extensions");
63+ string lib_extensions = get_lib_path (PACKAGE_NAME);
64+ if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0)
65+ stdout.printf ("extensions: %s %s\n", source_extensions, lib_extensions);
66+ var engine = Peas.Engine.get_default ();
67+ engine.ref ();
68+ engine.load_plugin.connect ((info)=>{
69+ if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "extensions") == 0)
70+ stdout.printf ("Extension %s loaded\n", info.get_name ());
71+ });
72+ engine.enable_loader ("python");
73+ engine.add_search_path (source_extensions, null);
74+ engine.add_search_path (lib_extensions, null);
75 }
76
77 public static void mkdir_with_parents (string path, int mode = 0700) {
78
79=== modified file 'midori/midori-app.c'
80--- midori/midori-app.c 2013-09-01 12:49:06 +0000
81+++ midori/midori-app.c 2013-09-01 23:16:32 +0000
82@@ -1247,7 +1247,7 @@
83 midori_debug (const gchar* token)
84 {
85 static const gchar* debug_token = NULL;
86- const gchar* debug_tokens = "headers body referer cookies paths hsts unarmed bookmarks mouse app ";
87+ const gchar* debug_tokens = "headers body referer cookies paths hsts unarmed bookmarks mouse app extensions ";
88 const gchar* full_debug_tokens = "adblock:match adblock:time startup ";
89 if (debug_token == NULL)
90 {
91
92=== modified file 'midori/midori-view.c'
93--- midori/midori-view.c 2013-09-01 16:40:29 +0000
94+++ midori/midori-view.c 2013-09-01 23:16:32 +0000
95@@ -22,6 +22,8 @@
96
97 #include <config.h>
98
99+#include <libpeas/peas.h>
100+
101 #ifdef HAVE_GRANITE
102 #include <granite.h>
103 #endif
104@@ -3474,6 +3476,24 @@
105 }
106 #endif
107
108+static void
109+midori_view_extension_added (PeasExtensionSet* extensions,
110+ PeasPluginInfo* info,
111+ PeasExtension* extension,
112+ MidoriView* view)
113+{
114+ peas_activatable_activate (PEAS_ACTIVATABLE (extension));
115+}
116+
117+static void
118+midori_view_extension_removed (PeasExtensionSet* extensions,
119+ PeasPluginInfo* info,
120+ PeasExtension* extension,
121+ MidoriView* view)
122+{
123+ peas_activatable_deactivate (PEAS_ACTIVATABLE (extension));
124+}
125+
126 static GObject*
127 midori_view_constructor (GType type,
128 guint n_construct_properties,
129@@ -3626,6 +3646,13 @@
130 NULL);
131 #endif
132 gtk_widget_show_all (view->scrolled_window);
133+
134+ PeasEngine* engine = peas_engine_get_default ();
135+ PeasExtensionSet* extensions = peas_extension_set_new (engine, PEAS_TYPE_ACTIVATABLE, "object", object, NULL);
136+ g_signal_connect (extensions, "extension-added", G_CALLBACK (midori_view_extension_added), object);
137+ g_signal_connect (extensions, "extension-removed", G_CALLBACK (midori_view_extension_removed), object);
138+ peas_extension_set_foreach (extensions, midori_view_extension_added, object);
139+
140 return object;
141 }
142
143@@ -3685,11 +3712,30 @@
144 GString* ns_plugins,
145 gboolean html)
146 {
147+ if (html)
148+ g_string_append (ns_plugins, "<h2>Extensions:</h2><table>");
149+ PeasEngine* engine = peas_engine_get_default ();
150+ GList* pplugin, * pplugins = peas_engine_get_plugin_list (engine);
151+ for (pplugin = pplugins; pplugin; pplugin = g_list_next (pplugin))
152+ {
153+ GError* error = NULL;
154+ peas_plugin_info_is_available (pplugin->data, &error);
155+ midori_view_add_version (ns_plugins, html, g_markup_printf_escaped ("%s %s (%s) %s",
156+ peas_plugin_info_get_name (pplugin->data),
157+ peas_plugin_info_get_version (pplugin->data),
158+ peas_plugin_info_get_module_name (pplugin->data),
159+ error ? error->message : (peas_plugin_info_is_loaded (pplugin->data) ? "[x]" : "[ ]")));
160+ if (error)
161+ g_error_free (error);
162+ }
163+ if (html)
164+ g_string_append (ns_plugins, "</table>");
165+
166 if (!midori_web_settings_has_plugin_support ())
167 return;
168
169 if (html)
170- g_string_append (ns_plugins, "<br><h2>Netscape Plugins:</h2>");
171+ g_string_append (ns_plugins, "<h2>Netscape Plugins:</h2><table>");
172 else
173 g_string_append_c (ns_plugins, '\n');
174
175@@ -3723,6 +3769,9 @@
176 }
177 webkit_web_plugin_database_plugins_list_free (plugins);
178 #endif
179+
180+ if (html)
181+ g_string_append (ns_plugins, "</table>");
182 }
183
184 static void
185@@ -4024,12 +4073,10 @@
186 midori_view_add_version (tmp, TRUE, g_markup_printf_escaped ("Identification %s",
187 ident));
188 midori_view_list_video_formats (view, tmp, TRUE);
189+ g_string_append (tmp, "</table>");
190
191- g_string_append (tmp, "</table><table>");
192 midori_view_list_plugins (view, tmp, TRUE);
193- g_string_append (tmp, "</table>");
194 list_about_uris (tmp);
195- /* TODO: list active extensions */
196
197 g_string_append (tmp, "</body></html>");
198 data = g_string_free (tmp, FALSE);
199
200=== modified file 'midori/midori-websettings.c'
201--- midori/midori-websettings.c 2013-08-04 19:08:38 +0000
202+++ midori/midori-websettings.c 2013-09-01 23:16:32 +0000
203@@ -32,6 +32,7 @@
204 #include <sys/types.h>
205 #include <sys/sysctl.h>
206 #endif
207+#include <libpeas/peas.h>
208
209 #ifdef HAVE_WEBKIT2
210 #define WEB_SETTINGS_STRING(x) "WebKitSettings::"x""
211@@ -1459,6 +1460,9 @@
212 *extensions = g_key_file_get_keys (key_file, "extensions", NULL, NULL);
213 g_key_file_free (key_file);
214
215+ PeasEngine* engine = peas_engine_get_default ();
216+ peas_engine_set_loaded_plugins (engine, *extensions);
217+
218 /* Load accelerators */
219 katze_assign (config_file, midori_paths_get_config_filename_for_reading ("accels"));
220 if (g_access (config_file, F_OK) != 0)

Subscribers

People subscribed via source and target branches

to all changes: