Merge lp:~midori/midori/twoWebKittens into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6601
Merged at revision: 6629
Proposed branch: lp:~midori/midori/twoWebKittens
Merge into: lp:midori
Diff against target: 1007 lines (+373/-87)
16 files modified
CMakeLists.txt (+3/-0)
extensions/adblock/extension.vala (+40/-16)
extensions/adblock/subscriptions.vala (+5/-1)
extensions/notes.vala (+2/-0)
extensions/open-with.vala (+4/-9)
katze/midori-paths.vala (+22/-6)
katze/midori-uri.vala (+92/-0)
midori/midori-app.c (+1/-1)
midori/midori-browser.c (+39/-18)
midori/midori-historycompletion.vala (+2/-2)
midori/midori-searchcompletion.vala (+2/-2)
midori/midori-tab.vala (+37/-0)
midori/midori-view.c (+111/-32)
midori/midori-view.h (+5/-0)
midori/webkit2gtk-3.0.vapi (+7/-0)
midori/webkitgtk-3.0.vapi (+1/-0)
To merge this branch: bzr merge lp:~midori/midori/twoWebKittens
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
gue5t gue5t Approve
Review via email: mp+208984@code.launchpad.net

Commit message

Make trunk build with WebKit2 again

Support editing actions with WebKit2
Set cache and cookies correctly in Midori.Paths
Disable WebExtension with WebKitGTK+ 2.3.91
Opt in to multiple rendering processes
Implement new windows opening with WebKit2
Make View Source work with WebKit2

To post a comment you must log in.
Revision history for this message
gue5t gue5t (gue5t) wrote :

View source doesn't seem to respect the editor set in preferences.

Multiple processes do spawn, but it doesn't seem they're ever cleaned up. Closing the last tab over and over seems to result in more and more processes sitting around.

I don't think these are regressions, though, and wk2 is still behind the half-broken-incomplete switch.

review: Approve
Revision history for this message
Cris Dywan (kalikiana) wrote :

There's a TODO for view source - it does something unlike before.

The processes are spawned by WebKitGTK+ I don't think we have any control over it - unless there's a bug more generally in our ref counting of tabs which would trigger this but in that case it would probably mean a memory leak in WebKit1 also.

lp:~midori/midori/twoWebKittens updated
6599. By Cris Dywan

Use HAVE_WEBKIT2_3_91 to guard WebKit.WebView.with_related_view

6600. By Cris Dywan

Move Copy and Select All menu items out of the selection clause

Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve
lp:~midori/midori/twoWebKittens updated
6601. By Cris Dywan

Merge lp:midori

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-03-04 14:41:28 +0000
+++ CMakeLists.txt 2014-03-26 21:12:29 +0000
@@ -216,6 +216,9 @@
216 set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-3.0.vapi")216 set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-3.0.vapi")
217 set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)217 set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
218 set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)218 set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)
219 if (${DEPS_GTK_webkit2gtk-3.0_VERSION} VERSION_GREATER "2.3.90")
220 set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91)
221 endif ()
219elseif (USE_GTK3)222elseif (USE_GTK3)
220 pkg_check_modules(DEPS_GTK REQUIRED223 pkg_check_modules(DEPS_GTK REQUIRED
221 gtk+-3.0>=3.0.0224 gtk+-3.0>=3.0.0
222225
=== modified file 'extensions/adblock/extension.vala'
--- extensions/adblock/extension.vala 2014-03-18 16:57:25 +0000
+++ extensions/adblock/extension.vala 2014-03-26 21:12:29 +0000
@@ -56,7 +56,8 @@
56#endif56#endif
5757
58#if HAVE_WEBKIT258#if HAVE_WEBKIT2
59 public Extension (WebKit.WebExtension web_extension) {59#if !HAVE_WEBKIT2_3_91
60 public Extension.WebExtension (WebKit.WebExtension web_extension) {
60 init ();61 init ();
61 web_extension.page_created.connect (page_created);62 web_extension.page_created.connect (page_created);
62 }63 }
@@ -68,7 +69,9 @@
68 bool send_request (WebKit.WebPage web_page, WebKit.URIRequest request, WebKit.URIResponse? redirected_response) {69 bool send_request (WebKit.WebPage web_page, WebKit.URIRequest request, WebKit.URIResponse? redirected_response) {
69 return request_handled (request.uri, web_page.uri);70 return request_handled (request.uri, web_page.uri);
70 }71 }
71#else72#endif
73#endif
74
72 public Extension () {75 public Extension () {
73 GLib.Object (name: _("Advertisement blocker"),76 GLib.Object (name: _("Advertisement blocker"),
74 description: _("Block advertisements according to a filter list"),77 description: _("Block advertisements according to a filter list"),
@@ -84,6 +87,21 @@
84 }87 }
8588
86 void extension_activated (Midori.App app) {89 void extension_activated (Midori.App app) {
90#if HAVE_WEBKIT2
91 string cache_dir = Environment.get_user_cache_dir ();
92 string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext");
93 Midori.Paths.mkdir_with_parents (wk2path);
94 string filename = "libadblock." + GLib.Module.SUFFIX;
95 var wk2link = File.new_for_path (wk2path).get_child (filename);
96 var library = File.new_for_path (Midori.Paths.get_lib_path (PACKAGE_NAME)).get_child (filename);
97 try {
98 wk2link.make_symbolic_link (library.get_path ());
99 } catch (IOError.EXISTS exist_error) {
100 /* It's no error if the file already exists. */
101 } catch (Error error) {
102 critical ("Failed to create WebKit2 link: %s", error.message);
103 }
104#endif
87 init ();105 init ();
88 foreach (var browser in app.get_browsers ())106 foreach (var browser in app.get_browsers ())
89 browser_added (browser);107 browser_added (browser);
@@ -120,15 +138,19 @@
120 }138 }
121139
122 void tab_added (Midori.View view) {140 void tab_added (Midori.View view) {
141 view.navigation_requested.connect (navigation_requested);
142#if !HAVE_WEBKIT2
123 view.web_view.resource_request_starting.connect (resource_requested);143 view.web_view.resource_request_starting.connect (resource_requested);
124 view.web_view.navigation_policy_decision_requested.connect (navigation_requested);144#endif
125 view.notify["load-status"].connect (load_status_changed);145 view.notify["load-status"].connect (load_status_changed);
126 view.context_menu.connect (context_menu);146 view.context_menu.connect (context_menu);
127 }147 }
128148
129 void tab_removed (Midori.View view) {149 void tab_removed (Midori.View view) {
150#if !HAVE_WEBKIT2
130 view.web_view.resource_request_starting.disconnect (resource_requested);151 view.web_view.resource_request_starting.disconnect (resource_requested);
131 view.web_view.navigation_policy_decision_requested.disconnect (navigation_requested);152#endif
153 view.navigation_requested.disconnect (navigation_requested);
132 view.notify["load-status"].disconnect (load_status_changed);154 view.notify["load-status"].disconnect (load_status_changed);
133 view.context_menu.disconnect (context_menu);155 view.context_menu.disconnect (context_menu);
134 }156 }
@@ -160,6 +182,7 @@
160 menu.add (action);182 menu.add (action);
161 }183 }
162184
185#if !HAVE_WEBKIT2
163 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,186 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,
164 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {187 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
165188
@@ -167,13 +190,10 @@
167 request.set_uri ("about:blank");190 request.set_uri ("about:blank");
168 }191 }
169 }192 }
170193#endif
171 bool navigation_requested (WebKit.WebFrame frame, WebKit.NetworkRequest request,194
172 WebKit.WebNavigationAction action, WebKit.WebPolicyDecision decision) {195 bool navigation_requested (Midori.Tab tab, string uri) {
173
174 string uri = request.uri;
175 if (uri.has_prefix ("abp:")) {196 if (uri.has_prefix ("abp:")) {
176 decision.ignore ();
177 string parsed_uri = parse_subscription_uri (uri);197 string parsed_uri = parse_subscription_uri (uri);
178 manager.add_subscription (parsed_uri);198 manager.add_subscription (parsed_uri);
179 return true;199 return true;
@@ -318,7 +338,6 @@
318 if (style != null)338 if (style != null)
319 view.inject_stylesheet (style);339 view.inject_stylesheet (style);
320 }340 }
321#endif
322341
323 internal void init () {342 internal void init () {
324 hider_selectors = new StringBuilder ();343 hider_selectors = new StringBuilder ();
@@ -351,7 +370,12 @@
351 }370 }
352371
353 void load_config () {372 void load_config () {
373#if HAVE_WEBKIT2
374 string config_dir = Path.build_filename (Environment.get_user_config_dir (), "midori", "extensions", "libadblock." + GLib.Module.SUFFIX);
375 Midori.Paths.mkdir_with_parents (config_dir);
376#else
354 string config_dir = Midori.Paths.get_extension_config_dir ("adblock");377 string config_dir = Midori.Paths.get_extension_config_dir ("adblock");
378#endif
355 string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config");379 string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config");
356 string filename = Path.build_filename (config_dir, "config");380 string filename = Path.build_filename (config_dir, "config");
357 config = new Config (filename, presets);381 config = new Config (filename, presets);
@@ -451,17 +475,18 @@
451}475}
452476
453#if HAVE_WEBKIT2477#if HAVE_WEBKIT2
478#if !HAVE_WEBKIT2_3_91
454Adblock.Extension? filter;479Adblock.Extension? filter;
455public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension) {480public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension) {
456 filter = new Adblock.Extension (web_extension);481 filter = new Adblock.Extension.WebExtension (web_extension);
457}482}
458#else483#endif
484#endif
485
459public Midori.Extension extension_init () {486public Midori.Extension extension_init () {
460 return new Adblock.Extension ();487 return new Adblock.Extension ();
461}488}
462#endif
463489
464#if !HAVE_WEBKIT2
465static string? tmp_folder = null;490static string? tmp_folder = null;
466string get_test_file (string contents) {491string get_test_file (string contents) {
467 if (tmp_folder == null)492 if (tmp_folder == null)
@@ -833,5 +858,4 @@
833 Test.add_func ("/extensions/adblock2/update", test_subscription_update);858 Test.add_func ("/extensions/adblock2/update", test_subscription_update);
834 Test.add_func ("/extensions/adblock2/subsparse", test_subscription_uri_parsing);859 Test.add_func ("/extensions/adblock2/subsparse", test_subscription_uri_parsing);
835}860}
836#endif
837861
838862
=== modified file 'extensions/adblock/subscriptions.vala'
--- extensions/adblock/subscriptions.vala 2014-03-20 20:09:34 +0000
+++ extensions/adblock/subscriptions.vala 2014-03-26 21:12:29 +0000
@@ -40,7 +40,9 @@
40 public Options optslist;40 public Options optslist;
41 public Whitelist whitelist;41 public Whitelist whitelist;
42 public Element element;42 public Element element;
43#if !HAVE_WEBKIT2
43 WebKit.Download? download;44 WebKit.Download? download;
45#endif
4446
45 public Subscription (string uri) {47 public Subscription (string uri) {
46 debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");48 debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
@@ -289,6 +291,7 @@
289 }291 }
290 }292 }
291293
294#if !HAVE_WEBKIT2
292 void download_status (ParamSpec pspec) {295 void download_status (ParamSpec pspec) {
293 if (download.get_status () != WebKit.DownloadStatus.FINISHED)296 if (download.get_status () != WebKit.DownloadStatus.FINISHED)
294 return;297 return;
@@ -300,6 +303,7 @@
300 warning ("Error parsing %s: %s", uri, error.message);303 warning ("Error parsing %s: %s", uri, error.message);
301 }304 }
302 }305 }
306#endif
303307
304 public void parse () throws Error308 public void parse () throws Error
305 {309 {
@@ -340,8 +344,8 @@
340 download.destination_uri = destination_uri;344 download.destination_uri = destination_uri;
341 download.notify["status"].connect (download_status);345 download.notify["status"].connect (download_status);
342 download.start ();346 download.start ();
347 }
343#endif348#endif
344 }
345 return;349 return;
346 }350 }
347351
348352
=== modified file 'extensions/notes.vala'
--- extensions/notes.vala 2014-03-20 21:42:55 +0000
+++ extensions/notes.vala 2014-03-26 21:12:29 +0000
@@ -390,8 +390,10 @@
390 }390 }
391391
392 void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {392 void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {
393#if !HAVE_WEBKIT2
393 if ((hit_test_result.context & WebKit.HitTestResultContext.SELECTION) == 0)394 if ((hit_test_result.context & WebKit.HitTestResultContext.SELECTION) == 0)
394 return;395 return;
396#endif
395397
396 var view = tab as Midori.View;398 var view = tab as Midori.View;
397 var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null);399 var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null);
398400
=== modified file 'extensions/open-with.vala'
--- extensions/open-with.vala 2014-03-06 22:05:06 +0000
+++ extensions/open-with.vala 2014-03-26 21:12:29 +0000
@@ -615,17 +615,12 @@
615 return open_with_type (uri, get_content_type (uri, null), tab, NextStep.TRY_OPEN);615 return open_with_type (uri, get_content_type (uri, null), tab, NextStep.TRY_OPEN);
616 }616 }
617617
618 bool navigation_requested (WebKit.WebView web_view, WebKit.WebFrame frame, WebKit.NetworkRequest request,618 bool navigation_requested (Midori.Tab tab, string uri) {
619 WebKit.WebNavigationAction action, WebKit.WebPolicyDecision decision) {
620
621 string uri = request.uri;
622 if (uri.has_prefix ("file://") || Midori.URI.is_http (uri) || Midori.URI.is_blank (uri))619 if (uri.has_prefix ("file://") || Midori.URI.is_http (uri) || Midori.URI.is_blank (uri))
623 return false;620 return false;
624621
625 decision.ignore ();
626
627 string content_type = get_content_type (uri, null);622 string content_type = get_content_type (uri, null);
628 open_with_type (uri, content_type, web_view, NextStep.TRY_OPEN);623 open_with_type (uri, content_type, tab, NextStep.TRY_OPEN);
629 return true;624 return true;
630 }625 }
631626
@@ -769,13 +764,13 @@
769 }764 }
770765
771 public void tab_added (Midori.Browser browser, Midori.View view) {766 public void tab_added (Midori.Browser browser, Midori.View view) {
772 view.web_view.navigation_policy_decision_requested.connect_after (navigation_requested);767 view.navigation_requested.connect_after (navigation_requested);
773 view.open_uri.connect (open_uri);768 view.open_uri.connect (open_uri);
774 view.context_menu.connect (context_menu);769 view.context_menu.connect (context_menu);
775 }770 }
776771
777 public void tab_removed (Midori.Browser browser, Midori.View view) {772 public void tab_removed (Midori.Browser browser, Midori.View view) {
778 view.web_view.navigation_policy_decision_requested.disconnect (navigation_requested);773 view.navigation_requested.disconnect (navigation_requested);
779 view.open_uri.disconnect (open_uri);774 view.open_uri.disconnect (open_uri);
780 view.context_menu.disconnect (context_menu);775 view.context_menu.disconnect (context_menu);
781 }776 }
782777
=== modified file 'katze/midori-paths.vala'
--- katze/midori-paths.vala 2014-03-25 00:00:40 +0000
+++ katze/midori-paths.vala 2014-03-26 21:12:29 +0000
@@ -133,6 +133,11 @@
133 tmp_dir = get_runtime_dir ();133 tmp_dir = get_runtime_dir ();
134 }134 }
135 else {135 else {
136#if HAVE_WEBKIT2_3_91
137 /* Allow WebKit to spawn more than one rendering process */
138 if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? "")))
139 WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES);
140#endif
136 string? real_config = config != null && !Path.is_absolute (config)141 string? real_config = config != null && !Path.is_absolute (config)
137 ? Path.build_filename (Environment.get_current_dir (), config) : config;142 ? Path.build_filename (Environment.get_current_dir (), config) : config;
138 config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,143 config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,
@@ -140,16 +145,23 @@
140 cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,145 cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
141 Environment.get_user_cache_dir (), PACKAGE_NAME);146 Environment.get_user_cache_dir (), PACKAGE_NAME);
142 user_data_dir = Environment.get_user_data_dir ();147 user_data_dir = Environment.get_user_data_dir ();
148 tmp_dir = get_runtime_dir ();
149 }
143#if HAVE_WEBKIT2150#if HAVE_WEBKIT2
151 if (cache_dir != null) {
152 /* Cache and extension dir MUST be set no later than here to work */
153 WebKit.WebContext.get_default ().set_web_extensions_directory (
154 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext"));
144 WebKit.WebContext.get_default ().set_disk_cache_directory (155 WebKit.WebContext.get_default ().set_disk_cache_directory (
145 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web"));156 Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web"));
157 }
146158
159 if (config_dir != null) {
147 var cookie_manager = WebKit.WebContext.get_default ().get_cookie_manager ();160 var cookie_manager = WebKit.WebContext.get_default ().get_cookie_manager ();
148 cookie_manager.set_persistent_storage (Path.build_filename (config, "cookies.db"),161 cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"),
149 WebKit.CookiePersistentStorage.SQLITE);162 WebKit.CookiePersistentStorage.SQLITE);
163 }
150#endif164#endif
151 tmp_dir = get_runtime_dir ();
152 }
153 if (user_data_dir != null) {165 if (user_data_dir != null) {
154 string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");166 string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");
155#if HAVE_WEBKIT2167#if HAVE_WEBKIT2
@@ -451,6 +463,12 @@
451 remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));463 remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
452 }464 }
453465
466 /**
467 * Looks up a pixbuf for the given @uri. If @widget is given a generic
468 * file icon is used in case there's no icon.
469 *
470 * Deprecated: 0.5.8: Use Midori.URI.Icon or Midori.URI.get_icon instead.
471 **/
454 public static Gdk.Pixbuf? get_icon (string? uri, Gtk.Widget? widget) {472 public static Gdk.Pixbuf? get_icon (string? uri, Gtk.Widget? widget) {
455 if (!Midori.URI.is_resource (uri))473 if (!Midori.URI.is_resource (uri))
456 return null;474 return null;
@@ -461,9 +479,7 @@
461 else479 else
462 icon_width = icon_height = 0 /* maximum size */;480 icon_width = icon_height = 0 /* maximum size */;
463#if HAVE_WEBKIT2481#if HAVE_WEBKIT2
464 /* TODO async482 /* There is no sync API for WebKit2 */
465 var database = WebKit.WebContext.get_default ().get_favicon_database ();
466 database.get_favicon.begin (uri, null); */
467#else483#else
468 Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()484 Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()
469 .try_get_favicon_pixbuf (uri, icon_width, icon_height);485 .try_get_favicon_pixbuf (uri, icon_width, icon_height);
470486
=== modified file 'katze/midori-uri.vala'
--- katze/midori-uri.vala 2014-02-22 23:19:22 +0000
+++ katze/midori-uri.vala 2014-03-26 21:12:29 +0000
@@ -222,5 +222,97 @@
222 fork_uri = uri;222 fork_uri = uri;
223 return fork_uri != uri;223 return fork_uri != uri;
224 }224 }
225
226 /**
227 * Returns a Glib.Icon for the given @uri.
228 *
229 * Since: 0.5.8
230 **/
231 public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error {
232#if HAVE_WEBKIT2
233 var database = WebKit.WebContext.get_default ().get_favicon_database ();
234 var surface = yield database.get_favicon (uri, cancellable);
235 var image = (Cairo.ImageSurface)surface;
236 var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
237#else
238 var database = WebKit.get_favicon_database ();
239 var pixbuf = yield database.get_favicon_pixbuf (uri, 0, 0, cancellable);
240#endif
241 return pixbuf as GLib.Icon;
242 }
243
244 /**
245 * Returns a Glib.Icon for the given @uri or falls back to @fallback.
246 *
247 * Since: 0.5.8
248 **/
249 public static async GLib.Icon? get_icon_fallback (string uri, GLib.Icon? fallback=null, Cancellable? cancellable=null) {
250 try {
251 return yield get_icon (uri, cancellable);
252 } catch (Error error) {
253 debug ("Icon failed to load: %s", error.message);
254 return fallback;
255 }
256 }
257
258 /**
259 * A Glib.Icon subclass that loads the icon for a given URI.
260 * In the case of an error @fallback will be used.
261 *
262 * Since: 0.5.8
263 **/
264 public class Icon : InitiallyUnowned, GLib.Icon, LoadableIcon {
265 public string uri { get; private set; }
266 public GLib.Icon? fallback { get; private set; }
267 InputStream? stream = null;
268 public Icon (string website_uri, GLib.Icon? fallback=null) {
269 uri = website_uri;
270 /* TODO: Use fallback */
271 this.fallback = fallback;
272 }
273 public bool equal (GLib.Icon? other) {
274 return other is Icon && (other as Icon).uri == uri;
275 }
276 public uint hash () {
277 return uri.hash ();
278 }
279 public InputStream load (int size, out string? type = null, Cancellable? cancellable = null) throws Error {
280 /* Implementation notes:
281 GTK+ up to GTK+ 3.10 loads any GLib.Icon synchronously
282 Favicons may be cached but usually trigger loading here
283 Only one async code path in favour of consistent results
284 */
285 if (stream != null) {
286 type = "image/png";
287 return stream;
288 }
289 load_async.begin (size, cancellable, (obj, res)=>{
290 try {
291 stream = load_async.end (res);
292 }
293 catch (Error error) {
294 debug ("Icon failed to load: %s", error.message);
295 }
296 });
297 throw new FileError.EXIST ("Triggered load - no data yet");
298 }
299
300 public async InputStream load_async (int size, Cancellable? cancellable = null, out string? type = null) throws Error {
301 type = "image/png";
302 if (stream != null)
303 return stream;
304 var icon = yield get_icon (uri, cancellable);
305 if (icon != null && icon is Gdk.Pixbuf) {
306 var pixbuf = icon as Gdk.Pixbuf;
307 // TODO: scale it to "size" here
308 uint8[] buffer;
309 pixbuf.save_to_buffer (out buffer, "png");
310 stream = new MemoryInputStream.from_data (buffer, null);
311 }
312 else
313 throw new FileError.EXIST ("No icon available");
314 return stream;
315 }
316 }
225 }317 }
226}318}
227319
=== modified file 'midori/midori-app.c'
--- midori/midori-app.c 2014-03-20 20:30:46 +0000
+++ midori/midori-app.c 2014-03-26 21:12:29 +0000
@@ -1254,7 +1254,7 @@
1254midori_debug (const gchar* token)1254midori_debug (const gchar* token)
1255{1255{
1256 static const gchar* debug_token = NULL;1256 static const gchar* debug_token = NULL;
1257 const gchar* debug_tokens = "adblock:match adblock:parse adblock:time adblock:element adblock:css startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database ";1257 const gchar* debug_tokens = "wk2:no-multi-render-process adblock:match adblock:parse adblock:time adblock:element adblock:css startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database ";
1258 if (debug_token == NULL)1258 if (debug_token == NULL)
1259 {1259 {
1260 gchar* found_token;1260 gchar* found_token;
12611261
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2014-03-25 01:00:38 +0000
+++ midori/midori-browser.c 2014-03-26 21:12:29 +0000
@@ -2785,15 +2785,8 @@
27852785
2786 if (WEBKIT_IS_WEB_VIEW (widget))2786 if (WEBKIT_IS_WEB_VIEW (widget))
2787 {2787 {
2788#ifndef HAVE_WEBKIT22788 midori_tab_update_actions (MIDORI_TAB (widget), browser->action_group, NULL, NULL);
2789 WebKitWebView* view = WEBKIT_WEB_VIEW (widget);2789 return;
2790 can_undo = webkit_web_view_can_undo (view);
2791 can_redo = webkit_web_view_can_redo (view);
2792 can_cut = webkit_web_view_can_cut_clipboard (view);
2793 can_copy = webkit_web_view_can_copy_clipboard (view);
2794 can_paste = webkit_web_view_can_paste_clipboard (view);
2795 can_select_all = TRUE;
2796#endif
2797 }2790 }
2798 else if (GTK_IS_EDITABLE (widget))2791 else if (GTK_IS_EDITABLE (widget))
2799 {2792 {
@@ -2828,9 +2821,11 @@
2828_action_undo_activate (GtkAction* action,2821_action_undo_activate (GtkAction* action,
2829 MidoriBrowser* browser)2822 MidoriBrowser* browser)
2830{2823{
2831#ifndef HAVE_WEBKIT2
2832 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2824 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2833 if (WEBKIT_IS_WEB_VIEW (widget))2825 if (WEBKIT_IS_WEB_VIEW (widget))
2826#ifdef HAVE_WEBKIT2
2827 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO);
2828#else
2834 webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));2829 webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
2835#endif2830#endif
2836}2831}
@@ -2839,9 +2834,11 @@
2839_action_redo_activate (GtkAction* action,2834_action_redo_activate (GtkAction* action,
2840 MidoriBrowser* browser)2835 MidoriBrowser* browser)
2841{2836{
2842#ifndef HAVE_WEBKIT2
2843 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2837 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2844 if (WEBKIT_IS_WEB_VIEW (widget))2838 if (WEBKIT_IS_WEB_VIEW (widget))
2839#ifdef HAVE_WEBKIT2
2840 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO);
2841#else
2845 webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));2842 webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
2846#endif2843#endif
2847}2844}
@@ -2853,6 +2850,10 @@
2853 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2850 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2854 if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))2851 if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))
2855 g_signal_emit_by_name (widget, "cut-clipboard");2852 g_signal_emit_by_name (widget, "cut-clipboard");
2853#ifdef HAVE_WEBKIT2
2854 else if (WEBKIT_IS_WEB_VIEW (widget))
2855 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT);
2856#endif
2856}2857}
28572858
2858static void2859static void
@@ -2862,6 +2863,10 @@
2862 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2863 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2863 if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))2864 if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))
2864 g_signal_emit_by_name (widget, "copy-clipboard");2865 g_signal_emit_by_name (widget, "copy-clipboard");
2866#ifdef HAVE_WEBKIT2
2867 else if (WEBKIT_IS_WEB_VIEW (widget))
2868 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY);
2869#endif
2865}2870}
28662871
2867static void2872static void
@@ -2871,25 +2876,29 @@
2871 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2876 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2872 if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))2877 if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))
2873 g_signal_emit_by_name (widget, "paste-clipboard");2878 g_signal_emit_by_name (widget, "paste-clipboard");
2879#ifdef HAVE_WEBKIT2
2880 else if (WEBKIT_IS_WEB_VIEW (widget))
2881 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE);
2882#endif
2874}2883}
28752884
2876static void2885static void
2877_action_delete_activate (GtkAction* action,2886_action_delete_activate (GtkAction* action,
2878 MidoriBrowser* browser)2887 MidoriBrowser* browser)
2879{2888{
2880#ifndef HAVE_WEBKIT2
2881 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));2889 GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
2882 if (G_LIKELY (widget))2890 if (G_LIKELY (widget))
2883 {2891 {
2884 if (WEBKIT_IS_WEB_VIEW (widget))2892 if (GTK_IS_EDITABLE (widget))
2893 gtk_editable_delete_selection (GTK_EDITABLE (widget));
2894#ifndef HAVE_WEBKIT2
2895 else if (WEBKIT_IS_WEB_VIEW (widget))
2885 webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget));2896 webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget));
2886 else if (GTK_IS_EDITABLE (widget))2897#endif
2887 gtk_editable_delete_selection (GTK_EDITABLE (widget));
2888 else if (GTK_IS_TEXT_VIEW (widget))2898 else if (GTK_IS_TEXT_VIEW (widget))
2889 gtk_text_buffer_delete_selection (2899 gtk_text_buffer_delete_selection (
2890 gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);2900 gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);
2891 }2901 }
2892#endif
2893}2902}
28942903
2895static void2904static void
@@ -2901,6 +2910,10 @@
2901 {2910 {
2902 if (GTK_IS_EDITABLE (widget))2911 if (GTK_IS_EDITABLE (widget))
2903 gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);2912 gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
2913#ifdef HAVE_WEBKIT2
2914 else if (WEBKIT_IS_WEB_VIEW (widget))
2915 webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL);
2916#endif
2904 else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))2917 else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))
2905 {2918 {
2906 if (GTK_IS_TEXT_VIEW (widget))2919 if (GTK_IS_TEXT_VIEW (widget))
@@ -3484,11 +3497,18 @@
3484 MidoriBrowser* browser,3497 MidoriBrowser* browser,
3485 gboolean use_dom)3498 gboolean use_dom)
3486{3499{
3487 GtkWidget* view;3500 GtkWidget* view = midori_browser_get_current_tab (browser);
3501 #ifdef HAVE_WEBKIT2
3502 /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */
3503 GtkWidget* source = midori_view_new_with_item (NULL, browser->settings);
3504 GtkWidget* source_view = midori_view_get_web_view (MIDORI_VIEW (source));
3505 midori_tab_set_view_source (MIDORI_TAB (source), TRUE);
3506 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (source_view), midori_tab_get_uri (MIDORI_TAB (view)));
3507 midori_browser_add_tab (browser, source);
3508 #else
3488 gchar* text_editor;3509 gchar* text_editor;
3489 gchar* filename = NULL;3510 gchar* filename = NULL;
34903511
3491 view = midori_browser_get_current_tab (browser);
3492 filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, use_dom);3512 filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, use_dom);
3493 g_object_get (browser->settings, "text-editor", &text_editor, NULL);3513 g_object_get (browser->settings, "text-editor", &text_editor, NULL);
3494 if (!(text_editor && *text_editor))3514 if (!(text_editor && *text_editor))
@@ -3512,6 +3532,7 @@
3512 g_free (filename);3532 g_free (filename);
3513 }3533 }
3514 g_free (text_editor);3534 g_free (text_editor);
3535 #endif
3515}3536}
35163537
3517static void3538static void
35183539
=== modified file 'midori/midori-historycompletion.vala'
--- midori/midori-historycompletion.vala 2014-02-11 23:01:05 +0000
+++ midori/midori-historycompletion.vala 2014-03-26 21:12:29 +0000
@@ -46,12 +46,12 @@
46 if (item is Midori.HistoryWebsite) {46 if (item is Midori.HistoryWebsite) {
47 var website = item as Midori.HistoryWebsite;47 var website = item as Midori.HistoryWebsite;
48 suggestions.append (new Suggestion (website.uri, website.title,48 suggestions.append (new Suggestion (website.uri, website.title,
49 false, null, Midori.Paths.get_icon (website.uri, null)));49 false, null, yield Midori.URI.get_icon_fallback (website.uri, null, cancellable), this.position));
50 }50 }
51 else if (item is Midori.HistorySearch) {51 else if (item is Midori.HistorySearch) {
52 var search = item as Midori.HistorySearch;52 var search = item as Midori.HistorySearch;
53 suggestions.append (new Suggestion (search.uri, search.title + "\n" + search.uri,53 suggestions.append (new Suggestion (search.uri, search.title + "\n" + search.uri,
54 false, "gray", Midori.Paths.get_icon (search.uri, null), this.position));54 false, "gray", yield Midori.URI.get_icon_fallback (search.uri, null, cancellable), this.position));
55 }55 }
56 else56 else
57 warn_if_reached ();57 warn_if_reached ();
5858
=== modified file 'midori/midori-searchcompletion.vala'
--- midori/midori-searchcompletion.vala 2014-02-11 23:01:05 +0000
+++ midori/midori-searchcompletion.vala 2014-03-26 21:12:29 +0000
@@ -45,11 +45,11 @@
45 item.get ("text", out desc);45 item.get ("text", out desc);
46 string search_uri = URI.for_search (uri, text);46 string search_uri = URI.for_search (uri, text);
47 string search_title = _("Search with %s").printf (title);47 string search_title = _("Search with %s").printf (title);
48 Gdk.Pixbuf? pixbuf = Midori.Paths.get_icon (uri, null);48 Icon? icon = yield Midori.URI.get_icon_fallback (uri, null, cancellable);
49 string search_desc = search_title + "\n" + desc ?? uri;49 string search_desc = search_title + "\n" + desc ?? uri;
50 /* FIXME: Theming? Win32? */50 /* FIXME: Theming? Win32? */
51 string background = "gray";51 string background = "gray";
52 var suggestion = new Suggestion (search_uri, search_desc, false, background, pixbuf);52 var suggestion = new Suggestion (search_uri, search_desc, false, background, icon);
53 suggestions.append (suggestion);53 suggestions.append (suggestion);
5454
55 n++;55 n++;
5656
=== modified file 'midori/midori-tab.vala'
--- midori/midori-tab.vala 2014-03-18 16:56:38 +0000
+++ midori/midori-tab.vala 2014-03-26 21:12:29 +0000
@@ -34,6 +34,7 @@
34 }34 }
3535
36 public class Tab : Gtk.VBox {36 public class Tab : Gtk.VBox {
37 public Tab related { get; set construct; }
37 public WebKit.WebView web_view { get; private set; }38 public WebKit.WebView web_view { get; private set; }
3839
39 private string current_uri = "about:blank";40 private string current_uri = "about:blank";
@@ -94,6 +95,8 @@
94 Since: 0.5.895 Since: 0.5.8
95 */96 */
96 public signal bool open_uri (string uri);97 public signal bool open_uri (string uri);
98 /* Since: 0.5.8 */
99 public signal bool navigation_requested (string uri);
97 public signal void console_message (string message, int line, string source_id);100 public signal void console_message (string message, int line, string source_id);
98 public signal void attach_inspector (WebKit.WebView inspector_view);101 public signal void attach_inspector (WebKit.WebView inspector_view);
99 /* Emitted when an open inspector that was previously102 /* Emitted when an open inspector that was previously
@@ -120,7 +123,12 @@
120 orientation = Gtk.Orientation.VERTICAL;123 orientation = Gtk.Orientation.VERTICAL;
121 #endif124 #endif
122125
126#if HAVE_WEBKIT2_3_91
127 web_view = related != null ?
128 new WebKit.WebView.with_related_view (related.web_view) : new WebKit.WebView ();
129#else
123 web_view = new WebKit.WebView ();130 web_view = new WebKit.WebView ();
131#endif
124 /* Load something to avoid a bug where WebKit might not set a main frame */132 /* Load something to avoid a bug where WebKit might not set a main frame */
125 web_view.load_uri ("");133 web_view.load_uri ("");
126 }134 }
@@ -260,5 +268,34 @@
260 return found;268 return found;
261#endif269#endif
262 }270 }
271
272 /*
273 Updates all editing actions with regard to text selection.
274
275 Since: 0.5.8
276 */
277 public async void update_actions (Gtk.ActionGroup actions) {
278#if HAVE_WEBKIT2
279 try {
280 actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null);
281 actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null);
282 actions.get_action ("Cut").sensitive = yield web_view.can_execute_editing_command ("Cut", null);
283 actions.get_action ("Copy").sensitive = yield web_view.can_execute_editing_command ("Copy", null);
284 actions.get_action ("Paste").sensitive = yield web_view.can_execute_editing_command ("Paste", null);
285 actions.get_action ("Delete").sensitive = yield web_view.can_execute_editing_command ("Cut", null);
286 actions.get_action ("SelectAll").sensitive = yield web_view.can_execute_editing_command ("SelectAll", null);
287 } catch (Error error) {
288 critical ("Failed to update actions: %s", error.message);
289 }
290#else
291 actions.get_action ("Undo").sensitive = web_view.can_undo ();
292 actions.get_action ("Redo").sensitive = web_view.can_redo ();
293 actions.get_action ("Cut").sensitive = web_view.can_cut_clipboard ();
294 actions.get_action ("Copy").sensitive = web_view.can_copy_clipboard ();
295 actions.get_action ("Paste").sensitive = web_view.can_paste_clipboard ();
296 actions.get_action ("Delete").sensitive = true;
297 actions.get_action ("SelectAll").sensitive = true;
298#endif
299 }
263 }300 }
264}301}
265302
=== modified file 'midori/midori-view.c'
--- midori/midori-view.c 2014-03-18 18:45:32 +0000
+++ midori/midori-view.c 2014-03-26 21:12:29 +0000
@@ -544,10 +544,24 @@
544 webkit_policy_decision_download (decision);544 webkit_policy_decision_download (decision);
545 return TRUE;545 return TRUE;
546 }546 }
547 webkit_policy_decision_use (decision);
548 return TRUE;
549 }
550 else if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
551 {
552 }
553 else if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
554 {
555 }
556 else
557 {
558 g_debug ("Unhandled policy decision type %d", decision_type);
559 return FALSE;
547 }560 }
548561
549 void* request = NULL;562 void* request = NULL;
550 const gchar* uri = webkit_web_view_get_uri (web_view);563 const gchar* uri = webkit_uri_request_get_uri (
564 webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision)));
551 #else565 #else
552 const gchar* uri = webkit_network_request_get_uri (request);566 const gchar* uri = webkit_network_request_get_uri (request);
553 #endif567 #endif
@@ -648,6 +662,19 @@
648 g_free (result);662 g_free (result);
649 view->find_links = -1;663 view->find_links = -1;
650 #endif664 #endif
665
666 gboolean handled = FALSE;
667 g_signal_emit_by_name (view, "navigation-requested", uri, &handled);
668 if (handled)
669 {
670 #ifdef HAVE_WEBKIT2
671 webkit_policy_decision_ignore (decision);
672 #else
673 webkit_web_policy_decision_ignore (decision);
674 #endif
675 return TRUE;
676 }
677
651 return FALSE;678 return FALSE;
652}679}
653680
@@ -2246,21 +2273,7 @@
2246 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)2273 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)
2247 {2274 {
2248 /* Enforce update of actions - there's no "selection-changed" signal */2275 /* Enforce update of actions - there's no "selection-changed" signal */
2249 #ifndef HAVE_WEBKIT22276 midori_tab_update_actions (MIDORI_TAB (view), actions, NULL, NULL);
2250 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Undo"),
2251 webkit_web_view_can_undo (WEBKIT_WEB_VIEW (view->web_view)));
2252 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Redo"),
2253 webkit_web_view_can_redo (WEBKIT_WEB_VIEW (view->web_view)));
2254 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Cut"),
2255 webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (view->web_view)));
2256 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Copy"),
2257 webkit_web_view_can_copy_clipboard (WEBKIT_WEB_VIEW (view->web_view)));
2258 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Paste"),
2259 webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (view->web_view)));
2260 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Delete"),
2261 webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (view->web_view)));
2262 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "SelectAll"), TRUE);
2263 #endif
2264 midori_context_action_add_by_name (menu, "Undo");2277 midori_context_action_add_by_name (menu, "Undo");
2265 midori_context_action_add_by_name (menu, "Redo");2278 midori_context_action_add_by_name (menu, "Redo");
2266 midori_context_action_add (menu, NULL);2279 midori_context_action_add (menu, NULL);
@@ -2348,15 +2361,6 @@
2348 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)2361 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
2349 midori_context_action_add (menu, NULL);2362 midori_context_action_add (menu, NULL);
23502363
2351 /* No need to have Copy twice, which is already in the editable menu */
2352 if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
2353 {
2354 /* Enforce update of copy action - there's no "selection-changed" signal */
2355 midori_context_action_add_by_name (menu, "Copy");
2356 gtk_action_set_sensitive (gtk_action_group_get_action (actions, "Copy"),
2357 webkit_web_view_can_copy_clipboard (WEBKIT_WEB_VIEW (view->web_view)));
2358 }
2359
2360 /* Ensure view->selected_text */2364 /* Ensure view->selected_text */
2361 midori_view_has_selection (view);2365 midori_view_has_selection (view);
2362 if (midori_uri_is_valid (view->selected_text))2366 if (midori_uri_is_valid (view->selected_text))
@@ -2422,16 +2426,28 @@
2422 midori_context_action_add_by_name (menu, "Forward");2426 midori_context_action_add_by_name (menu, "Forward");
2423 midori_context_action_add_by_name (menu, "Stop");2427 midori_context_action_add_by_name (menu, "Stop");
2424 midori_context_action_add_by_name (menu, "Reload");2428 midori_context_action_add_by_name (menu, "Reload");
2429 }
2430
2431 /* No need to have Copy twice, which is already in the editable menu */
2432 if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
2433 {
2434 midori_context_action_add (menu, NULL);
2435 /* Enforce update of actions - there's no "selection-changed" signal */
2436 midori_tab_update_actions (MIDORI_TAB (view), actions, NULL, NULL);
2437 midori_context_action_add_by_name (menu, "Copy");
2438 midori_context_action_add_by_name (menu, "SelectAll");
2439 }
2440
2441 if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
2442 {
2425 midori_context_action_add (menu, NULL);2443 midori_context_action_add (menu, NULL);
2426 midori_context_action_add_by_name (menu, "UndoTabClose");2444 midori_context_action_add_by_name (menu, "UndoTabClose");
2427
2428 #ifndef HAVE_WEBKIT22445 #ifndef HAVE_WEBKIT2
2429 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);2446 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
2430 if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view))2447 if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view))
2431 midori_context_action_add_simple (menu, "OpenFrameInNewTab", _("Open _Frame in New Tab"), NULL, NULL,2448 midori_context_action_add_simple (menu, "OpenFrameInNewTab", _("Open _Frame in New Tab"), NULL, NULL,
2432 midori_web_view_open_frame_in_new_tab_cb, view);2449 midori_web_view_open_frame_in_new_tab_cb, view);
2433 #endif2450 #endif
2434
2435 midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,2451 midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,
2436 midori_view_tab_label_menu_window_new_cb, view);2452 midori_view_tab_label_menu_window_new_cb, view);
2437 midori_context_action_add_by_name (menu, "ZoomIn");2453 midori_context_action_add_by_name (menu, "ZoomIn");
@@ -2534,7 +2550,6 @@
2534}2550}
2535#endif2551#endif
25362552
2537#ifndef HAVE_WEBKIT2
2538static gboolean2553static gboolean
2539midori_view_web_view_close_cb (WebKitWebView* web_view,2554midori_view_web_view_close_cb (WebKitWebView* web_view,
2540 GtkWidget* view)2555 GtkWidget* view)
@@ -2550,7 +2565,11 @@
2550 MidoriNewView where = MIDORI_NEW_VIEW_TAB;2565 MidoriNewView where = MIDORI_NEW_VIEW_TAB;
2551 GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));2566 GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));
25522567
2568#ifdef HAVE_WEBKIT2
2569 WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view));
2570#else
2553 WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (WEBKIT_WEB_VIEW (web_view));2571 WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (WEBKIT_WEB_VIEW (web_view));
2572#endif
2554 gboolean locationbar_visible, menubar_visible, toolbar_visible;2573 gboolean locationbar_visible, menubar_visible, toolbar_visible;
2555 gint width, height;2574 gint width, height;
2556 g_object_get (features,2575 g_object_get (features,
@@ -2586,8 +2605,13 @@
2586 GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);2605 GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);
2587 if (width > 0 && height > 0)2606 if (width > 0 && height > 0)
2588 gtk_widget_set_size_request (toplevel, width, height);2607 gtk_widget_set_size_request (toplevel, width, height);
2608#ifdef HAVE_WEBKIT2
2609 g_signal_connect (web_view, "close",
2610 G_CALLBACK (midori_view_web_view_close_cb), new_view);
2611#else
2589 g_signal_connect (web_view, "close-web-view",2612 g_signal_connect (web_view, "close-web-view",
2590 G_CALLBACK (midori_view_web_view_close_cb), new_view);2613 G_CALLBACK (midori_view_web_view_close_cb), new_view);
2614#endif
2591 }2615 }
25922616
2593 return TRUE;2617 return TRUE;
@@ -2595,26 +2619,38 @@
25952619
2596static GtkWidget*2620static GtkWidget*
2597webkit_web_view_create_web_view_cb (GtkWidget* web_view,2621webkit_web_view_create_web_view_cb (GtkWidget* web_view,
2622#ifndef HAVE_WEBKIT2
2598 WebKitWebFrame* web_frame,2623 WebKitWebFrame* web_frame,
2624#endif
2599 MidoriView* view)2625 MidoriView* view)
2600{2626{
2601 MidoriView* new_view;2627 MidoriView* new_view;
26022628
2629#ifdef HAVE_WEBKIT2
2630 const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));
2631#else
2632 const gchar* uri = webkit_web_frame_get_uri (web_frame);
2633#endif
2603 if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)2634 if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
2604 new_view = view;2635 new_view = view;
2605 else2636 else
2606 {2637 {
2607 KatzeItem* item = katze_item_new ();2638 KatzeItem* item = katze_item_new ();
2608 item->uri = g_strdup (webkit_web_frame_get_uri (web_frame));2639 item->uri = g_strdup (uri);
2609 new_view = (MidoriView*)midori_view_new_with_item (item, view->settings);2640 new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL);
2641#ifdef HAVE_WEBKIT2
2642 g_signal_connect (new_view->web_view, "ready-to-show",
2643 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
2644#else
2610 g_signal_connect (new_view->web_view, "web-view-ready",2645 g_signal_connect (new_view->web_view, "web-view-ready",
2611 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);2646 G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
2647#endif
2612 }2648 }
2613 g_object_set_data_full (G_OBJECT (new_view), "opener-uri",2649 g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free);
2614 g_strdup (webkit_web_frame_get_uri (web_frame)), g_free);
2615 return new_view->web_view;2650 return new_view->web_view;
2616}2651}
26172652
2653#ifndef HAVE_WEBKIT2
2618static gboolean2654static gboolean
2619webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,2655webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
2620 WebKitWebFrame* web_frame,2656 WebKitWebFrame* web_frame,
@@ -3144,14 +3180,55 @@
3144 * Return value: a new #MidoriView3180 * Return value: a new #MidoriView
3145 *3181 *
3146 * Since: 0.4.33182 * Since: 0.4.3
3183 * Deprecated: 0.5.8: Use midori_view_new_from_view instead.
3147 **/3184 **/
3148GtkWidget*3185GtkWidget*
3149midori_view_new_with_item (KatzeItem* item,3186midori_view_new_with_item (KatzeItem* item,
3150 MidoriWebSettings* settings)3187 MidoriWebSettings* settings)
3151{3188{
3189 return midori_view_new_from_view (NULL, item, settings);
3190}
3191
3192/**
3193 * midori_view_new_with_item:
3194 * @view: a predating, related #MidoriView, or %NULL
3195 * @item: a #KatzeItem, or %NULL
3196 * @settings: a #MidoriWebSettings, or %NULL
3197 *
3198 * Creates a new view, visible by default.
3199 *
3200 * If a @view is specified the returned new view will share
3201 * its settings and if applicable re-use the rendering process.
3202 *
3203 * When @view should be passed:
3204 * The new one created is a new tab/ window for the old @view
3205 * A tab was duplicated
3206 *
3207 * When @view may be passed:
3208 * Old and new view belong to the same website or group
3209 *
3210 * Don't pass a @view if:
3211 * The new view is a completely new website
3212 *
3213 * The @item may contain title, URI and minimized status and will be copied.
3214 *
3215 * Usually @settings should be passed from an existing view or browser.
3216 *
3217 * Return value: a new #MidoriView
3218 *
3219 * Since: 0.5.8
3220 **/
3221GtkWidget*
3222midori_view_new_from_view (MidoriView* related,
3223 KatzeItem* item,
3224 MidoriWebSettings* settings)
3225{
3152 MidoriView* view = g_object_new (MIDORI_TYPE_VIEW,3226 MidoriView* view = g_object_new (MIDORI_TYPE_VIEW,
3227 "related", MIDORI_TAB (related),
3153 "title", item ? katze_item_get_name (item) : NULL,3228 "title", item ? katze_item_get_name (item) : NULL,
3154 NULL);3229 NULL);
3230 if (!settings && related)
3231 settings = related->settings;
3155 if (settings)3232 if (settings)
3156 _midori_view_set_settings (view, settings);3233 _midori_view_set_settings (view, settings);
3157 if (item)3234 if (item)
@@ -3427,6 +3504,8 @@
3427 midori_view_web_view_permission_request_cb, view,3504 midori_view_web_view_permission_request_cb, view,
3428 "signal::context-menu",3505 "signal::context-menu",
3429 midori_view_web_view_context_menu_cb, view,3506 midori_view_web_view_context_menu_cb, view,
3507 "signal::create",
3508 webkit_web_view_create_web_view_cb, view,
3430 #else3509 #else
3431 "signal::notify::load-status",3510 "signal::notify::load-status",
3432 midori_view_web_view_notify_load_status_cb, view,3511 midori_view_web_view_notify_load_status_cb, view,
34333512
=== modified file 'midori/midori-view.h'
--- midori/midori-view.h 2014-03-16 12:11:56 +0000
+++ midori/midori-view.h 2014-03-26 21:12:29 +0000
@@ -64,6 +64,11 @@
64midori_view_new_with_item (KatzeItem* item,64midori_view_new_with_item (KatzeItem* item,
65 MidoriWebSettings* settings);65 MidoriWebSettings* settings);
6666
67GtkWidget*
68midori_view_new_from_view (MidoriView* view,
69 KatzeItem* item,
70 MidoriWebSettings* settings);
71
67void72void
68midori_view_set_settings (MidoriView* view,73midori_view_set_settings (MidoriView* view,
69 MidoriWebSettings* settings);74 MidoriWebSettings* settings);
7075
=== modified file 'midori/webkit2gtk-3.0.vapi'
--- midori/webkit2gtk-3.0.vapi 2013-08-02 17:20:37 +0000
+++ midori/webkit2gtk-3.0.vapi 2014-03-26 21:12:29 +0000
@@ -436,6 +436,7 @@
436 public unowned string[] get_spell_checking_languages ();436 public unowned string[] get_spell_checking_languages ();
437 public void register_uri_scheme (string scheme, owned WebKit.URISchemeRequestCallback callback);437 public void register_uri_scheme (string scheme, owned WebKit.URISchemeRequestCallback callback);
438 public void set_additional_plugins_directory (string directory);438 public void set_additional_plugins_directory (string directory);
439 public void set_process_model (WebKit.ProcessModel process_model);
439 public void set_cache_model (WebKit.CacheModel cache_model);440 public void set_cache_model (WebKit.CacheModel cache_model);
440 public void set_spell_checking_enabled (bool enabled);441 public void set_spell_checking_enabled (bool enabled);
441 public void set_spell_checking_languages (string[] languages);442 public void set_spell_checking_languages (string[] languages);
@@ -486,6 +487,7 @@
486 public class WebView : WebKit.WebViewBase, Atk.Implementor, Gtk.Buildable {487 public class WebView : WebKit.WebViewBase, Atk.Implementor, Gtk.Buildable {
487 [CCode (has_construct_function = false, type = "GtkWidget*")]488 [CCode (has_construct_function = false, type = "GtkWidget*")]
488 public WebView ();489 public WebView ();
490 public WebView.with_related_view (WebKit.WebView related);
489 public async bool can_execute_editing_command (string command, GLib.Cancellable? cancellable) throws GLib.Error;491 public async bool can_execute_editing_command (string command, GLib.Cancellable? cancellable) throws GLib.Error;
490 public bool can_go_back ();492 public bool can_go_back ();
491 public bool can_go_forward ();493 public bool can_go_forward ();
@@ -594,6 +596,11 @@
594 public abstract void allow ();596 public abstract void allow ();
595 public abstract void deny ();597 public abstract void deny ();
596 }598 }
599 [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_PROCESS_MODEL_")]
600 public enum ProcessModel {
601 SHARED_SECONDARY_PROCESS,
602 MULTIPLE_SECONDARY_PROCESSES
603 }
597 [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_CACHE_MODEL_")]604 [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_CACHE_MODEL_")]
598 public enum CacheModel {605 public enum CacheModel {
599 DOCUMENT_VIEWER,606 DOCUMENT_VIEWER,
600607
=== modified file 'midori/webkitgtk-3.0.vapi'
--- midori/webkitgtk-3.0.vapi 2012-12-16 18:40:10 +0000
+++ midori/webkitgtk-3.0.vapi 2014-03-26 21:12:29 +0000
@@ -6,6 +6,7 @@
6 public class FaviconDatabase : GLib.Object {6 public class FaviconDatabase : GLib.Object {
7 public signal void icon_loaded (string frame_uri);7 public signal void icon_loaded (string frame_uri);
8 public Gdk.Pixbuf? try_get_favicon_pixbuf (string page_uri, uint width, uint height);8 public Gdk.Pixbuf? try_get_favicon_pixbuf (string page_uri, uint width, uint height);
9 public async Gdk.Pixbuf? get_favicon_pixbuf (string page_uri, uint width, uint height, GLib.Cancellable cancellable) throws GLib.Error;
9 public void set_path (string? path);10 public void set_path (string? path);
10 public void clear ();11 public void clear ();
11 }12 }

Subscribers

People subscribed via source and target branches

to all changes: