Merge lp:~midori/midori/webKitTwoOnly into lp:midori
- webKitTwoOnly
- Merge into trunk
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~midori/midori/webKitTwoOnly | ||||
Merge into: | lp:midori | ||||
Diff against target: |
6316 lines (+248/-3830) (has conflicts) 43 files modified
CMakeLists.txt (+19/-54) data/gtk3.css (+1/-6) extensions/CMakeLists.txt (+9/-11) extensions/about.vala (+0/-4) extensions/adblock/extension.vala (+26/-60) extensions/adblock/subscriptions.vala (+0/-34) extensions/addons.c (+3/-3) extensions/colorful-tabs.c (+0/-5) extensions/cookie-manager/cookie-manager.c (+2/-8) extensions/external-download-manager.vala (+0/-12) extensions/feed-panel/feed-panel.c (+0/-33) extensions/feed-panel/katze-net.c (+0/-117) extensions/notes.vala (+0/-5) extensions/open-with.vala (+0/-28) extensions/transfers.vala (+0/-22) katze/katze-item.c (+0/-27) katze/katze.h (+1/-6) katze/midori-paths.vala (+6/-27) katze/midori-uri.vala (+0/-6) midori/main.c (+3/-15) midori/midori-browser.c (+0/-402) midori/midori-browser.h (+0/-4) midori/midori-contextaction.vala (+0/-2) midori/midori-download.vala (+0/-191) midori/midori-frontend.c (+0/-3) midori/midori-locationaction.c (+26/-40) midori/midori-preferences.c (+0/-29) midori/midori-privatedata.c (+0/-39) midori/midori-searchaction.c (+1/-118) midori/midori-session.c (+5/-271) midori/midori-settings.vala (+36/-33) midori/midori-speeddial.vala (+0/-83) midori/midori-tab.vala (+5/-46) midori/midori-view.c (+74/-1650) midori/midori-websettings.c (+31/-301) midori/midori-websettings.h (+0/-9) midori/sokoke.c (+0/-39) tests/actions.vala (+0/-28) tests/browser.c (+0/-7) tests/download.vala (+0/-24) tests/extensions.c (+0/-4) tests/properties.c (+0/-5) tests/tab.vala (+0/-19) Text conflict in midori/main.c |
||||
To merge this branch: | bzr merge lp:~midori/midori/webKitTwoOnly | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Midori Devs | Pending | ||
Review via email: mp+285295@code.launchpad.net |
Commit message
Drop non-WebKit2 code paths
Description of the change
- 7102. By gue5t <email address hidden>
-
support user-stylesheet-uri with wk2 by adding a WebKit.
UserContentMana ger to Midori.Settings - 7103. By Cris Dywan
-
Use WebExtension without the bindings
- 7104. By gue5t <email address hidden>
-
Fix four MidoriView/
MidoriTab bugs causing popup window opening to segfault or misbehave Before these changes, clicking the first green arrow on http://
javascript. info/tutorial/ popup-windows results in a segfault, instead of the expected popup. There were four bugs here:
1. The constructor for Midori.Tab was mistakenly setting the nonexistent "related" property instead of the "related-view" property.
2. The signature of webkit_web_view_ create_ web_view_ cb did not match the signature of the "create" signal for a WK2 WebKitWebView, causing a WebKitNavigatio nAction to be used as a MidoriView.
3. The function called when a popup is ready to be shown was asking for the "width" and "height" properties used by WebKitWindowProperties in WK1 rather than the "geometry" property used in WK2. (Fixing these three resulted in no more crashes, but popups would be empty instead of loading the expected URIs.)
4. An old (WK1, touched in r5389 and r842, originally in 2009) workaround was unconditionally doing "web_view.load_uri ("")" which cancelled the loading of the intended URI for popups.
After the other fixes, removing this workaround results in everything working as expected.
- 7105. By Cris Dywan
-
Merge lp:midori
- 7106. By Cris Dywan
-
Use load-failed-
with-tls- errors to handle certificate errors - 7107. By gue5t <email address hidden>
-
fix theming issues under GTK+ 3.20
- 7108. By gue5t <email address hidden>
-
partially fix LocationAction dropdown under Wayland
Unmerged revisions
- 7108. By gue5t <email address hidden>
-
partially fix LocationAction dropdown under Wayland
- 7107. By gue5t <email address hidden>
-
fix theming issues under GTK+ 3.20
- 7106. By Cris Dywan
-
Use load-failed-
with-tls- errors to handle certificate errors - 7105. By Cris Dywan
-
Merge lp:midori
- 7104. By gue5t <email address hidden>
-
Fix four MidoriView/
MidoriTab bugs causing popup window opening to segfault or misbehave Before these changes, clicking the first green arrow on http://
javascript. info/tutorial/ popup-windows results in a segfault, instead of the expected popup. There were four bugs here:
1. The constructor for Midori.Tab was mistakenly setting the nonexistent "related" property instead of the "related-view" property.
2. The signature of webkit_web_view_ create_ web_view_ cb did not match the signature of the "create" signal for a WK2 WebKitWebView, causing a WebKitNavigatio nAction to be used as a MidoriView.
3. The function called when a popup is ready to be shown was asking for the "width" and "height" properties used by WebKitWindowProperties in WK1 rather than the "geometry" property used in WK2. (Fixing these three resulted in no more crashes, but popups would be empty instead of loading the expected URIs.)
4. An old (WK1, touched in r5389 and r842, originally in 2009) workaround was unconditionally doing "web_view.load_uri ("")" which cancelled the loading of the intended URI for popups.
After the other fixes, removing this workaround results in everything working as expected.
- 7103. By Cris Dywan
-
Use WebExtension without the bindings
- 7102. By gue5t <email address hidden>
-
support user-stylesheet-uri with wk2 by adding a WebKit.
UserContentMana ger to Midori.Settings - 7101. By Cris Dywan
-
Drop non-WebKit2 code paths
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-02-04 19:54:52 +0000 | |||
3 | +++ CMakeLists.txt 2016-09-20 20:57:01 +0000 | |||
4 | @@ -112,13 +112,13 @@ | |||
5 | 112 | sqlite3>=3.6.19 | 112 | sqlite3>=3.6.19 |
6 | 113 | gmodule-2.0 | 113 | gmodule-2.0 |
7 | 114 | gio-2.0>=2.32.3 | 114 | gio-2.0>=2.32.3 |
9 | 115 | libsoup-gnome-2.4>=2.37.1 | 115 | libsoup-2.4>=2.42.0 |
10 | 116 | ) | 116 | ) |
11 | 117 | add_definitions("-DHAVE_LIBXML") | 117 | add_definitions("-DHAVE_LIBXML") |
12 | 118 | add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"") | 118 | add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"") |
16 | 119 | add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-gnome-2.4_VERSION}\"") | 119 | add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-2.4_VERSION}\"") |
17 | 120 | set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4) | 120 | set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4 gtk+-3.0) |
18 | 121 | if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.40.0") | 121 | if (${DEPS_libsoup-2.4_VERSION} VERSION_GREATER "2.40.0") |
19 | 122 | # valac 0.16 didn't have the bindings yet | 122 | # valac 0.16 didn't have the bindings yet |
20 | 123 | # For consistency we need to ensure C code makes the same assumptions | 123 | # For consistency we need to ensure C code makes the same assumptions |
21 | 124 | if (${VALA_VERSION} VERSION_GREATER "0.17.0") | 124 | if (${VALA_VERSION} VERSION_GREATER "0.17.0") |
22 | @@ -126,7 +126,7 @@ | |||
23 | 126 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0) | 126 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0) |
24 | 127 | endif () | 127 | endif () |
25 | 128 | endif () | 128 | endif () |
27 | 129 | if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.48.0") | 129 | if (${DEPS_libsoup-2.4_VERSION} VERSION_GREATER "2.48.0") |
28 | 130 | add_definitions("-DHAVE_LIBSOUP_2_48_0") | 130 | add_definitions("-DHAVE_LIBSOUP_2_48_0") |
29 | 131 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_48_0) | 131 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_48_0) |
30 | 132 | endif () | 132 | endif () |
31 | @@ -142,21 +142,14 @@ | |||
32 | 142 | set(PKGS ${PKGS} libnotify) | 142 | set(PKGS ${PKGS} libnotify) |
33 | 143 | endif () | 143 | endif () |
34 | 144 | 144 | ||
35 | 145 | option(USE_GTK3 "Use GTK+3" OFF) | ||
36 | 146 | option(HALF_BRO_INCOM_WEBKIT2 "Serve as a guniea pig" OFF) | ||
37 | 147 | option(USE_ZEITGEIST "Zeitgeist history integration" ON) | 145 | option(USE_ZEITGEIST "Zeitgeist history integration" ON) |
38 | 148 | option(USE_GRANITE "Fancy notebook and pop-overs" OFF) | 146 | option(USE_GRANITE "Fancy notebook and pop-overs" OFF) |
39 | 149 | option(USE_APIDOCS "API documentation" OFF) | 147 | option(USE_APIDOCS "API documentation" OFF) |
40 | 150 | option(USE_GIR "Generate GObject Introspection bindings" OFF) | 148 | option(USE_GIR "Generate GObject Introspection bindings" OFF) |
41 | 151 | option(EXTRA_WARNINGS "Additional compiler warnings" OFF) | 149 | option(EXTRA_WARNINGS "Additional compiler warnings" OFF) |
42 | 152 | 150 | ||
43 | 153 | # GTK+3 is implied here, whether set or not | ||
44 | 154 | if (USE_GRANITE OR HALF_BRO_INCOM_WEBKIT2) | ||
45 | 155 | set(USE_GTK3 ON) | ||
46 | 156 | endif () | ||
47 | 157 | |||
48 | 158 | if (USE_GRANITE) | 151 | if (USE_GRANITE) |
50 | 159 | pkg_check_modules(GRANITE granite>=0.2) | 152 | pkg_check_modules(GRANITE REQUIRED granite>=0.2) |
51 | 160 | set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}") | 153 | set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}") |
52 | 161 | set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}") | 154 | set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}") |
53 | 162 | add_definitions("-DHAVE_GRANITE") | 155 | add_definitions("-DHAVE_GRANITE") |
54 | @@ -178,53 +171,25 @@ | |||
55 | 178 | if (WIN32) | 171 | if (WIN32) |
56 | 179 | add_definitions("-DGCR_VERSION=\"No\"") | 172 | add_definitions("-DGCR_VERSION=\"No\"") |
57 | 180 | else () | 173 | else () |
63 | 181 | if (USE_GTK3) | 174 | pkg_check_modules(GCR REQUIRED gcr-3>=2.32) |
59 | 182 | pkg_check_modules(GCR REQUIRED gcr-3>=2.32) | ||
60 | 183 | else () | ||
61 | 184 | pkg_check_modules(GCR REQUIRED gcr-base-3>=2.32) | ||
62 | 185 | endif () | ||
64 | 186 | add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"") | 175 | add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"") |
65 | 187 | add_definitions("-DHAVE_GCR") | 176 | add_definitions("-DHAVE_GCR") |
66 | 188 | set(OPTS_INCLUDE_DIRS ${OPTS_INCLUDE_DIRS} ${GCR_INCLUDE_DIRS}) | 177 | set(OPTS_INCLUDE_DIRS ${OPTS_INCLUDE_DIRS} ${GCR_INCLUDE_DIRS}) |
67 | 189 | set(OPTS_LIBRARIES ${OPTS_LIBRARIES} ${GCR_LIBRARIES}) | 178 | set(OPTS_LIBRARIES ${OPTS_LIBRARIES} ${GCR_LIBRARIES}) |
68 | 190 | endif () | 179 | endif () |
69 | 191 | 180 | ||
106 | 192 | if (HALF_BRO_INCOM_WEBKIT2) | 181 | pkg_check_modules(DEPS_GTK REQUIRED |
107 | 193 | pkg_check_modules(DEPS_GTK REQUIRED | 182 | gtk+-3.0>=3.10.0 |
108 | 194 | gtk+-3.0>=3.10.0 | 183 | webkit2gtk-4.0>=2.3.91 |
109 | 195 | webkit2gtk-4.0>=2.3.91 | 184 | ) |
110 | 196 | ) | 185 | add_definitions("-DHAVE_WEBKIT2") |
111 | 197 | add_definitions("-DHAVE_WEBKIT2") | 186 | add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"") |
112 | 198 | add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"") | 187 | add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-4.0_VERSION}\"") |
113 | 199 | add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-4.0_VERSION}\"") | 188 | # set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-web-extension-4.0.vapi") |
114 | 200 | set(PKGS ${PKGS} gtk+-3.0) | 189 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-4.0.vapi") |
115 | 201 | # set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-web-extension-4.0.vapi") | 190 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3) |
116 | 202 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-4.0.vapi") | 191 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2) |
117 | 203 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3) | 192 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91) |
82 | 204 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2) | ||
83 | 205 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91) | ||
84 | 206 | elseif (USE_GTK3) | ||
85 | 207 | pkg_check_modules(DEPS_GTK REQUIRED | ||
86 | 208 | gtk+-3.0>=3.10.0 | ||
87 | 209 | webkitgtk-3.0>=1.8.1 | ||
88 | 210 | javascriptcoregtk-3.0 | ||
89 | 211 | ) | ||
90 | 212 | add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"") | ||
91 | 213 | add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkitgtk-3.0_VERSION}\"") | ||
92 | 214 | set(PKGS ${PKGS} gtk+-3.0) | ||
93 | 215 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi") | ||
94 | 216 | set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3) | ||
95 | 217 | else () | ||
96 | 218 | pkg_check_modules(DEPS_GTK REQUIRED | ||
97 | 219 | gtk+-2.0>=2.24.0 | ||
98 | 220 | webkit-1.0>=1.8.1 | ||
99 | 221 | javascriptcoregtk-1.0 | ||
100 | 222 | ) | ||
101 | 223 | add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-2.0_VERSION}\"") | ||
102 | 224 | add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit-1.0_VERSION}\"") | ||
103 | 225 | set(PKGS ${PKGS} gtk+-2.0) | ||
104 | 226 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi") | ||
105 | 227 | endif () | ||
118 | 228 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/katze/katze.vapi") | 193 | set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/katze/katze.vapi") |
119 | 229 | 194 | ||
120 | 230 | # dh_translations detects this if there's no variable used | 195 | # dh_translations detects this if there's no variable used |
121 | 231 | 196 | ||
122 | === modified file 'data/gtk3.css' | |||
123 | --- data/gtk3.css 2014-01-13 22:55:08 +0000 | |||
124 | +++ data/gtk3.css 2016-09-20 20:57:01 +0000 | |||
125 | @@ -1,9 +1,4 @@ | |||
126 | 1 | .notebook tab .button { | 1 | .notebook tab .button { |
127 | 2 | -GtkButton-default-border: 0; | ||
128 | 3 | -GtkButton-default-outside-border: 0; | ||
129 | 4 | -GtkButton-inner-border: 0; | ||
130 | 5 | -GtkWidget-focus-line-width: 0; | ||
131 | 6 | -GtkWidget-focus-padding: 0; | ||
132 | 7 | padding: 0; | 2 | padding: 0; |
133 | 8 | border-width: 1px 1px 0 0; | 3 | border-width: 1px 1px 0 0; |
134 | 9 | } | 4 | } |
135 | @@ -23,7 +18,7 @@ | |||
136 | 23 | /* Kill grey backround on inactive buttons */ | 18 | /* Kill grey backround on inactive buttons */ |
137 | 24 | GtkDrawingArea, | 19 | GtkDrawingArea, |
138 | 25 | GtkImage, | 20 | GtkImage, |
140 | 26 | GtkImage:insensitive, | 21 | GtkImage:disabled, |
141 | 27 | GtkImage:selected { | 22 | GtkImage:selected { |
142 | 28 | background-color: @transparent; | 23 | background-color: @transparent; |
143 | 29 | } | 24 | } |
144 | 30 | 25 | ||
145 | === modified file 'extensions/CMakeLists.txt' | |||
146 | --- extensions/CMakeLists.txt 2015-04-19 14:06:12 +0000 | |||
147 | +++ extensions/CMakeLists.txt 2016-09-20 20:57:01 +0000 | |||
148 | @@ -13,17 +13,15 @@ | |||
149 | 13 | "${CMAKE_BINARY_DIR}/midori" | 13 | "${CMAKE_BINARY_DIR}/midori" |
150 | 14 | ) | 14 | ) |
151 | 15 | file(GLOB EXTENSIONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) | 15 | file(GLOB EXTENSIONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) |
163 | 16 | if (HALF_BRO_INCOM_WEBKIT2) | 16 | list(REMOVE_ITEM EXTENSIONS |
164 | 17 | list(REMOVE_ITEM EXTENSIONS | 17 | "cookie-permissions" |
165 | 18 | "cookie-permissions" | 18 | "addons.c" |
166 | 19 | "addons.c" | 19 | "formhistory" |
167 | 20 | "formhistory" | 20 | "external-download-manager.vala" |
168 | 21 | "external-download-manager.vala" | 21 | "nojs" |
169 | 22 | "nojs" | 22 | "nsplugin-manager.vala" |
170 | 23 | "nsplugin-manager.vala" | 23 | "tabs2one.c" |
171 | 24 | "tabs2one.c" | 24 | ) |
161 | 25 | ) | ||
162 | 26 | endif () | ||
172 | 27 | 25 | ||
173 | 28 | # FIXME: re-enable webmedia extension | 26 | # FIXME: re-enable webmedia extension |
174 | 29 | # once we have working notifications on win | 27 | # once we have working notifications on win |
175 | 30 | 28 | ||
176 | === modified file 'extensions/about.vala' | |||
177 | --- extensions/about.vala 2015-06-11 22:33:48 +0000 | |||
178 | +++ extensions/about.vala 2016-09-20 20:57:01 +0000 | |||
179 | @@ -15,11 +15,7 @@ | |||
180 | 15 | public abstract string uri { get; set; } | 15 | public abstract string uri { get; set; } |
181 | 16 | public abstract void get_contents (Midori.View view, string uri); | 16 | public abstract void get_contents (Midori.View view, string uri); |
182 | 17 | protected void load_html (Midori.View view, string content, string uri) { | 17 | protected void load_html (Midori.View view, string content, string uri) { |
183 | 18 | #if HAVE_WEBKIT2 | ||
184 | 19 | view.web_view.load_html (content, uri); | 18 | view.web_view.load_html (content, uri); |
185 | 20 | #else | ||
186 | 21 | view.web_view.load_html_string (content, uri); | ||
187 | 22 | #endif | ||
188 | 23 | } | 19 | } |
189 | 24 | } | 20 | } |
190 | 25 | 21 | ||
191 | 26 | 22 | ||
192 | === modified file 'extensions/adblock/extension.vala' | |||
193 | --- extensions/adblock/extension.vala 2016-02-01 19:48:47 +0000 | |||
194 | +++ extensions/adblock/extension.vala 2016-09-20 20:57:01 +0000 | |||
195 | @@ -55,22 +55,20 @@ | |||
196 | 55 | internal string? js_hider_function_body; | 55 | internal string? js_hider_function_body; |
197 | 56 | #endif | 56 | #endif |
198 | 57 | 57 | ||
215 | 58 | #if HAVE_WEBKIT2 | 58 | public Extension.WebExtension (GLib.Object extension) { |
216 | 59 | #if !HAVE_WEBKIT2_3_91 | 59 | Midori.Paths.init_exec_path ({"/usr/share"}); |
217 | 60 | public Extension.WebExtension (WebKit.WebExtension web_extension) { | 60 | extension.connect ("signal::page-created", page_created, null); |
218 | 61 | init (); | 61 | } |
219 | 62 | web_extension.page_created.connect (page_created); | 62 | |
220 | 63 | } | 63 | void page_created (GLib.Object page) { |
221 | 64 | 64 | page.connect ("signal::send-request", send_request, page); | |
222 | 65 | void page_created (WebKit.WebPage web_page) { | 65 | } |
223 | 66 | web_page.send_request.connect (send_request); | 66 | |
224 | 67 | } | 67 | bool send_request (WebKit.URIRequest request, WebKit.URIResponse? redirected_response, GLib.Object page) { |
225 | 68 | 68 | string uri; | |
226 | 69 | bool send_request (WebKit.WebPage web_page, WebKit.URIRequest request, WebKit.URIResponse? redirected_response) { | 69 | page.get ("uri", out uri); |
227 | 70 | return request_handled (request.uri, web_page.uri); | 70 | return request_handled (request.uri, uri); |
228 | 71 | } | 71 | } |
213 | 72 | #endif | ||
214 | 73 | #endif | ||
229 | 74 | 72 | ||
230 | 75 | public Extension () { | 73 | public Extension () { |
231 | 76 | GLib.Object (name: _("Advertisement blocker"), | 74 | GLib.Object (name: _("Advertisement blocker"), |
232 | @@ -87,7 +85,6 @@ | |||
233 | 87 | } | 85 | } |
234 | 88 | 86 | ||
235 | 89 | void extension_activated (Midori.App app) { | 87 | void extension_activated (Midori.App app) { |
236 | 90 | #if HAVE_WEBKIT2 | ||
237 | 91 | string cache_dir = Environment.get_user_cache_dir (); | 88 | string cache_dir = Environment.get_user_cache_dir (); |
238 | 92 | string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext"); | 89 | string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext"); |
239 | 93 | Midori.Paths.mkdir_with_parents (wk2path); | 90 | Midori.Paths.mkdir_with_parents (wk2path); |
240 | @@ -101,7 +98,6 @@ | |||
241 | 101 | } catch (Error error) { | 98 | } catch (Error error) { |
242 | 102 | critical ("Failed to create WebKit2 link: %s", error.message); | 99 | critical ("Failed to create WebKit2 link: %s", error.message); |
243 | 103 | } | 100 | } |
244 | 104 | #endif | ||
245 | 105 | init (); | 101 | init (); |
246 | 106 | foreach (var browser in app.get_browsers ()) | 102 | foreach (var browser in app.get_browsers ()) |
247 | 107 | browser_added (browser); | 103 | browser_added (browser); |
248 | @@ -136,17 +132,11 @@ | |||
249 | 136 | 132 | ||
250 | 137 | void tab_added (Midori.View view) { | 133 | void tab_added (Midori.View view) { |
251 | 138 | view.navigation_requested.connect (navigation_requested); | 134 | view.navigation_requested.connect (navigation_requested); |
252 | 139 | #if !HAVE_WEBKIT2 | ||
253 | 140 | view.web_view.resource_request_starting.connect (resource_requested); | ||
254 | 141 | #endif | ||
255 | 142 | view.notify["load-status"].connect (load_status_changed); | 135 | view.notify["load-status"].connect (load_status_changed); |
256 | 143 | view.context_menu.connect (context_menu); | 136 | view.context_menu.connect (context_menu); |
257 | 144 | } | 137 | } |
258 | 145 | 138 | ||
259 | 146 | void tab_removed (Midori.View view) { | 139 | void tab_removed (Midori.View view) { |
260 | 147 | #if !HAVE_WEBKIT2 | ||
261 | 148 | view.web_view.resource_request_starting.disconnect (resource_requested); | ||
262 | 149 | #endif | ||
263 | 150 | view.navigation_requested.disconnect (navigation_requested); | 140 | view.navigation_requested.disconnect (navigation_requested); |
264 | 151 | view.notify["load-status"].disconnect (load_status_changed); | 141 | view.notify["load-status"].disconnect (load_status_changed); |
265 | 152 | view.context_menu.disconnect (context_menu); | 142 | view.context_menu.disconnect (context_menu); |
266 | @@ -179,23 +169,6 @@ | |||
267 | 179 | menu.add (action); | 169 | menu.add (action); |
268 | 180 | } | 170 | } |
269 | 181 | 171 | ||
270 | 182 | #if !HAVE_WEBKIT2 | ||
271 | 183 | void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame, | ||
272 | 184 | WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) { | ||
273 | 185 | |||
274 | 186 | WebKit.WebFrame main_frame = web_view.get_main_frame (); | ||
275 | 187 | |||
276 | 188 | WebKit.WebDataSource? ds = main_frame.get_provisional_data_source (); | ||
277 | 189 | WebKit.NetworkRequest? main_frame_request = (ds != null) ? ds.get_request () : null; | ||
278 | 190 | string? main_frame_uri = (main_frame_request != null) ? main_frame_request.uri : null; | ||
279 | 191 | |||
280 | 192 | bool is_main_frame_request = (frame == main_frame) && (request.uri == main_frame_uri); | ||
281 | 193 | if (!is_main_frame_request && request_handled (request.uri, web_view.uri)) { | ||
282 | 194 | request.set_uri ("about:blank"); | ||
283 | 195 | } | ||
284 | 196 | } | ||
285 | 197 | #endif | ||
286 | 198 | |||
287 | 199 | bool navigation_requested (Midori.Tab tab, string uri) { | 172 | bool navigation_requested (Midori.Tab tab, string uri) { |
288 | 200 | if (uri.has_prefix ("abp:")) { | 173 | if (uri.has_prefix ("abp:")) { |
289 | 201 | string parsed_uri = parse_subscription_uri (uri); | 174 | string parsed_uri = parse_subscription_uri (uri); |
290 | @@ -346,7 +319,7 @@ | |||
291 | 346 | 319 | ||
292 | 347 | internal void init () { | 320 | internal void init () { |
293 | 348 | hider_selectors = new StringBuilder (); | 321 | hider_selectors = new StringBuilder (); |
295 | 349 | load_config (); | 322 | config = load_config (); |
296 | 350 | manager = new SubscriptionManager (config); | 323 | manager = new SubscriptionManager (config); |
297 | 351 | status_icon = new StatusIcon (config, manager); | 324 | status_icon = new StatusIcon (config, manager); |
298 | 352 | foreach (unowned Subscription sub in config) { | 325 | foreach (unowned Subscription sub in config) { |
299 | @@ -374,29 +347,26 @@ | |||
300 | 374 | hider_selectors = new StringBuilder (); | 347 | hider_selectors = new StringBuilder (); |
301 | 375 | } | 348 | } |
302 | 376 | 349 | ||
305 | 377 | void load_config () { | 350 | static Config load_config () { |
304 | 378 | #if HAVE_WEBKIT2 | ||
306 | 379 | string config_dir = Path.build_filename (GLib.Environment.get_user_config_dir (), PACKAGE_NAME, "extensions", "libadblock." + GLib.Module.SUFFIX); | 351 | string config_dir = Path.build_filename (GLib.Environment.get_user_config_dir (), PACKAGE_NAME, "extensions", "libadblock." + GLib.Module.SUFFIX); |
307 | 380 | Midori.Paths.mkdir_with_parents (config_dir); | 352 | Midori.Paths.mkdir_with_parents (config_dir); |
308 | 381 | #else | ||
309 | 382 | string config_dir = Midori.Paths.get_extension_config_dir ("adblock"); | ||
310 | 383 | #endif | ||
311 | 384 | string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config"); | 353 | string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config"); |
312 | 385 | string filename = Path.build_filename (config_dir, "config"); | 354 | string filename = Path.build_filename (config_dir, "config"); |
314 | 386 | config = new Config (filename, presets); | 355 | var config = new Config (filename, presets); |
315 | 387 | string custom_list = GLib.Path.build_filename (config_dir, "custom.list"); | 356 | string custom_list = GLib.Path.build_filename (config_dir, "custom.list"); |
316 | 388 | try { | 357 | try { |
318 | 389 | custom = new Subscription (Filename.to_uri (custom_list, null)); | 358 | var custom = new Subscription (Filename.to_uri (custom_list, null)); |
319 | 390 | custom.mutable = false; | 359 | custom.mutable = false; |
320 | 391 | custom.title = _("Custom"); | 360 | custom.title = _("Custom"); |
321 | 392 | config.add (custom); | 361 | config.add (custom); |
322 | 393 | } catch (Error error) { | 362 | } catch (Error error) { |
323 | 394 | custom = null; | ||
324 | 395 | warning ("Failed to add custom list %s: %s", custom_list, error.message); | 363 | warning ("Failed to add custom list %s: %s", custom_list, error.message); |
325 | 396 | } | 364 | } |
326 | 365 | return config; | ||
327 | 397 | } | 366 | } |
328 | 398 | 367 | ||
330 | 399 | public Adblock.Directive get_directive_for_uri (string request_uri, string page_uri) { | 368 | static Adblock.Directive get_directive_for_uri (string request_uri, string page_uri) { |
331 | 369 | var config = load_config (); | ||
332 | 400 | if (!config.enabled) | 370 | if (!config.enabled) |
333 | 401 | return Directive.ALLOW; | 371 | return Directive.ALLOW; |
334 | 402 | 372 | ||
335 | @@ -422,11 +392,11 @@ | |||
336 | 422 | if (directive == null) | 392 | if (directive == null) |
337 | 423 | directive = Directive.ALLOW; | 393 | directive = Directive.ALLOW; |
338 | 424 | else if (directive == Directive.BLOCK) { | 394 | else if (directive == Directive.BLOCK) { |
340 | 425 | status_icon.set_state (State.BLOCKED); | 395 | // FIXME: status_icon.set_state (State.BLOCKED); |
341 | 426 | #if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES | 396 | #if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES |
343 | 427 | hider_selectors.append ("img[src*=\"%s\"] , iframe[src*=\"%s\"] , ".printf (request_uri, request_uri)); | 397 | // FIXME: hider_selectors.append ("img[src*=\"%s\"] , iframe[src*=\"%s\"] , ".printf (request_uri, request_uri)); |
344 | 428 | #else | 398 | #else |
346 | 429 | hider_selectors.append (" uris.push ('%s');\n".printf (request_uri)); | 399 | // FIXME: hider_selectors.append (" uris.push ('%s');\n".printf (request_uri)); |
347 | 430 | #endif | 400 | #endif |
348 | 431 | } | 401 | } |
349 | 432 | return directive; | 402 | return directive; |
350 | @@ -482,14 +452,10 @@ | |||
351 | 482 | } | 452 | } |
352 | 483 | } | 453 | } |
353 | 484 | 454 | ||
354 | 485 | #if HAVE_WEBKIT2 | ||
355 | 486 | #if !HAVE_WEBKIT2_3_91 | ||
356 | 487 | Adblock.Extension? filter; | 455 | Adblock.Extension? filter; |
359 | 488 | public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension) { | 456 | public static void webkit_web_extension_initialize (GLib.Object extension) { |
360 | 489 | filter = new Adblock.Extension.WebExtension (web_extension); | 457 | filter = new Adblock.Extension.WebExtension (extension); |
361 | 490 | } | 458 | } |
362 | 491 | #endif | ||
363 | 492 | #endif | ||
364 | 493 | 459 | ||
365 | 494 | public Midori.Extension extension_init () { | 460 | public Midori.Extension extension_init () { |
366 | 495 | return new Adblock.Extension (); | 461 | return new Adblock.Extension (); |
367 | 496 | 462 | ||
368 | === modified file 'extensions/adblock/subscriptions.vala' | |||
369 | --- extensions/adblock/subscriptions.vala 2015-06-12 21:43:40 +0000 | |||
370 | +++ extensions/adblock/subscriptions.vala 2016-09-20 20:57:01 +0000 | |||
371 | @@ -40,9 +40,6 @@ | |||
372 | 40 | public Options optslist; | 40 | public Options optslist; |
373 | 41 | public Whitelist whitelist; | 41 | public Whitelist whitelist; |
374 | 42 | public Element element; | 42 | public Element element; |
375 | 43 | #if !HAVE_WEBKIT2 | ||
376 | 44 | WebKit.Download? download; | ||
377 | 45 | #endif | ||
378 | 46 | 43 | ||
379 | 47 | public Subscription (string uri) { | 44 | public Subscription (string uri) { |
380 | 48 | debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""); | 45 | debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""); |
381 | @@ -292,20 +289,6 @@ | |||
382 | 292 | } | 289 | } |
383 | 293 | } | 290 | } |
384 | 294 | 291 | ||
385 | 295 | #if !HAVE_WEBKIT2 | ||
386 | 296 | void download_status (ParamSpec pspec) { | ||
387 | 297 | if (download.get_status () != WebKit.DownloadStatus.FINISHED) | ||
388 | 298 | return; | ||
389 | 299 | |||
390 | 300 | download = null; | ||
391 | 301 | try { | ||
392 | 302 | parse (); | ||
393 | 303 | } catch (Error error) { | ||
394 | 304 | warning ("Error parsing %s: %s", uri, error.message); | ||
395 | 305 | } | ||
396 | 306 | } | ||
397 | 307 | #endif | ||
398 | 308 | |||
399 | 309 | public void parse () throws Error | 292 | public void parse () throws Error |
400 | 310 | { | 293 | { |
401 | 311 | if (!active) | 294 | if (!active) |
402 | @@ -329,24 +312,7 @@ | |||
403 | 329 | try { | 312 | try { |
404 | 330 | stream = new DataInputStream (filter_file.read ()); | 313 | stream = new DataInputStream (filter_file.read ()); |
405 | 331 | } catch (IOError.NOT_FOUND exist_error) { | 314 | } catch (IOError.NOT_FOUND exist_error) { |
406 | 332 | #if HAVE_WEBKIT2 | ||
407 | 333 | /* TODO */ | 315 | /* TODO */ |
408 | 334 | #else | ||
409 | 335 | /* Don't bother trying to download local files */ | ||
410 | 336 | if (!uri.has_prefix ("file://")) { | ||
411 | 337 | if (download != null) | ||
412 | 338 | return; | ||
413 | 339 | |||
414 | 340 | string destination_uri = Filename.to_uri (path, null); | ||
415 | 341 | debug ("Fetching %s to %s now", uri, destination_uri); | ||
416 | 342 | download = new WebKit.Download (new WebKit.NetworkRequest (uri)); | ||
417 | 343 | if (!Midori.Download.has_enough_space (download, destination_uri, true)) | ||
418 | 344 | throw new FileError.EXIST ("Can't download to \"%s\"", path); | ||
419 | 345 | download.destination_uri = destination_uri; | ||
420 | 346 | download.notify["status"].connect (download_status); | ||
421 | 347 | download.start (); | ||
422 | 348 | } | ||
423 | 349 | #endif | ||
424 | 350 | return; | 316 | return; |
425 | 351 | } | 317 | } |
426 | 352 | 318 | ||
427 | 353 | 319 | ||
428 | === modified file 'extensions/addons.c' | |||
429 | --- extensions/addons.c 2015-04-15 22:51:01 +0000 | |||
430 | +++ extensions/addons.c 2016-09-20 20:57:01 +0000 | |||
431 | @@ -1599,7 +1599,7 @@ | |||
432 | 1599 | MidoriApp* app = midori_extension_get_app (extension); | 1599 | MidoriApp* app = midori_extension_get_app (extension); |
433 | 1600 | MidoriWebSettings* settings = katze_object_get_object (app, "settings"); | 1600 | MidoriWebSettings* settings = katze_object_get_object (app, "settings"); |
434 | 1601 | gchar* data = addons_generate_global_stylesheet (extension); | 1601 | gchar* data = addons_generate_global_stylesheet (extension); |
436 | 1602 | midori_web_settings_add_style (settings, "addons", data); | 1602 | midori_settings_add_style (MIDORI_SETTINGS (settings), "addons", data); |
437 | 1603 | g_free (data); | 1603 | g_free (data); |
438 | 1604 | g_object_unref (settings); | 1604 | g_object_unref (settings); |
439 | 1605 | } | 1605 | } |
440 | @@ -1738,7 +1738,7 @@ | |||
441 | 1738 | 1738 | ||
442 | 1739 | addons_disable_monitors (extension); | 1739 | addons_disable_monitors (extension); |
443 | 1740 | addons_save_settings (NULL, extension); | 1740 | addons_save_settings (NULL, extension); |
445 | 1741 | midori_web_settings_remove_style (settings, "addons"); | 1741 | midori_settings_remove_style (MIDORI_SETTINGS (settings), "addons"); |
446 | 1742 | 1742 | ||
447 | 1743 | browsers = katze_object_get_object (app, "browsers"); | 1743 | browsers = katze_object_get_object (app, "browsers"); |
448 | 1744 | KATZE_ARRAY_FOREACH_ITEM (browser, browsers) | 1744 | KATZE_ARRAY_FOREACH_ITEM (browser, browsers) |
449 | @@ -1860,7 +1860,7 @@ | |||
450 | 1860 | addons_update_elements (extension, ADDONS_USER_SCRIPTS); | 1860 | addons_update_elements (extension, ADDONS_USER_SCRIPTS); |
451 | 1861 | addons_monitor_directories (extension, ADDONS_USER_SCRIPTS); | 1861 | addons_monitor_directories (extension, ADDONS_USER_SCRIPTS); |
452 | 1862 | data = addons_generate_global_stylesheet (extension); | 1862 | data = addons_generate_global_stylesheet (extension); |
454 | 1863 | midori_web_settings_add_style (settings, "addons", data); | 1863 | midori_settings_add_style (MIDORI_SETTINGS (settings), "addons", data); |
455 | 1864 | 1864 | ||
456 | 1865 | KATZE_ARRAY_FOREACH_ITEM (browser, browsers) | 1865 | KATZE_ARRAY_FOREACH_ITEM (browser, browsers) |
457 | 1866 | addons_app_add_browser_cb (app, browser, extension); | 1866 | addons_app_add_browser_cb (app, browser, extension); |
458 | 1867 | 1867 | ||
459 | === modified file 'extensions/colorful-tabs.c' | |||
460 | --- extensions/colorful-tabs.c 2016-02-24 21:45:09 +0000 | |||
461 | +++ extensions/colorful-tabs.c 2016-09-20 20:57:01 +0000 | |||
462 | @@ -244,11 +244,6 @@ | |||
463 | 244 | void | 244 | void |
464 | 245 | extension_test (void) | 245 | extension_test (void) |
465 | 246 | { | 246 | { |
466 | 247 | #ifndef HAVE_WEBKIT2 | ||
467 | 248 | g_object_set_data (G_OBJECT (webkit_get_default_session ()), | ||
468 | 249 | "midori-session-initialized", (void*)1); | ||
469 | 250 | #endif | ||
470 | 251 | |||
471 | 252 | /* TODO: Add test which uses favicon codepath */ | 247 | /* TODO: Add test which uses favicon codepath */ |
472 | 253 | 248 | ||
473 | 254 | g_test_add_func ("/extensions/colorful_tabs/hostname_colour", test_colour_for_hostname); | 249 | g_test_add_func ("/extensions/colorful_tabs/hostname_colour", test_colour_for_hostname); |
474 | 255 | 250 | ||
475 | === modified file 'extensions/cookie-manager/cookie-manager.c' | |||
476 | --- extensions/cookie-manager/cookie-manager.c 2013-07-29 21:05:02 +0000 | |||
477 | +++ extensions/cookie-manager/cookie-manager.c 2016-09-20 20:57:01 +0000 | |||
478 | @@ -12,7 +12,7 @@ | |||
479 | 12 | #include "config.h" | 12 | #include "config.h" |
480 | 13 | #include <midori/midori.h> | 13 | #include <midori/midori.h> |
481 | 14 | #include "katze/katze.h" | 14 | #include "katze/katze.h" |
483 | 15 | #include <libsoup/soup-cookie-jar-sqlite.h> | 15 | #include <libsoup/soup-cookie-jar-db.h> |
484 | 16 | 16 | ||
485 | 17 | #include "cookie-manager.h" | 17 | #include "cookie-manager.h" |
486 | 18 | #include "cookie-manager-page.h" | 18 | #include "cookie-manager-page.h" |
487 | @@ -280,15 +280,9 @@ | |||
488 | 280 | COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING); | 280 | COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING); |
489 | 281 | 281 | ||
490 | 282 | /* setup soup */ | 282 | /* setup soup */ |
491 | 283 | #ifdef HAVE_WEBKIT2 | ||
492 | 284 | gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db"); | 283 | gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db"); |
494 | 285 | priv->jar = soup_cookie_jar_sqlite_new (filename, FALSE); | 284 | priv->jar = soup_cookie_jar_db_new (filename, FALSE); |
495 | 286 | g_free(filename); | 285 | g_free(filename); |
496 | 287 | #else | ||
497 | 288 | SoupSession *session = webkit_get_default_session(); | ||
498 | 289 | priv->jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, soup_cookie_jar_get_type())); | ||
499 | 290 | g_object_ref(priv->jar); | ||
500 | 291 | #endif | ||
501 | 292 | g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self); | 286 | g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self); |
502 | 293 | 287 | ||
503 | 294 | cookie_manager_refresh_store(self); | 288 | cookie_manager_refresh_store(self); |
504 | 295 | 289 | ||
505 | === modified file 'extensions/external-download-manager.vala' | |||
506 | --- extensions/external-download-manager.vala 2015-08-20 06:18:50 +0000 | |||
507 | +++ extensions/external-download-manager.vala 2016-09-20 20:57:01 +0000 | |||
508 | @@ -36,16 +36,8 @@ | |||
509 | 36 | if (download_type == Midori.DownloadType.SAVE) { | 36 | if (download_type == Midori.DownloadType.SAVE) { |
510 | 37 | var dlReq = new DownloadRequest (); | 37 | var dlReq = new DownloadRequest (); |
511 | 38 | 38 | ||
512 | 39 | #if HAVE_WEBKIT2 | ||
513 | 40 | dlReq.uri = download.request.get_uri (); | 39 | dlReq.uri = download.request.get_uri (); |
514 | 41 | weak Soup.MessageHeaders headers = download.request.get_http_headers (); | 40 | weak Soup.MessageHeaders headers = download.request.get_http_headers (); |
515 | 42 | #else | ||
516 | 43 | dlReq.uri = download.get_uri (); | ||
517 | 44 | var request = download.get_network_request (); | ||
518 | 45 | var message = request.get_message (); | ||
519 | 46 | weak Soup.MessageHeaders headers = message.request_headers; | ||
520 | 47 | #endif | ||
521 | 48 | |||
522 | 49 | dlReq.auth = headers.get ("Authorization"); | 41 | dlReq.auth = headers.get ("Authorization"); |
523 | 50 | dlReq.referer = headers.get ("Referer"); | 42 | dlReq.referer = headers.get ("Referer"); |
524 | 51 | dlReq.cookie_header = this.cookie_jar.get_cookies (new Soup.URI (dlReq.uri), true); | 43 | dlReq.cookie_header = this.cookie_jar.get_cookies (new Soup.URI (dlReq.uri), true); |
525 | @@ -101,11 +93,7 @@ | |||
526 | 101 | } | 93 | } |
527 | 102 | 94 | ||
528 | 103 | construct { | 95 | construct { |
529 | 104 | #if HAVE_WEBKIT2 | ||
530 | 105 | var session= new Session (); | 96 | var session= new Session (); |
531 | 106 | #else | ||
532 | 107 | var session = WebKit.get_default_session (); | ||
533 | 108 | #endif | ||
534 | 109 | this.cookie_jar = session.get_feature (typeof (Soup.CookieJar)) as Soup.CookieJar; | 97 | this.cookie_jar = session.get_feature (typeof (Soup.CookieJar)) as Soup.CookieJar; |
535 | 110 | } | 98 | } |
536 | 111 | } | 99 | } |
537 | 112 | 100 | ||
538 | === modified file 'extensions/feed-panel/feed-panel.c' | |||
539 | --- extensions/feed-panel/feed-panel.c 2013-10-25 21:49:56 +0000 | |||
540 | +++ extensions/feed-panel/feed-panel.c 2016-09-20 20:57:01 +0000 | |||
541 | @@ -589,31 +589,6 @@ | |||
542 | 589 | return MIDORI_EVENT_CONTEXT_MENU (event); | 589 | return MIDORI_EVENT_CONTEXT_MENU (event); |
543 | 590 | } | 590 | } |
544 | 591 | 591 | ||
545 | 592 | #ifndef HAVE_WEBKIT2 | ||
546 | 593 | static gboolean | ||
547 | 594 | webview_navigation_request_cb (WebKitWebView* web_view, | ||
548 | 595 | WebKitWebFrame* frame, | ||
549 | 596 | WebKitNetworkRequest* request, | ||
550 | 597 | WebKitWebNavigationAction* navigation_action, | ||
551 | 598 | WebKitWebPolicyDecision* policy_decision, | ||
552 | 599 | FeedPanel* panel) | ||
553 | 600 | { | ||
554 | 601 | if (webkit_web_navigation_action_get_reason (navigation_action) == | ||
555 | 602 | WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) | ||
556 | 603 | { | ||
557 | 604 | MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel)); | ||
558 | 605 | const gchar* uri = webkit_network_request_get_uri (request); | ||
559 | 606 | GtkWidget* view = midori_browser_add_uri (browser, uri); | ||
560 | 607 | midori_browser_set_current_tab (browser, view); | ||
561 | 608 | webkit_web_policy_decision_ignore (policy_decision); | ||
562 | 609 | |||
563 | 610 | return TRUE; | ||
564 | 611 | } | ||
565 | 612 | |||
566 | 613 | return FALSE; | ||
567 | 614 | } | ||
568 | 615 | #endif | ||
569 | 616 | |||
570 | 617 | static const gchar* | 592 | static const gchar* |
571 | 618 | feed_panel_get_label (MidoriViewable* viewable) | 593 | feed_panel_get_label (MidoriViewable* viewable) |
572 | 619 | { | 594 | { |
573 | @@ -800,12 +775,8 @@ | |||
574 | 800 | NULL); | 775 | NULL); |
575 | 801 | gtk_widget_show (treeview); | 776 | gtk_widget_show (treeview); |
576 | 802 | 777 | ||
577 | 803 | #if GTK_CHECK_VERSION(3,0,0) | ||
578 | 804 | font_desc = (PangoFontDescription*)gtk_style_context_get_font ( | 778 | font_desc = (PangoFontDescription*)gtk_style_context_get_font ( |
579 | 805 | gtk_widget_get_style_context (treeview), GTK_STATE_FLAG_NORMAL); | 779 | gtk_widget_get_style_context (treeview), GTK_STATE_FLAG_NORMAL); |
580 | 806 | #else | ||
581 | 807 | font_desc = treeview->style->font_desc; | ||
582 | 808 | #endif | ||
583 | 809 | family = pango_font_description_get_family (font_desc); | 780 | family = pango_font_description_get_family (font_desc); |
584 | 810 | size = pango_font_description_get_size (font_desc) / PANGO_SCALE; | 781 | size = pango_font_description_get_size (font_desc) / PANGO_SCALE; |
585 | 811 | settings = midori_web_settings_new (); | 782 | settings = midori_web_settings_new (); |
586 | @@ -814,10 +785,6 @@ | |||
587 | 814 | webview = midori_view_new_with_item (NULL, settings); | 785 | webview = midori_view_new_with_item (NULL, settings); |
588 | 815 | gtk_widget_set_size_request (webview, -1, 50); | 786 | gtk_widget_set_size_request (webview, -1, 50); |
589 | 816 | g_object_connect (midori_tab_get_web_view (MIDORI_TAB (webview)), | 787 | g_object_connect (midori_tab_get_web_view (MIDORI_TAB (webview)), |
590 | 817 | #ifndef HAVE_WEBKIT2 | ||
591 | 818 | "signal::navigation-policy-decision-requested", | ||
592 | 819 | webview_navigation_request_cb, panel, | ||
593 | 820 | #endif | ||
594 | 821 | "signal::button-press-event", | 788 | "signal::button-press-event", |
595 | 822 | webview_button_press_event_cb, NULL, | 789 | webview_button_press_event_cb, NULL, |
596 | 823 | "signal::button-release-event", | 790 | "signal::button-release-event", |
597 | 824 | 791 | ||
598 | === modified file 'extensions/feed-panel/katze-net.c' | |||
599 | --- extensions/feed-panel/katze-net.c 2013-08-02 17:42:29 +0000 | |||
600 | +++ extensions/feed-panel/katze-net.c 2016-09-20 20:57:01 +0000 | |||
601 | @@ -66,85 +66,6 @@ | |||
602 | 66 | KatzeNetRequest* request; | 66 | KatzeNetRequest* request; |
603 | 67 | } KatzeNetPriv; | 67 | } KatzeNetPriv; |
604 | 68 | 68 | ||
605 | 69 | #ifndef HAVE_WEBKIT2 | ||
606 | 70 | static void | ||
607 | 71 | katze_net_priv_free (KatzeNetPriv* priv) | ||
608 | 72 | { | ||
609 | 73 | KatzeNetRequest* request = priv->request; | ||
610 | 74 | g_free (request->uri); | ||
611 | 75 | g_free (request->mime_type); | ||
612 | 76 | g_free (request->data); | ||
613 | 77 | g_slice_free (KatzeNetRequest, request); | ||
614 | 78 | g_slice_free (KatzeNetPriv, priv); | ||
615 | 79 | } | ||
616 | 80 | |||
617 | 81 | static void | ||
618 | 82 | katze_net_got_body_cb (SoupMessage* msg, | ||
619 | 83 | KatzeNetPriv* priv); | ||
620 | 84 | |||
621 | 85 | static void | ||
622 | 86 | katze_net_got_headers_cb (SoupMessage* msg, | ||
623 | 87 | KatzeNetPriv* priv) | ||
624 | 88 | { | ||
625 | 89 | KatzeNetRequest* request = priv->request; | ||
626 | 90 | |||
627 | 91 | switch (msg->status_code) | ||
628 | 92 | { | ||
629 | 93 | case 200: | ||
630 | 94 | request->status = KATZE_NET_VERIFIED; | ||
631 | 95 | break; | ||
632 | 96 | case 301: | ||
633 | 97 | request->status = KATZE_NET_MOVED; | ||
634 | 98 | break; | ||
635 | 99 | default: | ||
636 | 100 | request->status = KATZE_NET_NOT_FOUND; | ||
637 | 101 | } | ||
638 | 102 | |||
639 | 103 | if (!priv->status_cb (request, priv->user_data)) | ||
640 | 104 | { | ||
641 | 105 | g_signal_handlers_disconnect_by_func (msg, katze_net_got_headers_cb, priv); | ||
642 | 106 | g_signal_handlers_disconnect_by_func (msg, katze_net_got_body_cb, priv); | ||
643 | 107 | soup_session_cancel_message (webkit_get_default_session (), msg, 1); | ||
644 | 108 | } | ||
645 | 109 | } | ||
646 | 110 | |||
647 | 111 | static void | ||
648 | 112 | katze_net_got_body_cb (SoupMessage* msg, | ||
649 | 113 | KatzeNetPriv* priv) | ||
650 | 114 | { | ||
651 | 115 | KatzeNetRequest* request = priv->request; | ||
652 | 116 | |||
653 | 117 | if (msg->response_body->length > 0) | ||
654 | 118 | { | ||
655 | 119 | request->data = g_memdup (msg->response_body->data, | ||
656 | 120 | msg->response_body->length); | ||
657 | 121 | request->length = msg->response_body->length; | ||
658 | 122 | } | ||
659 | 123 | |||
660 | 124 | priv->transfer_cb (request, priv->user_data); | ||
661 | 125 | } | ||
662 | 126 | |||
663 | 127 | static void | ||
664 | 128 | katze_net_finished_cb (SoupMessage* msg, | ||
665 | 129 | KatzeNetPriv* priv) | ||
666 | 130 | { | ||
667 | 131 | katze_net_priv_free (priv); | ||
668 | 132 | } | ||
669 | 133 | |||
670 | 134 | static gboolean | ||
671 | 135 | katze_net_default_cb (KatzeNetPriv* priv) | ||
672 | 136 | { | ||
673 | 137 | KatzeNetRequest* request; | ||
674 | 138 | |||
675 | 139 | request = priv->request; | ||
676 | 140 | request->status = KATZE_NET_NOT_FOUND; | ||
677 | 141 | if (priv->status_cb) | ||
678 | 142 | priv->status_cb (request, priv->user_data); | ||
679 | 143 | katze_net_priv_free (priv); | ||
680 | 144 | return FALSE; | ||
681 | 145 | } | ||
682 | 146 | #endif | ||
683 | 147 | |||
684 | 148 | /** | 69 | /** |
685 | 149 | * katze_net_load_uri: | 70 | * katze_net_load_uri: |
686 | 150 | * @net: a #KatzeNet, or %NULL | 71 | * @net: a #KatzeNet, or %NULL |
687 | @@ -172,43 +93,5 @@ | |||
688 | 172 | KatzeNetTransferCb transfer_cb, | 93 | KatzeNetTransferCb transfer_cb, |
689 | 173 | gpointer user_data) | 94 | gpointer user_data) |
690 | 174 | { | 95 | { |
691 | 175 | #ifndef HAVE_WEBKIT2 | ||
692 | 176 | KatzeNetRequest* request; | ||
693 | 177 | KatzeNetPriv* priv; | ||
694 | 178 | SoupMessage* msg; | ||
695 | 179 | |||
696 | 180 | g_return_if_fail (uri != NULL); | ||
697 | 181 | |||
698 | 182 | if (!status_cb && !transfer_cb) | ||
699 | 183 | return; | ||
700 | 184 | |||
701 | 185 | request = g_slice_new (KatzeNetRequest); | ||
702 | 186 | request->uri = g_strdup (uri); | ||
703 | 187 | request->mime_type = NULL; | ||
704 | 188 | request->data = NULL; | ||
705 | 189 | |||
706 | 190 | priv = g_slice_new (KatzeNetPriv); | ||
707 | 191 | priv->status_cb = status_cb; | ||
708 | 192 | priv->transfer_cb = transfer_cb; | ||
709 | 193 | priv->user_data = user_data; | ||
710 | 194 | priv->request = request; | ||
711 | 195 | |||
712 | 196 | if (midori_uri_is_http (uri)) | ||
713 | 197 | { | ||
714 | 198 | msg = soup_message_new ("GET", uri); | ||
715 | 199 | if (status_cb) | ||
716 | 200 | g_signal_connect (msg, "got-headers", | ||
717 | 201 | G_CALLBACK (katze_net_got_headers_cb), priv); | ||
718 | 202 | if (transfer_cb) | ||
719 | 203 | g_signal_connect (msg, "got-body", | ||
720 | 204 | G_CALLBACK (katze_net_got_body_cb), priv); | ||
721 | 205 | g_signal_connect (msg, "finished", | ||
722 | 206 | G_CALLBACK (katze_net_finished_cb), priv); | ||
723 | 207 | soup_session_queue_message (webkit_get_default_session (), msg, NULL, NULL); | ||
724 | 208 | return; | ||
725 | 209 | } | ||
726 | 210 | |||
727 | 211 | g_idle_add ((GSourceFunc)katze_net_default_cb, priv); | ||
728 | 212 | #endif | ||
729 | 213 | } | 96 | } |
730 | 214 | 97 | ||
731 | 215 | 98 | ||
732 | === modified file 'extensions/notes.vala' | |||
733 | --- extensions/notes.vala 2015-03-18 21:18:11 +0000 | |||
734 | +++ extensions/notes.vala 2016-09-20 20:57:01 +0000 | |||
735 | @@ -385,11 +385,6 @@ | |||
736 | 385 | } | 385 | } |
737 | 386 | 386 | ||
738 | 387 | void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) { | 387 | void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) { |
739 | 388 | #if !HAVE_WEBKIT2 | ||
740 | 389 | if ((hit_test_result.context & WebKit.HitTestResultContext.SELECTION) == 0) | ||
741 | 390 | return; | ||
742 | 391 | #endif | ||
743 | 392 | |||
744 | 393 | var view = tab as Midori.View; | 388 | var view = tab as Midori.View; |
745 | 394 | var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null); | 389 | var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null); |
746 | 395 | action.activate.connect ((action)=> { | 390 | action.activate.connect ((action)=> { |
747 | 396 | 391 | ||
748 | === modified file 'extensions/open-with.vala' | |||
749 | --- extensions/open-with.vala 2016-02-17 20:26:51 +0000 | |||
750 | +++ extensions/open-with.vala 2016-09-20 20:57:01 +0000 | |||
751 | @@ -663,33 +663,7 @@ | |||
752 | 663 | 663 | ||
753 | 664 | /* Returns %TRUE if the attempt to download and open failed immediately, %FALSE otherwise */ | 664 | /* Returns %TRUE if the attempt to download and open failed immediately, %FALSE otherwise */ |
754 | 665 | bool open_with_type (string uri, string content_type, Gtk.Widget widget, NextStep next_step) { | 665 | bool open_with_type (string uri, string content_type, Gtk.Widget widget, NextStep next_step) { |
755 | 666 | #if HAVE_WEBKIT2 | ||
756 | 667 | return open_now (uri, content_type, widget, next_step); | 666 | return open_now (uri, content_type, widget, next_step); |
757 | 668 | #else | ||
758 | 669 | if (!Midori.URI.is_http (uri)) | ||
759 | 670 | return open_now (uri, content_type, widget, next_step); | ||
760 | 671 | /* Don't download websites */ | ||
761 | 672 | if (content_type == "application/octet-stream") | ||
762 | 673 | return open_now (uri, content_type, widget, next_step); | ||
763 | 674 | |||
764 | 675 | var download = new WebKit.Download (new WebKit.NetworkRequest (uri)); | ||
765 | 676 | download.destination_uri = Midori.Download.prepare_destination_uri (download, null); | ||
766 | 677 | if (!Midori.Download.has_enough_space (download, download.destination_uri)) | ||
767 | 678 | return false; | ||
768 | 679 | |||
769 | 680 | download.notify["status"].connect ((pspec) => { | ||
770 | 681 | if (download.status == WebKit.DownloadStatus.FINISHED) { | ||
771 | 682 | open_now (download.destination_uri, content_type, widget, next_step); | ||
772 | 683 | } | ||
773 | 684 | else if (download.status == WebKit.DownloadStatus.ERROR) | ||
774 | 685 | Midori.show_message_dialog (Gtk.MessageType.ERROR, | ||
775 | 686 | _("Download error"), | ||
776 | 687 | _("Cannot open '%s' because the download failed." | ||
777 | 688 | ).printf (download.destination_uri), false); | ||
778 | 689 | }); | ||
779 | 690 | download.start (); | ||
780 | 691 | return true; | ||
781 | 692 | #endif | ||
782 | 693 | } | 667 | } |
783 | 694 | 668 | ||
784 | 695 | /* If @next_step is %NextStep.TRY_OPEN, tries to pick a handler automatically. | 669 | /* If @next_step is %NextStep.TRY_OPEN, tries to pick a handler automatically. |
785 | @@ -730,7 +704,6 @@ | |||
786 | 730 | }); | 704 | }); |
787 | 731 | menu.add (action); | 705 | menu.add (action); |
788 | 732 | } | 706 | } |
789 | 733 | #if !HAVE_WEBKIT2 | ||
790 | 734 | if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) { | 707 | if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) { |
791 | 735 | string uri = hit_test_result.image_uri; | 708 | string uri = hit_test_result.image_uri; |
792 | 736 | var action = new Gtk.Action ("OpenImageInViewer", _("Open in Image _Viewer"), null, null); | 709 | var action = new Gtk.Action ("OpenImageInViewer", _("Open in Image _Viewer"), null, null); |
793 | @@ -739,7 +712,6 @@ | |||
794 | 739 | }); | 712 | }); |
795 | 740 | menu.add (action); | 713 | menu.add (action); |
796 | 741 | } | 714 | } |
797 | 742 | #endif | ||
798 | 743 | } | 715 | } |
799 | 744 | 716 | ||
800 | 745 | void show_preferences (Katze.Preferences preferences) { | 717 | void show_preferences (Katze.Preferences preferences) { |
801 | 746 | 718 | ||
802 | === modified file 'extensions/transfers.vala' | |||
803 | --- extensions/transfers.vala 2016-04-02 08:15:11 +0000 | |||
804 | +++ extensions/transfers.vala 2016-09-20 20:57:01 +0000 | |||
805 | @@ -36,23 +36,11 @@ | |||
806 | 36 | internal double progress { get { | 36 | internal double progress { get { |
807 | 37 | return Midori.Download.get_progress (download); | 37 | return Midori.Download.get_progress (download); |
808 | 38 | } } | 38 | } } |
809 | 39 | #if HAVE_WEBKIT2 | ||
810 | 40 | public bool succeeded { get; protected set; default = false; } | 39 | public bool succeeded { get; protected set; default = false; } |
811 | 41 | public bool finished { get; protected set; default = false; } | 40 | public bool finished { get; protected set; default = false; } |
812 | 42 | internal string destination { get { | 41 | internal string destination { get { |
813 | 43 | return download.destination; | 42 | return download.destination; |
814 | 44 | } } | 43 | } } |
815 | 45 | #else | ||
816 | 46 | internal bool succeeded { get { | ||
817 | 47 | return download.status == WebKit.DownloadStatus.FINISHED; | ||
818 | 48 | } } | ||
819 | 49 | internal bool finished { get { | ||
820 | 50 | return Midori.Download.is_finished (download); | ||
821 | 51 | } } | ||
822 | 52 | internal string destination { get { | ||
823 | 53 | return download.destination_uri; | ||
824 | 54 | } } | ||
825 | 55 | #endif | ||
826 | 56 | 44 | ||
827 | 57 | internal Transfer (WebKit.Download download) { | 45 | internal Transfer (WebKit.Download download) { |
828 | 58 | poll_source = Timeout.add(1000/10, () => { | 46 | poll_source = Timeout.add(1000/10, () => { |
829 | @@ -60,7 +48,6 @@ | |||
830 | 60 | return true; | 48 | return true; |
831 | 61 | }); | 49 | }); |
832 | 62 | this.download = download; | 50 | this.download = download; |
833 | 63 | #if HAVE_WEBKIT2 | ||
834 | 64 | download.finished.connect (() => { | 51 | download.finished.connect (() => { |
835 | 65 | succeeded = finished = true; | 52 | succeeded = finished = true; |
836 | 66 | changed (); | 53 | changed (); |
837 | @@ -74,15 +61,6 @@ | |||
838 | 74 | Source.remove (poll_source); | 61 | Source.remove (poll_source); |
839 | 75 | poll_source = 0; | 62 | poll_source = 0; |
840 | 76 | }); | 63 | }); |
841 | 77 | #else | ||
842 | 78 | download.notify["status"].connect (() => { | ||
843 | 79 | changed (); | ||
844 | 80 | if (download.status == WebKit.DownloadStatus.FINISHED || download.status == WebKit.DownloadStatus.ERROR) { | ||
845 | 81 | Source.remove (poll_source); | ||
846 | 82 | poll_source = 0; | ||
847 | 83 | } | ||
848 | 84 | }); | ||
849 | 85 | #endif | ||
850 | 86 | } | 64 | } |
851 | 87 | } | 65 | } |
852 | 88 | 66 | ||
853 | 89 | 67 | ||
854 | === modified file 'katze/katze-item.c' | |||
855 | --- katze/katze-item.c 2015-08-10 02:44:13 +0000 | |||
856 | +++ katze/katze-item.c 2016-09-20 20:57:01 +0000 | |||
857 | @@ -459,34 +459,11 @@ | |||
858 | 459 | static void | 459 | static void |
859 | 460 | katze_item_image_destroyed_cb (GtkWidget* image, | 460 | katze_item_image_destroyed_cb (GtkWidget* image, |
860 | 461 | KatzeItem* item); | 461 | KatzeItem* item); |
861 | 462 | #ifndef HAVE_WEBKIT2 | ||
862 | 463 | static void | ||
863 | 464 | katze_item_icon_loaded_cb (WebKitFaviconDatabase* database, | ||
864 | 465 | const gchar* frame_uri, | ||
865 | 466 | GtkWidget* image) | ||
866 | 467 | { | ||
867 | 468 | KatzeItem* item = g_object_get_data (G_OBJECT (image), "KatzeItem"); | ||
868 | 469 | GdkPixbuf* pixbuf; | ||
869 | 470 | if (!g_strcmp0 (frame_uri, item->uri) | ||
870 | 471 | && (pixbuf = midori_paths_get_icon (frame_uri, image))) | ||
871 | 472 | { | ||
872 | 473 | gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); | ||
873 | 474 | g_object_unref (pixbuf); | ||
874 | 475 | /* This signal fires extremely often (WebKit bug?) | ||
875 | 476 | we must throttle it (disconnect) once we have an icon */ | ||
876 | 477 | katze_item_image_destroyed_cb (image, g_object_ref (item)); | ||
877 | 478 | } | ||
878 | 479 | } | ||
879 | 480 | #endif | ||
880 | 481 | 462 | ||
881 | 482 | static void | 463 | static void |
882 | 483 | katze_item_image_destroyed_cb (GtkWidget* image, | 464 | katze_item_image_destroyed_cb (GtkWidget* image, |
883 | 484 | KatzeItem* item) | 465 | KatzeItem* item) |
884 | 485 | { | 466 | { |
885 | 486 | #ifndef HAVE_WEBKIT2 | ||
886 | 487 | g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (), | ||
887 | 488 | katze_item_icon_loaded_cb, image); | ||
888 | 489 | #endif | ||
889 | 490 | g_object_unref (item); | 467 | g_object_unref (item); |
890 | 491 | } | 468 | } |
891 | 492 | 469 | ||
892 | @@ -521,10 +498,6 @@ | |||
893 | 521 | g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item)); | 498 | g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item)); |
894 | 522 | g_signal_connect (image, "destroy", | 499 | g_signal_connect (image, "destroy", |
895 | 523 | G_CALLBACK (katze_item_image_destroyed_cb), item); | 500 | G_CALLBACK (katze_item_image_destroyed_cb), item); |
896 | 524 | #ifndef HAVE_WEBKIT2 | ||
897 | 525 | g_signal_connect (webkit_get_favicon_database (), "icon-loaded", | ||
898 | 526 | G_CALLBACK (katze_item_icon_loaded_cb), image); | ||
899 | 527 | #endif | ||
900 | 528 | return image; | 501 | return image; |
901 | 529 | } | 502 | } |
902 | 530 | 503 | ||
903 | 531 | 504 | ||
904 | === modified file 'katze/katze.h' | |||
905 | --- katze/katze.h 2013-10-22 22:38:26 +0000 | |||
906 | +++ katze/katze.h 2016-09-20 20:57:01 +0000 | |||
907 | @@ -18,11 +18,6 @@ | |||
908 | 18 | #include "katze-array.h" | 18 | #include "katze-array.h" |
909 | 19 | #include "katze-arrayaction.h" | 19 | #include "katze-arrayaction.h" |
910 | 20 | #include "katze-preferences.h" | 20 | #include "katze-preferences.h" |
917 | 21 | 21 | #include <webkit2/webkit2.h> | |
912 | 22 | #ifndef HAVE_WEBKIT2 | ||
913 | 23 | #include <webkit/webkit.h> | ||
914 | 24 | #else | ||
915 | 25 | #include <webkit2/webkit2.h> | ||
916 | 26 | #endif | ||
918 | 27 | 22 | ||
919 | 28 | #endif /* __KATZE_H__ */ | 23 | #endif /* __KATZE_H__ */ |
920 | 29 | 24 | ||
921 | === modified file 'katze/midori-paths.vala' | |||
922 | --- katze/midori-paths.vala 2016-01-15 19:18:17 +0000 | |||
923 | +++ katze/midori-paths.vala 2016-09-20 20:57:01 +0000 | |||
924 | @@ -134,11 +134,9 @@ | |||
925 | 134 | tmp_dir = get_runtime_dir (); | 134 | tmp_dir = get_runtime_dir (); |
926 | 135 | } | 135 | } |
927 | 136 | else { | 136 | else { |
928 | 137 | #if HAVE_WEBKIT2_3_91 | ||
929 | 138 | /* Allow WebKit to spawn more than one rendering process */ | 137 | /* Allow WebKit to spawn more than one rendering process */ |
930 | 139 | if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""))) | 138 | if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""))) |
931 | 140 | WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES); | 139 | WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES); |
932 | 141 | #endif | ||
933 | 142 | string? real_config = config != null && !Path.is_absolute (config) | 140 | string? real_config = config != null && !Path.is_absolute (config) |
934 | 143 | ? Path.build_filename (Environment.get_current_dir (), config) : config; | 141 | ? Path.build_filename (Environment.get_current_dir (), config) : config; |
935 | 144 | config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S, | 142 | config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S, |
936 | @@ -148,11 +146,10 @@ | |||
937 | 148 | user_data_dir = Environment.get_user_data_dir (); | 146 | user_data_dir = Environment.get_user_data_dir (); |
938 | 149 | tmp_dir = get_runtime_dir (); | 147 | tmp_dir = get_runtime_dir (); |
939 | 150 | } | 148 | } |
940 | 151 | #if HAVE_WEBKIT2 | ||
941 | 152 | if (cache_dir != null) { | 149 | if (cache_dir != null) { |
942 | 153 | /* Cache and extension dir MUST be set no later than here to work */ | 150 | /* Cache and extension dir MUST be set no later than here to work */ |
943 | 154 | WebKit.WebContext.get_default ().set_web_extensions_directory ( | 151 | WebKit.WebContext.get_default ().set_web_extensions_directory ( |
945 | 155 | Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext")); | 152 | get_lib_path (PACKAGE_NAME)); |
946 | 156 | WebKit.WebContext.get_default ().set_disk_cache_directory ( | 153 | WebKit.WebContext.get_default ().set_disk_cache_directory ( |
947 | 157 | Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web")); | 154 | Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web")); |
948 | 158 | } | 155 | } |
949 | @@ -162,32 +159,25 @@ | |||
950 | 162 | cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"), | 159 | cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"), |
951 | 163 | WebKit.CookiePersistentStorage.SQLITE); | 160 | WebKit.CookiePersistentStorage.SQLITE); |
952 | 164 | } | 161 | } |
953 | 165 | #endif | ||
954 | 166 | if (user_data_dir != null) { | 162 | if (user_data_dir != null) { |
955 | 167 | string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase"); | 163 | string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase"); |
956 | 168 | #if HAVE_WEBKIT2 | ||
957 | 169 | WebKit.WebContext.get_default ().set_favicon_database_directory (folder); | 164 | WebKit.WebContext.get_default ().set_favicon_database_directory (folder); |
958 | 170 | #else | ||
959 | 171 | WebKit.get_favicon_database ().set_path (folder); | ||
960 | 172 | #endif | ||
961 | 173 | } | 165 | } |
962 | 174 | else | 166 | else |
963 | 175 | { | 167 | { |
964 | 176 | #if HAVE_WEBKIT2 | ||
965 | 177 | /* with wk2 set_favicon_database_directory can only be called once and actually | 168 | /* with wk2 set_favicon_database_directory can only be called once and actually |
966 | 178 | initializes and enables the favicon database, so we do not call it in this case */ | 169 | initializes and enables the favicon database, so we do not call it in this case */ |
967 | 179 | #else | ||
968 | 180 | /* wk1 documentation claims that the favicon database is not enabled unless | ||
969 | 181 | a call to favicon_database.set_path is made, but in fact it must be explicitly | ||
970 | 182 | disabled by setting to null (verified as of webkitgtk 2.3.1) */ | ||
971 | 183 | WebKit.get_favicon_database ().set_path (null); | ||
972 | 184 | #endif | ||
973 | 185 | } | 170 | } |
974 | 186 | 171 | ||
975 | 187 | #if !HAVE_WIN32 | 172 | #if !HAVE_WIN32 |
976 | 188 | Gtk.IconTheme.get_default ().append_search_path (exec_path); | 173 | Gtk.IconTheme.get_default ().append_search_path (exec_path); |
977 | 189 | #endif | 174 | #endif |
978 | 190 | 175 | ||
979 | 176 | if (("wk2:ignore-tls" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""))) | ||
980 | 177 | WebKit.WebContext.get_default ().set_tls_errors_policy (WebKit.TLSErrorsPolicy.IGNORE); | ||
981 | 178 | else | ||
982 | 179 | WebKit.WebContext.get_default ().set_tls_errors_policy (WebKit.TLSErrorsPolicy.FAIL); | ||
983 | 180 | |||
984 | 191 | if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) { | 181 | if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) { |
985 | 192 | stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n", | 182 | stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n", |
986 | 193 | config_dir, cache_dir, user_data_dir, tmp_dir); | 183 | config_dir, cache_dir, user_data_dir, tmp_dir); |
987 | @@ -451,11 +441,7 @@ | |||
988 | 451 | public static void clear_icons () { | 441 | public static void clear_icons () { |
989 | 452 | assert (cache_dir != null); | 442 | assert (cache_dir != null); |
990 | 453 | assert (user_data_dir != null); | 443 | assert (user_data_dir != null); |
991 | 454 | #if HAVE_WEBKIT2 | ||
992 | 455 | WebKit.WebContext.get_default ().get_favicon_database ().clear (); | 444 | WebKit.WebContext.get_default ().get_favicon_database ().clear (); |
993 | 456 | #else | ||
994 | 457 | WebKit.get_favicon_database ().clear (); | ||
995 | 458 | #endif | ||
996 | 459 | /* FIXME: Exclude search engine icons */ | 445 | /* FIXME: Exclude search engine icons */ |
997 | 460 | remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase")); | 446 | remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase")); |
998 | 461 | } | 447 | } |
999 | @@ -475,14 +461,7 @@ | |||
1000 | 475 | Gtk.IconSize.MENU, out icon_width, out icon_height); | 461 | Gtk.IconSize.MENU, out icon_width, out icon_height); |
1001 | 476 | else | 462 | else |
1002 | 477 | icon_width = icon_height = 0 /* maximum size */; | 463 | icon_width = icon_height = 0 /* maximum size */; |
1003 | 478 | #if HAVE_WEBKIT2 | ||
1004 | 479 | /* There is no sync API for WebKit2 */ | 464 | /* There is no sync API for WebKit2 */ |
1005 | 480 | #else | ||
1006 | 481 | Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database () | ||
1007 | 482 | .try_get_favicon_pixbuf (uri, icon_width, icon_height); | ||
1008 | 483 | if (pixbuf != null) | ||
1009 | 484 | return pixbuf; | ||
1010 | 485 | #endif | ||
1011 | 486 | if (widget != null) | 465 | if (widget != null) |
1012 | 487 | return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null); | 466 | return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null); |
1013 | 488 | return null; | 467 | return null; |
1014 | 489 | 468 | ||
1015 | === modified file 'katze/midori-uri.vala' | |||
1016 | --- katze/midori-uri.vala 2015-04-12 13:30:03 +0000 | |||
1017 | +++ katze/midori-uri.vala 2016-09-20 20:57:01 +0000 | |||
1018 | @@ -248,16 +248,10 @@ | |||
1019 | 248 | * Since: 0.5.8 | 248 | * Since: 0.5.8 |
1020 | 249 | **/ | 249 | **/ |
1021 | 250 | public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error { | 250 | public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error { |
1022 | 251 | #if HAVE_WEBKIT2 | ||
1023 | 252 | var database = WebKit.WebContext.get_default ().get_favicon_database (); | 251 | var database = WebKit.WebContext.get_default ().get_favicon_database (); |
1024 | 253 | var surface = yield database.get_favicon (uri, cancellable); | 252 | var surface = yield database.get_favicon (uri, cancellable); |
1025 | 254 | var image = (Cairo.ImageSurface)surface; | 253 | var image = (Cairo.ImageSurface)surface; |
1026 | 255 | var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ()); | 254 | var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ()); |
1027 | 256 | #else | ||
1028 | 257 | var database = WebKit.get_favicon_database (); | ||
1029 | 258 | // We must not pass a Cancellable due to a crasher bug | ||
1030 | 259 | var pixbuf = yield database.get_favicon_pixbuf (uri, 0, 0, null); | ||
1031 | 260 | #endif | ||
1032 | 261 | return pixbuf as GLib.Icon; | 255 | return pixbuf as GLib.Icon; |
1033 | 262 | } | 256 | } |
1034 | 263 | 257 | ||
1035 | 264 | 258 | ||
1036 | === modified file 'midori/main.c' | |||
1037 | --- midori/main.c 2016-03-21 19:19:52 +0000 | |||
1038 | +++ midori/main.c 2016-09-20 20:57:01 +0000 | |||
1039 | @@ -39,6 +39,7 @@ | |||
1040 | 39 | g_free (uri); | 39 | g_free (uri); |
1041 | 40 | } | 40 | } |
1042 | 41 | 41 | ||
1043 | 42 | <<<<<<< TREE | ||
1044 | 42 | #ifndef HAVE_WEBKIT2 | 43 | #ifndef HAVE_WEBKIT2 |
1045 | 43 | static void | 44 | static void |
1046 | 44 | snapshot_load_finished_cb (GtkWidget* web_view, | 45 | snapshot_load_finished_cb (GtkWidget* web_view, |
1047 | @@ -96,6 +97,8 @@ | |||
1048 | 96 | fclose (logfile); | 97 | fclose (logfile); |
1049 | 97 | } | 98 | } |
1050 | 98 | 99 | ||
1051 | 100 | ======= | ||
1052 | 101 | >>>>>>> MERGE-SOURCE | ||
1053 | 99 | int | 102 | int |
1054 | 100 | main (int argc, | 103 | main (int argc, |
1055 | 101 | char** argv) | 104 | char** argv) |
1056 | @@ -321,10 +324,6 @@ | |||
1057 | 321 | else | 324 | else |
1058 | 322 | gtk_widget_set_size_request (web_view, 800, 600); | 325 | gtk_widget_set_size_request (web_view, 800, 600); |
1059 | 323 | gtk_widget_show_all (offscreen); | 326 | gtk_widget_show_all (offscreen); |
1060 | 324 | #ifndef HAVE_WEBKIT2 | ||
1061 | 325 | g_signal_connect (web_view, "load-finished", | ||
1062 | 326 | G_CALLBACK (snapshot_load_finished_cb), filename); | ||
1063 | 327 | #endif | ||
1064 | 328 | uri = sokoke_magic_uri (snapshot, FALSE, TRUE); | 327 | uri = sokoke_magic_uri (snapshot, FALSE, TRUE); |
1065 | 329 | webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri); | 328 | webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri); |
1066 | 330 | g_free (uri); | 329 | g_free (uri); |
1067 | @@ -343,19 +342,11 @@ | |||
1068 | 343 | GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | 342 | GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
1069 | 344 | GtkWidget* vbox = gtk_vbox_new (FALSE, 0); | 343 | GtkWidget* vbox = gtk_vbox_new (FALSE, 0); |
1070 | 345 | GtkWidget* entry = gtk_entry_new (); | 344 | GtkWidget* entry = gtk_entry_new (); |
1071 | 346 | #ifndef HAVE_WEBKIT2 | ||
1072 | 347 | GtkWidget* scrolled = gtk_scrolled_window_new (NULL, NULL); | ||
1073 | 348 | #endif | ||
1074 | 349 | GtkWidget* web_view = webkit_web_view_new (); | 345 | GtkWidget* web_view = webkit_web_view_new (); |
1075 | 350 | katze_window_set_sensible_default_size (GTK_WINDOW (window)); | 346 | katze_window_set_sensible_default_size (GTK_WINDOW (window)); |
1076 | 351 | 347 | ||
1077 | 352 | gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); | 348 | gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); |
1078 | 353 | #ifndef HAVE_WEBKIT2 | ||
1079 | 354 | gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0); | ||
1080 | 355 | gtk_container_add (GTK_CONTAINER (scrolled), web_view); | ||
1081 | 356 | #else | ||
1082 | 357 | gtk_box_pack_start (GTK_BOX (vbox), web_view, TRUE, TRUE, 0); | 349 | gtk_box_pack_start (GTK_BOX (vbox), web_view, TRUE, TRUE, 0); |
1083 | 358 | #endif | ||
1084 | 359 | gtk_container_add (GTK_CONTAINER (window), vbox); | 350 | gtk_container_add (GTK_CONTAINER (window), vbox); |
1085 | 360 | gtk_entry_set_text (GTK_ENTRY (entry), uris && *uris ? *uris : "http://www.example.com"); | 351 | gtk_entry_set_text (GTK_ENTRY (entry), uris && *uris ? *uris : "http://www.example.com"); |
1086 | 361 | plain_entry_activate_cb (entry, web_view); | 352 | plain_entry_activate_cb (entry, web_view); |
1087 | @@ -381,9 +372,6 @@ | |||
1088 | 381 | 372 | ||
1089 | 382 | MidoriBrowser* browser = midori_browser_new (); | 373 | MidoriBrowser* browser = midori_browser_new (); |
1090 | 383 | MidoriWebSettings* settings = midori_browser_get_settings (browser); | 374 | MidoriWebSettings* settings = midori_browser_get_settings (browser); |
1091 | 384 | #ifndef HAVE_WEBKIT2 | ||
1092 | 385 | g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1); | ||
1093 | 386 | #endif | ||
1094 | 387 | midori_load_soup_session (settings); | 375 | midori_load_soup_session (settings); |
1095 | 388 | 376 | ||
1096 | 389 | gchar* msg = NULL; | 377 | gchar* msg = NULL; |
1097 | 390 | 378 | ||
1098 | === modified file 'midori/midori-browser.c' | |||
1099 | --- midori/midori-browser.c 2016-01-23 19:21:31 +0000 | |||
1100 | +++ midori/midori-browser.c 2016-09-20 20:57:01 +0000 | |||
1101 | @@ -153,11 +153,9 @@ | |||
1102 | 153 | static void | 153 | static void |
1103 | 154 | midori_browser_finalize (GObject* object); | 154 | midori_browser_finalize (GObject* object); |
1104 | 155 | 155 | ||
1105 | 156 | #ifdef HAVE_WEBKIT2 | ||
1106 | 157 | void download_created_destination_cb (WebKitDownload *download, | 156 | void download_created_destination_cb (WebKitDownload *download, |
1107 | 158 | gchar *destination, | 157 | gchar *destination, |
1108 | 159 | gpointer user_data); | 158 | gpointer user_data); |
1109 | 160 | #endif | ||
1110 | 161 | 159 | ||
1111 | 162 | static void | 160 | static void |
1112 | 163 | midori_browser_set_property (GObject* object, | 161 | midori_browser_set_property (GObject* object, |
1113 | @@ -1319,54 +1317,11 @@ | |||
1114 | 1319 | if (!midori_download_has_enough_space (download, uri, FALSE)) | 1317 | if (!midori_download_has_enough_space (download, uri, FALSE)) |
1115 | 1320 | return FALSE; | 1318 | return FALSE; |
1116 | 1321 | 1319 | ||
1117 | 1322 | #ifdef HAVE_WEBKIT2 | ||
1118 | 1323 | webkit_download_set_destination (download, uri); | 1320 | webkit_download_set_destination (download, uri); |
1119 | 1324 | #else | ||
1120 | 1325 | webkit_download_set_destination_uri (download, uri); | ||
1121 | 1326 | #endif | ||
1122 | 1327 | g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download); | 1321 | g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download); |
1123 | 1328 | return TRUE; | 1322 | return TRUE; |
1124 | 1329 | } | 1323 | } |
1125 | 1330 | 1324 | ||
1126 | 1331 | #ifndef HAVE_WEBKIT2 | ||
1127 | 1332 | static void | ||
1128 | 1333 | midori_browser_save_resources (GList* resources, | ||
1129 | 1334 | const gchar* folder) | ||
1130 | 1335 | { | ||
1131 | 1336 | GList* list; | ||
1132 | 1337 | katze_mkdir_with_parents (folder, 0700); | ||
1133 | 1338 | |||
1134 | 1339 | for (list = resources; list; list = g_list_next (list)) | ||
1135 | 1340 | { | ||
1136 | 1341 | WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data); | ||
1137 | 1342 | GString* data = webkit_web_resource_get_data (resource); | ||
1138 | 1343 | |||
1139 | 1344 | /* Resource could be adblocked, skip it in that case */ | ||
1140 | 1345 | if (!g_strcmp0 (webkit_web_resource_get_uri (resource), "about:blank")) | ||
1141 | 1346 | continue; | ||
1142 | 1347 | |||
1143 | 1348 | gchar* sub_filename = midori_download_get_filename_suggestion_for_uri ( | ||
1144 | 1349 | webkit_web_resource_get_mime_type (resource), | ||
1145 | 1350 | webkit_web_resource_get_uri (resource)); | ||
1146 | 1351 | gchar* sub_path = g_build_filename (folder, sub_filename, NULL); | ||
1147 | 1352 | sub_path = midori_download_get_unique_filename (sub_path); | ||
1148 | 1353 | if (data) | ||
1149 | 1354 | { | ||
1150 | 1355 | GError* error = NULL; | ||
1151 | 1356 | if (!g_file_set_contents (sub_path, data->str, data->len, &error)) | ||
1152 | 1357 | { | ||
1153 | 1358 | g_warning ("Failed to save %s: %s", sub_filename, error->message); | ||
1154 | 1359 | g_error_free (error); | ||
1155 | 1360 | } | ||
1156 | 1361 | } | ||
1157 | 1362 | else | ||
1158 | 1363 | g_warning ("Skipping empty resource %s", sub_filename); | ||
1159 | 1364 | g_free (sub_filename); | ||
1160 | 1365 | g_free (sub_path); | ||
1161 | 1366 | } | ||
1162 | 1367 | } | ||
1163 | 1368 | #endif | ||
1164 | 1369 | |||
1165 | 1370 | void | 1325 | void |
1166 | 1371 | midori_browser_save_uri (MidoriBrowser* browser, | 1326 | midori_browser_save_uri (MidoriBrowser* browser, |
1167 | 1372 | MidoriView* view, | 1327 | MidoriView* view, |
1168 | @@ -1395,50 +1350,6 @@ | |||
1169 | 1395 | g_free (dirname); | 1350 | g_free (dirname); |
1170 | 1396 | } | 1351 | } |
1171 | 1397 | 1352 | ||
1172 | 1398 | #ifndef HAVE_WEBKIT2 | ||
1173 | 1399 | GList* resources = midori_view_get_resources (view); | ||
1174 | 1400 | gboolean file_only = TRUE; | ||
1175 | 1401 | GtkWidget* checkbox = NULL; | ||
1176 | 1402 | |||
1177 | 1403 | if (resources != NULL && g_list_nth_data (resources, 1) != NULL) | ||
1178 | 1404 | { | ||
1179 | 1405 | file_only = FALSE; | ||
1180 | 1406 | checkbox = gtk_check_button_new_with_mnemonic (_("Save associated _resources")); | ||
1181 | 1407 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE); | ||
1182 | 1408 | gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), checkbox); | ||
1183 | 1409 | } | ||
1184 | 1410 | |||
1185 | 1411 | if (!file_only && !g_str_equal (title, uri)) | ||
1186 | 1412 | filename = midori_download_clean_filename (title); | ||
1187 | 1413 | else | ||
1188 | 1414 | { | ||
1189 | 1415 | gchar* mime_type = katze_object_get_object (view, "mime-type"); | ||
1190 | 1416 | filename = midori_download_get_filename_suggestion_for_uri (mime_type, uri); | ||
1191 | 1417 | g_free (mime_type); | ||
1192 | 1418 | } | ||
1193 | 1419 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename); | ||
1194 | 1420 | g_free (filename); | ||
1195 | 1421 | |||
1196 | 1422 | if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) | ||
1197 | 1423 | { | ||
1198 | 1424 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); | ||
1199 | 1425 | if (checkbox != NULL) | ||
1200 | 1426 | file_only = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); | ||
1201 | 1427 | if (!file_only) | ||
1202 | 1428 | { | ||
1203 | 1429 | gchar* fullname = g_strconcat (filename, ".html", NULL); | ||
1204 | 1430 | midori_view_save_source (view, uri, fullname, FALSE); | ||
1205 | 1431 | g_free (fullname); | ||
1206 | 1432 | midori_browser_save_resources (resources, filename); | ||
1207 | 1433 | } | ||
1208 | 1434 | else | ||
1209 | 1435 | midori_view_save_source (view, uri, filename, FALSE); | ||
1210 | 1436 | katze_assign (last_dir, | ||
1211 | 1437 | gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog))); | ||
1212 | 1438 | } | ||
1213 | 1439 | g_list_foreach (resources, (GFunc)g_object_unref, NULL); | ||
1214 | 1440 | g_list_free (resources); | ||
1215 | 1441 | #else | ||
1216 | 1442 | filename = midori_download_clean_filename (title); | 1353 | filename = midori_download_clean_filename (title); |
1217 | 1443 | gchar* suggested_filename = g_strconcat (filename, ".mht", NULL); | 1354 | gchar* suggested_filename = g_strconcat (filename, ".mht", NULL); |
1218 | 1444 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename); | 1355 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename); |
1219 | @@ -1456,7 +1367,6 @@ | |||
1220 | 1456 | katze_assign (last_dir, | 1367 | katze_assign (last_dir, |
1221 | 1457 | gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog))); | 1368 | gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog))); |
1222 | 1458 | } | 1369 | } |
1223 | 1459 | #endif | ||
1224 | 1460 | gtk_widget_destroy (dialog); | 1370 | gtk_widget_destroy (dialog); |
1225 | 1461 | } | 1371 | } |
1226 | 1462 | 1372 | ||
1227 | @@ -1493,28 +1403,6 @@ | |||
1228 | 1493 | midori_browser_view_copy_to_item_history (GtkWidget* view, | 1403 | midori_browser_view_copy_to_item_history (GtkWidget* view, |
1229 | 1494 | KatzeItem* item) | 1404 | KatzeItem* item) |
1230 | 1495 | { | 1405 | { |
1231 | 1496 | #ifndef HAVE_WEBKIT2 | ||
1232 | 1497 | WebKitWebView* copy_from; | ||
1233 | 1498 | WebKitWebBackForwardList* list_from; | ||
1234 | 1499 | guint length_from; | ||
1235 | 1500 | gint i; | ||
1236 | 1501 | GPtrArray* history; | ||
1237 | 1502 | |||
1238 | 1503 | copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view))); | ||
1239 | 1504 | list_from = webkit_web_view_get_back_forward_list (copy_from); | ||
1240 | 1505 | length_from = webkit_web_back_forward_list_get_back_length (list_from); | ||
1241 | 1506 | history = g_ptr_array_new (); | ||
1242 | 1507 | |||
1243 | 1508 | for (i = -length_from; i <= -1 ; i++) | ||
1244 | 1509 | { | ||
1245 | 1510 | WebKitWebHistoryItem* hist_item = webkit_web_back_forward_list_get_nth_item (list_from, i); | ||
1246 | 1511 | if (hist_item == NULL) | ||
1247 | 1512 | break; | ||
1248 | 1513 | g_object_ref ((gpointer) hist_item); | ||
1249 | 1514 | g_ptr_array_add (history, (gpointer) hist_item); | ||
1250 | 1515 | } | ||
1251 | 1516 | g_object_set_data (G_OBJECT (item), "tab-history", (gpointer) history); | ||
1252 | 1517 | #endif | ||
1253 | 1518 | } | 1406 | } |
1254 | 1519 | 1407 | ||
1255 | 1520 | static void | 1408 | static void |
1256 | @@ -1579,63 +1467,14 @@ | |||
1257 | 1579 | GtkWidget* view_from, | 1467 | GtkWidget* view_from, |
1258 | 1580 | gboolean omit_last) | 1468 | gboolean omit_last) |
1259 | 1581 | { | 1469 | { |
1260 | 1582 | #ifndef HAVE_WEBKIT2 | ||
1261 | 1583 | WebKitWebView* copy_from; | ||
1262 | 1584 | WebKitWebBackForwardList* list_from; | ||
1263 | 1585 | WebKitWebView* copy_to; | ||
1264 | 1586 | WebKitWebBackForwardList* list_to; | ||
1265 | 1587 | guint length_from; | ||
1266 | 1588 | gint i; | ||
1267 | 1589 | |||
1268 | 1590 | copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_from))); | ||
1269 | 1591 | list_from = webkit_web_view_get_back_forward_list (copy_from); | ||
1270 | 1592 | copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_to))); | ||
1271 | 1593 | list_to = webkit_web_view_get_back_forward_list (copy_to); | ||
1272 | 1594 | length_from = webkit_web_back_forward_list_get_back_length (list_from); | ||
1273 | 1595 | |||
1274 | 1596 | for (i = -length_from; i <= (omit_last ? -1 : 0); i++) | ||
1275 | 1597 | { | ||
1276 | 1598 | WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item (list_from, i); | ||
1277 | 1599 | if (item == NULL) | ||
1278 | 1600 | break; | ||
1279 | 1601 | webkit_web_back_forward_list_add_item (list_to, item); | ||
1280 | 1602 | } | ||
1281 | 1603 | #endif | ||
1282 | 1604 | } | 1470 | } |
1283 | 1605 | 1471 | ||
1284 | 1606 | |||
1285 | 1607 | static void | 1472 | static void |
1286 | 1608 | midori_browser_view_copy_from_item_history (GtkWidget* view, | 1473 | midori_browser_view_copy_from_item_history (GtkWidget* view, |
1287 | 1609 | KatzeItem* item) | 1474 | KatzeItem* item) |
1288 | 1610 | { | 1475 | { |
1289 | 1611 | #ifndef HAVE_WEBKIT2 | ||
1290 | 1612 | WebKitWebView* copy_to; | ||
1291 | 1613 | WebKitWebBackForwardList* list_to; | ||
1292 | 1614 | guint i; | ||
1293 | 1615 | GPtrArray* list_from; | ||
1294 | 1616 | |||
1295 | 1617 | copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view))); | ||
1296 | 1618 | list_to = webkit_web_view_get_back_forward_list (copy_to); | ||
1297 | 1619 | |||
1298 | 1620 | if (item == NULL) | ||
1299 | 1621 | return; | ||
1300 | 1622 | list_from = g_object_get_data (G_OBJECT (item), "tab-history"); | ||
1301 | 1623 | if (list_from == NULL) | ||
1302 | 1624 | return; | ||
1303 | 1625 | |||
1304 | 1626 | for (i = 0; i < list_from->len; i++) | ||
1305 | 1627 | { | ||
1306 | 1628 | WebKitWebHistoryItem* hist_item = (WebKitWebHistoryItem*) g_ptr_array_index (list_from, i); | ||
1307 | 1629 | if (hist_item == NULL) | ||
1308 | 1630 | break; | ||
1309 | 1631 | webkit_web_back_forward_list_add_item (list_to, hist_item); | ||
1310 | 1632 | } | ||
1311 | 1633 | g_ptr_array_unref (list_from); | ||
1312 | 1634 | #endif | ||
1313 | 1635 | } | 1476 | } |
1314 | 1636 | 1477 | ||
1315 | 1637 | |||
1316 | 1638 | |||
1317 | 1639 | static gboolean | 1478 | static gboolean |
1318 | 1640 | midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser) | 1479 | midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser) |
1319 | 1641 | { | 1480 | { |
1320 | @@ -1785,7 +1624,6 @@ | |||
1321 | 1785 | } | 1624 | } |
1322 | 1786 | } | 1625 | } |
1323 | 1787 | 1626 | ||
1324 | 1788 | #ifdef HAVE_WEBKIT2 | ||
1325 | 1789 | static void | 1627 | static void |
1326 | 1790 | midori_browser_close_tab_idle (GObject* resource, | 1628 | midori_browser_close_tab_idle (GObject* resource, |
1327 | 1791 | GAsyncResult* result, | 1629 | GAsyncResult* result, |
1328 | @@ -1795,16 +1633,8 @@ | |||
1329 | 1795 | result, NULL, NULL); | 1633 | result, NULL, NULL); |
1330 | 1796 | if (data != NULL) | 1634 | if (data != NULL) |
1331 | 1797 | return; | 1635 | return; |
1332 | 1798 | #else | ||
1333 | 1799 | static gboolean | ||
1334 | 1800 | midori_browser_close_tab_idle (gpointer view) | ||
1335 | 1801 | { | ||
1336 | 1802 | #endif | ||
1337 | 1803 | MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); | 1636 | MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); |
1338 | 1804 | midori_browser_close_tab (browser, GTK_WIDGET (view)); | 1637 | midori_browser_close_tab (browser, GTK_WIDGET (view)); |
1339 | 1805 | #ifndef HAVE_WEBKIT2 | ||
1340 | 1806 | return G_SOURCE_REMOVE; | ||
1341 | 1807 | #endif | ||
1342 | 1808 | } | 1638 | } |
1343 | 1809 | 1639 | ||
1344 | 1810 | static gboolean | 1640 | static gboolean |
1345 | @@ -1820,11 +1650,7 @@ | |||
1346 | 1820 | { | 1650 | { |
1347 | 1821 | handled = FALSE; | 1651 | handled = FALSE; |
1348 | 1822 | } | 1652 | } |
1349 | 1823 | #ifdef HAVE_WEBKIT2 | ||
1350 | 1824 | else if (!webkit_download_get_destination (download)) | 1653 | else if (!webkit_download_get_destination (download)) |
1351 | 1825 | #else | ||
1352 | 1826 | else if (!webkit_download_get_destination_uri (download)) | ||
1353 | 1827 | #endif | ||
1354 | 1828 | { | 1654 | { |
1355 | 1829 | if (type == MIDORI_DOWNLOAD_SAVE_AS) | 1655 | if (type == MIDORI_DOWNLOAD_SAVE_AS) |
1356 | 1830 | { | 1656 | { |
1357 | @@ -1833,12 +1659,8 @@ | |||
1358 | 1833 | 1659 | ||
1359 | 1834 | if (!dialog) | 1660 | if (!dialog) |
1360 | 1835 | { | 1661 | { |
1361 | 1836 | #ifdef HAVE_WEBKIT2 | ||
1362 | 1837 | const gchar* download_uri = webkit_uri_response_get_uri ( | 1662 | const gchar* download_uri = webkit_uri_response_get_uri ( |
1363 | 1838 | webkit_download_get_response (download)); | 1663 | webkit_download_get_response (download)); |
1364 | 1839 | #else | ||
1365 | 1840 | const gchar* download_uri = webkit_download_get_uri (download); | ||
1366 | 1841 | #endif | ||
1367 | 1842 | gchar* folder; | 1664 | gchar* folder; |
1368 | 1843 | dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file"), | 1665 | dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file"), |
1369 | 1844 | GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE); | 1666 | GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE); |
1370 | @@ -1883,24 +1705,14 @@ | |||
1371 | 1883 | midori_browser_prepare_download (browser, download, destination_uri); | 1705 | midori_browser_prepare_download (browser, download, destination_uri); |
1372 | 1884 | g_free (destination_uri); | 1706 | g_free (destination_uri); |
1373 | 1885 | } | 1707 | } |
1374 | 1886 | #ifndef HAVE_WEBKIT2 | ||
1375 | 1887 | webkit_download_start (download); | ||
1376 | 1888 | #endif | ||
1377 | 1889 | } | 1708 | } |
1378 | 1890 | 1709 | ||
1379 | 1891 | /* Close empty tabs due to download links with a target */ | 1710 | /* Close empty tabs due to download links with a target */ |
1380 | 1892 | if (midori_view_is_blank (MIDORI_VIEW (view))) | 1711 | if (midori_view_is_blank (MIDORI_VIEW (view))) |
1381 | 1893 | { | 1712 | { |
1382 | 1894 | GtkWidget* web_view = midori_view_get_web_view (MIDORI_VIEW (view)); | 1713 | GtkWidget* web_view = midori_view_get_web_view (MIDORI_VIEW (view)); |
1383 | 1895 | #ifdef HAVE_WEBKIT2 | ||
1384 | 1896 | WebKitWebResource* resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (web_view)); | 1714 | WebKitWebResource* resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (web_view)); |
1385 | 1897 | webkit_web_resource_get_data (resource, NULL, midori_browser_close_tab_idle, view); | 1715 | webkit_web_resource_get_data (resource, NULL, midori_browser_close_tab_idle, view); |
1386 | 1898 | #else | ||
1387 | 1899 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)); | ||
1388 | 1900 | WebKitWebDataSource* datasource = webkit_web_frame_get_data_source (web_frame); | ||
1389 | 1901 | if (webkit_web_data_source_get_data (datasource) == NULL) | ||
1390 | 1902 | g_idle_add (midori_browser_close_tab_idle, view); | ||
1391 | 1903 | #endif | ||
1392 | 1904 | } | 1716 | } |
1393 | 1905 | return handled; | 1717 | return handled; |
1394 | 1906 | } | 1718 | } |
1395 | @@ -2145,35 +1957,6 @@ | |||
1396 | 2145 | return TRUE; | 1957 | return TRUE; |
1397 | 2146 | } | 1958 | } |
1398 | 2147 | 1959 | ||
1399 | 2148 | #ifndef HAVE_WEBKIT2 | ||
1400 | 2149 | GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (widget)); | ||
1401 | 2150 | if (focus == NULL) | ||
1402 | 2151 | gtk_widget_grab_focus (midori_browser_get_current_tab (MIDORI_BROWSER (widget))); | ||
1403 | 2152 | else if (G_OBJECT_TYPE (focus) == WEBKIT_TYPE_WEB_VIEW | ||
1404 | 2153 | && event->keyval == GDK_KEY_space | ||
1405 | 2154 | && (!(event->state & GDK_SHIFT_MASK)) | ||
1406 | 2155 | && !webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (focus)) | ||
1407 | 2156 | && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus))) | ||
1408 | 2157 | { | ||
1409 | 2158 | /* Space at the bottom of the page: Go to next page */ | ||
1410 | 2159 | MidoriView* view = midori_view_get_for_widget (focus); | ||
1411 | 2160 | GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus)); | ||
1412 | 2161 | GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled); | ||
1413 | 2162 | if (gtk_adjustment_get_value (vadjust) | ||
1414 | 2163 | == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust))) | ||
1415 | 2164 | { | ||
1416 | 2165 | /* Duplicate here because the URI pointer might change */ | ||
1417 | 2166 | gchar* uri = g_strdup (midori_view_get_next_page (view)); | ||
1418 | 2167 | if (uri != NULL) | ||
1419 | 2168 | { | ||
1420 | 2169 | midori_view_set_uri (view, uri); | ||
1421 | 2170 | g_free (uri); | ||
1422 | 2171 | return TRUE; | ||
1423 | 2172 | } | ||
1424 | 2173 | } | ||
1425 | 2174 | } | ||
1426 | 2175 | #endif | ||
1427 | 2176 | |||
1428 | 2177 | if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) | 1960 | if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) |
1429 | 2178 | if (sokoke_window_activate_key (window, event)) | 1961 | if (sokoke_window_activate_key (window, event)) |
1430 | 2179 | return TRUE; | 1962 | return TRUE; |
1431 | @@ -2991,11 +2774,7 @@ | |||
1432 | 2991 | { | 2774 | { |
1433 | 2992 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); | 2775 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); |
1434 | 2993 | if (WEBKIT_IS_WEB_VIEW (widget)) | 2776 | if (WEBKIT_IS_WEB_VIEW (widget)) |
1435 | 2994 | #ifdef HAVE_WEBKIT2 | ||
1436 | 2995 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO); | 2777 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO); |
1437 | 2996 | #else | ||
1438 | 2997 | webkit_web_view_undo (WEBKIT_WEB_VIEW (widget)); | ||
1439 | 2998 | #endif | ||
1440 | 2999 | } | 2778 | } |
1441 | 3000 | 2779 | ||
1442 | 3001 | static void | 2780 | static void |
1443 | @@ -3004,11 +2783,7 @@ | |||
1444 | 3004 | { | 2783 | { |
1445 | 3005 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); | 2784 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); |
1446 | 3006 | if (WEBKIT_IS_WEB_VIEW (widget)) | 2785 | if (WEBKIT_IS_WEB_VIEW (widget)) |
1447 | 3007 | #ifdef HAVE_WEBKIT2 | ||
1448 | 3008 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO); | 2786 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO); |
1449 | 3009 | #else | ||
1450 | 3010 | webkit_web_view_redo (WEBKIT_WEB_VIEW (widget)); | ||
1451 | 3011 | #endif | ||
1452 | 3012 | } | 2787 | } |
1453 | 3013 | 2788 | ||
1454 | 3014 | static void | 2789 | static void |
1455 | @@ -3018,10 +2793,8 @@ | |||
1456 | 3018 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); | 2793 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); |
1457 | 3019 | if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget))) | 2794 | if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget))) |
1458 | 3020 | g_signal_emit_by_name (widget, "cut-clipboard"); | 2795 | g_signal_emit_by_name (widget, "cut-clipboard"); |
1459 | 3021 | #ifdef HAVE_WEBKIT2 | ||
1460 | 3022 | else if (WEBKIT_IS_WEB_VIEW (widget)) | 2796 | else if (WEBKIT_IS_WEB_VIEW (widget)) |
1461 | 3023 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT); | 2797 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT); |
1462 | 3024 | #endif | ||
1463 | 3025 | } | 2798 | } |
1464 | 3026 | 2799 | ||
1465 | 3027 | static void | 2800 | static void |
1466 | @@ -3031,10 +2804,8 @@ | |||
1467 | 3031 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); | 2804 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); |
1468 | 3032 | if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget))) | 2805 | if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget))) |
1469 | 3033 | g_signal_emit_by_name (widget, "copy-clipboard"); | 2806 | g_signal_emit_by_name (widget, "copy-clipboard"); |
1470 | 3034 | #ifdef HAVE_WEBKIT2 | ||
1471 | 3035 | else if (WEBKIT_IS_WEB_VIEW (widget)) | 2807 | else if (WEBKIT_IS_WEB_VIEW (widget)) |
1472 | 3036 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY); | 2808 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY); |
1473 | 3037 | #endif | ||
1474 | 3038 | } | 2809 | } |
1475 | 3039 | 2810 | ||
1476 | 3040 | static void | 2811 | static void |
1477 | @@ -3044,10 +2815,8 @@ | |||
1478 | 3044 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); | 2815 | GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser)); |
1479 | 3045 | if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget))) | 2816 | if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget))) |
1480 | 3046 | g_signal_emit_by_name (widget, "paste-clipboard"); | 2817 | g_signal_emit_by_name (widget, "paste-clipboard"); |
1481 | 3047 | #ifdef HAVE_WEBKIT2 | ||
1482 | 3048 | else if (WEBKIT_IS_WEB_VIEW (widget)) | 2818 | else if (WEBKIT_IS_WEB_VIEW (widget)) |
1483 | 3049 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE); | 2819 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE); |
1484 | 3050 | #endif | ||
1485 | 3051 | } | 2820 | } |
1486 | 3052 | 2821 | ||
1487 | 3053 | static void | 2822 | static void |
1488 | @@ -3059,10 +2828,6 @@ | |||
1489 | 3059 | { | 2828 | { |
1490 | 3060 | if (GTK_IS_EDITABLE (widget)) | 2829 | if (GTK_IS_EDITABLE (widget)) |
1491 | 3061 | gtk_editable_delete_selection (GTK_EDITABLE (widget)); | 2830 | gtk_editable_delete_selection (GTK_EDITABLE (widget)); |
1492 | 3062 | #ifndef HAVE_WEBKIT2 | ||
1493 | 3063 | else if (WEBKIT_IS_WEB_VIEW (widget)) | ||
1494 | 3064 | webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget)); | ||
1495 | 3065 | #endif | ||
1496 | 3066 | else if (GTK_IS_TEXT_VIEW (widget)) | 2831 | else if (GTK_IS_TEXT_VIEW (widget)) |
1497 | 3067 | gtk_text_buffer_delete_selection ( | 2832 | gtk_text_buffer_delete_selection ( |
1498 | 3068 | gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE); | 2833 | gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE); |
1499 | @@ -3078,10 +2843,8 @@ | |||
1500 | 3078 | { | 2843 | { |
1501 | 3079 | if (GTK_IS_EDITABLE (widget)) | 2844 | if (GTK_IS_EDITABLE (widget)) |
1502 | 3080 | gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); | 2845 | gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); |
1503 | 3081 | #ifdef HAVE_WEBKIT2 | ||
1504 | 3082 | else if (WEBKIT_IS_WEB_VIEW (widget)) | 2846 | else if (WEBKIT_IS_WEB_VIEW (widget)) |
1505 | 3083 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL); | 2847 | webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL); |
1506 | 3084 | #endif | ||
1507 | 3085 | else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget))) | 2848 | else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget))) |
1508 | 3086 | { | 2849 | { |
1509 | 3087 | if (GTK_IS_TEXT_VIEW (widget)) | 2850 | if (GTK_IS_TEXT_VIEW (widget)) |
1510 | @@ -3595,11 +3358,7 @@ | |||
1511 | 3595 | encoding = "ISO-8859-1"; | 3358 | encoding = "ISO-8859-1"; |
1512 | 3596 | else | 3359 | else |
1513 | 3597 | g_assert_not_reached (); | 3360 | g_assert_not_reached (); |
1514 | 3598 | #ifdef HAVE_WEBKIT2 | ||
1515 | 3599 | webkit_web_view_set_custom_charset (web_view, encoding); | 3361 | webkit_web_view_set_custom_charset (web_view, encoding); |
1516 | 3600 | #else | ||
1517 | 3601 | webkit_web_view_set_custom_encoding (web_view, encoding); | ||
1518 | 3602 | #endif | ||
1519 | 3603 | } | 3362 | } |
1520 | 3604 | 3363 | ||
1521 | 3605 | static void | 3364 | static void |
1522 | @@ -3607,39 +3366,7 @@ | |||
1523 | 3607 | MidoriBrowser* browser, | 3366 | MidoriBrowser* browser, |
1524 | 3608 | gboolean use_dom) | 3367 | gboolean use_dom) |
1525 | 3609 | { | 3368 | { |
1526 | 3610 | #ifdef HAVE_WEBKIT2 | ||
1527 | 3611 | /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */ | 3369 | /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */ |
1528 | 3612 | #else | ||
1529 | 3613 | GtkWidget* view = midori_browser_get_current_tab (browser); | ||
1530 | 3614 | gchar* filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, use_dom); | ||
1531 | 3615 | gchar* text_editor; | ||
1532 | 3616 | GAppInfo* info; | ||
1533 | 3617 | g_object_get (browser->settings, "text-editor", &text_editor, NULL); | ||
1534 | 3618 | if (text_editor && *text_editor) | ||
1535 | 3619 | info = g_app_info_create_from_commandline (text_editor, NULL, 0, NULL); | ||
1536 | 3620 | else | ||
1537 | 3621 | info = g_app_info_get_default_for_type ("text/plain", FALSE); | ||
1538 | 3622 | GFile* file = g_file_new_for_path (filename); | ||
1539 | 3623 | GList* files = g_list_append (NULL, file); | ||
1540 | 3624 | GError* error = NULL; | ||
1541 | 3625 | GdkDisplay* display = gtk_widget_get_display (view); | ||
1542 | 3626 | #if GTK_CHECK_VERSION (3, 0, 0) | ||
1543 | 3627 | GdkAppLaunchContext* ctx = gdk_display_get_app_launch_context (display); | ||
1544 | 3628 | #else | ||
1545 | 3629 | GdkAppLaunchContext* ctx = gdk_app_launch_context_new (); | ||
1546 | 3630 | gdk_app_launch_context_set_display (ctx, display); | ||
1547 | 3631 | #endif | ||
1548 | 3632 | if (!g_app_info_launch (info, files, G_APP_LAUNCH_CONTEXT (ctx), &error)) | ||
1549 | 3633 | { | ||
1550 | 3634 | g_printerr ("Failed to open editor: %s", error->message); | ||
1551 | 3635 | g_error_free (error); | ||
1552 | 3636 | } | ||
1553 | 3637 | g_object_unref (info); | ||
1554 | 3638 | g_list_free (files); | ||
1555 | 3639 | g_object_unref (file); | ||
1556 | 3640 | g_free (filename); | ||
1557 | 3641 | g_free (text_editor); | ||
1558 | 3642 | #endif | ||
1559 | 3643 | } | 3370 | } |
1560 | 3644 | 3371 | ||
1561 | 3645 | static void | 3372 | static void |
1562 | @@ -3736,20 +3463,6 @@ | |||
1563 | 3736 | _action_scroll_somewhere_activate (GtkAction* action, | 3463 | _action_scroll_somewhere_activate (GtkAction* action, |
1564 | 3737 | MidoriBrowser* browser) | 3464 | MidoriBrowser* browser) |
1565 | 3738 | { | 3465 | { |
1566 | 3739 | #ifndef HAVE_WEBKIT2 | ||
1567 | 3740 | GtkWidget* view = midori_browser_get_current_tab (browser); | ||
1568 | 3741 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view))); | ||
1569 | 3742 | const gchar* name = gtk_action_get_name (action); | ||
1570 | 3743 | |||
1571 | 3744 | if (g_str_equal (name, "ScrollLeft")) | ||
1572 | 3745 | webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, -1); | ||
1573 | 3746 | else if (g_str_equal (name, "ScrollDown")) | ||
1574 | 3747 | webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, 1); | ||
1575 | 3748 | else if (g_str_equal (name, "ScrollUp")) | ||
1576 | 3749 | webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, -1); | ||
1577 | 3750 | else if (g_str_equal (name, "ScrollRight")) | ||
1578 | 3751 | webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, 1); | ||
1579 | 3752 | #endif | ||
1580 | 3753 | } | 3466 | } |
1581 | 3754 | 3467 | ||
1582 | 3755 | static void | 3468 | static void |
1583 | @@ -3833,15 +3546,9 @@ | |||
1584 | 3833 | if (middle_click) | 3546 | if (middle_click) |
1585 | 3834 | { | 3547 | { |
1586 | 3835 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); | 3548 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); |
1587 | 3836 | #ifdef HAVE_WEBKIT2 | ||
1588 | 3837 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | 3549 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); |
1589 | 3838 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list); | 3550 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list); |
1590 | 3839 | const gchar* back_uri = webkit_back_forward_list_item_get_uri (item); | 3551 | const gchar* back_uri = webkit_back_forward_list_item_get_uri (item); |
1591 | 3840 | #else | ||
1592 | 3841 | WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
1593 | 3842 | WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list); | ||
1594 | 3843 | const gchar* back_uri = webkit_web_history_item_get_uri (item); | ||
1595 | 3844 | #endif | ||
1596 | 3845 | 3552 | ||
1597 | 3846 | GtkWidget* new_view = midori_browser_add_uri (browser, back_uri); | 3553 | GtkWidget* new_view = midori_browser_add_uri (browser, back_uri); |
1598 | 3847 | midori_browser_set_current_tab_smartly (browser, new_view); | 3554 | midori_browser_set_current_tab_smartly (browser, new_view); |
1599 | @@ -3856,15 +3563,9 @@ | |||
1600 | 3856 | if (middle_click) | 3563 | if (middle_click) |
1601 | 3857 | { | 3564 | { |
1602 | 3858 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); | 3565 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); |
1603 | 3859 | #ifdef HAVE_WEBKIT2 | ||
1604 | 3860 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | 3566 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); |
1605 | 3861 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list); | 3567 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list); |
1606 | 3862 | const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item); | 3568 | const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item); |
1607 | 3863 | #else | ||
1608 | 3864 | WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
1609 | 3865 | WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list); | ||
1610 | 3866 | const gchar* forward_uri = webkit_web_history_item_get_uri (item); | ||
1611 | 3867 | #endif | ||
1612 | 3868 | 3569 | ||
1613 | 3869 | GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri); | 3570 | GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri); |
1614 | 3870 | midori_browser_set_current_tab_smartly (browser, new_view); | 3571 | midori_browser_set_current_tab_smartly (browser, new_view); |
1615 | @@ -3963,41 +3664,10 @@ | |||
1616 | 3963 | midori_browser_get_current_uri (browser)); | 3664 | midori_browser_get_current_uri (browser)); |
1617 | 3964 | } | 3665 | } |
1618 | 3965 | 3666 | ||
1619 | 3966 | #ifndef HAVE_WEBKIT2 | ||
1620 | 3967 | static void | ||
1621 | 3968 | midori_browser_item_icon_loaded_cb (WebKitFaviconDatabase* database, | ||
1622 | 3969 | const gchar* frame_uri, | ||
1623 | 3970 | KatzeItem* item) | ||
1624 | 3971 | { | ||
1625 | 3972 | gchar* uri = g_object_get_data (G_OBJECT (item), "browser-queue-icon"); | ||
1626 | 3973 | if (strcmp (frame_uri, uri)) | ||
1627 | 3974 | return; | ||
1628 | 3975 | |||
1629 | 3976 | gchar* icon_uri = webkit_favicon_database_get_favicon_uri ( | ||
1630 | 3977 | webkit_get_favicon_database (), frame_uri); | ||
1631 | 3978 | if (icon_uri != NULL) | ||
1632 | 3979 | { | ||
1633 | 3980 | g_free (icon_uri); | ||
1634 | 3981 | katze_item_set_icon (item, frame_uri); | ||
1635 | 3982 | /* This signal fires extremely often (WebKit bug?) | ||
1636 | 3983 | we must throttle it (disconnect) once we have an icon */ | ||
1637 | 3984 | g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (), | ||
1638 | 3985 | midori_browser_item_icon_loaded_cb, item); | ||
1639 | 3986 | } | ||
1640 | 3987 | } | ||
1641 | 3988 | #endif | ||
1642 | 3989 | |||
1643 | 3990 | static void | 3667 | static void |
1644 | 3991 | midori_browser_queue_item_for_icon (KatzeItem* item, | 3668 | midori_browser_queue_item_for_icon (KatzeItem* item, |
1645 | 3992 | const gchar* uri) | 3669 | const gchar* uri) |
1646 | 3993 | { | 3670 | { |
1647 | 3994 | #ifndef HAVE_WEBKIT2 | ||
1648 | 3995 | if (katze_item_get_icon (item) != NULL) | ||
1649 | 3996 | return; | ||
1650 | 3997 | g_object_set_data_full (G_OBJECT (item), "browser-queue-icon", g_strdup (uri), g_free); | ||
1651 | 3998 | g_signal_connect (webkit_get_favicon_database (), "icon-loaded", | ||
1652 | 3999 | G_CALLBACK (midori_browser_item_icon_loaded_cb), item); | ||
1653 | 4000 | #endif | ||
1654 | 4001 | } | 3671 | } |
1655 | 4002 | 3672 | ||
1656 | 4003 | static void | 3673 | static void |
1657 | @@ -6171,7 +5841,6 @@ | |||
1658 | 6171 | gint icon_size = 16; | 5841 | gint icon_size = 16; |
1659 | 6172 | gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)), | 5842 | gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)), |
1660 | 6173 | GTK_ICON_SIZE_MENU, &icon_size, NULL); | 5843 | GTK_ICON_SIZE_MENU, &icon_size, NULL); |
1661 | 6174 | gtk_widget_set_size_request (throbber_box, icon_size, icon_size); | ||
1662 | 6175 | gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber); | 5844 | gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber); |
1663 | 6176 | gtk_widget_show (throbber_box); | 5845 | gtk_widget_show (throbber_box); |
1664 | 6177 | gtk_container_add (GTK_CONTAINER (menuitem), throbber_box); | 5846 | gtk_container_add (GTK_CONTAINER (menuitem), throbber_box); |
1665 | @@ -6389,17 +6058,6 @@ | |||
1666 | 6389 | gtk_toolbar_style); | 6058 | gtk_toolbar_style); |
1667 | 6390 | } | 6059 | } |
1668 | 6391 | 6060 | ||
1669 | 6392 | #ifndef HAVE_WEBKIT2 | ||
1670 | 6393 | static void | ||
1671 | 6394 | midori_browser_toolbar_popup_context_menu_history_cb (GtkMenuItem* menu_item, | ||
1672 | 6395 | MidoriBrowser* browser) | ||
1673 | 6396 | { | ||
1674 | 6397 | gint steps = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "steps")); | ||
1675 | 6398 | MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser)); | ||
1676 | 6399 | midori_view_go_back_or_forward (view, steps); | ||
1677 | 6400 | } | ||
1678 | 6401 | #endif | ||
1679 | 6402 | |||
1680 | 6403 | static void | 6061 | static void |
1681 | 6404 | midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser, | 6062 | midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser, |
1682 | 6405 | GtkWidget* widget, | 6063 | GtkWidget* widget, |
1683 | @@ -6407,61 +6065,6 @@ | |||
1684 | 6407 | gint x, | 6065 | gint x, |
1685 | 6408 | gint y) | 6066 | gint y) |
1686 | 6409 | { | 6067 | { |
1687 | 6410 | #ifndef HAVE_WEBKIT2 | ||
1688 | 6411 | const gint step = back ? -1 : 1; | ||
1689 | 6412 | gint steps = step; | ||
1690 | 6413 | GtkWidget* menu; | ||
1691 | 6414 | WebKitWebBackForwardList* list; | ||
1692 | 6415 | WebKitWebHistoryItem* current_item; | ||
1693 | 6416 | WebKitWebHistoryItem* history_item; | ||
1694 | 6417 | WebKitWebHistoryItem* (*history_next)(WebKitWebBackForwardList*); | ||
1695 | 6418 | void (*history_action)(WebKitWebBackForwardList*); | ||
1696 | 6419 | |||
1697 | 6420 | list = webkit_web_view_get_back_forward_list ( | ||
1698 | 6421 | WEBKIT_WEB_VIEW (midori_view_get_web_view ( | ||
1699 | 6422 | MIDORI_VIEW (midori_browser_get_current_tab (browser))))); | ||
1700 | 6423 | |||
1701 | 6424 | if (!list) | ||
1702 | 6425 | return; | ||
1703 | 6426 | |||
1704 | 6427 | menu = gtk_menu_new (); | ||
1705 | 6428 | |||
1706 | 6429 | history_action = back ? | ||
1707 | 6430 | webkit_web_back_forward_list_go_back : | ||
1708 | 6431 | webkit_web_back_forward_list_go_forward; | ||
1709 | 6432 | history_next = back ? | ||
1710 | 6433 | webkit_web_back_forward_list_get_back_item : | ||
1711 | 6434 | webkit_web_back_forward_list_get_forward_item; | ||
1712 | 6435 | current_item = webkit_web_back_forward_list_get_current_item (list); | ||
1713 | 6436 | |||
1714 | 6437 | for (; (history_item = history_next (list)); history_action (list), steps += step) | ||
1715 | 6438 | { | ||
1716 | 6439 | const gchar* uri = webkit_web_history_item_get_uri (history_item); | ||
1717 | 6440 | GtkWidget* menu_item = gtk_image_menu_item_new_with_label ( | ||
1718 | 6441 | webkit_web_history_item_get_title (history_item)); | ||
1719 | 6442 | GdkPixbuf* pixbuf; | ||
1720 | 6443 | if ((pixbuf = midori_paths_get_icon (uri, widget))) | ||
1721 | 6444 | { | ||
1722 | 6445 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), | ||
1723 | 6446 | gtk_image_new_from_pixbuf (pixbuf)); | ||
1724 | 6447 | g_object_unref (pixbuf); | ||
1725 | 6448 | } | ||
1726 | 6449 | g_object_set_data (G_OBJECT (menu_item), "uri", (gpointer)uri); | ||
1727 | 6450 | g_object_set_data (G_OBJECT (menu_item), "steps", GINT_TO_POINTER (steps)); | ||
1728 | 6451 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); | ||
1729 | 6452 | g_signal_connect (G_OBJECT (menu_item), "activate", | ||
1730 | 6453 | G_CALLBACK (midori_browser_toolbar_popup_context_menu_history_cb), | ||
1731 | 6454 | browser); | ||
1732 | 6455 | if (steps == (10 - 1)) | ||
1733 | 6456 | break; | ||
1734 | 6457 | } | ||
1735 | 6458 | |||
1736 | 6459 | webkit_web_back_forward_list_go_to_item (list, current_item); | ||
1737 | 6460 | gtk_widget_show_all (menu); | ||
1738 | 6461 | |||
1739 | 6462 | katze_widget_popup (widget, GTK_MENU (menu), NULL, | ||
1740 | 6463 | KATZE_MENU_POSITION_LEFT); | ||
1741 | 6464 | #endif | ||
1742 | 6465 | } | 6068 | } |
1743 | 6466 | 6069 | ||
1744 | 6467 | static void | 6070 | static void |
1745 | @@ -7031,11 +6634,6 @@ | |||
1746 | 7031 | g_return_if_fail (MIDORI_IS_BROWSER (browser)); | 6634 | g_return_if_fail (MIDORI_IS_BROWSER (browser)); |
1747 | 7032 | g_return_if_fail (GTK_IS_WIDGET (view)); | 6635 | g_return_if_fail (GTK_IS_WIDGET (view)); |
1748 | 7033 | 6636 | ||
1749 | 7034 | #ifndef HAVE_WEBKIT2 | ||
1750 | 7035 | if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()), | ||
1751 | 7036 | "midori-session-initialized")) | ||
1752 | 7037 | g_critical ("midori_load_soup_session was not called!"); | ||
1753 | 7038 | #endif | ||
1754 | 7039 | g_signal_emit (browser, signals[ADD_TAB], 0, view); | 6637 | g_signal_emit (browser, signals[ADD_TAB], 0, view); |
1755 | 7040 | } | 6638 | } |
1756 | 7041 | 6639 | ||
1757 | 7042 | 6640 | ||
1758 | === modified file 'midori/midori-browser.h' | |||
1759 | --- midori/midori-browser.h 2015-05-24 00:19:21 +0000 | |||
1760 | +++ midori/midori-browser.h 2016-09-20 20:57:01 +0000 | |||
1761 | @@ -40,11 +40,7 @@ | |||
1762 | 40 | /* Signals */ | 40 | /* Signals */ |
1763 | 41 | void | 41 | void |
1764 | 42 | (*window_object_cleared) (MidoriBrowser* browser, | 42 | (*window_object_cleared) (MidoriBrowser* browser, |
1765 | 43 | #ifndef HAVE_WEBKIT2 | ||
1766 | 44 | WebKitWebFrame* web_frame, | ||
1767 | 45 | #else | ||
1768 | 46 | void* web_frame, | 43 | void* web_frame, |
1769 | 47 | #endif | ||
1770 | 48 | JSContextRef* context, | 44 | JSContextRef* context, |
1771 | 49 | JSObjectRef* window_object); | 45 | JSObjectRef* window_object); |
1772 | 50 | void | 46 | void |
1773 | 51 | 47 | ||
1774 | === modified file 'midori/midori-contextaction.vala' | |||
1775 | --- midori/midori-contextaction.vala 2015-06-06 12:20:44 +0000 | |||
1776 | +++ midori/midori-contextaction.vala 2016-09-20 20:57:01 +0000 | |||
1777 | @@ -70,7 +70,6 @@ | |||
1778 | 70 | warning ("Action %s not known to ContextAction", name); | 70 | warning ("Action %s not known to ContextAction", name); |
1779 | 71 | } | 71 | } |
1780 | 72 | 72 | ||
1781 | 73 | #if HAVE_WEBKIT2 | ||
1782 | 74 | public WebKit.ContextMenu create_webkit_context_menu (WebKit.ContextMenu? default_menu) { | 73 | public WebKit.ContextMenu create_webkit_context_menu (WebKit.ContextMenu? default_menu) { |
1783 | 75 | var menu = default_menu ?? new WebKit.ContextMenu (); | 74 | var menu = default_menu ?? new WebKit.ContextMenu (); |
1784 | 76 | foreach (var action in children) { | 75 | foreach (var action in children) { |
1785 | @@ -90,7 +89,6 @@ | |||
1786 | 90 | } | 89 | } |
1787 | 91 | return menu; | 90 | return menu; |
1788 | 92 | } | 91 | } |
1789 | 93 | #endif | ||
1790 | 94 | 92 | ||
1791 | 95 | Gtk.ToolButton toolitem; | 93 | Gtk.ToolButton toolitem; |
1792 | 96 | public override unowned Gtk.Widget create_tool_item () { | 94 | public override unowned Gtk.Widget create_tool_item () { |
1793 | 97 | 95 | ||
1794 | === modified file 'midori/midori-download.vala' | |||
1795 | --- midori/midori-download.vala 2016-01-15 19:18:17 +0000 | |||
1796 | +++ midori/midori-download.vala 2016-09-20 20:57:01 +0000 | |||
1797 | @@ -16,20 +16,9 @@ | |||
1798 | 16 | namespace Midori { | 16 | namespace Midori { |
1799 | 17 | namespace Download { | 17 | namespace Download { |
1800 | 18 | public static bool is_finished (WebKit.Download download) { | 18 | public static bool is_finished (WebKit.Download download) { |
1801 | 19 | #if !HAVE_WEBKIT2 | ||
1802 | 20 | switch (download.status) { | ||
1803 | 21 | case WebKit.DownloadStatus.FINISHED: | ||
1804 | 22 | case WebKit.DownloadStatus.CANCELLED: | ||
1805 | 23 | case WebKit.DownloadStatus.ERROR: | ||
1806 | 24 | return true; | ||
1807 | 25 | default: | ||
1808 | 26 | return false; | ||
1809 | 27 | } | ||
1810 | 28 | #else | ||
1811 | 29 | if (download.estimated_progress == 1) | 19 | if (download.estimated_progress == 1) |
1812 | 30 | return true; | 20 | return true; |
1813 | 31 | return false; | 21 | return false; |
1814 | 32 | #endif | ||
1815 | 33 | } | 22 | } |
1816 | 34 | 23 | ||
1817 | 35 | public static int get_type (WebKit.Download download) { | 24 | public static int get_type (WebKit.Download download) { |
1818 | @@ -40,90 +29,17 @@ | |||
1819 | 40 | download.set_data<int> ("midori-download-type", type); | 29 | download.set_data<int> ("midori-download-type", type); |
1820 | 41 | } | 30 | } |
1821 | 42 | 31 | ||
1822 | 43 | #if HAVE_WEBKIT2 | ||
1823 | 44 | public static string get_filename (WebKit.Download download) { | 32 | public static string get_filename (WebKit.Download download) { |
1824 | 45 | return download.get_data<string> ("midori-download-filename"); | 33 | return download.get_data<string> ("midori-download-filename"); |
1825 | 46 | } | 34 | } |
1826 | 47 | public static void set_filename (WebKit.Download download, string name) { | 35 | public static void set_filename (WebKit.Download download, string name) { |
1827 | 48 | download.set_data<string> ("midori-download-filename", name); | 36 | download.set_data<string> ("midori-download-filename", name); |
1828 | 49 | } | 37 | } |
1829 | 50 | #endif | ||
1830 | 51 | public static double get_progress (WebKit.Download download) { | 38 | public static double get_progress (WebKit.Download download) { |
1831 | 52 | #if !HAVE_WEBKIT2 | ||
1832 | 53 | /* Avoid a bug in WebKit */ | ||
1833 | 54 | if (download.status == WebKit.DownloadStatus.CREATED) | ||
1834 | 55 | return 0.0; | ||
1835 | 56 | return download.progress; | ||
1836 | 57 | #else | ||
1837 | 58 | return download.estimated_progress; | 39 | return download.estimated_progress; |
1838 | 59 | #endif | ||
1839 | 60 | } | 40 | } |
1840 | 61 | 41 | ||
1841 | 62 | public static string calculate_tooltip (WebKit.Download download) { | 42 | public static string calculate_tooltip (WebKit.Download download) { |
1842 | 63 | #if !HAVE_WEBKIT2 | ||
1843 | 64 | string filename = Midori.Download.get_basename_for_display (download.destination_uri); | ||
1844 | 65 | /* i18n: Download tooltip (size): 4KB of 43MB */ | ||
1845 | 66 | string size = _("%s of %s").printf ( | ||
1846 | 67 | format_size (download.current_size), | ||
1847 | 68 | format_size (download.total_size)); | ||
1848 | 69 | |||
1849 | 70 | /* Finished, no speed or remaining time */ | ||
1850 | 71 | if (is_finished (download) || download.status == WebKit.DownloadStatus.CREATED) | ||
1851 | 72 | return "%s\n%s".printf (filename, size); | ||
1852 | 73 | |||
1853 | 74 | uint64 total_size = download.total_size, current_size = download.current_size; | ||
1854 | 75 | double elapsed = download.get_elapsed_time (), | ||
1855 | 76 | diff = elapsed / current_size, | ||
1856 | 77 | estimated = (total_size - current_size) * diff; | ||
1857 | 78 | int hour = 3600, minute = 60; | ||
1858 | 79 | int hours = (int)(estimated / hour), | ||
1859 | 80 | minutes = (int)((estimated - (hours * hour)) / minute), | ||
1860 | 81 | seconds = (int)((estimated - (hours * hour) - (minutes * minute))); | ||
1861 | 82 | string hours_ = ngettext ("%d hour", "%d hours", hours).printf (hours); | ||
1862 | 83 | string minutes_ = ngettext ("%d minute", "%d minutes", minutes).printf (minutes); | ||
1863 | 84 | string seconds_ = ngettext ("%d second", "%d seconds", seconds).printf (seconds); | ||
1864 | 85 | double last_time = download.get_data<int> ("last-time"); | ||
1865 | 86 | |||
1866 | 87 | string eta = ""; | ||
1867 | 88 | if (estimated > 0) { | ||
1868 | 89 | if (hours > 0) | ||
1869 | 90 | eta = hours_ + ", " + minutes_; | ||
1870 | 91 | else if (minutes >= 10) | ||
1871 | 92 | eta = minutes_; | ||
1872 | 93 | else if (minutes < 10 && minutes > 0) | ||
1873 | 94 | eta = minutes_ + ", " + seconds_; | ||
1874 | 95 | else if (seconds > 0) | ||
1875 | 96 | eta = seconds_; | ||
1876 | 97 | if (eta != "") | ||
1877 | 98 | /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */ | ||
1878 | 99 | eta = _(" - %s remaining").printf (eta); | ||
1879 | 100 | } | ||
1880 | 101 | |||
1881 | 102 | string speed = ""; | ||
1882 | 103 | uint64? last_size = download.get_data<uint64?> ("last-size"); | ||
1883 | 104 | if (last_size != null && elapsed != last_time) { | ||
1884 | 105 | if (current_size != last_size) { | ||
1885 | 106 | speed = format_size ((uint64)( | ||
1886 | 107 | (current_size - last_size) / (elapsed - last_time))); | ||
1887 | 108 | download.set_data ("last-speed", speed.dup ()); | ||
1888 | 109 | } | ||
1889 | 110 | else { | ||
1890 | 111 | speed = download.get_data ("last-speed"); | ||
1891 | 112 | } | ||
1892 | 113 | } | ||
1893 | 114 | else | ||
1894 | 115 | /* i18n: Unknown number of bytes, used for transfer rate like ?B/s */ | ||
1895 | 116 | speed = _("?B"); | ||
1896 | 117 | /* i18n: Download tooltip (transfer rate): (130KB/s) */ | ||
1897 | 118 | speed = _(" (%s/s)").printf (speed); | ||
1898 | 119 | |||
1899 | 120 | if (elapsed - last_time > 0.0) { | ||
1900 | 121 | download.set_data<int> ("last-time", (int)elapsed); | ||
1901 | 122 | download.set_data<uint64?> ("last-size", current_size); | ||
1902 | 123 | } | ||
1903 | 124 | |||
1904 | 125 | return "%s\n%s %s%s".printf (filename, size, speed, eta); | ||
1905 | 126 | #else | ||
1906 | 127 | string filename = Midori.Download.get_basename_for_display (download.destination); | 43 | string filename = Midori.Download.get_basename_for_display (download.destination); |
1907 | 128 | 44 | ||
1908 | 129 | string size = "%s".printf (format_size (download.get_received_data_length ())); | 45 | string size = "%s".printf (format_size (download.get_received_data_length ())); |
1909 | @@ -134,17 +50,12 @@ | |||
1910 | 134 | if (is_finished (download)) | 50 | if (is_finished (download)) |
1911 | 135 | return "%s\n %s".printf (filename, size); | 51 | return "%s\n %s".printf (filename, size); |
1912 | 136 | return "%s\n %s - %s".printf (filename, speed, progress); | 52 | return "%s\n %s - %s".printf (filename, speed, progress); |
1913 | 137 | #endif | ||
1914 | 138 | } | 53 | } |
1915 | 139 | 54 | ||
1916 | 140 | public static string get_content_type (WebKit.Download download, string? mime_type) { | 55 | public static string get_content_type (WebKit.Download download, string? mime_type) { |
1917 | 141 | #if HAVE_WEBKIT2 | ||
1918 | 142 | string? content_type = ContentType.guess (download.response.suggested_filename == null ? | 56 | string? content_type = ContentType.guess (download.response.suggested_filename == null ? |
1919 | 143 | download.destination : download.response.suggested_filename, | 57 | download.destination : download.response.suggested_filename, |
1920 | 144 | null, null); | 58 | null, null); |
1921 | 145 | #else | ||
1922 | 146 | string? content_type = ContentType.guess (download.suggested_filename, null, null); | ||
1923 | 147 | #endif | ||
1924 | 148 | if (content_type == null) { | 59 | if (content_type == null) { |
1925 | 149 | content_type = ContentType.from_mime_type (mime_type); | 60 | content_type = ContentType.from_mime_type (mime_type); |
1926 | 150 | if (content_type == null) | 61 | if (content_type == null) |
1927 | @@ -157,24 +68,14 @@ | |||
1928 | 157 | int status = download.get_data<int> ("checksum-status"); | 68 | int status = download.get_data<int> ("checksum-status"); |
1929 | 158 | if (status == 0) { | 69 | if (status == 0) { |
1930 | 159 | /* Link Fingerprint */ | 70 | /* Link Fingerprint */ |
1931 | 160 | #if HAVE_WEBKIT2 | ||
1932 | 161 | string? original_uri = download.get_request ().uri; | 71 | string? original_uri = download.get_request ().uri; |
1933 | 162 | #else | ||
1934 | 163 | string? original_uri = download.network_request.get_data<string> ("midori-original-uri"); | ||
1935 | 164 | if (original_uri == null) | ||
1936 | 165 | original_uri = download.get_uri (); | ||
1937 | 166 | #endif | ||
1938 | 167 | string? fingerprint; | 72 | string? fingerprint; |
1939 | 168 | ChecksumType checksum_type = URI.get_fingerprint (original_uri, out fingerprint, null); | 73 | ChecksumType checksum_type = URI.get_fingerprint (original_uri, out fingerprint, null); |
1940 | 169 | /* By default, no wrong checksum */ | 74 | /* By default, no wrong checksum */ |
1941 | 170 | status = 2; | 75 | status = 2; |
1942 | 171 | if (fingerprint != null) { | 76 | if (fingerprint != null) { |
1943 | 172 | try { | 77 | try { |
1944 | 173 | #if HAVE_WEBKIT2 | ||
1945 | 174 | string filename = Filename.from_uri (download.destination); | 78 | string filename = Filename.from_uri (download.destination); |
1946 | 175 | #else | ||
1947 | 176 | string filename = Filename.from_uri (download.destination_uri); | ||
1948 | 177 | #endif | ||
1949 | 178 | string contents; | 79 | string contents; |
1950 | 179 | size_t length; | 80 | size_t length; |
1951 | 180 | bool y = FileUtils.get_contents (filename, out contents, out length); | 81 | bool y = FileUtils.get_contents (filename, out contents, out length); |
1952 | @@ -194,62 +95,16 @@ | |||
1953 | 194 | } | 95 | } |
1954 | 195 | 96 | ||
1955 | 196 | public static bool action_clear (WebKit.Download download, Gtk.Widget widget) throws Error { | 97 | public static bool action_clear (WebKit.Download download, Gtk.Widget widget) throws Error { |
1956 | 197 | #if !HAVE_WEBKIT2 | ||
1957 | 198 | switch (download.status) { | ||
1958 | 199 | case WebKit.DownloadStatus.CREATED: | ||
1959 | 200 | case WebKit.DownloadStatus.STARTED: | ||
1960 | 201 | download.cancel (); | ||
1961 | 202 | break; | ||
1962 | 203 | case WebKit.DownloadStatus.FINISHED: | ||
1963 | 204 | if (open (download, widget)) | ||
1964 | 205 | return true; | ||
1965 | 206 | break; | ||
1966 | 207 | case WebKit.DownloadStatus.CANCELLED: | ||
1967 | 208 | return true; | ||
1968 | 209 | default: | ||
1969 | 210 | critical ("action_clear: %d", download.status); | ||
1970 | 211 | warn_if_reached (); | ||
1971 | 212 | break; | ||
1972 | 213 | } | ||
1973 | 214 | #else | ||
1974 | 215 | |||
1975 | 216 | if (download.estimated_progress < 1) { | ||
1976 | 217 | download.cancel (); | ||
1977 | 218 | } else { | ||
1978 | 219 | if (open (download, widget)) | ||
1979 | 220 | return true; | ||
1980 | 221 | } | ||
1981 | 222 | #endif | ||
1982 | 223 | return false; | 98 | return false; |
1983 | 224 | } | 99 | } |
1984 | 225 | 100 | ||
1985 | 226 | public static string action_stock_id (WebKit.Download download) { | 101 | public static string action_stock_id (WebKit.Download download) { |
1986 | 227 | #if !HAVE_WEBKIT2 | ||
1987 | 228 | switch (download.status) { | ||
1988 | 229 | case WebKit.DownloadStatus.CREATED: | ||
1989 | 230 | case WebKit.DownloadStatus.STARTED: | ||
1990 | 231 | return Gtk.Stock.CANCEL; | ||
1991 | 232 | case WebKit.DownloadStatus.FINISHED: | ||
1992 | 233 | if (has_wrong_checksum (download)) | ||
1993 | 234 | return Gtk.Stock.DIALOG_WARNING; | ||
1994 | 235 | return Gtk.Stock.OPEN; | ||
1995 | 236 | case WebKit.DownloadStatus.CANCELLED: | ||
1996 | 237 | return Gtk.Stock.CLEAR; | ||
1997 | 238 | case WebKit.DownloadStatus.ERROR: | ||
1998 | 239 | return Gtk.Stock.DIALOG_ERROR; | ||
1999 | 240 | default: | ||
2000 | 241 | critical ("action_stock_id: %d", download.status); | ||
2001 | 242 | warn_if_reached (); | ||
2002 | 243 | return Gtk.Stock.MISSING_IMAGE; | ||
2003 | 244 | } | ||
2004 | 245 | #else | ||
2005 | 246 | if (download.estimated_progress == 1) | 102 | if (download.estimated_progress == 1) |
2006 | 247 | if (has_wrong_checksum (download)) | 103 | if (has_wrong_checksum (download)) |
2007 | 248 | return Gtk.Stock.DIALOG_WARNING; | 104 | return Gtk.Stock.DIALOG_WARNING; |
2008 | 249 | else | 105 | else |
2009 | 250 | return Gtk.Stock.OPEN; | 106 | return Gtk.Stock.OPEN; |
2010 | 251 | return Gtk.Stock.CANCEL; | 107 | return Gtk.Stock.CANCEL; |
2011 | 252 | #endif | ||
2012 | 253 | } | 108 | } |
2013 | 254 | 109 | ||
2014 | 255 | /* returns whether an application was successfully launched to handle the file */ | 110 | /* returns whether an application was successfully launched to handle the file */ |
2015 | @@ -265,11 +120,7 @@ | |||
2016 | 265 | Tab? tab = null; | 120 | Tab? tab = null; |
2017 | 266 | browser.get ("tab", &tab); | 121 | browser.get ("tab", &tab); |
2018 | 267 | if (tab != null) | 122 | if (tab != null) |
2019 | 268 | #if HAVE_WEBKIT2 | ||
2020 | 269 | return tab.open_uri (download.destination); | 123 | return tab.open_uri (download.destination); |
2021 | 270 | #else | ||
2022 | 271 | return tab.open_uri (download.destination_uri); | ||
2023 | 272 | #endif | ||
2024 | 273 | } | 124 | } |
2025 | 274 | return false; | 125 | return false; |
2026 | 275 | } | 126 | } |
2027 | @@ -297,16 +148,10 @@ | |||
2028 | 297 | } | 148 | } |
2029 | 298 | 149 | ||
2030 | 299 | public string get_suggested_filename (WebKit.Download download) { | 150 | public string get_suggested_filename (WebKit.Download download) { |
2031 | 300 | #if !HAVE_WEBKIT2 | ||
2032 | 301 | /* https://bugs.webkit.org/show_bug.cgi?id=83161 | ||
2033 | 302 | https://d19vezwu8eufl6.cloudfront.net/nlp/slides%2F03-01-FormalizingNB.pdf */ | ||
2034 | 303 | return clean_filename (download.get_suggested_filename ()); | ||
2035 | 304 | #else | ||
2036 | 305 | string name = get_filename (download); | 151 | string name = get_filename (download); |
2037 | 306 | if (name == null) | 152 | if (name == null) |
2038 | 307 | return ""; | 153 | return ""; |
2039 | 308 | return name; | 154 | return name; |
2040 | 309 | #endif | ||
2041 | 310 | } | 155 | } |
2042 | 311 | 156 | ||
2043 | 312 | /** | 157 | /** |
2044 | @@ -397,42 +242,6 @@ | |||
2045 | 397 | * @destination_uri, considering space on disk and permissions | 242 | * @destination_uri, considering space on disk and permissions |
2046 | 398 | */ | 243 | */ |
2047 | 399 | public static bool has_enough_space (WebKit.Download download, string destination_uri, bool quiet=false) { | 244 | public static bool has_enough_space (WebKit.Download download, string destination_uri, bool quiet=false) { |
2048 | 400 | #if !HAVE_WEBKIT2 | ||
2049 | 401 | var folder = File.new_for_uri (destination_uri).get_parent (); | ||
2050 | 402 | bool can_write; | ||
2051 | 403 | uint64 free_space; | ||
2052 | 404 | try { | ||
2053 | 405 | var info = folder.query_filesystem_info ("filesystem::free"); | ||
2054 | 406 | free_space = info.get_attribute_uint64 ("filesystem::free"); | ||
2055 | 407 | info = folder.query_info ("access::can-write", 0); | ||
2056 | 408 | can_write = info.get_attribute_boolean ("access::can-write"); | ||
2057 | 409 | } | ||
2058 | 410 | catch (Error error) { | ||
2059 | 411 | can_write = false; | ||
2060 | 412 | free_space = 0; | ||
2061 | 413 | } | ||
2062 | 414 | |||
2063 | 415 | if (free_space < download.total_size || !can_write) { | ||
2064 | 416 | string message; | ||
2065 | 417 | string detailed_message; | ||
2066 | 418 | if (!can_write) { | ||
2067 | 419 | message = _("The file \"%s\" can't be saved in this folder.").printf ( | ||
2068 | 420 | Midori.Download.get_basename_for_display (destination_uri)); | ||
2069 | 421 | detailed_message = _("You don't have permission to write in this location."); | ||
2070 | 422 | } | ||
2071 | 423 | else if (free_space < download.total_size) { | ||
2072 | 424 | message = _("There is not enough free space to download \"%s\".").printf ( | ||
2073 | 425 | Midori.Download.get_basename_for_display (destination_uri)); | ||
2074 | 426 | detailed_message = _("The file needs %s but only %s are left.").printf ( | ||
2075 | 427 | format_size (download.total_size), format_size (free_space)); | ||
2076 | 428 | } | ||
2077 | 429 | else | ||
2078 | 430 | assert_not_reached (); | ||
2079 | 431 | if (!quiet) | ||
2080 | 432 | Sokoke.message_dialog (Gtk.MessageType.ERROR, message, detailed_message, false); | ||
2081 | 433 | return false; | ||
2082 | 434 | } | ||
2083 | 435 | #endif | ||
2084 | 436 | return true; | 245 | return true; |
2085 | 437 | } | 246 | } |
2086 | 438 | } | 247 | } |
2087 | 439 | 248 | ||
2088 | === modified file 'midori/midori-frontend.c' | |||
2089 | --- midori/midori-frontend.c 2016-01-23 19:21:31 +0000 | |||
2090 | +++ midori/midori-frontend.c 2016-09-20 20:57:01 +0000 | |||
2091 | @@ -175,9 +175,6 @@ | |||
2092 | 175 | guint i; | 175 | guint i; |
2093 | 176 | 176 | ||
2094 | 177 | midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config); | 177 | midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config); |
2095 | 178 | #ifndef HAVE_WEBKIT2 | ||
2096 | 179 | g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1); | ||
2097 | 180 | #endif | ||
2098 | 181 | 178 | ||
2099 | 182 | /* Mask the timezone, which can be read by Javascript */ | 179 | /* Mask the timezone, which can be read by Javascript */ |
2100 | 183 | g_setenv ("TZ", "UTC", TRUE); | 180 | g_setenv ("TZ", "UTC", TRUE); |
2101 | 184 | 181 | ||
2102 | === modified file 'midori/midori-locationaction.c' | |||
2103 | --- midori/midori-locationaction.c 2015-08-10 23:42:56 +0000 | |||
2104 | +++ midori/midori-locationaction.c 2016-09-20 20:57:01 +0000 | |||
2105 | @@ -22,6 +22,7 @@ | |||
2106 | 22 | #include "config.h" | 22 | #include "config.h" |
2107 | 23 | #include <string.h> | 23 | #include <string.h> |
2108 | 24 | #include <glib/gi18n.h> | 24 | #include <glib/gi18n.h> |
2109 | 25 | #include <gdk/gdk.h> | ||
2110 | 25 | #include <gdk/gdkkeysyms.h> | 26 | #include <gdk/gdkkeysyms.h> |
2111 | 26 | 27 | ||
2112 | 27 | #include <sqlite3.h> | 28 | #include <sqlite3.h> |
2113 | @@ -46,6 +47,10 @@ | |||
2114 | 46 | gint completion_index; | 47 | gint completion_index; |
2115 | 47 | GtkWidget* entry; | 48 | GtkWidget* entry; |
2116 | 48 | KatzeArray* history; | 49 | KatzeArray* history; |
2117 | 50 | #if GTK_CHECK_VERSION (3, 18, 0) | ||
2118 | 51 | GdkDevice* device; | ||
2119 | 52 | guint32 time; | ||
2120 | 53 | #endif | ||
2121 | 49 | }; | 54 | }; |
2122 | 50 | 55 | ||
2123 | 51 | struct _MidoriLocationActionClass | 56 | struct _MidoriLocationActionClass |
2124 | @@ -738,6 +743,8 @@ | |||
2125 | 738 | g_signal_connect (popup, "destroy", | 743 | g_signal_connect (popup, "destroy", |
2126 | 739 | G_CALLBACK (gtk_widget_destroyed), &action->popup); | 744 | G_CALLBACK (gtk_widget_destroyed), &action->popup); |
2127 | 740 | gtk_widget_show_all (popup_frame); | 745 | gtk_widget_show_all (popup_frame); |
2128 | 746 | |||
2129 | 747 | gtk_widget_realize (action->popup); | ||
2130 | 741 | } | 748 | } |
2131 | 742 | 749 | ||
2132 | 743 | if (!gtk_widget_get_visible (action->popup)) | 750 | if (!gtk_widget_get_visible (action->popup)) |
2133 | @@ -746,6 +753,21 @@ | |||
2134 | 746 | gtk_window_set_screen (GTK_WINDOW (action->popup), | 753 | gtk_window_set_screen (GTK_WINDOW (action->popup), |
2135 | 747 | gtk_widget_get_screen (action->entry)); | 754 | gtk_widget_get_screen (action->entry)); |
2136 | 748 | gtk_window_set_transient_for (GTK_WINDOW (action->popup), GTK_WINDOW (toplevel)); | 755 | gtk_window_set_transient_for (GTK_WINDOW (action->popup), GTK_WINDOW (toplevel)); |
2137 | 756 | gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), | ||
2138 | 757 | GTK_WINDOW (action->popup)); | ||
2139 | 758 | |||
2140 | 759 | #if GTK_CHECK_VERSION (3, 18, 0) | ||
2141 | 760 | GdkDevice* device = action->device; | ||
2142 | 761 | |||
2143 | 762 | if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) | ||
2144 | 763 | device = gdk_device_get_associated_device (device); | ||
2145 | 764 | |||
2146 | 765 | gdk_device_grab (device, gtk_widget_get_window (action->popup), | ||
2147 | 766 | GDK_OWNERSHIP_WINDOW, TRUE, | ||
2148 | 767 | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, | ||
2149 | 768 | NULL, action->time); | ||
2150 | 769 | #endif | ||
2151 | 770 | |||
2152 | 749 | #if GTK_CHECK_VERSION (3, 4, 0) | 771 | #if GTK_CHECK_VERSION (3, 4, 0) |
2153 | 750 | gtk_window_set_attached_to (GTK_WINDOW (action->popup), action->entry); | 772 | gtk_window_set_attached_to (GTK_WINDOW (action->popup), action->entry); |
2154 | 751 | #endif | 773 | #endif |
2155 | @@ -767,6 +789,10 @@ | |||
2156 | 767 | g_signal_connect (entry, "destroy", | 789 | g_signal_connect (entry, "destroy", |
2157 | 768 | G_CALLBACK (gtk_widget_destroyed), &action->entry); | 790 | G_CALLBACK (gtk_widget_destroyed), &action->entry); |
2158 | 769 | } | 791 | } |
2159 | 792 | #if GTK_CHECK_VERSION (3, 18, 0) | ||
2160 | 793 | action->device = gtk_get_current_event_device (); | ||
2161 | 794 | action->time = gtk_get_current_event_time (); | ||
2162 | 795 | #endif | ||
2163 | 770 | g_idle_add (midori_location_action_popup_timeout_cb, action); | 796 | g_idle_add (midori_location_action_popup_timeout_cb, action); |
2164 | 771 | } | 797 | } |
2165 | 772 | 798 | ||
2166 | @@ -1294,33 +1320,6 @@ | |||
2167 | 1294 | #include <gcr/gcr.h> | 1320 | #include <gcr/gcr.h> |
2168 | 1295 | #endif | 1321 | #endif |
2169 | 1296 | 1322 | ||
2170 | 1297 | #ifndef HAVE_WEBKIT2 | ||
2171 | 1298 | static GHashTable* message_map = NULL; | ||
2172 | 1299 | void | ||
2173 | 1300 | midori_map_add_message (SoupMessage* message) | ||
2174 | 1301 | { | ||
2175 | 1302 | SoupURI* uri = soup_message_get_uri (message); | ||
2176 | 1303 | if (message_map == NULL) | ||
2177 | 1304 | message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); | ||
2178 | 1305 | g_return_if_fail (uri && uri->host); | ||
2179 | 1306 | g_hash_table_insert (message_map, g_strdup (uri->host), g_object_ref (message)); | ||
2180 | 1307 | } | ||
2181 | 1308 | |||
2182 | 1309 | SoupMessage* | ||
2183 | 1310 | midori_map_get_message (SoupMessage* message) | ||
2184 | 1311 | { | ||
2185 | 1312 | SoupURI* uri = soup_message_get_uri (message); | ||
2186 | 1313 | SoupMessage* full; | ||
2187 | 1314 | g_return_val_if_fail (uri && uri->host, message); | ||
2188 | 1315 | if (message_map == NULL) | ||
2189 | 1316 | message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); | ||
2190 | 1317 | full = g_hash_table_lookup (message_map, uri->host); | ||
2191 | 1318 | if (full != NULL) | ||
2192 | 1319 | return full; | ||
2193 | 1320 | return message; | ||
2194 | 1321 | } | ||
2195 | 1322 | #endif | ||
2196 | 1323 | |||
2197 | 1324 | #ifdef HAVE_GCR | 1323 | #ifdef HAVE_GCR |
2198 | 1325 | typedef enum { | 1324 | typedef enum { |
2199 | 1326 | MIDORI_CERT_TRUST, | 1325 | MIDORI_CERT_TRUST, |
2200 | @@ -1458,14 +1457,7 @@ | |||
2201 | 1458 | 1457 | ||
2202 | 1459 | MidoriBrowser* browser = midori_browser_get_for_widget (widget); | 1458 | MidoriBrowser* browser = midori_browser_get_for_widget (widget); |
2203 | 1460 | MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser)); | 1459 | MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser)); |
2204 | 1461 | #ifdef HAVE_WEBKIT2 | ||
2205 | 1462 | void* request = NULL; | 1460 | void* request = NULL; |
2206 | 1463 | #else | ||
2207 | 1464 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); | ||
2208 | 1465 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view); | ||
2209 | 1466 | WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame); | ||
2210 | 1467 | WebKitNetworkRequest* request = webkit_web_data_source_get_request (source); | ||
2211 | 1468 | #endif | ||
2212 | 1469 | midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname); | 1461 | midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname); |
2213 | 1470 | if (tls_cert == NULL) | 1462 | if (tls_cert == NULL) |
2214 | 1471 | { | 1463 | { |
2215 | @@ -1482,12 +1474,10 @@ | |||
2216 | 1482 | der_cert->data, der_cert->len); | 1474 | der_cert->data, der_cert->len); |
2217 | 1483 | g_byte_array_unref (der_cert); | 1475 | g_byte_array_unref (der_cert); |
2218 | 1484 | 1476 | ||
2219 | 1485 | #if GTK_CHECK_VERSION (3, 0, 0) | ||
2220 | 1486 | GtkWidget* details; | 1477 | GtkWidget* details; |
2221 | 1487 | details = (GtkWidget*)gcr_certificate_details_widget_new (gcr_cert); | 1478 | details = (GtkWidget*)gcr_certificate_details_widget_new (gcr_cert); |
2222 | 1488 | gtk_widget_show (details); | 1479 | gtk_widget_show (details); |
2223 | 1489 | gtk_container_add (GTK_CONTAINER (box), details); | 1480 | gtk_container_add (GTK_CONTAINER (box), details); |
2224 | 1490 | #endif | ||
2225 | 1491 | 1481 | ||
2226 | 1492 | #if GTK_CHECK_VERSION (3, 12, 0) | 1482 | #if GTK_CHECK_VERSION (3, 12, 0) |
2227 | 1493 | GtkWidget* button; | 1483 | GtkWidget* button; |
2228 | @@ -1527,10 +1517,6 @@ | |||
2229 | 1527 | g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref); | 1517 | g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref); |
2230 | 1528 | #endif | 1518 | #endif |
2231 | 1529 | 1519 | ||
2232 | 1530 | /* With GTK+2 the scrolled contents can't communicate a natural size to the window */ | ||
2233 | 1531 | #if !GTK_CHECK_VERSION (3, 0, 0) | ||
2234 | 1532 | gtk_window_set_default_size (GTK_WINDOW (dialog), 250, 200); | ||
2235 | 1533 | #endif | ||
2236 | 1534 | if (!g_tls_certificate_get_issuer (tls_cert)) | 1520 | if (!g_tls_certificate_get_issuer (tls_cert)) |
2237 | 1535 | gtk_box_pack_start (box, gtk_label_new (_("Self-signed")), FALSE, FALSE, 0); | 1521 | gtk_box_pack_start (box, gtk_label_new (_("Self-signed")), FALSE, FALSE, 0); |
2238 | 1536 | 1522 | ||
2239 | 1537 | 1523 | ||
2240 | === modified file 'midori/midori-preferences.c' | |||
2241 | --- midori/midori-preferences.c 2015-07-06 21:26:46 +0000 | |||
2242 | +++ midori/midori-preferences.c 2016-09-20 20:57:01 +0000 | |||
2243 | @@ -371,20 +371,6 @@ | |||
2244 | 371 | INDENTED_ADD (button); | 371 | INDENTED_ADD (button); |
2245 | 372 | button = katze_property_proxy (settings, "enable-webgl", NULL); | 372 | button = katze_property_proxy (settings, "enable-webgl", NULL); |
2246 | 373 | gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support")); | 373 | gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support")); |
2247 | 374 | #ifndef HAVE_WEBKIT2 | ||
2248 | 375 | if (parent && MIDORI_IS_BROWSER (parent)) | ||
2249 | 376 | { | ||
2250 | 377 | GtkWidget* tab = midori_browser_get_current_tab (MIDORI_BROWSER (parent)); | ||
2251 | 378 | WebKitWebView* web_view = midori_tab_get_web_view (MIDORI_TAB (tab)); | ||
2252 | 379 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)); | ||
2253 | 380 | JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); | ||
2254 | 381 | gchar* supports_web_gl = sokoke_js_script_eval (js_context, | ||
2255 | 382 | "!!window.WebGLRenderingContext", NULL); | ||
2256 | 383 | if (g_strcmp0 (supports_web_gl, "true")) | ||
2257 | 384 | gtk_widget_hide (button); | ||
2258 | 385 | g_free (supports_web_gl); | ||
2259 | 386 | } | ||
2260 | 387 | #endif | ||
2261 | 388 | SPANNED_ADD (button); | 374 | SPANNED_ADD (button); |
2262 | 389 | button = katze_property_proxy (settings, "zoom-text-and-images", NULL); | 375 | button = katze_property_proxy (settings, "zoom-text-and-images", NULL); |
2263 | 390 | gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images")); | 376 | gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images")); |
2264 | @@ -522,21 +508,6 @@ | |||
2265 | 522 | g_signal_connect_object (settings, "notify::proxy-type", | 508 | g_signal_connect_object (settings, "notify::proxy-type", |
2266 | 523 | G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0); | 509 | G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0); |
2267 | 524 | midori_preferences_notify_proxy_type_cb (settings, NULL, label); | 510 | midori_preferences_notify_proxy_type_cb (settings, NULL, label); |
2268 | 525 | #ifndef HAVE_WEBKIT2 | ||
2269 | 526 | if (soup_session_get_feature (webkit_get_default_session (), SOUP_TYPE_CACHE)) | ||
2270 | 527 | { | ||
2271 | 528 | label = gtk_label_new (_("Web Cache")); | ||
2272 | 529 | gtk_widget_set_tooltip_text (label, _("The maximum size of cached pages on disk")); | ||
2273 | 530 | INDENTED_ADD (label); | ||
2274 | 531 | button = katze_property_proxy (settings, "maximum-cache-size", NULL); | ||
2275 | 532 | gtk_spin_button_set_range (GTK_SPIN_BUTTON (button), 0, G_MAXINT); | ||
2276 | 533 | gtk_widget_set_tooltip_text (button, _("The maximum size of cached pages on disk")); | ||
2277 | 534 | SPANNED_ADD (button); | ||
2278 | 535 | label = gtk_label_new (_("MB")); | ||
2279 | 536 | gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); | ||
2280 | 537 | SPANNED_ADD (label); | ||
2281 | 538 | } | ||
2282 | 539 | #endif | ||
2283 | 540 | /* i18n: This refers to an application, not the 'user agent' string */ | 511 | /* i18n: This refers to an application, not the 'user agent' string */ |
2284 | 541 | label = gtk_label_new (_("Identify as")); | 512 | label = gtk_label_new (_("Identify as")); |
2285 | 542 | gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); | 513 | gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); |
2286 | 543 | 514 | ||
2287 | === modified file 'midori/midori-privatedata.c' | |||
2288 | --- midori/midori-privatedata.c 2015-07-06 21:26:46 +0000 | |||
2289 | +++ midori/midori-privatedata.c 2016-09-20 20:57:01 +0000 | |||
2290 | @@ -281,28 +281,9 @@ | |||
2291 | 281 | static void | 281 | static void |
2292 | 282 | midori_clear_web_cookies_cb (void) | 282 | midori_clear_web_cookies_cb (void) |
2293 | 283 | { | 283 | { |
2294 | 284 | #ifdef HAVE_WEBKIT2 | ||
2295 | 285 | WebKitWebContext* context = webkit_web_context_get_default (); | 284 | WebKitWebContext* context = webkit_web_context_get_default (); |
2296 | 286 | WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); | 285 | WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); |
2297 | 287 | webkit_cookie_manager_delete_all_cookies (cookie_manager); | 286 | webkit_cookie_manager_delete_all_cookies (cookie_manager); |
2298 | 288 | /* FIXME: site data policy */ | ||
2299 | 289 | #else | ||
2300 | 290 | SoupSession* session = webkit_get_default_session (); | ||
2301 | 291 | MidoriWebSettings* settings = g_object_get_data (G_OBJECT (session), "midori-settings"); | ||
2302 | 292 | SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); | ||
2303 | 293 | GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar)); | ||
2304 | 294 | |||
2305 | 295 | /* HTTP Cookies/ Web Cookies */ | ||
2306 | 296 | for (; cookies != NULL; cookies = g_slist_next (cookies)) | ||
2307 | 297 | { | ||
2308 | 298 | const gchar* domain = ((SoupCookie*)cookies->data)->domain; | ||
2309 | 299 | if (midori_web_settings_get_site_data_policy (settings, domain) | ||
2310 | 300 | == MIDORI_SITE_DATA_PRESERVE) | ||
2311 | 301 | continue; | ||
2312 | 302 | soup_cookie_jar_delete_cookie ((SoupCookieJar*)jar, cookies->data); | ||
2313 | 303 | } | ||
2314 | 304 | soup_cookies_free (cookies); | ||
2315 | 305 | #endif | ||
2316 | 306 | 287 | ||
2317 | 307 | /* Local shared objects/ Flash cookies */ | 288 | /* Local shared objects/ Flash cookies */ |
2318 | 308 | if (midori_web_settings_has_plugin_support ()) | 289 | if (midori_web_settings_has_plugin_support ()) |
2319 | @@ -324,17 +305,7 @@ | |||
2320 | 324 | #endif | 305 | #endif |
2321 | 325 | } | 306 | } |
2322 | 326 | 307 | ||
2323 | 327 | #ifdef HAVE_WEBKIT2 | ||
2324 | 328 | /* TODO: clear databases and offline app caches */ | 308 | /* TODO: clear databases and offline app caches */ |
2325 | 329 | #else | ||
2326 | 330 | /* HTML5 databases */ | ||
2327 | 331 | webkit_remove_all_web_databases (); | ||
2328 | 332 | |||
2329 | 333 | /* HTML5 offline application caches */ | ||
2330 | 334 | /* Changing the size implies clearing the cache */ | ||
2331 | 335 | webkit_application_cache_set_maximum_size ( | ||
2332 | 336 | webkit_application_cache_get_maximum_size () - 1); | ||
2333 | 337 | #endif | ||
2334 | 338 | } | 309 | } |
2335 | 339 | 310 | ||
2336 | 340 | static void | 311 | static void |
2337 | @@ -358,17 +329,7 @@ | |||
2338 | 358 | static void | 329 | static void |
2339 | 359 | midori_clear_web_cache_cb (void) | 330 | midori_clear_web_cache_cb (void) |
2340 | 360 | { | 331 | { |
2341 | 361 | #ifdef HAVE_WEBKIT2 | ||
2342 | 362 | webkit_web_context_clear_cache (webkit_web_context_get_default ()); | 332 | webkit_web_context_clear_cache (webkit_web_context_get_default ()); |
2343 | 363 | #else | ||
2344 | 364 | SoupSession* session = webkit_get_default_session (); | ||
2345 | 365 | SoupSessionFeature* feature = soup_session_get_feature (session, SOUP_TYPE_CACHE); | ||
2346 | 366 | gchar* cache = g_build_filename (midori_paths_get_cache_dir (), "web", NULL); | ||
2347 | 367 | soup_cache_clear (SOUP_CACHE (feature)); | ||
2348 | 368 | soup_cache_flush (SOUP_CACHE (feature)); | ||
2349 | 369 | midori_paths_remove_path (cache); | ||
2350 | 370 | g_free (cache); | ||
2351 | 371 | #endif | ||
2352 | 372 | } | 333 | } |
2353 | 373 | 334 | ||
2354 | 374 | void | 335 | void |
2355 | 375 | 336 | ||
2356 | === modified file 'midori/midori-searchaction.c' | |||
2357 | --- midori/midori-searchaction.c 2015-07-06 21:26:46 +0000 | |||
2358 | +++ midori/midori-searchaction.c 2016-09-20 20:57:01 +0000 | |||
2359 | @@ -914,125 +914,8 @@ | |||
2360 | 914 | midori_search_action_get_engine_for_form (WebKitWebView* web_view, | 914 | midori_search_action_get_engine_for_form (WebKitWebView* web_view, |
2361 | 915 | PangoEllipsizeMode ellipsize) | 915 | PangoEllipsizeMode ellipsize) |
2362 | 916 | { | 916 | { |
2480 | 917 | #ifndef HAVE_WEBKIT2 | 917 | // TODO: Implement |
2364 | 918 | WebKitWebFrame* focused_frame; | ||
2365 | 919 | WebKitDOMDocument* doc; | ||
2366 | 920 | WebKitDOMHTMLFormElement* active_form; | ||
2367 | 921 | WebKitDOMHTMLCollection* form_nodes; | ||
2368 | 922 | WebKitDOMElement* active_element; | ||
2369 | 923 | gchar* token_element; | ||
2370 | 924 | const gchar* title; | ||
2371 | 925 | GString* uri_str; | ||
2372 | 926 | gulong form_len; | ||
2373 | 927 | const gchar* action; | ||
2374 | 928 | guint i; | ||
2375 | 929 | KatzeItem* item; | ||
2376 | 930 | gchar** parts; | ||
2377 | 931 | |||
2378 | 932 | focused_frame = webkit_web_view_get_focused_frame (web_view); | ||
2379 | 933 | if (focused_frame == NULL) | ||
2380 | 934 | return NULL; | ||
2381 | 935 | #if WEBKIT_CHECK_VERSION (1, 9, 5) | ||
2382 | 936 | doc = webkit_web_frame_get_dom_document (focused_frame); | ||
2383 | 937 | #else | ||
2384 | 938 | if (focused_frame != webkit_web_view_get_main_frame (web_view)) | ||
2385 | 939 | return NULL; | ||
2386 | 940 | doc = webkit_web_view_get_dom_document (web_view); | ||
2387 | 941 | #endif | ||
2388 | 942 | |||
2389 | 943 | active_element = webkit_dom_html_document_get_active_element ((WebKitDOMHTMLDocument*)doc); | ||
2390 | 944 | if (!WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (active_element)) | ||
2391 | 945 | return NULL; | ||
2392 | 946 | |||
2393 | 947 | active_form = webkit_dom_html_input_element_get_form ((WebKitDOMHTMLInputElement*)active_element); | ||
2394 | 948 | if (!active_form) | ||
2395 | 949 | return NULL; | ||
2396 | 950 | |||
2397 | 951 | token_element = webkit_dom_element_get_attribute (active_element, "name"); | ||
2398 | 952 | |||
2399 | 953 | form_nodes = webkit_dom_html_form_element_get_elements (active_form); | ||
2400 | 954 | form_len = webkit_dom_html_form_element_get_length (active_form); | ||
2401 | 955 | |||
2402 | 956 | /* action NULL or "": relative path */ | ||
2403 | 957 | if ((action = webkit_dom_html_form_element_get_action (active_form)) && *action) | ||
2404 | 958 | uri_str = g_string_new (action); | ||
2405 | 959 | else | ||
2406 | 960 | { | ||
2407 | 961 | gchar* hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL); | ||
2408 | 962 | uri_str = g_string_new ("http://"); | ||
2409 | 963 | g_string_append (uri_str, hostname); | ||
2410 | 964 | g_free (hostname); | ||
2411 | 965 | } | ||
2412 | 966 | g_string_append_c (uri_str, '?'); | ||
2413 | 967 | |||
2414 | 968 | for (i = 0; i < form_len; i++) | ||
2415 | 969 | { | ||
2416 | 970 | WebKitDOMNode* form_node = webkit_dom_html_collection_item (form_nodes, i); | ||
2417 | 971 | WebKitDOMElement* form_element = (WebKitDOMElement*) form_node; | ||
2418 | 972 | gchar* name = webkit_dom_element_get_attribute (form_element, "name"); | ||
2419 | 973 | |||
2420 | 974 | if (name && *name) | ||
2421 | 975 | { | ||
2422 | 976 | if (!g_strcmp0 (token_element, name)) | ||
2423 | 977 | g_string_append_printf (uri_str, "%s=%s&", name, "\%s"); | ||
2424 | 978 | else | ||
2425 | 979 | { | ||
2426 | 980 | gchar* value; | ||
2427 | 981 | if (!g_strcmp0 (webkit_dom_element_get_tag_name (form_element), "SELECT")) | ||
2428 | 982 | { | ||
2429 | 983 | WebKitDOMHTMLSelectElement* select_element = (WebKitDOMHTMLSelectElement*) form_element; | ||
2430 | 984 | gulong pos = webkit_dom_html_select_element_get_selected_index (select_element); | ||
2431 | 985 | WebKitDOMNode* selected_node = webkit_dom_html_select_element_item (select_element, pos); | ||
2432 | 986 | WebKitDOMElement* selected_element = (WebKitDOMElement*) selected_node; | ||
2433 | 987 | |||
2434 | 988 | value = webkit_dom_element_get_attribute (selected_element, "value"); | ||
2435 | 989 | } | ||
2436 | 990 | else | ||
2437 | 991 | value = webkit_dom_element_get_attribute (form_element, "value"); | ||
2438 | 992 | |||
2439 | 993 | g_string_append_printf (uri_str, "%s=%s&", name, value); | ||
2440 | 994 | g_free (value); | ||
2441 | 995 | } | ||
2442 | 996 | g_free (name); | ||
2443 | 997 | } | ||
2444 | 998 | } | ||
2445 | 999 | |||
2446 | 1000 | if (!(title = webkit_web_view_get_title (web_view))) | ||
2447 | 1001 | title = webkit_web_view_get_uri (web_view); | ||
2448 | 1002 | |||
2449 | 1003 | item = katze_item_new (); | ||
2450 | 1004 | item->uri = g_string_free (uri_str, FALSE); | ||
2451 | 1005 | item->token = midori_search_action_token_for_uri (webkit_web_view_get_uri (web_view)); | ||
2452 | 1006 | |||
2453 | 1007 | if (strstr (title, " - ")) | ||
2454 | 1008 | parts = g_strsplit (title, " - ", 2); | ||
2455 | 1009 | else if (strstr (title, ": ")) | ||
2456 | 1010 | parts = g_strsplit (title, ": ", 2); | ||
2457 | 1011 | else | ||
2458 | 1012 | parts = NULL; | ||
2459 | 1013 | if (parts != NULL) | ||
2460 | 1014 | { | ||
2461 | 1015 | /* See midori_view_set_title: title can be first or last */ | ||
2462 | 1016 | if (ellipsize == PANGO_ELLIPSIZE_END) | ||
2463 | 1017 | { | ||
2464 | 1018 | katze_item_set_name (item, parts[0]); | ||
2465 | 1019 | katze_item_set_text (item, parts[1]); | ||
2466 | 1020 | } | ||
2467 | 1021 | else | ||
2468 | 1022 | { | ||
2469 | 1023 | katze_item_set_name (item, parts[1]); | ||
2470 | 1024 | katze_item_set_text (item, parts[2]); | ||
2471 | 1025 | } | ||
2472 | 1026 | g_strfreev (parts); | ||
2473 | 1027 | } | ||
2474 | 1028 | else | ||
2475 | 1029 | katze_item_set_name (item, title); | ||
2476 | 1030 | |||
2477 | 1031 | g_free (token_element); | ||
2478 | 1032 | return item; | ||
2479 | 1033 | #else | ||
2481 | 1034 | return NULL; | 918 | return NULL; |
2482 | 1035 | #endif | ||
2483 | 1036 | } | 919 | } |
2484 | 1037 | 920 | ||
2485 | 1038 | void | 921 | void |
2486 | 1039 | 922 | ||
2487 | === modified file 'midori/midori-session.c' | |||
2488 | --- midori/midori-session.c 2015-03-23 11:33:24 +0000 | |||
2489 | +++ midori/midori-session.c 2016-09-20 20:57:01 +0000 | |||
2490 | @@ -17,300 +17,34 @@ | |||
2491 | 17 | #include "sokoke.h" | 17 | #include "sokoke.h" |
2492 | 18 | 18 | ||
2493 | 19 | #include <glib/gi18n-lib.h> | 19 | #include <glib/gi18n-lib.h> |
2572 | 20 | #include <libsoup/soup-cookie-jar-sqlite.h> | 20 | #include <libsoup/soup-cookie-jar-db.h> |
2573 | 21 | #include <libsoup/soup-gnome-features.h> | 21 | #define LIBSOUP_USE_UNSTABLE_REQUEST_API |
2574 | 22 | 22 | #include <libsoup/soup-cache.h> | |
2575 | 23 | #define LIBSOUP_USE_UNSTABLE_REQUEST_API | 23 | |
2498 | 24 | #include <libsoup/soup-cache.h> | ||
2499 | 25 | |||
2500 | 26 | #ifndef HAVE_WEBKIT2 | ||
2501 | 27 | static void | ||
2502 | 28 | midori_soup_session_set_proxy_uri (SoupSession* session, | ||
2503 | 29 | const gchar* uri) | ||
2504 | 30 | { | ||
2505 | 31 | SoupURI* proxy_uri; | ||
2506 | 32 | |||
2507 | 33 | /* soup_uri_new expects a non-NULL string with a protocol */ | ||
2508 | 34 | gchar* scheme = uri ? g_uri_parse_scheme (uri): NULL; | ||
2509 | 35 | if (scheme) | ||
2510 | 36 | { | ||
2511 | 37 | proxy_uri = soup_uri_new (uri); | ||
2512 | 38 | g_free (scheme); | ||
2513 | 39 | } | ||
2514 | 40 | else if (uri && *uri) | ||
2515 | 41 | { | ||
2516 | 42 | gchar* fixed_uri = g_strconcat ("http://", uri, NULL); | ||
2517 | 43 | proxy_uri = soup_uri_new (fixed_uri); | ||
2518 | 44 | g_free (fixed_uri); | ||
2519 | 45 | } | ||
2520 | 46 | else | ||
2521 | 47 | proxy_uri = NULL; | ||
2522 | 48 | g_object_set (session, "proxy-uri", proxy_uri, NULL); | ||
2523 | 49 | if (proxy_uri) | ||
2524 | 50 | soup_uri_free (proxy_uri); | ||
2525 | 51 | } | ||
2526 | 52 | |||
2527 | 53 | static void | ||
2528 | 54 | soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings, | ||
2529 | 55 | GParamSpec* pspec, | ||
2530 | 56 | SoupSession* session) | ||
2531 | 57 | { | ||
2532 | 58 | gboolean uses_proxy = TRUE; | ||
2533 | 59 | MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type"); | ||
2534 | 60 | if (proxy_type == MIDORI_PROXY_AUTOMATIC) | ||
2535 | 61 | { | ||
2536 | 62 | soup_session_add_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME); | ||
2537 | 63 | |||
2538 | 64 | GProxyResolver* resolver = g_proxy_resolver_get_default (); | ||
2539 | 65 | gchar** proxies = g_proxy_resolver_lookup (resolver, "none", NULL, NULL); | ||
2540 | 66 | |||
2541 | 67 | if (!proxies || !g_strcmp0 (proxies[0], "direct://")) | ||
2542 | 68 | uses_proxy = FALSE; | ||
2543 | 69 | g_strfreev (proxies); | ||
2544 | 70 | } | ||
2545 | 71 | else if (proxy_type == MIDORI_PROXY_HTTP) | ||
2546 | 72 | { | ||
2547 | 73 | soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME); | ||
2548 | 74 | gchar* proxy = katze_object_get_string (settings, "http-proxy"); | ||
2549 | 75 | GString* http_proxy = g_string_new (proxy); | ||
2550 | 76 | g_string_append_printf (http_proxy, ":%d", katze_object_get_int (settings, "http-proxy-port")); | ||
2551 | 77 | midori_soup_session_set_proxy_uri (session, http_proxy->str); | ||
2552 | 78 | g_string_free (http_proxy, TRUE); | ||
2553 | 79 | g_free (proxy); | ||
2554 | 80 | } | ||
2555 | 81 | else | ||
2556 | 82 | { | ||
2557 | 83 | uses_proxy = FALSE; | ||
2558 | 84 | soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME); | ||
2559 | 85 | midori_soup_session_set_proxy_uri (session, NULL); | ||
2560 | 86 | } | ||
2561 | 87 | |||
2562 | 88 | /* If a proxy server looks to be active, we disable prefetching, otherwise | ||
2563 | 89 | libSoup may be prefetching outside the proxy server beyond our control. | ||
2564 | 90 | */ | ||
2565 | 91 | |||
2566 | 92 | if (uses_proxy) | ||
2567 | 93 | g_object_set (settings, "enable-dns-prefetching", FALSE, NULL); | ||
2568 | 94 | } | ||
2569 | 95 | #endif | ||
2570 | 96 | |||
2571 | 97 | #if WEBKIT_CHECK_VERSION (1, 1, 21) | ||
2576 | 98 | static void | 24 | static void |
2577 | 99 | soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings, | 25 | soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings, |
2578 | 100 | GParamSpec* pspec, | 26 | GParamSpec* pspec, |
2579 | 101 | gpointer user_data) | 27 | gpointer user_data) |
2580 | 102 | { | 28 | { |
2581 | 103 | gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only"); | 29 | gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only"); |
2582 | 104 | #ifdef HAVE_WEBKIT2 | ||
2583 | 105 | WebKitWebContext* context = webkit_web_context_get_default (); | 30 | WebKitWebContext* context = webkit_web_context_get_default (); |
2584 | 106 | WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); | 31 | WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); |
2585 | 107 | webkit_cookie_manager_set_accept_policy (cookie_manager, | 32 | webkit_cookie_manager_set_accept_policy (cookie_manager, |
2586 | 108 | yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY | 33 | yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY |
2587 | 109 | : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); | 34 | : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); |
2655 | 110 | #else | 35 | } |
2589 | 111 | SoupSession* session = webkit_get_default_session (); | ||
2590 | 112 | gpointer jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); | ||
2591 | 113 | g_object_set (jar, "accept-policy", | ||
2592 | 114 | yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY | ||
2593 | 115 | : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL); | ||
2594 | 116 | #endif | ||
2595 | 117 | } | ||
2596 | 118 | #endif | ||
2597 | 119 | |||
2598 | 120 | #if !defined (HAVE_WEBKIT2) | ||
2599 | 121 | /* Implemented in MidoriLocationAction */ | ||
2600 | 122 | void | ||
2601 | 123 | midori_map_add_message (SoupMessage* message); | ||
2602 | 124 | |||
2603 | 125 | static void | ||
2604 | 126 | midori_soup_session_request_started_cb (SoupSession* session, | ||
2605 | 127 | SoupMessage* message, | ||
2606 | 128 | SoupSocket* socket, | ||
2607 | 129 | gpointer user_data) | ||
2608 | 130 | { | ||
2609 | 131 | midori_map_add_message (message); | ||
2610 | 132 | } | ||
2611 | 133 | #endif | ||
2612 | 134 | |||
2613 | 135 | #ifndef HAVE_WEBKIT2 | ||
2614 | 136 | const gchar* | ||
2615 | 137 | midori_web_settings_get_accept_language (MidoriWebSettings* settings); | ||
2616 | 138 | |||
2617 | 139 | static void | ||
2618 | 140 | midori_soup_session_settings_accept_language_cb (SoupSession* session, | ||
2619 | 141 | SoupMessage* msg, | ||
2620 | 142 | MidoriWebSettings* settings) | ||
2621 | 143 | { | ||
2622 | 144 | const gchar* accept = midori_web_settings_get_accept_language (settings); | ||
2623 | 145 | soup_message_headers_append (msg->request_headers, "Accept-Language", accept); | ||
2624 | 146 | |||
2625 | 147 | if (katze_object_get_boolean (settings, "strip-referer")) | ||
2626 | 148 | { | ||
2627 | 149 | const gchar* referer | ||
2628 | 150 | = soup_message_headers_get_one (msg->request_headers, "Referer"); | ||
2629 | 151 | SoupURI* destination = soup_message_get_uri (msg); | ||
2630 | 152 | SoupURI* stripped_uri; | ||
2631 | 153 | if (referer && destination && !strstr (referer, destination->host) | ||
2632 | 154 | && (stripped_uri = soup_uri_new (referer))) | ||
2633 | 155 | { | ||
2634 | 156 | gchar* stripped_referer; | ||
2635 | 157 | soup_uri_set_path (stripped_uri, ""); | ||
2636 | 158 | soup_uri_set_query (stripped_uri, NULL); | ||
2637 | 159 | stripped_referer = soup_uri_to_string (stripped_uri, FALSE); | ||
2638 | 160 | soup_uri_free (stripped_uri); | ||
2639 | 161 | if (strcmp (stripped_referer, referer)) | ||
2640 | 162 | { | ||
2641 | 163 | if (midori_debug ("referer")) | ||
2642 | 164 | g_message ("Referer '%s' stripped to '%s'", referer, stripped_referer); | ||
2643 | 165 | soup_message_headers_replace (msg->request_headers, "Referer", | ||
2644 | 166 | stripped_referer); | ||
2645 | 167 | } | ||
2646 | 168 | g_free (stripped_referer); | ||
2647 | 169 | } | ||
2648 | 170 | |||
2649 | 171 | /* With HTTP, Host is optional. Strip to outsmart some filter proxies */ | ||
2650 | 172 | if (destination && destination->scheme == SOUP_URI_SCHEME_HTTP) | ||
2651 | 173 | soup_message_headers_remove (msg->request_headers, "Host"); | ||
2652 | 174 | } | ||
2653 | 175 | } | ||
2654 | 176 | #endif | ||
2656 | 177 | 36 | ||
2657 | 178 | gboolean | 37 | gboolean |
2658 | 179 | midori_load_soup_session (gpointer settings) | 38 | midori_load_soup_session (gpointer settings) |
2659 | 180 | { | 39 | { |
2660 | 181 | #if WEBKIT_CHECK_VERSION (1, 1, 21) | ||
2661 | 182 | g_signal_connect (settings, "notify::first-party-cookies-only", | 40 | g_signal_connect (settings, "notify::first-party-cookies-only", |
2662 | 183 | G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL); | 41 | G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL); |
2663 | 184 | #endif | ||
2664 | 185 | |||
2665 | 186 | #ifndef HAVE_WEBKIT2 | ||
2666 | 187 | SoupSession* session = webkit_get_default_session (); | ||
2667 | 188 | |||
2668 | 189 | #ifndef G_OS_WIN32 | ||
2669 | 190 | g_object_set (session, | ||
2670 | 191 | "ssl-use-system-ca-file", TRUE, | ||
2671 | 192 | "ssl-strict", FALSE, | ||
2672 | 193 | NULL); | ||
2673 | 194 | #else /* G_OS_WIN32 */ | ||
2674 | 195 | /* We cannot use "ssl-use-system-ca-file" on Windows | ||
2675 | 196 | * some GTLS backend pieces are missing currently. | ||
2676 | 197 | * Instead we specify the bundle we ship ourselves */ | ||
2677 | 198 | gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt"); | ||
2678 | 199 | g_object_set (session, | ||
2679 | 200 | "ssl-ca-file", certificate_file, | ||
2680 | 201 | "ssl-strict", FALSE, | ||
2681 | 202 | NULL); | ||
2682 | 203 | g_free (certificate_file); | ||
2683 | 204 | #endif | ||
2684 | 205 | |||
2685 | 206 | g_object_set_data (G_OBJECT (session), "midori-settings", settings); | ||
2686 | 207 | soup_session_settings_notify_http_proxy_cb (settings, NULL, session); | ||
2687 | 208 | g_signal_connect (settings, "notify::http-proxy", | ||
2688 | 209 | G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session); | ||
2689 | 210 | g_signal_connect (settings, "notify::proxy-type", | ||
2690 | 211 | G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session); | ||
2691 | 212 | |||
2692 | 213 | g_signal_connect (session, "request-started", | ||
2693 | 214 | G_CALLBACK (midori_soup_session_request_started_cb), session); | ||
2694 | 215 | g_signal_connect (session, "request-queued", | ||
2695 | 216 | G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings); | ||
2696 | 217 | |||
2697 | 218 | soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ())); | ||
2698 | 219 | |||
2699 | 220 | if (midori_debug ("headers")) | ||
2700 | 221 | { | ||
2701 | 222 | SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1); | ||
2702 | 223 | soup_logger_attach (logger, session); | ||
2703 | 224 | g_object_unref (logger); | ||
2704 | 225 | } | ||
2705 | 226 | else if (midori_debug ("body")) | ||
2706 | 227 | { | ||
2707 | 228 | SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1); | ||
2708 | 229 | soup_logger_attach (logger, session); | ||
2709 | 230 | g_object_unref (logger); | ||
2710 | 231 | } | ||
2711 | 232 | |||
2712 | 233 | g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1); | ||
2713 | 234 | #endif | ||
2714 | 235 | return FALSE; | 42 | return FALSE; |
2715 | 236 | } | 43 | } |
2716 | 237 | 44 | ||
2717 | 238 | #ifndef HAVE_WEBKIT2 | ||
2718 | 239 | static void | ||
2719 | 240 | midori_session_cookie_jar_changed_cb (SoupCookieJar* jar, | ||
2720 | 241 | SoupCookie* old_cookie, | ||
2721 | 242 | SoupCookie* new_cookie, | ||
2722 | 243 | MidoriWebSettings* settings) | ||
2723 | 244 | { | ||
2724 | 245 | |||
2725 | 246 | if (midori_debug ("cookies")) | ||
2726 | 247 | { | ||
2727 | 248 | gchar* old = old_cookie ? soup_cookie_to_cookie_header (old_cookie) : NULL; | ||
2728 | 249 | gchar* new = new_cookie ? soup_cookie_to_cookie_header (new_cookie) : NULL; | ||
2729 | 250 | g_print ("cookie changed from %s to %s\n", old, new); | ||
2730 | 251 | g_free (old); | ||
2731 | 252 | g_free (new); | ||
2732 | 253 | } | ||
2733 | 254 | |||
2734 | 255 | /* Don't allow revival of expiring cookies */ | ||
2735 | 256 | if (new_cookie && old_cookie && old_cookie->expires) | ||
2736 | 257 | soup_cookie_set_expires (new_cookie, old_cookie->expires); | ||
2737 | 258 | |||
2738 | 259 | if (new_cookie && new_cookie->expires) | ||
2739 | 260 | { | ||
2740 | 261 | time_t expires = soup_date_to_time_t (new_cookie->expires); | ||
2741 | 262 | gint age = katze_object_get_int (settings, "maximum-cookie-age"); | ||
2742 | 263 | /* An age of 0 to SoupCookie means already-expired | ||
2743 | 264 | A user choosing 0 days probably expects 1 hour. | ||
2744 | 265 | */ | ||
2745 | 266 | int seconds = age > 0 ? age * SOUP_COOKIE_MAX_AGE_ONE_DAY : SOUP_COOKIE_MAX_AGE_ONE_HOUR; | ||
2746 | 267 | SoupDate* max_date = soup_date_new_from_now (seconds); | ||
2747 | 268 | if (expires > soup_date_to_time_t (max_date)) | ||
2748 | 269 | { | ||
2749 | 270 | if (midori_debug ("cookies")) | ||
2750 | 271 | { | ||
2751 | 272 | gchar* new_date = soup_date_to_string (max_date, SOUP_DATE_COOKIE); | ||
2752 | 273 | g_print ("^^ enforcing expiry: %s\n", new_date); | ||
2753 | 274 | g_free (new_date); | ||
2754 | 275 | } | ||
2755 | 276 | soup_cookie_set_expires (new_cookie, max_date); | ||
2756 | 277 | } | ||
2757 | 278 | soup_date_free (max_date); | ||
2758 | 279 | } | ||
2759 | 280 | } | ||
2760 | 281 | #endif | ||
2761 | 282 | |||
2762 | 283 | gboolean | 45 | gboolean |
2763 | 284 | midori_load_soup_session_full (gpointer settings) | 46 | midori_load_soup_session_full (gpointer settings) |
2764 | 285 | { | 47 | { |
2765 | 286 | #ifndef HAVE_WEBKIT2 | ||
2766 | 287 | SoupSession* session = webkit_get_default_session (); | ||
2767 | 288 | SoupCookieJar* jar; | ||
2768 | 289 | gchar* config_file; | ||
2769 | 290 | SoupSessionFeature* feature; | ||
2770 | 291 | |||
2771 | 292 | midori_load_soup_session (settings); | ||
2772 | 293 | |||
2773 | 294 | config_file = midori_paths_get_config_filename_for_writing ("logins"); | ||
2774 | 295 | feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL); | ||
2775 | 296 | soup_session_add_feature (session, feature); | ||
2776 | 297 | g_object_unref (feature); | ||
2777 | 298 | |||
2778 | 299 | katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db")); | ||
2779 | 300 | jar = soup_cookie_jar_sqlite_new (config_file, FALSE); | ||
2780 | 301 | soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar)); | ||
2781 | 302 | g_signal_connect (jar, "changed", | ||
2782 | 303 | G_CALLBACK (midori_session_cookie_jar_changed_cb), settings); | ||
2783 | 304 | g_object_unref (jar); | ||
2784 | 305 | |||
2785 | 306 | katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL)); | ||
2786 | 307 | feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0)); | ||
2787 | 308 | soup_session_add_feature (session, feature); | ||
2788 | 309 | soup_cache_set_max_size (SOUP_CACHE (feature), | ||
2789 | 310 | katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024); | ||
2790 | 311 | soup_cache_load (SOUP_CACHE (feature)); | ||
2791 | 312 | g_free (config_file); | ||
2792 | 313 | #endif | ||
2793 | 314 | return FALSE; | 48 | return FALSE; |
2794 | 315 | } | 49 | } |
2795 | 316 | 50 | ||
2796 | 317 | 51 | ||
2797 | === modified file 'midori/midori-settings.vala' | |||
2798 | --- midori/midori-settings.vala 2013-11-24 21:50:38 +0000 | |||
2799 | +++ midori/midori-settings.vala 2016-09-20 20:57:01 +0000 | |||
2800 | @@ -19,23 +19,6 @@ | |||
2801 | 19 | FULLSCREEN | 19 | FULLSCREEN |
2802 | 20 | } | 20 | } |
2803 | 21 | /* Since: 0.1.3 */ | 21 | /* Since: 0.1.3 */ |
2804 | 22 | #if !HAVE_WEBKIT2 | ||
2805 | 23 | public class Settings : WebKit.WebSettings { | ||
2806 | 24 | /* Since: 0.5.0 */ | ||
2807 | 25 | public bool enable_javascript { get { | ||
2808 | 26 | return enable_scripts; | ||
2809 | 27 | } set { | ||
2810 | 28 | enable_scripts = value; | ||
2811 | 29 | } } | ||
2812 | 30 | /* Since: 0.5.1 */ | ||
2813 | 31 | public string default_charset { owned get { | ||
2814 | 32 | return default_encoding; | ||
2815 | 33 | } set { | ||
2816 | 34 | default_encoding = value; | ||
2817 | 35 | } } | ||
2818 | 36 | /* Since: 0.1.3 */ | ||
2819 | 37 | public bool zoom_text_and_images { get; set; default = true; } | ||
2820 | 38 | #else | ||
2821 | 39 | public class Settings : WebKit.Settings { | 22 | public class Settings : WebKit.Settings { |
2822 | 40 | public bool zoom_text_and_images { get { | 23 | public bool zoom_text_and_images { get { |
2823 | 41 | return !zoom_text_only; | 24 | return !zoom_text_only; |
2824 | @@ -47,7 +30,6 @@ | |||
2825 | 47 | } set { | 30 | } set { |
2826 | 48 | WebKit.WebContext.get_default ().set_spell_checking_enabled (value); | 31 | WebKit.WebContext.get_default ().set_spell_checking_enabled (value); |
2827 | 49 | } } | 32 | } } |
2828 | 50 | #endif | ||
2829 | 51 | public bool remember_last_window_size { get; set; default = true; } | 33 | public bool remember_last_window_size { get; set; default = true; } |
2830 | 52 | public int last_window_width { get; set; default = 0; } | 34 | public int last_window_width { get; set; default = 0; } |
2831 | 53 | public int last_window_height { get; set; default = 0; } | 35 | public int last_window_height { get; set; default = 0; } |
2832 | @@ -62,6 +44,9 @@ | |||
2833 | 62 | /* Since: 0.1.3 */ | 44 | /* Since: 0.1.3 */ |
2834 | 63 | public WindowState last_window_state { get; set; default = WindowState.NORMAL; } | 45 | public WindowState last_window_state { get; set; default = WindowState.NORMAL; } |
2835 | 64 | 46 | ||
2836 | 47 | GLib.HashTable<string, WebKit.UserStyleSheet> user_stylesheets; | ||
2837 | 48 | public WebKit.UserContentManager user_content_manager { get; private set; default = new WebKit.UserContentManager(); } | ||
2838 | 49 | |||
2839 | 65 | /* Since: 0.4.8 */ | 50 | /* Since: 0.4.8 */ |
2840 | 66 | public uint inactivity_reset { get; set; default = 0; } | 51 | public uint inactivity_reset { get; set; default = 0; } |
2841 | 67 | 52 | ||
2842 | @@ -90,21 +75,7 @@ | |||
2843 | 90 | public string? block_uris { get { | 75 | public string? block_uris { get { |
2844 | 91 | return block_uris_regex != null ? block_uris_regex.get_pattern () : null; | 76 | return block_uris_regex != null ? block_uris_regex.get_pattern () : null; |
2845 | 92 | } set { | 77 | } set { |
2861 | 93 | #if !HAVE_WEBKIT2 | 78 | // TODO: Implement |
2847 | 94 | if (value == null || value == "") | ||
2848 | 95 | return; | ||
2849 | 96 | if (block_uris_regex == null) | ||
2850 | 97 | WebKit.get_default_session ().request_queued.connect ((msg) => { | ||
2851 | 98 | if (block_uris_regex.match (msg.uri.to_string (false))) | ||
2852 | 99 | msg.uri = new Soup.URI ("http://.invalid"); | ||
2853 | 100 | }); | ||
2854 | 101 | try { | ||
2855 | 102 | block_uris_regex = new GLib.Regex (value); | ||
2856 | 103 | } | ||
2857 | 104 | catch (Error error) { | ||
2858 | 105 | critical ("block-uris: %s", error.message); | ||
2859 | 106 | } | ||
2860 | 107 | #endif | ||
2862 | 108 | } } | 79 | } } |
2863 | 109 | 80 | ||
2864 | 110 | /** | 81 | /** |
2865 | @@ -189,5 +160,37 @@ | |||
2866 | 189 | || property == "user-stylesheet-uri" | 160 | || property == "user-stylesheet-uri" |
2867 | 190 | || property.has_suffix ("-width"); | 161 | || property.has_suffix ("-width"); |
2868 | 191 | } | 162 | } |
2869 | 163 | |||
2870 | 164 | /* Adds a stylesheet to midori settings. Since: 0.5.12 */ | ||
2871 | 165 | public void add_style (string rule_id, string style) | ||
2872 | 166 | { | ||
2873 | 167 | if (user_stylesheets == null) | ||
2874 | 168 | user_stylesheets = new GLib.HashTable<string, WebKit.UserStyleSheet>(str_hash, str_equal); | ||
2875 | 169 | |||
2876 | 170 | var ss = new WebKit.UserStyleSheet(style, | ||
2877 | 171 | WebKit.UserContentInjectedFrames.ALL_FRAMES, | ||
2878 | 172 | WebKit.UserStyleLevel.USER, | ||
2879 | 173 | null, null); | ||
2880 | 174 | user_stylesheets[rule_id]=ss; | ||
2881 | 175 | user_content_manager.add_style_sheet (ss); | ||
2882 | 176 | } | ||
2883 | 177 | |||
2884 | 178 | /* Removes a stylesheet from midori settings. Since: 0.5.12 */ | ||
2885 | 179 | public void remove_style (string rule_id) | ||
2886 | 180 | { | ||
2887 | 181 | if (user_stylesheets != null) | ||
2888 | 182 | { | ||
2889 | 183 | if (user_stylesheets.contains (rule_id)) | ||
2890 | 184 | { | ||
2891 | 185 | user_stylesheets.remove (rule_id); | ||
2892 | 186 | |||
2893 | 187 | /* the API is rather silly: we have to remove all sheets and re-add all others */ | ||
2894 | 188 | user_content_manager.remove_all_style_sheets (); | ||
2895 | 189 | user_stylesheets.foreach((key, ss) => { | ||
2896 | 190 | user_content_manager.add_style_sheet (ss); | ||
2897 | 191 | }); | ||
2898 | 192 | } | ||
2899 | 193 | } | ||
2900 | 194 | } | ||
2901 | 192 | } | 195 | } |
2902 | 193 | } | 196 | } |
2903 | 194 | 197 | ||
2904 | === modified file 'midori/midori-speeddial.vala' | |||
2905 | --- midori/midori-speeddial.vala 2015-06-11 22:33:48 +0000 | |||
2906 | +++ midori/midori-speeddial.vala 2016-09-20 20:57:01 +0000 | |||
2907 | @@ -32,10 +32,6 @@ | |||
2908 | 32 | string filename; | 32 | string filename; |
2909 | 33 | string? html = null; | 33 | string? html = null; |
2910 | 34 | List<Spec> thumb_queue = null; | 34 | List<Spec> thumb_queue = null; |
2911 | 35 | #if !HAVE_WEBKIT2 | ||
2912 | 36 | WebKit.WebView thumb_view = null; | ||
2913 | 37 | Spec? spec = null; | ||
2914 | 38 | #endif | ||
2915 | 39 | 35 | ||
2916 | 40 | public GLib.KeyFile keyfile; | 36 | public GLib.KeyFile keyfile; |
2917 | 41 | public bool close_buttons_left { get; set; default = false; } | 37 | public bool close_buttons_left { get; set; default = false; } |
2918 | @@ -340,86 +336,7 @@ | |||
2919 | 340 | refresh (); | 336 | refresh (); |
2920 | 341 | } | 337 | } |
2921 | 342 | 338 | ||
2922 | 343 | #if !HAVE_WEBKIT2 | ||
2923 | 344 | void load_status (GLib.Object thumb_view_, ParamSpec pspec) { | ||
2924 | 345 | if (thumb_view.load_status != WebKit.LoadStatus.FINISHED | ||
2925 | 346 | && thumb_view.load_status != WebKit.LoadStatus.FAILED) | ||
2926 | 347 | return; | ||
2927 | 348 | thumb_view.notify["load-status"].disconnect (load_status); | ||
2928 | 349 | /* Schedule an idle to give the offscreen time to draw */ | ||
2929 | 350 | Idle.add (save_thumbnail); | ||
2930 | 351 | } | ||
2931 | 352 | #endif | ||
2932 | 353 | |||
2933 | 354 | #if !HAVE_WEBKIT2 | ||
2934 | 355 | bool save_thumbnail () { | ||
2935 | 356 | return_val_if_fail (spec != null, false); | ||
2936 | 357 | |||
2937 | 358 | var offscreen = (thumb_view.parent as Gtk.OffscreenWindow); | ||
2938 | 359 | var pixbuf = offscreen.get_pixbuf (); | ||
2939 | 360 | int image_width = pixbuf.get_width (), image_height = pixbuf.get_height (); | ||
2940 | 361 | int thumb_width = 240, thumb_height = 160; | ||
2941 | 362 | float image_ratio = image_width / image_height; | ||
2942 | 363 | float thumb_ratio = thumb_width / thumb_height; | ||
2943 | 364 | int x_offset, y_offset, computed_width, computed_height; | ||
2944 | 365 | if (image_ratio > thumb_ratio) { | ||
2945 | 366 | computed_width = (int)(image_height * thumb_ratio); | ||
2946 | 367 | computed_height = image_height; | ||
2947 | 368 | x_offset = (image_width - computed_width) / 2; | ||
2948 | 369 | y_offset = 0; | ||
2949 | 370 | } | ||
2950 | 371 | else { | ||
2951 | 372 | computed_width = image_width; | ||
2952 | 373 | computed_height = (int)(image_width / thumb_ratio); | ||
2953 | 374 | x_offset = 0; | ||
2954 | 375 | y_offset = 0; | ||
2955 | 376 | } | ||
2956 | 377 | var sub = pixbuf; | ||
2957 | 378 | if (y_offset + computed_height <= image_height) | ||
2958 | 379 | sub = new Gdk.Pixbuf.subpixbuf (pixbuf, x_offset, y_offset, computed_width, computed_height); | ||
2959 | 380 | var scaled = sub.scale_simple (thumb_width, thumb_height, Gdk.InterpType.TILES); | ||
2960 | 381 | add_with_id (spec.dial_id, spec.uri, thumb_view.get_title () ?? spec.uri, scaled); | ||
2961 | 382 | |||
2962 | 383 | thumb_queue.remove (spec); | ||
2963 | 384 | if (thumb_queue.length () > 0) { | ||
2964 | 385 | spec = thumb_queue.nth_data (0); | ||
2965 | 386 | thumb_view.notify["load-status"].connect (load_status); | ||
2966 | 387 | thumb_view.load_uri (spec.uri); | ||
2967 | 388 | } | ||
2968 | 389 | return false; | ||
2969 | 390 | } | ||
2970 | 391 | #endif | ||
2971 | 392 | |||
2972 | 393 | void get_thumb (string dial_id, string uri) { | 339 | void get_thumb (string dial_id, string uri) { |
2973 | 394 | #if !HAVE_WEBKIT2 | ||
2974 | 395 | if (thumb_view == null) { | ||
2975 | 396 | thumb_view = new WebKit.WebView (); | ||
2976 | 397 | thumb_view.settings.set ( | ||
2977 | 398 | "enable-scripts", false, | ||
2978 | 399 | "enable-plugins", false, | ||
2979 | 400 | "auto-load-images", true, | ||
2980 | 401 | "enable-html5-database", false, | ||
2981 | 402 | "enable-html5-local-storage", false, | ||
2982 | 403 | "enable-java-applet", false); | ||
2983 | 404 | var offscreen = new Gtk.OffscreenWindow (); | ||
2984 | 405 | offscreen.add (thumb_view); | ||
2985 | 406 | thumb_view.set_size_request (800, 600); | ||
2986 | 407 | offscreen.show_all (); | ||
2987 | 408 | } | ||
2988 | 409 | |||
2989 | 410 | /* Don't load thumbnails already queued */ | ||
2990 | 411 | foreach (var spec_ in thumb_queue) | ||
2991 | 412 | if (spec_.dial_id == dial_id) | ||
2992 | 413 | return; | ||
2993 | 414 | |||
2994 | 415 | thumb_queue.append (new Spec (dial_id, uri)); | ||
2995 | 416 | if (thumb_queue.length () > 1) | ||
2996 | 417 | return; | ||
2997 | 418 | |||
2998 | 419 | spec = thumb_queue.nth_data (0); | ||
2999 | 420 | thumb_view.notify["load-status"].connect (load_status); | ||
3000 | 421 | thumb_view.load_uri (spec.uri); | ||
3001 | 422 | #endif | ||
3002 | 423 | } | 340 | } |
3003 | 424 | } | 341 | } |
3004 | 425 | } | 342 | } |
3005 | 426 | 343 | ||
3006 | === modified file 'midori/midori-tab.vala' | |||
3007 | --- midori/midori-tab.vala 2015-04-19 14:06:12 +0000 | |||
3008 | +++ midori/midori-tab.vala 2016-09-20 20:57:01 +0000 | |||
3009 | @@ -44,6 +44,7 @@ | |||
3010 | 44 | 44 | ||
3011 | 45 | public class Tab : Gtk.VBox { | 45 | public class Tab : Gtk.VBox { |
3012 | 46 | public Tab related { get; set construct; } | 46 | public Tab related { get; set construct; } |
3013 | 47 | public WebKit.UserContentManager user_content_manager { private get; set construct; } | ||
3014 | 47 | public WebKit.WebView web_view { get; private set; } | 48 | public WebKit.WebView web_view { get; private set; } |
3015 | 48 | 49 | ||
3016 | 49 | private string current_uri = "about:blank"; | 50 | private string current_uri = "about:blank"; |
3017 | @@ -133,30 +134,13 @@ | |||
3018 | 133 | orientation = Gtk.Orientation.VERTICAL; | 134 | orientation = Gtk.Orientation.VERTICAL; |
3019 | 134 | #endif | 135 | #endif |
3020 | 135 | 136 | ||
3029 | 136 | #if HAVE_WEBKIT2_3_91 | 137 | if (related != null) |
3030 | 137 | web_view = related != null ? | 138 | web_view = (WebKit.WebView)GLib.Object.new(typeof (WebKit.WebView), "user-content-manager", user_content_manager, "related-view", related.web_view); |
3031 | 138 | new WebKit.WebView.with_related_view (related.web_view) : new WebKit.WebView (); | 139 | else |
3032 | 139 | #else | 140 | web_view = (WebKit.WebView)GLib.Object.new(typeof (WebKit.WebView), "user-content-manager", user_content_manager); |
3025 | 140 | web_view = new WebKit.WebView (); | ||
3026 | 141 | #endif | ||
3027 | 142 | /* Load something to avoid a bug where WebKit might not set a main frame */ | ||
3028 | 143 | web_view.load_uri (""); | ||
3033 | 144 | } | 141 | } |
3034 | 145 | 142 | ||
3035 | 146 | public void inject_stylesheet (string stylesheet) { | 143 | public void inject_stylesheet (string stylesheet) { |
3036 | 147 | #if !HAVE_WEBKIT2 | ||
3037 | 148 | var dom = web_view.get_dom_document (); | ||
3038 | 149 | return_if_fail (dom.head != null); | ||
3039 | 150 | try { | ||
3040 | 151 | var style = dom.create_element ("style"); | ||
3041 | 152 | style.set_attribute ("type", "text/css"); | ||
3042 | 153 | style.append_child (dom.create_text_node (stylesheet)); | ||
3043 | 154 | dom.head.append_child (style); | ||
3044 | 155 | } | ||
3045 | 156 | catch (Error error) { | ||
3046 | 157 | critical (_("Failed to inject stylesheet: %s"), error.message); | ||
3047 | 158 | } | ||
3048 | 159 | #endif | ||
3049 | 160 | } | 144 | } |
3050 | 161 | 145 | ||
3051 | 162 | /* Since: 0.5.1 | 146 | /* Since: 0.5.1 |
3052 | @@ -219,10 +203,6 @@ | |||
3053 | 219 | return false; | 203 | return false; |
3054 | 220 | if (view_source) | 204 | if (view_source) |
3055 | 221 | return false; | 205 | return false; |
3056 | 222 | #if !HAVE_WEBKIT2 | ||
3057 | 223 | if (web_view.get_main_frame ().get_data_source ().get_data () == null) | ||
3058 | 224 | return false; | ||
3059 | 225 | #endif | ||
3060 | 226 | return true; | 206 | return true; |
3061 | 227 | } | 207 | } |
3062 | 228 | 208 | ||
3063 | @@ -239,13 +219,9 @@ | |||
3064 | 239 | } | 219 | } |
3065 | 240 | 220 | ||
3066 | 241 | public void unmark_text_matches () { | 221 | public void unmark_text_matches () { |
3067 | 242 | #if !HAVE_WEBKIT2 | ||
3068 | 243 | web_view.unmark_text_matches (); | ||
3069 | 244 | #endif | ||
3070 | 245 | } | 222 | } |
3071 | 246 | 223 | ||
3072 | 247 | public bool find (string text, bool case_sensitive, bool forward) { | 224 | public bool find (string text, bool case_sensitive, bool forward) { |
3073 | 248 | #if HAVE_WEBKIT2 | ||
3074 | 249 | var controller = web_view.get_find_controller (); | 225 | var controller = web_view.get_find_controller (); |
3075 | 250 | uint options = WebKit.FindOptions.WRAP_AROUND; | 226 | uint options = WebKit.FindOptions.WRAP_AROUND; |
3076 | 251 | if (!case_sensitive) | 227 | if (!case_sensitive) |
3077 | @@ -255,13 +231,6 @@ | |||
3078 | 255 | controller.search (text, options, 0); | 231 | controller.search (text, options, 0); |
3079 | 256 | // FIXME: mark matches, count matches, not found | 232 | // FIXME: mark matches, count matches, not found |
3080 | 257 | return true; | 233 | return true; |
3081 | 258 | #else | ||
3082 | 259 | bool found = false; | ||
3083 | 260 | found = web_view.search_text (text, case_sensitive, forward, true); | ||
3084 | 261 | web_view.mark_text_matches (text, case_sensitive, 0); | ||
3085 | 262 | web_view.set_highlight_text_matches (true); | ||
3086 | 263 | return found; | ||
3087 | 264 | #endif | ||
3088 | 265 | } | 234 | } |
3089 | 266 | 235 | ||
3090 | 267 | /* | 236 | /* |
3091 | @@ -270,7 +239,6 @@ | |||
3092 | 270 | Since: 0.5.8 | 239 | Since: 0.5.8 |
3093 | 271 | */ | 240 | */ |
3094 | 272 | public async void update_actions (Gtk.ActionGroup actions) { | 241 | public async void update_actions (Gtk.ActionGroup actions) { |
3095 | 273 | #if HAVE_WEBKIT2 | ||
3096 | 274 | try { | 242 | try { |
3097 | 275 | actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null); | 243 | actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null); |
3098 | 276 | actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null); | 244 | actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null); |
3099 | @@ -282,15 +250,6 @@ | |||
3100 | 282 | } catch (Error error) { | 250 | } catch (Error error) { |
3101 | 283 | critical ("Failed to update actions: %s", error.message); | 251 | critical ("Failed to update actions: %s", error.message); |
3102 | 284 | } | 252 | } |
3103 | 285 | #else | ||
3104 | 286 | actions.get_action ("Undo").sensitive = web_view.can_undo (); | ||
3105 | 287 | actions.get_action ("Redo").sensitive = web_view.can_redo (); | ||
3106 | 288 | actions.get_action ("Cut").sensitive = web_view.can_cut_clipboard (); | ||
3107 | 289 | actions.get_action ("Copy").sensitive = web_view.can_copy_clipboard (); | ||
3108 | 290 | actions.get_action ("Paste").sensitive = web_view.can_paste_clipboard (); | ||
3109 | 291 | actions.get_action ("Delete").sensitive = web_view.can_cut_clipboard (); | ||
3110 | 292 | actions.get_action ("SelectAll").sensitive = true; | ||
3111 | 293 | #endif | ||
3112 | 294 | } | 253 | } |
3113 | 295 | } | 254 | } |
3114 | 296 | } | 255 | } |
3115 | 297 | 256 | ||
3116 | === modified file 'midori/midori-view.c' | |||
3117 | --- midori/midori-view.c 2016-02-28 00:07:54 +0000 | |||
3118 | +++ midori/midori-view.c 2016-09-20 20:57:01 +0000 | |||
3119 | @@ -27,11 +27,6 @@ | |||
3120 | 27 | #include <gcr/gcr.h> | 27 | #include <gcr/gcr.h> |
3121 | 28 | #endif | 28 | #endif |
3122 | 29 | 29 | ||
3123 | 30 | #if !defined (HAVE_WEBKIT2) | ||
3124 | 31 | SoupMessage* | ||
3125 | 32 | midori_map_get_message (SoupMessage* message); | ||
3126 | 33 | #endif | ||
3127 | 34 | |||
3128 | 35 | #include <string.h> | 30 | #include <string.h> |
3129 | 36 | #include <stdlib.h> | 31 | #include <stdlib.h> |
3130 | 37 | #include <glib/gi18n.h> | 32 | #include <glib/gi18n.h> |
3131 | @@ -61,7 +56,6 @@ | |||
3132 | 61 | _midori_view_set_settings (MidoriView* view, | 56 | _midori_view_set_settings (MidoriView* view, |
3133 | 62 | MidoriWebSettings* settings); | 57 | MidoriWebSettings* settings); |
3134 | 63 | 58 | ||
3135 | 64 | #ifdef HAVE_WEBKIT2 | ||
3136 | 65 | static void | 59 | static void |
3137 | 66 | midori_view_uri_scheme_res (WebKitURISchemeRequest* request, | 60 | midori_view_uri_scheme_res (WebKitURISchemeRequest* request, |
3138 | 67 | gpointer user_data); | 61 | gpointer user_data); |
3139 | @@ -74,7 +68,6 @@ | |||
3140 | 74 | midori_view_download_query_action (MidoriView* view, | 68 | midori_view_download_query_action (MidoriView* view, |
3141 | 75 | WebKitDownload* download, | 69 | WebKitDownload* download, |
3142 | 76 | const gchar * suggested_filename ); | 70 | const gchar * suggested_filename ); |
3143 | 77 | #endif | ||
3144 | 78 | 71 | ||
3145 | 79 | static gboolean | 72 | static gboolean |
3146 | 80 | midori_view_display_error (MidoriView* view, | 73 | midori_view_display_error (MidoriView* view, |
3147 | @@ -85,11 +78,7 @@ | |||
3148 | 85 | const gchar* description, | 78 | const gchar* description, |
3149 | 86 | const gchar* suggestions, | 79 | const gchar* suggestions, |
3150 | 87 | const gchar* try_again, | 80 | const gchar* try_again, |
3151 | 88 | #ifndef HAVE_WEBKIT2 | ||
3152 | 89 | WebKitWebFrame* web_frame); | ||
3153 | 90 | #else | ||
3154 | 91 | void* web_frame); | 81 | void* web_frame); |
3155 | 92 | #endif | ||
3156 | 93 | 82 | ||
3157 | 94 | struct _MidoriView | 83 | struct _MidoriView |
3158 | 95 | { | 84 | { |
3159 | @@ -496,7 +485,6 @@ | |||
3160 | 496 | _midori_web_view_load_icon (MidoriView* view) | 485 | _midori_web_view_load_icon (MidoriView* view) |
3161 | 497 | { | 486 | { |
3162 | 498 | GdkPixbuf* pixbuf = NULL; | 487 | GdkPixbuf* pixbuf = NULL; |
3163 | 499 | #ifdef HAVE_WEBKIT2 | ||
3164 | 500 | cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view)); | 488 | cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view)); |
3165 | 501 | if (surface != NULL | 489 | if (surface != NULL |
3166 | 502 | && (pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, | 490 | && (pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, |
3167 | @@ -505,11 +493,6 @@ | |||
3168 | 505 | { | 493 | { |
3169 | 506 | midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri); | 494 | midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri); |
3170 | 507 | } | 495 | } |
3171 | 508 | #else | ||
3172 | 509 | if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf ( | ||
3173 | 510 | WEBKIT_WEB_VIEW (view->web_view), 0, 0))) | ||
3174 | 511 | midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri); | ||
3175 | 512 | #endif | ||
3176 | 513 | } | 496 | } |
3177 | 514 | 497 | ||
3178 | 515 | static void | 498 | static void |
3179 | @@ -537,45 +520,20 @@ | |||
3180 | 537 | GTlsCertificateFlags* tls_flags, | 520 | GTlsCertificateFlags* tls_flags, |
3181 | 538 | gchar** hostname) | 521 | gchar** hostname) |
3182 | 539 | { | 522 | { |
3183 | 540 | #ifdef HAVE_WEBKIT2 | ||
3184 | 541 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); | 523 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); |
3185 | 542 | *hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL); | 524 | *hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL); |
3186 | 543 | gboolean success = webkit_web_view_get_tls_info (web_view, tls_cert, tls_flags); | 525 | gboolean success = webkit_web_view_get_tls_info (web_view, tls_cert, tls_flags); |
3187 | 544 | if (*tls_cert != NULL) | 526 | if (*tls_cert != NULL) |
3188 | 545 | g_object_ref (*tls_cert); | 527 | g_object_ref (*tls_cert); |
3189 | 546 | return success && *tls_flags == 0; | 528 | return success && *tls_flags == 0; |
3190 | 547 | #else | ||
3191 | 548 | SoupMessage* message = midori_map_get_message (webkit_network_request_get_message (request)); | ||
3192 | 549 | if (message != NULL) | ||
3193 | 550 | { | ||
3194 | 551 | SoupURI* uri = soup_message_get_uri (message); | ||
3195 | 552 | *hostname = uri ? g_strdup (uri->host) : NULL; | ||
3196 | 553 | g_object_get (message, "tls-certificate", tls_cert, "tls-errors", tls_flags, NULL); | ||
3197 | 554 | if (soup_message_get_flags (message) & SOUP_MESSAGE_CERTIFICATE_TRUSTED) | ||
3198 | 555 | return TRUE; | ||
3199 | 556 | return *tls_flags == 0; | ||
3200 | 557 | } | ||
3201 | 558 | *tls_cert = NULL; | ||
3202 | 559 | *tls_flags = 0; | ||
3203 | 560 | *hostname = NULL; | ||
3204 | 561 | return FALSE; | ||
3205 | 562 | #endif | ||
3206 | 563 | } | 529 | } |
3207 | 564 | 530 | ||
3208 | 565 | static gboolean | 531 | static gboolean |
3209 | 566 | midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view, | 532 | midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view, |
3210 | 567 | #ifdef HAVE_WEBKIT2 | ||
3211 | 568 | WebKitPolicyDecision* decision, | 533 | WebKitPolicyDecision* decision, |
3212 | 569 | WebKitPolicyDecisionType decision_type, | 534 | WebKitPolicyDecisionType decision_type, |
3213 | 570 | #else | ||
3214 | 571 | WebKitWebFrame* web_frame, | ||
3215 | 572 | WebKitNetworkRequest* request, | ||
3216 | 573 | WebKitWebNavigationAction* action, | ||
3217 | 574 | WebKitWebPolicyDecision* decision, | ||
3218 | 575 | #endif | ||
3219 | 576 | MidoriView* view) | 535 | MidoriView* view) |
3220 | 577 | { | 536 | { |
3221 | 578 | #ifdef HAVE_WEBKIT2 | ||
3222 | 579 | if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE) | 537 | if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE) |
3223 | 580 | { | 538 | { |
3224 | 581 | WebKitURIResponse* response = webkit_response_policy_decision_get_response ( | 539 | WebKitURIResponse* response = webkit_response_policy_decision_get_response ( |
3225 | @@ -610,9 +568,6 @@ | |||
3226 | 610 | 568 | ||
3227 | 611 | WebKitURIRequest * request = webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision)); | 569 | WebKitURIRequest * request = webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision)); |
3228 | 612 | const gchar* uri = webkit_uri_request_get_uri (request); | 570 | const gchar* uri = webkit_uri_request_get_uri (request); |
3229 | 613 | #else | ||
3230 | 614 | const gchar* uri = webkit_network_request_get_uri (request); | ||
3231 | 615 | #endif | ||
3232 | 616 | if (g_str_has_prefix (uri, "geo:") && strstr (uri, ",")) | 571 | if (g_str_has_prefix (uri, "geo:") && strstr (uri, ",")) |
3233 | 617 | { | 572 | { |
3234 | 618 | gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE); | 573 | gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE); |
3235 | @@ -624,42 +579,34 @@ | |||
3236 | 624 | { | 579 | { |
3237 | 625 | /* For security reasons, main content served as data: is limited to images | 580 | /* For security reasons, main content served as data: is limited to images |
3238 | 626 | http://lcamtuf.coredump.cx/switch/ */ | 581 | http://lcamtuf.coredump.cx/switch/ */ |
3239 | 627 | #ifdef HAVE_WEBKIT2 | ||
3240 | 628 | webkit_policy_decision_ignore (decision); | 582 | webkit_policy_decision_ignore (decision); |
3241 | 629 | #else | ||
3242 | 630 | webkit_web_policy_decision_ignore (decision); | ||
3243 | 631 | #endif | ||
3244 | 632 | return TRUE; | 583 | return TRUE; |
3245 | 633 | } | 584 | } |
3248 | 634 | #ifdef HAVE_GCR | 585 | else if (midori_tab_get_special (MIDORI_TAB (view)) && !strncmp (uri, "https", 5)) |
3247 | 635 | else if (/* midori_tab_get_special (MIDORI_TAB (view)) && */ !strncmp (uri, "https", 5)) | ||
3249 | 636 | { | 586 | { |
3250 | 637 | /* We show an error page if the certificate is invalid. | 587 | /* We show an error page if the certificate is invalid. |
3251 | 638 | If a "special", unverified page loads a form, it must be that page. | 588 | If a "special", unverified page loads a form, it must be that page. |
3252 | 639 | if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED) | 589 | if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED) |
3253 | 640 | FIXME: Verify more stricly that this cannot be eg. a simple Reload */ | 590 | FIXME: Verify more stricly that this cannot be eg. a simple Reload */ |
3254 | 641 | #ifdef HAVE_WEBKIT2 | ||
3255 | 642 | if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) | 591 | if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) |
3256 | 643 | #else | ||
3257 | 644 | if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_RELOAD) | ||
3258 | 645 | #endif | ||
3259 | 646 | { | 592 | { |
3265 | 647 | GTlsCertificate* tls_cert; | 593 | gchar* hostname = midori_uri_parse_hostname (uri, NULL); |
3266 | 648 | GTlsCertificateFlags tls_flags; | 594 | g_return_val_if_fail (hostname != NULL, FALSE); |
3267 | 649 | gchar* hostname; | 595 | GTlsCertificate* cert = g_object_get_data (G_OBJECT (view->web_view), "tls-cert"); |
3268 | 650 | if (!midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname) | 596 | g_return_val_if_fail (cert != NULL, FALSE); |
3269 | 651 | && tls_cert != NULL) | 597 | webkit_web_context_allow_tls_certificate_for_host (webkit_web_context_get_default (), |
3270 | 598 | cert, hostname); | ||
3271 | 599 | if (cert != NULL) | ||
3272 | 652 | { | 600 | { |
3280 | 653 | GcrCertificate* gcr_cert; | 601 | GByteArray* der; |
3281 | 654 | GByteArray* der_cert; | 602 | g_object_get (cert, "certificate", &der, NULL); |
3282 | 655 | 603 | GcrCertificate* gcr = gcr_simple_certificate_new (der->data, der->len); | |
3283 | 656 | g_object_get (tls_cert, "certificate", &der_cert, NULL); | 604 | g_return_val_if_fail (gcr != NULL, FALSE); |
3284 | 657 | gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len); | 605 | // FIXME: g_object_unref (der); |
3285 | 658 | g_byte_array_unref (der_cert); | 606 | if (hostname && !gcr_trust_is_certificate_pinned (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL)) |
3279 | 659 | if (hostname && !gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL)) | ||
3286 | 660 | { | 607 | { |
3287 | 661 | GError* error = NULL; | 608 | GError* error = NULL; |
3289 | 662 | gcr_trust_add_pinned_certificate (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, &error); | 609 | gcr_trust_add_pinned_certificate (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, &error); |
3290 | 663 | if (error != NULL) | 610 | if (error != NULL) |
3291 | 664 | { | 611 | { |
3292 | 665 | gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ()); | 612 | gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ()); |
3293 | @@ -675,14 +622,11 @@ | |||
3294 | 675 | g_error_free (error); | 622 | g_error_free (error); |
3295 | 676 | } | 623 | } |
3296 | 677 | } | 624 | } |
3298 | 678 | g_object_unref (gcr_cert); | 625 | g_object_unref (gcr); |
3299 | 679 | } | 626 | } |
3300 | 680 | if (tls_cert != NULL) | ||
3301 | 681 | g_object_unref (tls_cert); | ||
3302 | 682 | g_free (hostname); | 627 | g_free (hostname); |
3303 | 683 | } | 628 | } |
3304 | 684 | } | 629 | } |
3305 | 685 | #endif | ||
3306 | 686 | 630 | ||
3307 | 687 | if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_PENDING_UNDELAY) | 631 | if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_PENDING_UNDELAY) |
3308 | 688 | { | 632 | { |
3309 | @@ -690,39 +634,11 @@ | |||
3310 | 690 | katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED); | 634 | katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED); |
3311 | 691 | } | 635 | } |
3312 | 692 | 636 | ||
3313 | 693 | #ifndef HAVE_WEBKIT2 | ||
3314 | 694 | /* Remove link labels */ | ||
3315 | 695 | JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); | ||
3316 | 696 | gchar* result = sokoke_js_script_eval (js_context, | ||
3317 | 697 | "(function (links) {" | ||
3318 | 698 | "if (links != undefined && links.length > 0) {" | ||
3319 | 699 | " for (var i = links.length - 1; i >= 0; i--) {" | ||
3320 | 700 | " var parent = links[i].parentNode;" | ||
3321 | 701 | " parent.removeChild(links[i]); } } }) (" | ||
3322 | 702 | "document.getElementsByClassName ('midoriHKD87346'));", | ||
3323 | 703 | NULL); | ||
3324 | 704 | g_free (result); | ||
3325 | 705 | result = sokoke_js_script_eval (js_context, | ||
3326 | 706 | "(function (links) {" | ||
3327 | 707 | "if (links != undefined && links.length > 0) {" | ||
3328 | 708 | " for (var i = links.length - 1; i >= 0; i--) {" | ||
3329 | 709 | " var parent = links[i].parentNode;" | ||
3330 | 710 | " parent.removeChild(links[i]); } } }) (" | ||
3331 | 711 | "document.getElementsByClassName ('midori_access_key_fc04de'));", | ||
3332 | 712 | NULL); | ||
3333 | 713 | g_free (result); | ||
3334 | 714 | view->find_links = -1; | ||
3335 | 715 | #endif | ||
3336 | 716 | |||
3337 | 717 | gboolean handled = FALSE; | 637 | gboolean handled = FALSE; |
3338 | 718 | g_signal_emit_by_name (view, "navigation-requested", uri, &handled); | 638 | g_signal_emit_by_name (view, "navigation-requested", uri, &handled); |
3339 | 719 | if (handled) | 639 | if (handled) |
3340 | 720 | { | 640 | { |
3341 | 721 | #ifdef HAVE_WEBKIT2 | ||
3342 | 722 | webkit_policy_decision_ignore (decision); | 641 | webkit_policy_decision_ignore (decision); |
3343 | 723 | #else | ||
3344 | 724 | webkit_web_policy_decision_ignore (decision); | ||
3345 | 725 | #endif | ||
3346 | 726 | return TRUE; | 642 | return TRUE; |
3347 | 727 | } | 643 | } |
3348 | 728 | 644 | ||
3349 | @@ -764,54 +680,6 @@ | |||
3350 | 764 | g_object_set (view, "title", NULL, NULL); | 680 | g_object_set (view, "title", NULL, NULL); |
3351 | 765 | midori_view_unset_icon (view); | 681 | midori_view_unset_icon (view); |
3352 | 766 | 682 | ||
3353 | 767 | if (!strncmp (uri, "https", 5)) | ||
3354 | 768 | { | ||
3355 | 769 | #ifdef HAVE_WEBKIT2 | ||
3356 | 770 | void* request = NULL; | ||
3357 | 771 | #else | ||
3358 | 772 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); | ||
3359 | 773 | WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame); | ||
3360 | 774 | WebKitNetworkRequest* request = webkit_web_data_source_get_request (source); | ||
3361 | 775 | #endif | ||
3362 | 776 | GTlsCertificate* tls_cert; | ||
3363 | 777 | GTlsCertificateFlags tls_flags; | ||
3364 | 778 | gchar* hostname; | ||
3365 | 779 | if (midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname)) | ||
3366 | 780 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED); | ||
3367 | 781 | #ifdef HAVE_GCR | ||
3368 | 782 | else if (!midori_tab_get_special (MIDORI_TAB (view)) && tls_cert != NULL) | ||
3369 | 783 | { | ||
3370 | 784 | GcrCertificate* gcr_cert; | ||
3371 | 785 | GByteArray* der_cert; | ||
3372 | 786 | |||
3373 | 787 | g_object_get (tls_cert, "certificate", &der_cert, NULL); | ||
3374 | 788 | gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len); | ||
3375 | 789 | g_byte_array_unref (der_cert); | ||
3376 | 790 | if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL)) | ||
3377 | 791 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED); | ||
3378 | 792 | else | ||
3379 | 793 | { | ||
3380 | 794 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN); | ||
3381 | 795 | midori_tab_stop_loading (MIDORI_TAB (view)); | ||
3382 | 796 | midori_view_display_error (view, NULL, NULL, NULL, _("Security unknown"), | ||
3383 | 797 | midori_location_action_tls_flags_to_string (tls_flags), NULL, | ||
3384 | 798 | _("Trust this website"), | ||
3385 | 799 | NULL); | ||
3386 | 800 | } | ||
3387 | 801 | g_object_unref (gcr_cert); | ||
3388 | 802 | } | ||
3389 | 803 | #endif | ||
3390 | 804 | else | ||
3391 | 805 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN); | ||
3392 | 806 | #ifdef HAVE_GCR | ||
3393 | 807 | if (tls_cert != NULL) | ||
3394 | 808 | g_object_unref (tls_cert); | ||
3395 | 809 | g_free (hostname); | ||
3396 | 810 | #endif | ||
3397 | 811 | } | ||
3398 | 812 | else | ||
3399 | 813 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_NONE); | ||
3400 | 814 | |||
3401 | 815 | view->find_links = -1; | 683 | view->find_links = -1; |
3402 | 816 | 684 | ||
3403 | 817 | midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED); | 685 | midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED); |
3404 | @@ -828,7 +696,6 @@ | |||
3405 | 828 | midori_tab_set_progress (MIDORI_TAB (view), progress); | 696 | midori_tab_set_progress (MIDORI_TAB (view), progress); |
3406 | 829 | } | 697 | } |
3407 | 830 | 698 | ||
3408 | 831 | #ifdef HAVE_WEBKIT2 | ||
3409 | 832 | static void | 699 | static void |
3410 | 833 | midori_view_uri_scheme_res (WebKitURISchemeRequest* request, | 700 | midori_view_uri_scheme_res (WebKitURISchemeRequest* request, |
3411 | 834 | gpointer user_data) | 701 | gpointer user_data) |
3412 | @@ -836,17 +703,6 @@ | |||
3413 | 836 | const gchar* uri = webkit_uri_scheme_request_get_uri (request); | 703 | const gchar* uri = webkit_uri_scheme_request_get_uri (request); |
3414 | 837 | WebKitWebView* web_view = webkit_uri_scheme_request_get_web_view (request); | 704 | WebKitWebView* web_view = webkit_uri_scheme_request_get_web_view (request); |
3415 | 838 | MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (web_view)); | 705 | MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (web_view)); |
3416 | 839 | #else | ||
3417 | 840 | static void | ||
3418 | 841 | midori_view_web_view_resource_request_cb (WebKitWebView* web_view, | ||
3419 | 842 | WebKitWebFrame* web_frame, | ||
3420 | 843 | WebKitWebResource* web_resource, | ||
3421 | 844 | WebKitNetworkRequest* request, | ||
3422 | 845 | WebKitNetworkResponse* response, | ||
3423 | 846 | MidoriView* view) | ||
3424 | 847 | { | ||
3425 | 848 | const gchar* uri = webkit_network_request_get_uri (request); | ||
3426 | 849 | #endif | ||
3427 | 850 | 706 | ||
3428 | 851 | /* Only apply custom URIs to special pages for security purposes */ | 707 | /* Only apply custom URIs to special pages for security purposes */ |
3429 | 852 | if (!midori_tab_get_special (MIDORI_TAB (view))) | 708 | if (!midori_tab_get_special (MIDORI_TAB (view))) |
3430 | @@ -855,7 +711,6 @@ | |||
3431 | 855 | if (g_str_has_prefix (uri, "res://")) | 711 | if (g_str_has_prefix (uri, "res://")) |
3432 | 856 | { | 712 | { |
3433 | 857 | gchar* filepath = midori_paths_get_res_filename (&uri[6]); | 713 | gchar* filepath = midori_paths_get_res_filename (&uri[6]); |
3434 | 858 | #ifdef HAVE_WEBKIT2 | ||
3435 | 859 | gchar* contents; | 714 | gchar* contents; |
3436 | 860 | gsize length; | 715 | gsize length; |
3437 | 861 | if (g_file_get_contents (filepath, &contents, &length, NULL)) | 716 | if (g_file_get_contents (filepath, &contents, &length, NULL)) |
3438 | @@ -868,11 +723,6 @@ | |||
3439 | 868 | g_free (mime_type); | 723 | g_free (mime_type); |
3440 | 869 | g_free (content_type); | 724 | g_free (content_type); |
3441 | 870 | } | 725 | } |
3442 | 871 | #else | ||
3443 | 872 | gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL); | ||
3444 | 873 | webkit_network_request_set_uri (request, file_uri); | ||
3445 | 874 | g_free (file_uri); | ||
3446 | 875 | #endif | ||
3447 | 876 | g_free (filepath); | 726 | g_free (filepath); |
3448 | 877 | } | 727 | } |
3449 | 878 | else if (g_str_has_prefix (uri, "stock://")) | 728 | else if (g_str_has_prefix (uri, "stock://")) |
3450 | @@ -936,14 +786,9 @@ | |||
3451 | 936 | encoded = g_base64_encode ((guchar*)buffer, buffer_size); | 786 | encoded = g_base64_encode ((guchar*)buffer, buffer_size); |
3452 | 937 | data_uri = g_strconcat ("data:image/png;base64,", encoded, NULL); | 787 | data_uri = g_strconcat ("data:image/png;base64,", encoded, NULL); |
3453 | 938 | g_free (encoded); | 788 | g_free (encoded); |
3454 | 939 | #ifdef HAVE_WEBKIT2 | ||
3455 | 940 | GInputStream* stream = g_memory_input_stream_new_from_data (buffer, buffer_size, g_free); | 789 | GInputStream* stream = g_memory_input_stream_new_from_data (buffer, buffer_size, g_free); |
3456 | 941 | webkit_uri_scheme_request_finish (request, stream, -1, "image/png"); | 790 | webkit_uri_scheme_request_finish (request, stream, -1, "image/png"); |
3457 | 942 | g_object_unref (stream); | 791 | g_object_unref (stream); |
3458 | 943 | #else | ||
3459 | 944 | g_free (buffer); | ||
3460 | 945 | webkit_network_request_set_uri (request, data_uri); | ||
3461 | 946 | #endif | ||
3462 | 947 | g_free (data_uri); | 792 | g_free (data_uri); |
3463 | 948 | return; | 793 | return; |
3464 | 949 | } | 794 | } |
3465 | @@ -1032,7 +877,6 @@ | |||
3466 | 1032 | return infobar; | 877 | return infobar; |
3467 | 1033 | } | 878 | } |
3468 | 1034 | 879 | ||
3469 | 1035 | #ifdef HAVE_WEBKIT2 | ||
3470 | 1036 | static gboolean | 880 | static gboolean |
3471 | 1037 | midori_view_web_view_permission_request_cb (WebKitWebView* web_view, | 881 | midori_view_web_view_permission_request_cb (WebKitWebView* web_view, |
3472 | 1038 | WebKitPermissionRequest* decision, | 882 | WebKitPermissionRequest* decision, |
3473 | @@ -1044,86 +888,6 @@ | |||
3474 | 1044 | } */ | 888 | } */ |
3475 | 1045 | return FALSE; | 889 | return FALSE; |
3476 | 1046 | } | 890 | } |
3477 | 1047 | #else | ||
3478 | 1048 | static void | ||
3479 | 1049 | midori_view_database_response_cb (GtkWidget* infobar, | ||
3480 | 1050 | gint response, | ||
3481 | 1051 | WebKitWebDatabase* database) | ||
3482 | 1052 | { | ||
3483 | 1053 | if (response != GTK_RESPONSE_ACCEPT) | ||
3484 | 1054 | { | ||
3485 | 1055 | WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database); | ||
3486 | 1056 | webkit_security_origin_set_web_database_quota (origin, 0); | ||
3487 | 1057 | webkit_web_database_remove (database); | ||
3488 | 1058 | } | ||
3489 | 1059 | /* TODO: Remember the decision */ | ||
3490 | 1060 | } | ||
3491 | 1061 | |||
3492 | 1062 | static void | ||
3493 | 1063 | midori_view_web_view_database_quota_exceeded_cb (WebKitWebView* web_view, | ||
3494 | 1064 | WebKitWebFrame* web_frame, | ||
3495 | 1065 | WebKitWebDatabase* database, | ||
3496 | 1066 | MidoriView* view) | ||
3497 | 1067 | { | ||
3498 | 1068 | const gchar* uri = webkit_web_frame_get_uri (web_frame); | ||
3499 | 1069 | MidoriSiteDataPolicy policy = midori_web_settings_get_site_data_policy (view->settings, uri); | ||
3500 | 1070 | |||
3501 | 1071 | switch (policy) | ||
3502 | 1072 | { | ||
3503 | 1073 | case MIDORI_SITE_DATA_BLOCK: | ||
3504 | 1074 | { | ||
3505 | 1075 | WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database); | ||
3506 | 1076 | webkit_security_origin_set_web_database_quota (origin, 0); | ||
3507 | 1077 | webkit_web_database_remove (database); | ||
3508 | 1078 | } | ||
3509 | 1079 | case MIDORI_SITE_DATA_ACCEPT: | ||
3510 | 1080 | case MIDORI_SITE_DATA_PRESERVE: | ||
3511 | 1081 | return; | ||
3512 | 1082 | case MIDORI_SITE_DATA_UNDETERMINED: | ||
3513 | 1083 | { | ||
3514 | 1084 | gchar* hostname = midori_uri_parse_hostname (uri, NULL); | ||
3515 | 1085 | gchar* message = g_strdup_printf (_("%s wants to save an HTML5 database."), | ||
3516 | 1086 | hostname && *hostname ? hostname : uri); | ||
3517 | 1087 | midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message, | ||
3518 | 1088 | G_CALLBACK (midori_view_database_response_cb), database, | ||
3519 | 1089 | _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT, | ||
3520 | 1090 | NULL); | ||
3521 | 1091 | g_free (hostname); | ||
3522 | 1092 | g_free (message); | ||
3523 | 1093 | } | ||
3524 | 1094 | } | ||
3525 | 1095 | } | ||
3526 | 1096 | |||
3527 | 1097 | static void | ||
3528 | 1098 | midori_view_location_response_cb (GtkWidget* infobar, | ||
3529 | 1099 | gint response, | ||
3530 | 1100 | WebKitGeolocationPolicyDecision* decision) | ||
3531 | 1101 | { | ||
3532 | 1102 | if (response == GTK_RESPONSE_ACCEPT) | ||
3533 | 1103 | webkit_geolocation_policy_allow (decision); | ||
3534 | 1104 | else | ||
3535 | 1105 | webkit_geolocation_policy_deny (decision); | ||
3536 | 1106 | } | ||
3537 | 1107 | |||
3538 | 1108 | static gboolean | ||
3539 | 1109 | midori_view_web_view_geolocation_decision_cb (WebKitWebView* web_view, | ||
3540 | 1110 | WebKitWebFrame* web_frame, | ||
3541 | 1111 | WebKitGeolocationPolicyDecision* decision, | ||
3542 | 1112 | MidoriView* view) | ||
3543 | 1113 | { | ||
3544 | 1114 | const gchar* uri = webkit_web_frame_get_uri (web_frame); | ||
3545 | 1115 | gchar* hostname = midori_uri_parse_hostname (uri, NULL); | ||
3546 | 1116 | gchar* message = g_strdup_printf (_("%s wants to know your location."), | ||
3547 | 1117 | hostname && *hostname ? hostname : uri); | ||
3548 | 1118 | midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, | ||
3549 | 1119 | message, G_CALLBACK (midori_view_location_response_cb), decision, | ||
3550 | 1120 | _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT, | ||
3551 | 1121 | NULL); | ||
3552 | 1122 | g_free (hostname); | ||
3553 | 1123 | g_free (message); | ||
3554 | 1124 | return TRUE; | ||
3555 | 1125 | } | ||
3556 | 1126 | #endif | ||
3557 | 1127 | 891 | ||
3558 | 1128 | void | 892 | void |
3559 | 1129 | midori_view_set_html (MidoriView* view, | 893 | midori_view_set_html (MidoriView* view, |
3560 | @@ -1137,23 +901,10 @@ | |||
3561 | 1137 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); | 901 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); |
3562 | 1138 | if (!uri) | 902 | if (!uri) |
3563 | 1139 | uri = "about:blank"; | 903 | uri = "about:blank"; |
3564 | 1140 | #ifndef HAVE_WEBKIT2 | ||
3565 | 1141 | WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view); | ||
3566 | 1142 | if (!web_frame) | ||
3567 | 1143 | web_frame = main_frame; | ||
3568 | 1144 | if (web_frame == main_frame) | ||
3569 | 1145 | { | ||
3570 | 1146 | katze_item_set_uri (view->item, uri); | ||
3571 | 1147 | midori_tab_set_special (MIDORI_TAB (view), TRUE); | ||
3572 | 1148 | } | ||
3573 | 1149 | webkit_web_frame_load_alternate_string ( | ||
3574 | 1150 | web_frame, data, uri, uri); | ||
3575 | 1151 | #else | ||
3576 | 1152 | /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */ | 904 | /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */ |
3577 | 1153 | katze_item_set_uri (view->item, uri); | 905 | katze_item_set_uri (view->item, uri); |
3578 | 1154 | midori_tab_set_special (MIDORI_TAB (view), TRUE); | 906 | midori_tab_set_special (MIDORI_TAB (view), TRUE); |
3579 | 1155 | webkit_web_view_load_alternate_html (web_view, data, uri, uri); | 907 | webkit_web_view_load_alternate_html (web_view, data, uri, uri); |
3580 | 1156 | #endif | ||
3581 | 1157 | } | 908 | } |
3582 | 1158 | 909 | ||
3583 | 1159 | static gboolean | 910 | static gboolean |
3584 | @@ -1165,11 +916,7 @@ | |||
3585 | 1165 | const gchar* description, | 916 | const gchar* description, |
3586 | 1166 | const gchar* suggestions, | 917 | const gchar* suggestions, |
3587 | 1167 | const gchar* try_again, | 918 | const gchar* try_again, |
3588 | 1168 | #ifndef HAVE_WEBKIT2 | ||
3589 | 1169 | WebKitWebFrame* web_frame) | ||
3590 | 1170 | #else | ||
3591 | 1171 | void* web_frame) | 919 | void* web_frame) |
3592 | 1172 | #endif | ||
3593 | 1173 | { | 920 | { |
3594 | 1174 | gchar* path = midori_paths_get_res_filename ("error.html"); | 921 | gchar* path = midori_paths_get_res_filename ("error.html"); |
3595 | 1175 | gchar* template; | 922 | gchar* template; |
3596 | @@ -1182,11 +929,7 @@ | |||
3597 | 1182 | gchar* result; | 929 | gchar* result; |
3598 | 1183 | gboolean is_main_frame; | 930 | gboolean is_main_frame; |
3599 | 1184 | 931 | ||
3600 | 1185 | #ifdef HAVE_WEBKIT2 | ||
3601 | 1186 | is_main_frame = TRUE; | 932 | is_main_frame = TRUE; |
3602 | 1187 | #else | ||
3603 | 1188 | is_main_frame = web_frame && (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)) == web_frame); | ||
3604 | 1189 | #endif | ||
3605 | 1190 | 933 | ||
3606 | 1191 | #if !GTK_CHECK_VERSION (3, 0, 0) | 934 | #if !GTK_CHECK_VERSION (3, 0, 0) |
3607 | 1192 | /* g_object_get_valist: object class `GtkSettings' has no property named `gtk-button-images' */ | 935 | /* g_object_get_valist: object class `GtkSettings' has no property named `gtk-button-images' */ |
3608 | @@ -1234,11 +977,7 @@ | |||
3609 | 1234 | 977 | ||
3610 | 1235 | static gboolean | 978 | static gboolean |
3611 | 1236 | webkit_web_view_load_error_cb (WebKitWebView* web_view, | 979 | webkit_web_view_load_error_cb (WebKitWebView* web_view, |
3612 | 1237 | #ifdef HAVE_WEBKIT2 | ||
3613 | 1238 | WebKitLoadEvent load_event, | 980 | WebKitLoadEvent load_event, |
3614 | 1239 | #else | ||
3615 | 1240 | WebKitWebFrame* web_frame, | ||
3616 | 1241 | #endif | ||
3617 | 1242 | const gchar* uri, | 981 | const gchar* uri, |
3618 | 1243 | GError* error, | 982 | GError* error, |
3619 | 1244 | MidoriView* view) | 983 | MidoriView* view) |
3620 | @@ -1247,12 +986,8 @@ | |||
3621 | 1247 | didFailProvisionalLoadWithErrorForFrame early-returns if the frame isn't | 986 | didFailProvisionalLoadWithErrorForFrame early-returns if the frame isn't |
3622 | 1248 | main, so we know that the pertinent frame here is the view's main frame--so | 987 | main, so we know that the pertinent frame here is the view's main frame--so |
3623 | 1249 | it's safe for midori_view_display_error to assume it fills in a main frame*/ | 988 | it's safe for midori_view_display_error to assume it fills in a main frame*/ |
3624 | 1250 | #ifdef HAVE_WEBKIT2 | ||
3625 | 1251 | void* web_frame = NULL; | 989 | void* web_frame = NULL; |
3626 | 1252 | void* main_frame = NULL; | 990 | void* main_frame = NULL; |
3627 | 1253 | #else | ||
3628 | 1254 | WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view); | ||
3629 | 1255 | #endif | ||
3630 | 1256 | gchar* title; | 991 | gchar* title; |
3631 | 1257 | gchar* message; | 992 | gchar* message; |
3632 | 1258 | gboolean result; | 993 | gboolean result; |
3633 | @@ -1332,95 +1067,54 @@ | |||
3634 | 1332 | } | 1067 | } |
3635 | 1333 | } | 1068 | } |
3636 | 1334 | 1069 | ||
3637 | 1070 | static gboolean | ||
3638 | 1071 | midori_view_web_view_tls_error_cb (WebKitWebView* web_view, | ||
3639 | 1072 | const gchar* failing_uri, | ||
3640 | 1073 | GTlsCertificate* cert, | ||
3641 | 1074 | GTlsCertificateFlags errors, | ||
3642 | 1075 | MidoriView* view) | ||
3643 | 1076 | { | ||
3644 | 1077 | GByteArray* der = NULL; | ||
3645 | 1078 | g_object_get (cert, "certificate", &der, NULL); | ||
3646 | 1079 | g_return_val_if_fail (der != NULL, FALSE); | ||
3647 | 1080 | GcrCertificate* gcr = gcr_simple_certificate_new (der->data, der->len); | ||
3648 | 1081 | // FIXME: g_object_unref (der); | ||
3649 | 1082 | g_return_val_if_fail (gcr != NULL, FALSE); | ||
3650 | 1083 | gchar* hostname = midori_uri_parse_hostname (failing_uri, NULL); | ||
3651 | 1084 | g_return_val_if_fail (hostname != NULL, FALSE); | ||
3652 | 1085 | if (gcr_trust_is_certificate_pinned (gcr, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL)) | ||
3653 | 1086 | { | ||
3654 | 1087 | webkit_web_context_allow_tls_certificate_for_host (webkit_web_context_get_default (), | ||
3655 | 1088 | cert, hostname); | ||
3656 | 1089 | webkit_web_view_load_uri (web_view, failing_uri); | ||
3657 | 1090 | } | ||
3658 | 1091 | else | ||
3659 | 1092 | { | ||
3660 | 1093 | midori_view_display_error (view, NULL, NULL, NULL, _("Security unknown"), | ||
3661 | 1094 | midori_location_action_tls_flags_to_string (errors), NULL, | ||
3662 | 1095 | _("Trust this website"), NULL); | ||
3663 | 1096 | g_object_set_data_full (G_OBJECT (web_view), "cert", g_object_ref (cert), (GDestroyNotify)g_object_unref); | ||
3664 | 1097 | // FIXME: g_object_set_data_full (G_OBJECT (web_view), "uri", g_strdup (failing_uri), (GDestroyNotify)g_free); | ||
3665 | 1098 | midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_SECURITY); | ||
3666 | 1099 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN); | ||
3667 | 1100 | } | ||
3668 | 1101 | g_free (hostname); | ||
3669 | 1102 | g_object_unref (gcr); | ||
3670 | 1103 | return TRUE; | ||
3671 | 1104 | } | ||
3672 | 1105 | |||
3673 | 1335 | static void | 1106 | static void |
3674 | 1336 | midori_view_load_finished (MidoriView* view) | 1107 | midori_view_load_finished (MidoriView* view) |
3675 | 1337 | { | 1108 | { |
3676 | 1109 | if (midori_tab_get_load_error (MIDORI_TAB (view)) == MIDORI_LOAD_ERROR_SECURITY) | ||
3677 | 1110 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN); | ||
3678 | 1111 | else if (!strncmp (midori_tab_get_uri (MIDORI_TAB (view)), "https", 5)) | ||
3679 | 1112 | midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED); | ||
3680 | 1338 | midori_view_apply_scroll_position (view); | 1113 | midori_view_apply_scroll_position (view); |
3681 | 1339 | #ifndef HAVE_WEBKIT2 | ||
3682 | 1340 | |||
3683 | 1341 | { | ||
3684 | 1342 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); | ||
3685 | 1343 | JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); | ||
3686 | 1344 | /* Icon: URI, News Feed: $URI|title, Search: :URI|title */ | ||
3687 | 1345 | gchar* value = sokoke_js_script_eval (js_context, | ||
3688 | 1346 | "(function (l) { var f = new Array (); for (var i in l) " | ||
3689 | 1347 | "{ var t = l[i].type; var r = l[i].rel; " | ||
3690 | 1348 | "if (t && (t.indexOf ('rss') != -1 || t.indexOf ('atom') != -1)) " | ||
3691 | 1349 | "f.push ('$' + l[i].href + '|' + l[i].title);" | ||
3692 | 1350 | "else if (r == 'search' && t == 'application/opensearchdescription+xml') " | ||
3693 | 1351 | "f.push (':' + l[i].href + '|' + l[i].title); } " | ||
3694 | 1352 | "return f; })(" | ||
3695 | 1353 | "document.getElementsByTagName ('link'));", NULL); | ||
3696 | 1354 | |||
3697 | 1355 | /* FIXME: If URI or title contains , parsing will break */ | ||
3698 | 1356 | gchar** items = g_strsplit (value, ",", 0); | ||
3699 | 1357 | gchar** current_item = items; | ||
3700 | 1358 | gchar* default_uri = NULL; | ||
3701 | 1359 | |||
3702 | 1360 | if (view->news_feeds != NULL) | ||
3703 | 1361 | katze_array_clear (view->news_feeds); | ||
3704 | 1362 | else | ||
3705 | 1363 | view->news_feeds = katze_array_new (KATZE_TYPE_ITEM); | ||
3706 | 1364 | |||
3707 | 1365 | while (current_item && *current_item) | ||
3708 | 1366 | { | ||
3709 | 1367 | const gchar* uri_and_title = *current_item; | ||
3710 | 1368 | if (uri_and_title[0] == '$') | ||
3711 | 1369 | { | ||
3712 | 1370 | const gchar* title; | ||
3713 | 1371 | gchar* uri; | ||
3714 | 1372 | KatzeItem* item; | ||
3715 | 1373 | |||
3716 | 1374 | uri_and_title++; | ||
3717 | 1375 | if (uri_and_title == NULL) | ||
3718 | 1376 | continue; | ||
3719 | 1377 | title = strchr (uri_and_title, '|'); | ||
3720 | 1378 | if (title == NULL) | ||
3721 | 1379 | goto news_feeds_continue; | ||
3722 | 1380 | title++; | ||
3723 | 1381 | |||
3724 | 1382 | uri = g_strndup (uri_and_title, title - 1 - uri_and_title); | ||
3725 | 1383 | item = g_object_new (KATZE_TYPE_ITEM, | ||
3726 | 1384 | "uri", uri, "name", title, NULL); | ||
3727 | 1385 | katze_array_add_item (view->news_feeds, item); | ||
3728 | 1386 | g_object_unref (item); | ||
3729 | 1387 | if (!default_uri) | ||
3730 | 1388 | default_uri = uri; | ||
3731 | 1389 | else | ||
3732 | 1390 | g_free (uri); | ||
3733 | 1391 | } | ||
3734 | 1392 | else if (uri_and_title[0] == ':') | ||
3735 | 1393 | { | ||
3736 | 1394 | const gchar* title; | ||
3737 | 1395 | |||
3738 | 1396 | uri_and_title++; | ||
3739 | 1397 | if (uri_and_title == NULL) | ||
3740 | 1398 | continue; | ||
3741 | 1399 | title = strchr (uri_and_title, '|'); | ||
3742 | 1400 | if (title == NULL) | ||
3743 | 1401 | goto news_feeds_continue; | ||
3744 | 1402 | title++; | ||
3745 | 1403 | /* TODO: Parse search engine XML | ||
3746 | 1404 | midori_view_add_info_bar (view, GTK_MESSAGE_INFO, title, | ||
3747 | 1405 | G_CALLBACK (midori_view_open_search_response_cb), view, | ||
3748 | 1406 | _("_Save Search engine"), GTK_RESPONSE_ACCEPT, NULL); */ | ||
3749 | 1407 | } | ||
3750 | 1408 | |||
3751 | 1409 | news_feeds_continue: | ||
3752 | 1410 | current_item++; | ||
3753 | 1411 | } | ||
3754 | 1412 | g_strfreev (items); | ||
3755 | 1413 | |||
3756 | 1414 | g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free); | ||
3757 | 1415 | g_free (value); | ||
3758 | 1416 | } | ||
3759 | 1417 | #endif | ||
3760 | 1418 | |||
3761 | 1419 | midori_tab_set_progress (MIDORI_TAB (view), 1.0); | 1114 | midori_tab_set_progress (MIDORI_TAB (view), 1.0); |
3762 | 1420 | midori_view_update_load_status (view, MIDORI_LOAD_FINISHED); | 1115 | midori_view_update_load_status (view, MIDORI_LOAD_FINISHED); |
3763 | 1421 | } | 1116 | } |
3764 | 1422 | 1117 | ||
3765 | 1423 | #ifdef HAVE_WEBKIT2 | ||
3766 | 1424 | static void | 1118 | static void |
3767 | 1425 | midori_view_web_view_crashed_cb (WebKitWebView* web_view, | 1119 | midori_view_web_view_crashed_cb (WebKitWebView* web_view, |
3768 | 1426 | MidoriView* view) | 1120 | MidoriView* view) |
3769 | @@ -1430,6 +1124,7 @@ | |||
3770 | 1430 | gchar* message = g_strdup_printf (_("Something went wrong with '%s'."), uri); | 1124 | gchar* message = g_strdup_printf (_("Something went wrong with '%s'."), uri); |
3771 | 1431 | midori_view_display_error (view, uri, NULL, title, | 1125 | midori_view_display_error (view, uri, NULL, title, |
3772 | 1432 | message, "", NULL, _("Try again"), NULL); | 1126 | message, "", NULL, _("Try again"), NULL); |
3773 | 1127 | midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_CRASH); | ||
3774 | 1433 | g_free (message); | 1128 | g_free (message); |
3775 | 1434 | g_free (title); | 1129 | g_free (title); |
3776 | 1435 | } | 1130 | } |
3777 | @@ -1461,50 +1156,16 @@ | |||
3778 | 1461 | 1156 | ||
3779 | 1462 | g_object_thaw_notify (G_OBJECT (view)); | 1157 | g_object_thaw_notify (G_OBJECT (view)); |
3780 | 1463 | } | 1158 | } |
3781 | 1464 | #else | ||
3782 | 1465 | static void | ||
3783 | 1466 | midori_view_web_view_notify_load_status_cb (WebKitWebView* web_view, | ||
3784 | 1467 | GParamSpec* pspec, | ||
3785 | 1468 | MidoriView* view) | ||
3786 | 1469 | { | ||
3787 | 1470 | g_object_freeze_notify (G_OBJECT (view)); | ||
3788 | 1471 | |||
3789 | 1472 | switch (webkit_web_view_get_load_status (web_view)) | ||
3790 | 1473 | { | ||
3791 | 1474 | case WEBKIT_LOAD_PROVISIONAL: | ||
3792 | 1475 | midori_view_load_started (view); | ||
3793 | 1476 | break; | ||
3794 | 1477 | case WEBKIT_LOAD_COMMITTED: | ||
3795 | 1478 | midori_view_load_committed (view); | ||
3796 | 1479 | break; | ||
3797 | 1480 | case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: | ||
3798 | 1481 | /* Not implemented */ | ||
3799 | 1482 | break; | ||
3800 | 1483 | case WEBKIT_LOAD_FINISHED: | ||
3801 | 1484 | case WEBKIT_LOAD_FAILED: | ||
3802 | 1485 | midori_view_load_finished (view); | ||
3803 | 1486 | break; | ||
3804 | 1487 | default: | ||
3805 | 1488 | g_warn_if_reached (); | ||
3806 | 1489 | } | ||
3807 | 1490 | |||
3808 | 1491 | g_object_thaw_notify (G_OBJECT (view)); | ||
3809 | 1492 | } | ||
3810 | 1493 | #endif | ||
3811 | 1494 | 1159 | ||
3812 | 1495 | static void | 1160 | static void |
3813 | 1496 | midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view, | 1161 | midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view, |
3814 | 1497 | GParamSpec* pspec, | 1162 | GParamSpec* pspec, |
3815 | 1498 | MidoriView* view) | 1163 | MidoriView* view) |
3816 | 1499 | { | 1164 | { |
3817 | 1500 | #ifdef HAVE_WEBKIT2 | ||
3818 | 1501 | const gchar* uri = webkit_web_view_get_uri (web_view); | 1165 | const gchar* uri = webkit_web_view_get_uri (web_view); |
3819 | 1502 | WebKitWebContext* context = webkit_web_context_get_default (); | 1166 | WebKitWebContext* context = webkit_web_context_get_default (); |
3820 | 1503 | WebKitFaviconDatabase* favicon_database = webkit_web_context_get_favicon_database (context); | 1167 | WebKitFaviconDatabase* favicon_database = webkit_web_context_get_favicon_database (context); |
3821 | 1504 | gchar* icon_uri = webkit_favicon_database_get_favicon_uri (favicon_database, uri); | 1168 | gchar* icon_uri = webkit_favicon_database_get_favicon_uri (favicon_database, uri); |
3822 | 1505 | #else | ||
3823 | 1506 | gchar* icon_uri = g_strdup (webkit_web_view_get_icon_uri (web_view)); | ||
3824 | 1507 | #endif | ||
3825 | 1508 | katze_assign (view->icon_uri, icon_uri); | 1169 | katze_assign (view->icon_uri, icon_uri); |
3826 | 1509 | _midori_web_view_load_icon (view); | 1170 | _midori_web_view_load_icon (view); |
3827 | 1510 | } | 1171 | } |
3828 | @@ -1519,17 +1180,6 @@ | |||
3829 | 1519 | g_object_notify (G_OBJECT (view), "title"); | 1180 | g_object_notify (G_OBJECT (view), "title"); |
3830 | 1520 | } | 1181 | } |
3831 | 1521 | 1182 | ||
3832 | 1522 | #ifndef HAVE_WEBKIT2 | ||
3833 | 1523 | static void | ||
3834 | 1524 | webkit_web_view_statusbar_text_changed_cb (WebKitWebView* web_view, | ||
3835 | 1525 | const gchar* text, | ||
3836 | 1526 | MidoriView* view) | ||
3837 | 1527 | { | ||
3838 | 1528 | midori_tab_set_statusbar_text (MIDORI_TAB (view), text); | ||
3839 | 1529 | } | ||
3840 | 1530 | #endif | ||
3841 | 1531 | |||
3842 | 1532 | #if GTK_CHECK_VERSION(3, 2, 0) | ||
3843 | 1533 | static gboolean | 1183 | static gboolean |
3844 | 1534 | midori_view_overlay_frame_enter_notify_event_cb (GtkOverlay* overlay, | 1184 | midori_view_overlay_frame_enter_notify_event_cb (GtkOverlay* overlay, |
3845 | 1535 | GdkEventCrossing* event, | 1185 | GdkEventCrossing* event, |
3846 | @@ -1541,7 +1191,6 @@ | |||
3847 | 1541 | ? GTK_ALIGN_END : GTK_ALIGN_START); | 1191 | ? GTK_ALIGN_END : GTK_ALIGN_START); |
3848 | 1542 | return FALSE; | 1192 | return FALSE; |
3849 | 1543 | } | 1193 | } |
3850 | 1544 | #endif | ||
3851 | 1545 | 1194 | ||
3852 | 1546 | static gboolean | 1195 | static gboolean |
3853 | 1547 | midori_view_web_view_leave_notify_event_cb (WebKitWebView* web_view, | 1196 | midori_view_web_view_leave_notify_event_cb (WebKitWebView* web_view, |
3854 | @@ -1554,16 +1203,10 @@ | |||
3855 | 1554 | 1203 | ||
3856 | 1555 | static void | 1204 | static void |
3857 | 1556 | webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view, | 1205 | webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view, |
3858 | 1557 | #ifdef HAVE_WEBKIT2 | ||
3859 | 1558 | WebKitHitTestResult* hit_test_result, | 1206 | WebKitHitTestResult* hit_test_result, |
3860 | 1559 | guint modifiers, | 1207 | guint modifiers, |
3861 | 1560 | #else | ||
3862 | 1561 | const gchar* tooltip, | ||
3863 | 1562 | const gchar* link_uri, | ||
3864 | 1563 | #endif | ||
3865 | 1564 | MidoriView* view) | 1208 | MidoriView* view) |
3866 | 1565 | { | 1209 | { |
3867 | 1566 | #ifdef HAVE_WEBKIT2 | ||
3868 | 1567 | katze_object_assign (view->hit_test, g_object_ref (hit_test_result)); | 1210 | katze_object_assign (view->hit_test, g_object_ref (hit_test_result)); |
3869 | 1568 | if (!webkit_hit_test_result_context_is_link (hit_test_result)) | 1211 | if (!webkit_hit_test_result_context_is_link (hit_test_result)) |
3870 | 1569 | { | 1212 | { |
3871 | @@ -1571,7 +1214,6 @@ | |||
3872 | 1571 | return; | 1214 | return; |
3873 | 1572 | } | 1215 | } |
3874 | 1573 | const gchar* link_uri = webkit_hit_test_result_get_link_uri (hit_test_result); | 1216 | const gchar* link_uri = webkit_hit_test_result_get_link_uri (hit_test_result); |
3875 | 1574 | #endif | ||
3876 | 1575 | 1217 | ||
3877 | 1576 | katze_assign (view->link_uri, g_strdup (link_uri)); | 1218 | katze_assign (view->link_uri, g_strdup (link_uri)); |
3878 | 1577 | if (link_uri && g_str_has_prefix (link_uri, "mailto:")) | 1219 | if (link_uri && g_str_has_prefix (link_uri, "mailto:")) |
3879 | @@ -1597,25 +1239,6 @@ | |||
3880 | 1597 | gint *y, | 1239 | gint *y, |
3881 | 1598 | GdkEventButton* event) | 1240 | GdkEventButton* event) |
3882 | 1599 | { | 1241 | { |
3883 | 1600 | #ifndef HAVE_WEBKIT2 | ||
3884 | 1601 | g_return_if_fail (MIDORI_IS_VIEW (view)); | ||
3885 | 1602 | |||
3886 | 1603 | if (gtk_widget_get_window (view->web_view)) | ||
3887 | 1604 | { | ||
3888 | 1605 | |||
3889 | 1606 | if (x != NULL) | ||
3890 | 1607 | *x = event->x; | ||
3891 | 1608 | if (y != NULL) | ||
3892 | 1609 | *y = event->y; | ||
3893 | 1610 | |||
3894 | 1611 | katze_object_assign (view->hit_test, | ||
3895 | 1612 | g_object_ref ( | ||
3896 | 1613 | webkit_web_view_get_hit_test_result ( | ||
3897 | 1614 | WEBKIT_WEB_VIEW (view->web_view), event))); | ||
3898 | 1615 | katze_assign (view->link_uri, | ||
3899 | 1616 | katze_object_get_string (view->hit_test, "link-uri")); | ||
3900 | 1617 | } | ||
3901 | 1618 | #endif | ||
3902 | 1619 | } | 1242 | } |
3903 | 1620 | 1243 | ||
3904 | 1621 | #define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \ | 1244 | #define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \ |
3905 | @@ -1678,70 +1301,6 @@ | |||
3906 | 1678 | view->button_press_handled = TRUE; | 1301 | view->button_press_handled = TRUE; |
3907 | 1679 | return TRUE; | 1302 | return TRUE; |
3908 | 1680 | } | 1303 | } |
3909 | 1681 | #if GTK_CHECK_VERSION (3, 4, 0) | ||
3910 | 1682 | if (katze_object_get_boolean (gtk_widget_get_settings (view->web_view), "gtk-enable-primary-paste")) | ||
3911 | 1683 | #else | ||
3912 | 1684 | if (midori_settings_get_middle_click_opens_selection (MIDORI_SETTINGS (view->settings))) | ||
3913 | 1685 | #endif | ||
3914 | 1686 | { | ||
3915 | 1687 | #ifndef HAVE_WEBKIT2 | ||
3916 | 1688 | WebKitHitTestResult* result = webkit_web_view_get_hit_test_result (web_view, event); | ||
3917 | 1689 | WebKitHitTestResultContext context = katze_object_get_int (result, "context"); | ||
3918 | 1690 | gboolean is_editable = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; | ||
3919 | 1691 | g_object_unref (result); | ||
3920 | 1692 | if (!is_editable) | ||
3921 | 1693 | { | ||
3922 | 1694 | gchar* uri; | ||
3923 | 1695 | GtkClipboard* clipboard = gtk_clipboard_get_for_display ( | ||
3924 | 1696 | gtk_widget_get_display (GTK_WIDGET (view)), | ||
3925 | 1697 | GDK_SELECTION_PRIMARY); | ||
3926 | 1698 | if ((uri = gtk_clipboard_wait_for_text (clipboard))) | ||
3927 | 1699 | { | ||
3928 | 1700 | guint i = 0; | ||
3929 | 1701 | while (uri[i++] != '\0') | ||
3930 | 1702 | if (uri[i] == '\n' || uri[i] == '\r') | ||
3931 | 1703 | uri[i] = ' '; | ||
3932 | 1704 | g_strstrip (uri); | ||
3933 | 1705 | |||
3934 | 1706 | /* Hold Alt to search for the selected word */ | ||
3935 | 1707 | if (event->state & GDK_MOD1_MASK) | ||
3936 | 1708 | { | ||
3937 | 1709 | gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE); | ||
3938 | 1710 | if (!new_uri) | ||
3939 | 1711 | { | ||
3940 | 1712 | gchar* search = katze_object_get_string ( | ||
3941 | 1713 | view->settings, "location-entry-search"); | ||
3942 | 1714 | new_uri = midori_uri_for_search (search, uri); | ||
3943 | 1715 | g_free (search); | ||
3944 | 1716 | } | ||
3945 | 1717 | katze_assign (uri, new_uri); | ||
3946 | 1718 | } | ||
3947 | 1719 | else if (midori_uri_is_location (uri)) | ||
3948 | 1720 | { | ||
3949 | 1721 | if (MIDORI_MOD_NEW_TAB (event->state)) | ||
3950 | 1722 | { | ||
3951 | 1723 | background = view->open_tabs_in_the_background; | ||
3952 | 1724 | if (MIDORI_MOD_BACKGROUND (event->state)) | ||
3953 | 1725 | background = !background; | ||
3954 | 1726 | g_signal_emit (view, signals[NEW_TAB], 0, uri, background); | ||
3955 | 1727 | } | ||
3956 | 1728 | else | ||
3957 | 1729 | { | ||
3958 | 1730 | midori_view_set_uri (MIDORI_VIEW (view), uri); | ||
3959 | 1731 | gtk_widget_grab_focus (GTK_WIDGET (view)); | ||
3960 | 1732 | } | ||
3961 | 1733 | g_free (uri); | ||
3962 | 1734 | view->button_press_handled = TRUE; | ||
3963 | 1735 | return TRUE; | ||
3964 | 1736 | } | ||
3965 | 1737 | else | ||
3966 | 1738 | { | ||
3967 | 1739 | g_free (uri); | ||
3968 | 1740 | } | ||
3969 | 1741 | } | ||
3970 | 1742 | } | ||
3971 | 1743 | #endif | ||
3972 | 1744 | } | ||
3973 | 1745 | if (MIDORI_MOD_SCROLL (event->state)) | 1304 | if (MIDORI_MOD_SCROLL (event->state)) |
3974 | 1746 | { | 1305 | { |
3975 | 1747 | midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0); | 1306 | midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0); |
3976 | @@ -1751,9 +1310,7 @@ | |||
3977 | 1751 | break; | 1310 | break; |
3978 | 1752 | case 3: | 1311 | case 3: |
3979 | 1753 | /* Older versions don't have the context-menu signal */ | 1312 | /* Older versions don't have the context-menu signal */ |
3980 | 1754 | #if WEBKIT_CHECK_VERSION (1, 10, 0) | ||
3981 | 1755 | if (event->state & GDK_CONTROL_MASK) | 1313 | if (event->state & GDK_CONTROL_MASK) |
3982 | 1756 | #endif | ||
3983 | 1757 | { | 1314 | { |
3984 | 1758 | /* Ctrl + Right-click suppresses javascript button handling */ | 1315 | /* Ctrl + Right-click suppresses javascript button handling */ |
3985 | 1759 | GtkWidget* menu = gtk_menu_new (); | 1316 | GtkWidget* menu = gtk_menu_new (); |
3986 | @@ -1814,150 +1371,6 @@ | |||
3987 | 1814 | GdkEventKey* event, | 1371 | GdkEventKey* event, |
3988 | 1815 | MidoriView* view) | 1372 | MidoriView* view) |
3989 | 1816 | { | 1373 | { |
3990 | 1817 | #ifndef HAVE_WEBKIT2 | ||
3991 | 1818 | gint digit = g_ascii_digit_value (event->keyval); | ||
3992 | 1819 | gunichar uc = gdk_keyval_to_unicode (event->keyval); | ||
3993 | 1820 | gchar* result = NULL; | ||
3994 | 1821 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view); | ||
3995 | 1822 | JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); | ||
3996 | 1823 | |||
3997 | 1824 | if (view->find_links < 0) | ||
3998 | 1825 | { | ||
3999 | 1826 | /* Links are currently off, turn them on */ | ||
4000 | 1827 | midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midoriHKD87346 {" | ||
4001 | 1828 | " font-size:small !important; font-weight:bold !important;" | ||
4002 | 1829 | " z-index:500; border-radius:0.3em; line-height:1 !important;" | ||
4003 | 1830 | " background: white !important; color: black !important;" | ||
4004 | 1831 | " border:1px solid gray; padding:0 0.1em !important;" | ||
4005 | 1832 | " position:absolute; display:inline !important; }"); | ||
4006 | 1833 | midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midori_access_key_fc04de {" | ||
4007 | 1834 | " font-size:small !important; font-weight:bold !important;" | ||
4008 | 1835 | " z-index:500; border-radius:0.3em; line-height:1 !important;" | ||
4009 | 1836 | " background: black !important; color: white !important;" | ||
4010 | 1837 | " border:1px solid gray; padding:0 0.1em 0.2em 0.1em !important;" | ||
4011 | 1838 | " position:absolute; display:inline !important; }"); | ||
4012 | 1839 | result = sokoke_js_script_eval (js_context, | ||
4013 | 1840 | " var label_count = 0;" | ||
4014 | 1841 | " for (i in document.links) {" | ||
4015 | 1842 | " if (document.links[i].href && document.links[i].insertBefore) {" | ||
4016 | 1843 | " var child = document.createElement ('span');" | ||
4017 | 1844 | " if (document.links[i].accessKey && isNaN (document.links[i].accessKey)) {" | ||
4018 | 1845 | " child.setAttribute ('class', 'midori_access_key_fc04de');" | ||
4019 | 1846 | " child.appendChild (document.createTextNode (document.links[i].accessKey));" | ||
4020 | 1847 | " } else {" | ||
4021 | 1848 | " child.setAttribute ('class', 'midoriHKD87346');" | ||
4022 | 1849 | " child.appendChild (document.createTextNode (label_count));" | ||
4023 | 1850 | " label_count++;" | ||
4024 | 1851 | " }" | ||
4025 | 1852 | " document.links[i].insertBefore (child); } }", | ||
4026 | 1853 | NULL); | ||
4027 | 1854 | view->find_links = 0; /* Links are now on */ | ||
4028 | 1855 | g_free (result); | ||
4029 | 1856 | return; | ||
4030 | 1857 | } | ||
4031 | 1858 | |||
4032 | 1859 | if (event->keyval == '.') | ||
4033 | 1860 | { | ||
4034 | 1861 | /* Pressed '.' with links on, so turn them off */ | ||
4035 | 1862 | result = sokoke_js_script_eval (js_context, | ||
4036 | 1863 | "var links = document.getElementsByClassName ('midoriHKD87346');" | ||
4037 | 1864 | "for (var i = links.length - 1; i >= 0; i--) {" | ||
4038 | 1865 | " var parent = links[i].parentNode;" | ||
4039 | 1866 | " parent.removeChild(links[i]); }", | ||
4040 | 1867 | NULL); | ||
4041 | 1868 | g_free (result); | ||
4042 | 1869 | result = sokoke_js_script_eval (js_context, | ||
4043 | 1870 | "var links = document.getElementsByClassName ('midori_access_key_fc04de');" | ||
4044 | 1871 | "if (links != undefined && links.length > 0) {" | ||
4045 | 1872 | " for (var i = links.length - 1; i >= 0; i--) {" | ||
4046 | 1873 | " var parent = links[i].parentNode;" | ||
4047 | 1874 | " parent.removeChild(links[i]); } }", | ||
4048 | 1875 | NULL); | ||
4049 | 1876 | g_free (result); | ||
4050 | 1877 | view->find_links = -1; | ||
4051 | 1878 | return; | ||
4052 | 1879 | } | ||
4053 | 1880 | |||
4054 | 1881 | /* Links are already on at this point, so process the input character */ | ||
4055 | 1882 | |||
4056 | 1883 | if (digit != -1 && event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_Escape) | ||
4057 | 1884 | { | ||
4058 | 1885 | /* Got a digit, add it to the link count/ number */ | ||
4059 | 1886 | if (view->find_links > 0) | ||
4060 | 1887 | view->find_links *= 10; | ||
4061 | 1888 | view->find_links += digit; | ||
4062 | 1889 | return; | ||
4063 | 1890 | } | ||
4064 | 1891 | |||
4065 | 1892 | if (event->keyval == GDK_KEY_Escape) | ||
4066 | 1893 | { | ||
4067 | 1894 | // Clear the link count/number | ||
4068 | 1895 | view->find_links = 0; | ||
4069 | 1896 | return; | ||
4070 | 1897 | } | ||
4071 | 1898 | |||
4072 | 1899 | if (g_unichar_isalpha (uc)) | ||
4073 | 1900 | { | ||
4074 | 1901 | /* letter pressed if we have a corresponding accessKey and grab URI */ | ||
4075 | 1902 | gchar* script = NULL; | ||
4076 | 1903 | gchar* utf8 = NULL; | ||
4077 | 1904 | gulong sz = g_unichar_to_utf8 (uc, NULL); | ||
4078 | 1905 | |||
4079 | 1906 | utf8 = g_malloc0 (sz); | ||
4080 | 1907 | g_unichar_to_utf8 (uc, utf8); | ||
4081 | 1908 | script = g_strdup_printf ( | ||
4082 | 1909 | "var l = 'undefined';" | ||
4083 | 1910 | "for (i in document.links) {" | ||
4084 | 1911 | " if ( document.links[i].href &&" | ||
4085 | 1912 | " document.links[i].accessKey == \"%s\" )" | ||
4086 | 1913 | " {" | ||
4087 | 1914 | " l = document.links[i].href;" | ||
4088 | 1915 | " break;" | ||
4089 | 1916 | " }" | ||
4090 | 1917 | "}" | ||
4091 | 1918 | "if (l != 'undefined') { l; }" | ||
4092 | 1919 | , utf8 | ||
4093 | 1920 | ); | ||
4094 | 1921 | g_free (utf8); | ||
4095 | 1922 | result = sokoke_js_script_eval (js_context, script, NULL); | ||
4096 | 1923 | g_free (script); | ||
4097 | 1924 | } | ||
4098 | 1925 | else if (event->keyval == GDK_KEY_Return) | ||
4099 | 1926 | { | ||
4100 | 1927 | /* Return pressed, grab URI if we have a link with the entered number */ | ||
4101 | 1928 | gchar* script = g_strdup_printf ( | ||
4102 | 1929 | "var links = document.getElementsByClassName ('midoriHKD87346');" | ||
4103 | 1930 | "var i = %d; var return_key = %d;" | ||
4104 | 1931 | "if (return_key) {" | ||
4105 | 1932 | " if (typeof links[i] != 'undefined')" | ||
4106 | 1933 | " links[i].parentNode.href; }", | ||
4107 | 1934 | view->find_links, event->keyval == GDK_KEY_Return | ||
4108 | 1935 | ); | ||
4109 | 1936 | result = sokoke_js_script_eval (js_context, script, NULL); | ||
4110 | 1937 | g_free (script); | ||
4111 | 1938 | } | ||
4112 | 1939 | |||
4113 | 1940 | /* Check the URI we grabbed to see if it's valid, if so go there */ | ||
4114 | 1941 | if (midori_uri_is_location (result)) | ||
4115 | 1942 | { | ||
4116 | 1943 | if (MIDORI_MOD_NEW_TAB (event->state)) | ||
4117 | 1944 | { | ||
4118 | 1945 | gboolean background = view->open_tabs_in_the_background; | ||
4119 | 1946 | if (MIDORI_MOD_BACKGROUND (event->state)) | ||
4120 | 1947 | background = !background; | ||
4121 | 1948 | g_signal_emit (view, signals[NEW_TAB], 0, result, background); | ||
4122 | 1949 | } | ||
4123 | 1950 | else | ||
4124 | 1951 | midori_view_set_uri (view, result); | ||
4125 | 1952 | view->find_links = -1; /* Turn off link mode */ | ||
4126 | 1953 | } | ||
4127 | 1954 | else /* Invalid URI, start over... */ | ||
4128 | 1955 | view->find_links = 0; | ||
4129 | 1956 | |||
4130 | 1957 | if (result) | ||
4131 | 1958 | g_free (result); | ||
4132 | 1959 | return; | ||
4133 | 1960 | #endif | ||
4134 | 1961 | } | 1374 | } |
4135 | 1962 | 1375 | ||
4136 | 1963 | static gboolean | 1376 | static gboolean |
4137 | @@ -1992,21 +1405,12 @@ | |||
4138 | 1992 | if (character == (event->keyval | 0x01000000)) | 1405 | if (character == (event->keyval | 0x01000000)) |
4139 | 1993 | return FALSE; | 1406 | return FALSE; |
4140 | 1994 | 1407 | ||
4141 | 1995 | #ifdef HAVE_WEBKIT2 | ||
4142 | 1996 | WebKitHitTestResultContext context = katze_object_get_int (view->hit_test, "context"); | 1408 | WebKitHitTestResultContext context = katze_object_get_int (view->hit_test, "context"); |
4143 | 1997 | if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) | 1409 | if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) |
4144 | 1998 | #else | ||
4145 | 1999 | if (!webkit_web_view_can_cut_clipboard (web_view) | ||
4146 | 2000 | && !webkit_web_view_can_paste_clipboard (web_view)) | ||
4147 | 2001 | #endif | ||
4148 | 2002 | { | 1410 | { |
4149 | 2003 | gchar* text = character ? g_strdup_printf ("%c", character) : NULL; | 1411 | gchar* text = character ? g_strdup_printf ("%c", character) : NULL; |
4150 | 2004 | #if GTK_CHECK_VERSION(3, 2, 0) | ||
4151 | 2005 | midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find), | 1412 | midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find), |
4152 | 2006 | (GtkWidget*)view, TRUE, katze_str_non_null (text)); | 1413 | (GtkWidget*)view, TRUE, katze_str_non_null (text)); |
4153 | 2007 | #else | ||
4154 | 2008 | g_signal_emit_by_name (view, "search-text", TRUE, katze_str_non_null (text)); | ||
4155 | 2009 | #endif | ||
4156 | 2010 | g_free (text); | 1414 | g_free (text); |
4157 | 2011 | return TRUE; | 1415 | return TRUE; |
4158 | 2012 | } | 1416 | } |
4159 | @@ -2058,19 +1462,10 @@ | |||
4160 | 2058 | MidoriDownloadType type, | 1462 | MidoriDownloadType type, |
4161 | 2059 | const gchar* uri) | 1463 | const gchar* uri) |
4162 | 2060 | { | 1464 | { |
4163 | 2061 | #ifdef HAVE_WEBKIT2 | ||
4164 | 2062 | WebKitDownload* download = webkit_web_view_download_uri (WEBKIT_WEB_VIEW (view->web_view), uri); | 1465 | WebKitDownload* download = webkit_web_view_download_uri (WEBKIT_WEB_VIEW (view->web_view), uri); |
4165 | 2063 | WebKitWebContext * web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view)); | 1466 | WebKitWebContext * web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view)); |
4166 | 2064 | midori_download_set_type (download, type); | 1467 | midori_download_set_type (download, type); |
4167 | 2065 | g_signal_emit_by_name (web_context, "download-started", download, view); | 1468 | g_signal_emit_by_name (web_context, "download-started", download, view); |
4168 | 2066 | #else | ||
4169 | 2067 | WebKitNetworkRequest* request = webkit_network_request_new (uri); | ||
4170 | 2068 | WebKitDownload* download = webkit_download_new (request); | ||
4171 | 2069 | g_object_unref (request); | ||
4172 | 2070 | midori_download_set_type (download, type); | ||
4173 | 2071 | gboolean handled; | ||
4174 | 2072 | g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled); | ||
4175 | 2073 | #endif | ||
4176 | 2074 | } | 1469 | } |
4177 | 2075 | 1470 | ||
4178 | 2076 | static void | 1471 | static void |
4179 | @@ -2106,19 +1501,7 @@ | |||
4180 | 2106 | GList* | 1501 | GList* |
4181 | 2107 | midori_view_get_resources (MidoriView* view) | 1502 | midori_view_get_resources (MidoriView* view) |
4182 | 2108 | { | 1503 | { |
4183 | 2109 | #ifndef HAVE_WEBKIT2 | ||
4184 | 2110 | g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL); | ||
4185 | 2111 | |||
4186 | 2112 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); | ||
4187 | 2113 | WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view); | ||
4188 | 2114 | WebKitWebDataSource* data_source = webkit_web_frame_get_data_source (frame); | ||
4189 | 2115 | GList* resources = webkit_web_data_source_get_subresources (data_source); | ||
4190 | 2116 | resources = g_list_prepend (resources, webkit_web_data_source_get_main_resource (data_source)); | ||
4191 | 2117 | g_list_foreach (resources, (GFunc)g_object_ref, NULL); | ||
4192 | 2118 | return resources; | ||
4193 | 2119 | #else | ||
4194 | 2120 | return NULL; | 1504 | return NULL; |
4195 | 2121 | #endif | ||
4196 | 2122 | } | 1505 | } |
4197 | 2123 | 1506 | ||
4198 | 2124 | static GString* | 1507 | static GString* |
4199 | @@ -2128,19 +1511,6 @@ | |||
4200 | 2128 | GList* resources = midori_view_get_resources (view); | 1511 | GList* resources = midori_view_get_resources (view); |
4201 | 2129 | GString* result = NULL; | 1512 | GString* result = NULL; |
4202 | 2130 | 1513 | ||
4203 | 2131 | #ifndef HAVE_WEBKIT2 | ||
4204 | 2132 | GList* list; | ||
4205 | 2133 | for (list = resources; list; list = g_list_next (list)) | ||
4206 | 2134 | { | ||
4207 | 2135 | WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data); | ||
4208 | 2136 | GString* data = webkit_web_resource_get_data (resource); | ||
4209 | 2137 | if (!g_strcmp0 (webkit_web_resource_get_uri (resource), uri)) | ||
4210 | 2138 | { | ||
4211 | 2139 | result = data; | ||
4212 | 2140 | break; | ||
4213 | 2141 | } | ||
4214 | 2142 | } | ||
4215 | 2143 | #endif | ||
4216 | 2144 | g_list_foreach (resources, (GFunc)g_object_unref, NULL); | 1514 | g_list_foreach (resources, (GFunc)g_object_unref, NULL); |
4217 | 2145 | g_list_free (resources); | 1515 | g_list_free (resources); |
4218 | 2146 | return result; | 1516 | return result; |
4219 | @@ -2225,20 +1595,6 @@ | |||
4220 | 2225 | g_free (uri); | 1595 | g_free (uri); |
4221 | 2226 | } | 1596 | } |
4222 | 2227 | 1597 | ||
4223 | 2228 | #ifndef HAVE_WEBKIT2 | ||
4224 | 2229 | static void | ||
4225 | 2230 | midori_view_menu_open_email_activate_cb (GtkAction* action, | ||
4226 | 2231 | gpointer user_data) | ||
4227 | 2232 | { | ||
4228 | 2233 | MidoriView* view = user_data; | ||
4229 | 2234 | gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri"); | ||
4230 | 2235 | gchar* uri = g_strconcat ("mailto:", data, NULL); | ||
4231 | 2236 | gboolean handled = FALSE; | ||
4232 | 2237 | g_signal_emit_by_name (view, "open-uri", uri, &handled); | ||
4233 | 2238 | g_free (uri); | ||
4234 | 2239 | } | ||
4235 | 2240 | #endif | ||
4236 | 2241 | |||
4237 | 2242 | static void | 1598 | static void |
4238 | 2243 | midori_view_menu_open_link_tab_activate_cb (GtkAction* action, | 1599 | midori_view_menu_open_link_tab_activate_cb (GtkAction* action, |
4239 | 2244 | gpointer user_data) | 1600 | gpointer user_data) |
4240 | @@ -2262,30 +1618,6 @@ | |||
4241 | 2262 | !view->open_tabs_in_the_background); | 1618 | !view->open_tabs_in_the_background); |
4242 | 2263 | } | 1619 | } |
4243 | 2264 | 1620 | ||
4244 | 2265 | #ifndef HAVE_WEBKIT2 | ||
4245 | 2266 | static void | ||
4246 | 2267 | midori_web_view_menu_search_web_activate_cb (GtkAction* action, | ||
4247 | 2268 | gpointer user_data) | ||
4248 | 2269 | { | ||
4249 | 2270 | MidoriView* view = user_data; | ||
4250 | 2271 | const gchar* search = g_object_get_data (G_OBJECT (action), "search"); | ||
4251 | 2272 | if (search == NULL) | ||
4252 | 2273 | search = midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings)); | ||
4253 | 2274 | gchar* uri = midori_uri_for_search (search, view->selected_text); | ||
4254 | 2275 | |||
4255 | 2276 | if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW) | ||
4256 | 2277 | g_signal_emit (view, signals[NEW_WINDOW], 0, uri); | ||
4257 | 2278 | /* FIXME: need a way to override behavior (middle click) | ||
4258 | 2279 | else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) | ||
4259 | 2280 | midori_view_set_uri (view, uri); */ | ||
4260 | 2281 | else | ||
4261 | 2282 | g_signal_emit (view, signals[NEW_TAB], 0, uri, | ||
4262 | 2283 | view->open_tabs_in_the_background); | ||
4263 | 2284 | |||
4264 | 2285 | g_free (uri); | ||
4265 | 2286 | } | ||
4266 | 2287 | #endif | ||
4267 | 2288 | |||
4268 | 2289 | static void | 1621 | static void |
4269 | 2290 | midori_view_tab_label_menu_window_new_cb (GtkAction* action, | 1622 | midori_view_tab_label_menu_window_new_cb (GtkAction* action, |
4270 | 2291 | gpointer user_data) | 1623 | gpointer user_data) |
4271 | @@ -2295,30 +1627,12 @@ | |||
4272 | 2295 | midori_view_get_display_uri (MIDORI_VIEW (view))); | 1627 | midori_view_get_display_uri (MIDORI_VIEW (view))); |
4273 | 2296 | } | 1628 | } |
4274 | 2297 | 1629 | ||
4275 | 2298 | #ifndef HAVE_WEBKIT2 | ||
4276 | 2299 | static void | ||
4277 | 2300 | midori_web_view_open_frame_in_new_tab_cb (GtkAction* action, | ||
4278 | 2301 | gpointer user_data) | ||
4279 | 2302 | { | ||
4280 | 2303 | MidoriView* view = user_data; | ||
4281 | 2304 | WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view)); | ||
4282 | 2305 | g_signal_emit (view, signals[NEW_TAB], 0, | ||
4283 | 2306 | webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background); | ||
4284 | 2307 | } | ||
4285 | 2308 | #endif | ||
4286 | 2309 | |||
4287 | 2310 | static void | 1630 | static void |
4288 | 2311 | midori_view_inspect_element_activate_cb (GtkAction* action, | 1631 | midori_view_inspect_element_activate_cb (GtkAction* action, |
4289 | 2312 | gpointer user_data) | 1632 | gpointer user_data) |
4290 | 2313 | { | 1633 | { |
4291 | 2314 | MidoriView* view = user_data; | 1634 | MidoriView* view = user_data; |
4292 | 2315 | WebKitWebInspector* inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view)); | 1635 | WebKitWebInspector* inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view)); |
4293 | 2316 | #ifndef HAVE_WEBKIT2 | ||
4294 | 2317 | WebKitHitTestResult* hit_test_result = view->hit_test; | ||
4295 | 2318 | gint x = katze_object_get_int (hit_test_result, "x"); | ||
4296 | 2319 | gint y = katze_object_get_int (hit_test_result, "y"); | ||
4297 | 2320 | webkit_web_inspector_inspect_coordinates (inspector, x, y); | ||
4298 | 2321 | #endif | ||
4299 | 2322 | webkit_web_inspector_show (inspector); | 1636 | webkit_web_inspector_show (inspector); |
4300 | 2323 | } | 1637 | } |
4301 | 2324 | 1638 | ||
4302 | @@ -2443,76 +1757,6 @@ | |||
4303 | 2443 | midori_web_view_menu_video_save_activate_cb, view); | 1757 | midori_web_view_menu_video_save_activate_cb, view); |
4304 | 2444 | } | 1758 | } |
4305 | 2445 | 1759 | ||
4306 | 2446 | #ifndef HAVE_WEBKIT2 | ||
4307 | 2447 | if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION) | ||
4308 | 2448 | { | ||
4309 | 2449 | if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) | ||
4310 | 2450 | midori_context_action_add (menu, NULL); | ||
4311 | 2451 | |||
4312 | 2452 | /* Ensure view->selected_text */ | ||
4313 | 2453 | midori_view_has_selection (view); | ||
4314 | 2454 | if (midori_uri_is_valid (view->selected_text)) | ||
4315 | 2455 | { | ||
4316 | 2456 | /* :// and @ together would mean login credentials */ | ||
4317 | 2457 | if (g_str_has_prefix (view->selected_text, "mailto:") | ||
4318 | 2458 | || (strchr (view->selected_text, '@') != NULL | ||
4319 | 2459 | && strstr (view->selected_text, "://") == NULL)) | ||
4320 | 2460 | { | ||
4321 | 2461 | gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text); | ||
4322 | 2462 | GtkAction* action = (GtkAction*)midori_context_action_new_escaped ("SendMessage", text, NULL, GTK_STOCK_JUMP_TO); | ||
4323 | 2463 | g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free); | ||
4324 | 2464 | g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_email_activate_cb), view); | ||
4325 | 2465 | midori_context_action_add (menu, action); | ||
4326 | 2466 | g_free (text); | ||
4327 | 2467 | } | ||
4328 | 2468 | else | ||
4329 | 2469 | { | ||
4330 | 2470 | GtkAction* action = gtk_action_new ("OpenAddressInNewTab", _("Open Address in New _Tab"), NULL, GTK_STOCK_JUMP_TO); | ||
4331 | 2471 | g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free); | ||
4332 | 2472 | g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view); | ||
4333 | 2473 | midori_context_action_add (menu, action); | ||
4334 | 2474 | } | ||
4335 | 2475 | } | ||
4336 | 2476 | |||
4337 | 2477 | KatzeArray* search_engines = katze_object_get_object (browser, "search-engines"); | ||
4338 | 2478 | if (search_engines != NULL) | ||
4339 | 2479 | { | ||
4340 | 2480 | MidoriContextAction* searches = midori_context_action_new ("SearchWith", _("Search _with"), NULL, NULL); | ||
4341 | 2481 | midori_context_action_add (menu, GTK_ACTION (searches)); | ||
4342 | 2482 | |||
4343 | 2483 | KatzeItem* item; | ||
4344 | 2484 | guint i = 0; | ||
4345 | 2485 | KATZE_ARRAY_FOREACH_ITEM (item, search_engines) | ||
4346 | 2486 | { | ||
4347 | 2487 | GdkPixbuf* pixbuf; | ||
4348 | 2488 | gchar* search_option = g_strdup_printf ("SearchWith%u", i); | ||
4349 | 2489 | GtkAction* action = (GtkAction*)midori_context_action_new_escaped (search_option, katze_item_get_name (item), NULL, STOCK_EDIT_FIND); | ||
4350 | 2490 | g_free (search_option); | ||
4351 | 2491 | midori_context_action_add (searches, action); | ||
4352 | 2492 | if ((pixbuf = midori_paths_get_icon (katze_item_get_uri (item), NULL))) | ||
4353 | 2493 | { | ||
4354 | 2494 | gtk_action_set_gicon (action, G_ICON (pixbuf)); | ||
4355 | 2495 | g_object_unref (pixbuf); | ||
4356 | 2496 | } | ||
4357 | 2497 | else | ||
4358 | 2498 | { | ||
4359 | 2499 | GIcon* icon = g_themed_icon_new_with_default_fallbacks ("edit-find-option-symbolic"); | ||
4360 | 2500 | gtk_action_set_gicon (action, icon); | ||
4361 | 2501 | } | ||
4362 | 2502 | gtk_action_set_always_show_image (GTK_ACTION (action), TRUE); | ||
4363 | 2503 | g_object_set_data (G_OBJECT (action), "search", (gchar*)katze_item_get_uri (item)); | ||
4364 | 2504 | g_signal_connect (action, "activate", | ||
4365 | 2505 | G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view); | ||
4366 | 2506 | i++; | ||
4367 | 2507 | } | ||
4368 | 2508 | g_object_unref (search_engines); | ||
4369 | 2509 | } | ||
4370 | 2510 | if (midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings)) != NULL) | ||
4371 | 2511 | midori_context_action_add_simple (menu, "SearchWeb", _("_Search the Web"), NULL, GTK_STOCK_FIND, | ||
4372 | 2512 | midori_web_view_menu_search_web_activate_cb, view); | ||
4373 | 2513 | } | ||
4374 | 2514 | #endif | ||
4375 | 2515 | |||
4376 | 2516 | if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT) | 1760 | if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT) |
4377 | 2517 | { | 1761 | { |
4378 | 2518 | midori_context_action_add_by_name (menu, "Back"); | 1762 | midori_context_action_add_by_name (menu, "Back"); |
4379 | @@ -2535,12 +1779,6 @@ | |||
4380 | 2535 | { | 1779 | { |
4381 | 2536 | midori_context_action_add (menu, NULL); | 1780 | midori_context_action_add (menu, NULL); |
4382 | 2537 | midori_context_action_add_by_name (menu, "UndoTabClose"); | 1781 | midori_context_action_add_by_name (menu, "UndoTabClose"); |
4383 | 2538 | #ifndef HAVE_WEBKIT2 | ||
4384 | 2539 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view); | ||
4385 | 2540 | if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view)) | ||
4386 | 2541 | midori_context_action_add_simple (menu, "OpenFrameInNewTab", _("Open _Frame in New Tab"), NULL, NULL, | ||
4387 | 2542 | midori_web_view_open_frame_in_new_tab_cb, view); | ||
4388 | 2543 | #endif | ||
4389 | 2544 | midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW, | 1782 | midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW, |
4390 | 2545 | midori_view_tab_label_menu_window_new_cb, view); | 1783 | midori_view_tab_label_menu_window_new_cb, view); |
4391 | 2546 | midori_context_action_add_by_name (menu, "ZoomIn"); | 1784 | midori_context_action_add_by_name (menu, "ZoomIn"); |
4392 | @@ -2614,26 +1852,14 @@ | |||
4393 | 2614 | #if WEBKIT_CHECK_VERSION (1, 10, 0) | 1852 | #if WEBKIT_CHECK_VERSION (1, 10, 0) |
4394 | 2615 | static gboolean | 1853 | static gboolean |
4395 | 2616 | midori_view_web_view_context_menu_cb (WebKitWebView* web_view, | 1854 | midori_view_web_view_context_menu_cb (WebKitWebView* web_view, |
4396 | 2617 | #ifdef HAVE_WEBKIT2 | ||
4397 | 2618 | WebKitContextMenu* context_menu, | 1855 | WebKitContextMenu* context_menu, |
4398 | 2619 | GdkEvent* event, | 1856 | GdkEvent* event, |
4399 | 2620 | WebKitHitTestResult* hit_test_result, | 1857 | WebKitHitTestResult* hit_test_result, |
4400 | 2621 | #else | ||
4401 | 2622 | GtkMenu* default_menu, | ||
4402 | 2623 | WebKitHitTestResult* hit_test_result, | ||
4403 | 2624 | gboolean keyboard, | ||
4404 | 2625 | #endif | ||
4405 | 2626 | MidoriView* view) | 1858 | MidoriView* view) |
4406 | 2627 | { | 1859 | { |
4407 | 2628 | #ifndef HAVE_WEBKIT2 | ||
4408 | 2629 | GdkEvent* event = gtk_get_current_event(); | ||
4409 | 2630 | midori_view_ensure_link_uri (view, NULL, NULL, (GdkEventButton *)event); | ||
4410 | 2631 | gdk_event_free (event); | ||
4411 | 2632 | #endif | ||
4412 | 2633 | MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result); | 1860 | MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result); |
4413 | 2634 | /* Retain specific menu items we can't re-create easily */ | 1861 | /* Retain specific menu items we can't re-create easily */ |
4414 | 2635 | guint guesses = 0, guesses_max = 10; /* Maximum number of spelling suggestions */ | 1862 | guint guesses = 0, guesses_max = 10; /* Maximum number of spelling suggestions */ |
4415 | 2636 | #ifdef HAVE_WEBKIT2 | ||
4416 | 2637 | GList* items = webkit_context_menu_get_items (context_menu), *item, *preserved = NULL; | 1863 | GList* items = webkit_context_menu_get_items (context_menu), *item, *preserved = NULL; |
4417 | 2638 | for (item = items; item; item = g_list_next (item)) | 1864 | for (item = items; item; item = g_list_next (item)) |
4418 | 2639 | { | 1865 | { |
4419 | @@ -2649,21 +1875,6 @@ | |||
4420 | 2649 | } | 1875 | } |
4421 | 2650 | g_list_free (preserved); | 1876 | g_list_free (preserved); |
4422 | 2651 | midori_context_action_create_webkit_context_menu (menu, context_menu); | 1877 | midori_context_action_create_webkit_context_menu (menu, context_menu); |
4423 | 2652 | #else | ||
4424 | 2653 | GList* items = gtk_container_get_children (GTK_CONTAINER (default_menu)), *item; | ||
4425 | 2654 | for (item = items; item; item = g_list_next (item)) | ||
4426 | 2655 | { | ||
4427 | 2656 | /* Private API: Source/WebCore/platform/ContextMenuItem.h */ | ||
4428 | 2657 | int stock_action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), "webkit-context-menu")); | ||
4429 | 2658 | const int ContextMenuItemTagSpellingGuess = 30; | ||
4430 | 2659 | if (stock_action == ContextMenuItemTagSpellingGuess && guesses++ < guesses_max) | ||
4431 | 2660 | continue; | ||
4432 | 2661 | else | ||
4433 | 2662 | gtk_widget_destroy (item->data); | ||
4434 | 2663 | } | ||
4435 | 2664 | g_list_free (items); | ||
4436 | 2665 | midori_context_action_create_menu (menu, default_menu, FALSE); | ||
4437 | 2666 | #endif | ||
4438 | 2667 | return FALSE; | 1878 | return FALSE; |
4439 | 2668 | } | 1879 | } |
4440 | 2669 | #endif | 1880 | #endif |
4441 | @@ -2683,20 +1894,18 @@ | |||
4442 | 2683 | MidoriNewView where = MIDORI_NEW_VIEW_TAB; | 1894 | MidoriNewView where = MIDORI_NEW_VIEW_TAB; |
4443 | 2684 | GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view)); | 1895 | GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view)); |
4444 | 2685 | 1896 | ||
4445 | 2686 | #ifdef HAVE_WEBKIT2 | ||
4446 | 2687 | WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view)); | 1897 | WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view)); |
4447 | 2688 | #else | ||
4448 | 2689 | WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (WEBKIT_WEB_VIEW (web_view)); | ||
4449 | 2690 | #endif | ||
4450 | 2691 | gboolean locationbar_visible, menubar_visible, toolbar_visible; | 1898 | gboolean locationbar_visible, menubar_visible, toolbar_visible; |
4451 | 1899 | GdkRectangle* geometry = NULL; | ||
4452 | 2692 | gint width, height; | 1900 | gint width, height; |
4453 | 2693 | g_object_get (features, | 1901 | g_object_get (features, |
4454 | 2694 | "locationbar-visible", &locationbar_visible, | 1902 | "locationbar-visible", &locationbar_visible, |
4455 | 2695 | "menubar-visible", &menubar_visible, | 1903 | "menubar-visible", &menubar_visible, |
4456 | 2696 | "toolbar-visible", &toolbar_visible, | 1904 | "toolbar-visible", &toolbar_visible, |
4459 | 2697 | "width", &width, | 1905 | "geometry", &geometry, |
4458 | 2698 | "height", &height, | ||
4460 | 2699 | NULL); | 1906 | NULL); |
4461 | 1907 | width = geometry->width; | ||
4462 | 1908 | height = geometry->height; | ||
4463 | 2700 | midori_tab_set_is_dialog (MIDORI_TAB (view), | 1909 | midori_tab_set_is_dialog (MIDORI_TAB (view), |
4464 | 2701 | !locationbar_visible && !menubar_visible && !toolbar_visible | 1910 | !locationbar_visible && !menubar_visible && !toolbar_visible |
4465 | 2702 | && width > 0 && height > 0); | 1911 | && width > 0 && height > 0); |
4466 | @@ -2723,32 +1932,21 @@ | |||
4467 | 2723 | GtkWidget* toplevel = gtk_widget_get_toplevel (new_view); | 1932 | GtkWidget* toplevel = gtk_widget_get_toplevel (new_view); |
4468 | 2724 | if (width > 0 && height > 0) | 1933 | if (width > 0 && height > 0) |
4469 | 2725 | gtk_widget_set_size_request (toplevel, width, height); | 1934 | gtk_widget_set_size_request (toplevel, width, height); |
4470 | 2726 | #ifdef HAVE_WEBKIT2 | ||
4471 | 2727 | g_signal_connect (web_view, "close", | 1935 | g_signal_connect (web_view, "close", |
4472 | 2728 | G_CALLBACK (midori_view_web_view_close_cb), new_view); | 1936 | G_CALLBACK (midori_view_web_view_close_cb), new_view); |
4473 | 2729 | #else | ||
4474 | 2730 | g_signal_connect (web_view, "close-web-view", | ||
4475 | 2731 | G_CALLBACK (midori_view_web_view_close_cb), new_view); | ||
4476 | 2732 | #endif | ||
4477 | 2733 | } | 1937 | } |
4478 | 2734 | 1938 | ||
4479 | 2735 | return TRUE; | 1939 | return TRUE; |
4480 | 2736 | } | 1940 | } |
4481 | 2737 | 1941 | ||
4482 | 2738 | static GtkWidget* | 1942 | static GtkWidget* |
4488 | 2739 | webkit_web_view_create_web_view_cb (GtkWidget* web_view, | 1943 | webkit_web_view_create_web_view_cb (GtkWidget* web_view, |
4489 | 2740 | #ifndef HAVE_WEBKIT2 | 1944 | WebKitNavigationAction* navigation_action, |
4490 | 2741 | WebKitWebFrame* web_frame, | 1945 | MidoriView* view) |
4486 | 2742 | #endif | ||
4487 | 2743 | MidoriView* view) | ||
4491 | 2744 | { | 1946 | { |
4492 | 2745 | MidoriView* new_view; | 1947 | MidoriView* new_view; |
4493 | 2746 | 1948 | ||
4494 | 2747 | #ifdef HAVE_WEBKIT2 | ||
4495 | 2748 | const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)); | 1949 | const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)); |
4496 | 2749 | #else | ||
4497 | 2750 | const gchar* uri = webkit_web_frame_get_uri (web_frame); | ||
4498 | 2751 | #endif | ||
4499 | 2752 | if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) | 1950 | if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) |
4500 | 2753 | new_view = view; | 1951 | new_view = view; |
4501 | 2754 | else | 1952 | else |
4502 | @@ -2756,53 +1954,13 @@ | |||
4503 | 2756 | KatzeItem* item = katze_item_new (); | 1954 | KatzeItem* item = katze_item_new (); |
4504 | 2757 | item->uri = g_strdup (uri); | 1955 | item->uri = g_strdup (uri); |
4505 | 2758 | new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL); | 1956 | new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL); |
4506 | 2759 | #ifdef HAVE_WEBKIT2 | ||
4507 | 2760 | g_signal_connect (new_view->web_view, "ready-to-show", | 1957 | g_signal_connect (new_view->web_view, "ready-to-show", |
4508 | 2761 | G_CALLBACK (webkit_web_view_web_view_ready_cb), view); | 1958 | G_CALLBACK (webkit_web_view_web_view_ready_cb), view); |
4509 | 2762 | #else | ||
4510 | 2763 | g_signal_connect (new_view->web_view, "web-view-ready", | ||
4511 | 2764 | G_CALLBACK (webkit_web_view_web_view_ready_cb), view); | ||
4512 | 2765 | #endif | ||
4513 | 2766 | } | 1959 | } |
4514 | 2767 | g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free); | 1960 | g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free); |
4515 | 2768 | return new_view->web_view; | 1961 | return new_view->web_view; |
4516 | 2769 | } | 1962 | } |
4517 | 2770 | 1963 | ||
4518 | 2771 | #ifndef HAVE_WEBKIT2 | ||
4519 | 2772 | static gboolean | ||
4520 | 2773 | webkit_web_view_mime_type_decision_cb (GtkWidget* web_view, | ||
4521 | 2774 | WebKitWebFrame* web_frame, | ||
4522 | 2775 | WebKitNetworkRequest* request, | ||
4523 | 2776 | const gchar* mime_type, | ||
4524 | 2777 | WebKitWebPolicyDecision* decision, | ||
4525 | 2778 | MidoriView* view) | ||
4526 | 2779 | { | ||
4527 | 2780 | /* FIXME: Never download plugins from sub resources */ | ||
4528 | 2781 | if (!strcmp (mime_type, "application/x-shockwave-flash")) | ||
4529 | 2782 | if (strcmp (midori_tab_get_uri (MIDORI_TAB (view)), webkit_network_request_get_uri (request))) | ||
4530 | 2783 | return FALSE; | ||
4531 | 2784 | |||
4532 | 2785 | if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type)) | ||
4533 | 2786 | { | ||
4534 | 2787 | if (web_frame == webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view))) | ||
4535 | 2788 | { | ||
4536 | 2789 | g_warn_if_fail (mime_type != NULL); | ||
4537 | 2790 | midori_tab_set_mime_type (MIDORI_TAB (view), mime_type); | ||
4538 | 2791 | katze_item_set_meta_string (view->item, "mime-type", mime_type); | ||
4539 | 2792 | if (view->icon == NULL) | ||
4540 | 2793 | midori_view_unset_icon (view); | ||
4541 | 2794 | } | ||
4542 | 2795 | |||
4543 | 2796 | return FALSE; | ||
4544 | 2797 | } | ||
4545 | 2798 | |||
4546 | 2799 | g_object_set_data(G_OBJECT (view), "download-mime-type", (gpointer)mime_type); | ||
4547 | 2800 | webkit_web_policy_decision_download (decision); | ||
4548 | 2801 | g_object_set_data(G_OBJECT (view), "download-mime-type", NULL); | ||
4549 | 2802 | return TRUE; | ||
4550 | 2803 | } | ||
4551 | 2804 | #endif | ||
4552 | 2805 | |||
4553 | 2806 | gint | 1964 | gint |
4554 | 2807 | midori_save_dialog (const gchar* title, | 1965 | midori_save_dialog (const gchar* title, |
4555 | 2808 | const gchar * hostname, | 1966 | const gchar * hostname, |
4556 | @@ -2851,7 +2009,6 @@ | |||
4557 | 2851 | return response; | 2009 | return response; |
4558 | 2852 | } | 2010 | } |
4559 | 2853 | 2011 | ||
4560 | 2854 | #ifdef HAVE_WEBKIT2 | ||
4561 | 2855 | static gboolean | 2012 | static gboolean |
4562 | 2856 | midori_view_download_decide_destination_cb (WebKitDownload* download, | 2013 | midori_view_download_decide_destination_cb (WebKitDownload* download, |
4563 | 2857 | const gchar * suggested_filename, | 2014 | const gchar * suggested_filename, |
4564 | @@ -2877,13 +2034,6 @@ | |||
4565 | 2877 | WebKitDownload* download, | 2034 | WebKitDownload* download, |
4566 | 2878 | const gchar * suggested_filename) | 2035 | const gchar * suggested_filename) |
4567 | 2879 | { | 2036 | { |
4568 | 2880 | #else | ||
4569 | 2881 | static gboolean | ||
4570 | 2882 | midori_view_download_requested_cb (GtkWidget* web_view, | ||
4571 | 2883 | WebKitDownload* download, | ||
4572 | 2884 | MidoriView* view) | ||
4573 | 2885 | { | ||
4574 | 2886 | #endif | ||
4575 | 2887 | gboolean handled = TRUE; | 2037 | gboolean handled = TRUE; |
4576 | 2888 | gchar* hostname; | 2038 | gchar* hostname; |
4577 | 2889 | gchar* content_type; | 2039 | gchar* content_type; |
4578 | @@ -2897,27 +2047,17 @@ | |||
4579 | 2897 | hostname = midori_uri_parse_hostname ( | 2047 | hostname = midori_uri_parse_hostname ( |
4580 | 2898 | opener_uri ? opener_uri : midori_view_get_display_uri (view), NULL); | 2048 | opener_uri ? opener_uri : midori_view_get_display_uri (view), NULL); |
4581 | 2899 | 2049 | ||
4582 | 2900 | #ifdef HAVE_WEBKIT2 | ||
4583 | 2901 | content_type = g_content_type_guess (suggested_filename, NULL , | 2050 | content_type = g_content_type_guess (suggested_filename, NULL , |
4584 | 2902 | 0 ,NULL); | 2051 | 0 ,NULL); |
4585 | 2903 | if (!content_type) | 2052 | if (!content_type) |
4586 | 2904 | content_type = g_strdup ("application/octet-stream"); | 2053 | content_type = g_strdup ("application/octet-stream"); |
4587 | 2905 | midori_download_set_filename (download, g_strdup (suggested_filename)); | 2054 | midori_download_set_filename (download, g_strdup (suggested_filename)); |
4588 | 2906 | #else | ||
4589 | 2907 | content_type = midori_download_get_content_type (download, | ||
4590 | 2908 | g_object_get_data (G_OBJECT (view), "download-mime-type")); | ||
4591 | 2909 | #endif | ||
4592 | 2910 | description = g_content_type_get_description (content_type); | 2055 | description = g_content_type_get_description (content_type); |
4593 | 2911 | 2056 | ||
4594 | 2912 | details = g_string_sized_new (20 * 4); | 2057 | details = g_string_sized_new (20 * 4); |
4595 | 2913 | #ifdef HAVE_WEBKIT2 | ||
4596 | 2914 | const gchar * suggestion = webkit_uri_response_get_suggested_filename (webkit_download_get_response (download)); | 2058 | const gchar * suggestion = webkit_uri_response_get_suggested_filename (webkit_download_get_response (download)); |
4597 | 2915 | g_string_append_printf (details, _("File Name: %s"), | 2059 | g_string_append_printf (details, _("File Name: %s"), |
4598 | 2916 | suggestion ? suggestion : suggested_filename); | 2060 | suggestion ? suggestion : suggested_filename); |
4599 | 2917 | #else | ||
4600 | 2918 | g_string_append_printf (details, _("File Name: %s"), | ||
4601 | 2919 | webkit_download_get_suggested_filename (download)); | ||
4602 | 2920 | #endif | ||
4603 | 2921 | g_string_append_c (details, '\n'); | 2061 | g_string_append_c (details, '\n'); |
4604 | 2922 | 2062 | ||
4605 | 2923 | if (g_strrstr (description, content_type)) | 2063 | if (g_strrstr (description, content_type)) |
4606 | @@ -2926,51 +2066,8 @@ | |||
4607 | 2926 | g_string_append_printf (details, _("File Type: %s ('%s')"), description, content_type); | 2066 | g_string_append_printf (details, _("File Type: %s ('%s')"), description, content_type); |
4608 | 2927 | g_string_append_c (details, '\n'); | 2067 | g_string_append_c (details, '\n'); |
4609 | 2928 | 2068 | ||
4610 | 2929 | #ifndef HAVE_WEBKIT2 | ||
4611 | 2930 | /* Link Fingerprint */ | ||
4612 | 2931 | /* We look at the original URI because redirection would lose the fragment */ | ||
4613 | 2932 | WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)); | ||
4614 | 2933 | WebKitWebDataSource* datasource = webkit_web_frame_get_provisional_data_source (web_frame); | ||
4615 | 2934 | if (datasource) | ||
4616 | 2935 | { | ||
4617 | 2936 | gchar* fingerprint; | ||
4618 | 2937 | gchar* fplabel; | ||
4619 | 2938 | WebKitNetworkRequest* original_request = webkit_web_data_source_get_initial_request (datasource); | ||
4620 | 2939 | const gchar* original_uri = webkit_network_request_get_uri (original_request); | ||
4621 | 2940 | midori_uri_get_fingerprint (original_uri, &fingerprint, &fplabel); | ||
4622 | 2941 | if (fplabel && fingerprint) | ||
4623 | 2942 | { | ||
4624 | 2943 | WebKitNetworkRequest* request = webkit_download_get_network_request (download); | ||
4625 | 2944 | |||
4626 | 2945 | g_string_append (details, fplabel); | ||
4627 | 2946 | g_string_append_c (details, ' '); | ||
4628 | 2947 | g_string_append (details, fingerprint); | ||
4629 | 2948 | g_string_append_c (details, '\n'); | ||
4630 | 2949 | |||
4631 | 2950 | /* Propagate original URI to make it available when the download finishes */ | ||
4632 | 2951 | g_object_set_data_full (G_OBJECT (request), "midori-original-uri", | ||
4633 | 2952 | g_strdup (original_uri), g_free); | ||
4634 | 2953 | } | ||
4635 | 2954 | g_free (fplabel); | ||
4636 | 2955 | g_free (fingerprint); | ||
4637 | 2956 | |||
4638 | 2957 | } | ||
4639 | 2958 | |||
4640 | 2959 | if (webkit_download_get_total_size (download) > webkit_download_get_current_size (download)) | ||
4641 | 2960 | { | ||
4642 | 2961 | gchar* total = g_format_size (webkit_download_get_total_size (download)); | ||
4643 | 2962 | g_string_append_printf (details, _("Size: %s"), total); | ||
4644 | 2963 | g_string_append_c (details, '\n'); | ||
4645 | 2964 | g_free (total); | ||
4646 | 2965 | } | ||
4647 | 2966 | #endif | ||
4648 | 2967 | |||
4649 | 2968 | #ifdef HAVE_WEBKIT2 | ||
4650 | 2969 | /* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */ | 2069 | /* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */ |
4651 | 2970 | title = g_strdup_printf (_("Open %s"), webkit_uri_request_get_uri (webkit_download_get_request (download))); | 2070 | title = g_strdup_printf (_("Open %s"), webkit_uri_request_get_uri (webkit_download_get_request (download))); |
4652 | 2971 | #else | ||
4653 | 2972 | title = g_strdup_printf (_("Open %s"), webkit_download_get_uri (download)); | ||
4654 | 2973 | #endif | ||
4655 | 2974 | response = midori_save_dialog (title, | 2071 | response = midori_save_dialog (title, |
4656 | 2975 | hostname, details, content_type); //We prompt a dialog | 2072 | hostname, details, content_type); //We prompt a dialog |
4657 | 2976 | g_free (title); | 2073 | g_free (title); |
4658 | @@ -2983,147 +2080,6 @@ | |||
4659 | 2983 | return handled; | 2080 | return handled; |
4660 | 2984 | } | 2081 | } |
4661 | 2985 | 2082 | ||
4662 | 2986 | #ifndef HAVE_WEBKIT2 | ||
4663 | 2987 | static gboolean | ||
4664 | 2988 | webkit_web_view_console_message_cb (GtkWidget* web_view, | ||
4665 | 2989 | const gchar* message, | ||
4666 | 2990 | guint line, | ||
4667 | 2991 | const gchar* source_id, | ||
4668 | 2992 | MidoriView* view) | ||
4669 | 2993 | { | ||
4670 | 2994 | if (g_object_get_data (G_OBJECT (webkit_get_default_session ()), | ||
4671 | 2995 | "pass-through-console")) | ||
4672 | 2996 | return FALSE; | ||
4673 | 2997 | |||
4674 | 2998 | if (!strncmp (message, "speed_dial-save", 13)) | ||
4675 | 2999 | { | ||
4676 | 3000 | MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); | ||
4677 | 3001 | MidoriSpeedDial* dial = katze_object_get_object (browser, "speed-dial"); | ||
4678 | 3002 | GError* error = NULL; | ||
4679 | 3003 | midori_speed_dial_save_message (dial, message, &error); | ||
4680 | 3004 | if (error != NULL) | ||
4681 | 3005 | { | ||
4682 | 3006 | g_critical ("Failed speed dial message: %s\n", error->message); | ||
4683 | 3007 | g_error_free (error); | ||
4684 | 3008 | } | ||
4685 | 3009 | } | ||
4686 | 3010 | else | ||
4687 | 3011 | g_signal_emit_by_name (view, "console-message", message, line, source_id); | ||
4688 | 3012 | return TRUE; | ||
4689 | 3013 | } | ||
4690 | 3014 | |||
4691 | 3015 | static void | ||
4692 | 3016 | midori_view_script_response_cb (GtkWidget* infobar, | ||
4693 | 3017 | gint response, | ||
4694 | 3018 | MidoriView* view) | ||
4695 | 3019 | { | ||
4696 | 3020 | view->alerts--; | ||
4697 | 3021 | } | ||
4698 | 3022 | |||
4699 | 3023 | static gboolean | ||
4700 | 3024 | midori_view_web_view_script_alert_cb (GtkWidget* web_view, | ||
4701 | 3025 | WebKitWebFrame* web_frame, | ||
4702 | 3026 | const gchar* message, | ||
4703 | 3027 | MidoriView* view) | ||
4704 | 3028 | { | ||
4705 | 3029 | gchar* text; | ||
4706 | 3030 | |||
4707 | 3031 | /* Allow a maximum of 5 alerts */ | ||
4708 | 3032 | if (view->alerts > 4) | ||
4709 | 3033 | return TRUE; | ||
4710 | 3034 | |||
4711 | 3035 | view->alerts++; | ||
4712 | 3036 | /* i18n: The text of an infobar for JavaScript alert messages */ | ||
4713 | 3037 | text = g_strdup_printf ("JavaScript: %s", message); | ||
4714 | 3038 | midori_view_add_info_bar (view, GTK_MESSAGE_WARNING, text, | ||
4715 | 3039 | G_CALLBACK (midori_view_script_response_cb), view, | ||
4716 | 3040 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); | ||
4717 | 3041 | g_free (text); | ||
4718 | 3042 | return TRUE; | ||
4719 | 3043 | } | ||
4720 | 3044 | |||
4721 | 3045 | static gboolean | ||
4722 | 3046 | midori_view_web_view_print_requested_cb (GtkWidget* web_view, | ||
4723 | 3047 | WebKitWebFrame* web_frame, | ||
4724 | 3048 | MidoriView* view) | ||
4725 | 3049 | { | ||
4726 | 3050 | midori_view_print (view); | ||
4727 | 3051 | return TRUE; | ||
4728 | 3052 | } | ||
4729 | 3053 | |||
4730 | 3054 | static void | ||
4731 | 3055 | webkit_web_view_window_object_cleared_cb (GtkWidget* web_view, | ||
4732 | 3056 | WebKitWebFrame* web_frame, | ||
4733 | 3057 | JSContextRef js_context, | ||
4734 | 3058 | JSObjectRef js_window, | ||
4735 | 3059 | MidoriView* view) | ||
4736 | 3060 | { | ||
4737 | 3061 | const gchar* page_uri; | ||
4738 | 3062 | |||
4739 | 3063 | page_uri = webkit_web_frame_get_uri (web_frame); | ||
4740 | 3064 | if (!midori_uri_is_http (page_uri)) | ||
4741 | 3065 | return; | ||
4742 | 3066 | |||
4743 | 3067 | if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_PRIVATE) | ||
4744 | 3068 | { | ||
4745 | 3069 | /* Mask language, architecture, no plugin list */ | ||
4746 | 3070 | gchar* result = sokoke_js_script_eval (js_context, | ||
4747 | 3071 | "navigator = { 'appName': 'Netscape'," | ||
4748 | 3072 | "'appCodeName': 'Mozilla'," | ||
4749 | 3073 | "'appVersion': '5.0 (X11)'," | ||
4750 | 3074 | "'userAgent': navigator.userAgent," | ||
4751 | 3075 | "'language': 'en-US'," | ||
4752 | 3076 | "'platform': 'Linux i686'," | ||
4753 | 3077 | "'cookieEnabled': true," | ||
4754 | 3078 | "'javaEnabled': function () { return true; }," | ||
4755 | 3079 | "'mimeTypes': {}," | ||
4756 | 3080 | "'plugins': {'refresh': function () { } } };", | ||
4757 | 3081 | NULL); | ||
4758 | 3082 | g_free (result); | ||
4759 | 3083 | } | ||
4760 | 3084 | } | ||
4761 | 3085 | |||
4762 | 3086 | static void | ||
4763 | 3087 | midori_view_hadjustment_notify_value_cb (GtkAdjustment* hadjustment, | ||
4764 | 3088 | GParamSpec* pspec, | ||
4765 | 3089 | MidoriView* view) | ||
4766 | 3090 | { | ||
4767 | 3091 | gint value = (gint)gtk_adjustment_get_value (hadjustment); | ||
4768 | 3092 | katze_item_set_meta_integer (view->item, "scrollh", value); | ||
4769 | 3093 | } | ||
4770 | 3094 | |||
4771 | 3095 | static void | ||
4772 | 3096 | midori_view_notify_hadjustment_cb (MidoriView* view, | ||
4773 | 3097 | GParamSpec* pspec, | ||
4774 | 3098 | gpointer data) | ||
4775 | 3099 | { | ||
4776 | 3100 | GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window); | ||
4777 | 3101 | GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment (scrolled); | ||
4778 | 3102 | g_signal_connect (hadjustment, "notify::value", | ||
4779 | 3103 | G_CALLBACK (midori_view_hadjustment_notify_value_cb), view); | ||
4780 | 3104 | } | ||
4781 | 3105 | |||
4782 | 3106 | static void | ||
4783 | 3107 | midori_view_vadjustment_notify_value_cb (GtkAdjustment* vadjustment, | ||
4784 | 3108 | GParamSpec* pspec, | ||
4785 | 3109 | MidoriView* view) | ||
4786 | 3110 | { | ||
4787 | 3111 | gint value = (gint)gtk_adjustment_get_value (vadjustment); | ||
4788 | 3112 | katze_item_set_meta_integer (view->item, "scrollv", value); | ||
4789 | 3113 | } | ||
4790 | 3114 | |||
4791 | 3115 | static void | ||
4792 | 3116 | midori_view_notify_vadjustment_cb (MidoriView* view, | ||
4793 | 3117 | GParamSpec* pspec, | ||
4794 | 3118 | gpointer data) | ||
4795 | 3119 | { | ||
4796 | 3120 | GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window); | ||
4797 | 3121 | GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment (scrolled); | ||
4798 | 3122 | g_signal_connect (vadjustment, "notify::value", | ||
4799 | 3123 | G_CALLBACK (midori_view_vadjustment_notify_value_cb), view); | ||
4800 | 3124 | } | ||
4801 | 3125 | #endif | ||
4802 | 3126 | |||
4803 | 3127 | static void | 2083 | static void |
4804 | 3128 | midori_view_init (MidoriView* view) | 2084 | midori_view_init (MidoriView* view) |
4805 | 3129 | { | 2085 | { |
4806 | @@ -3140,18 +2096,6 @@ | |||
4807 | 3140 | view->item = katze_item_new (); | 2096 | view->item = katze_item_new (); |
4808 | 3141 | 2097 | ||
4809 | 3142 | view->scrollh = view->scrollv = -2; | 2098 | view->scrollh = view->scrollv = -2; |
4810 | 3143 | #ifndef HAVE_WEBKIT2 | ||
4811 | 3144 | /* Adjustments are not created initially, but overwritten later */ | ||
4812 | 3145 | view->scrolled_window = gtk_scrolled_window_new (NULL, NULL); | ||
4813 | 3146 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); | ||
4814 | 3147 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window), | ||
4815 | 3148 | GTK_SHADOW_NONE); | ||
4816 | 3149 | g_signal_connect (view->scrolled_window, "notify::hadjustment", | ||
4817 | 3150 | G_CALLBACK (midori_view_notify_hadjustment_cb), view); | ||
4818 | 3151 | g_signal_connect (view->scrolled_window, "notify::vadjustment", | ||
4819 | 3152 | G_CALLBACK (midori_view_notify_vadjustment_cb), view); | ||
4820 | 3153 | #endif | ||
4821 | 3154 | |||
4822 | 3155 | g_signal_connect (view->item, "meta-data-changed", | 2099 | g_signal_connect (view->item, "meta-data-changed", |
4823 | 3156 | G_CALLBACK (midori_view_item_meta_data_changed), view); | 2100 | G_CALLBACK (midori_view_item_meta_data_changed), view); |
4824 | 3157 | } | 2101 | } |
4825 | @@ -3282,10 +2226,6 @@ | |||
4826 | 3282 | NULL); | 2226 | NULL); |
4827 | 3283 | 2227 | ||
4828 | 3284 | webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)settings); | 2228 | webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)settings); |
4829 | 3285 | #ifndef HAVE_WEBKIT2 | ||
4830 | 3286 | webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view), | ||
4831 | 3287 | zoom_text_and_images); | ||
4832 | 3288 | #endif | ||
4833 | 3289 | midori_view_set_zoom_level (view, zoom_level); | 2229 | midori_view_set_zoom_level (view, zoom_level); |
4834 | 3290 | } | 2230 | } |
4835 | 3291 | 2231 | ||
4836 | @@ -3368,12 +2308,15 @@ | |||
4837 | 3368 | KatzeItem* item, | 2308 | KatzeItem* item, |
4838 | 3369 | MidoriWebSettings* settings) | 2309 | MidoriWebSettings* settings) |
4839 | 3370 | { | 2310 | { |
4844 | 3371 | MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, | 2311 | MidoriView* view; |
4845 | 3372 | "related", MIDORI_TAB (related), | 2312 | |
4842 | 3373 | "title", item ? katze_item_get_name (item) : NULL, | ||
4843 | 3374 | NULL); | ||
4846 | 3375 | if (!settings && related) | 2313 | if (!settings && related) |
4847 | 3376 | settings = related->settings; | 2314 | settings = related->settings; |
4848 | 2315 | view = g_object_new (MIDORI_TYPE_VIEW, | ||
4849 | 2316 | "user-content-manager", midori_settings_get_user_content_manager (MIDORI_SETTINGS (settings)), | ||
4850 | 2317 | "related", MIDORI_TAB (related), | ||
4851 | 2318 | "title", item ? katze_item_get_name (item) : NULL, | ||
4852 | 2319 | NULL); | ||
4853 | 3377 | if (settings) | 2320 | if (settings) |
4854 | 3378 | _midori_view_set_settings (view, settings); | 2321 | _midori_view_set_settings (view, settings); |
4855 | 3379 | if (item) | 2322 | if (item) |
4856 | @@ -3400,14 +2343,6 @@ | |||
4857 | 3400 | 2343 | ||
4858 | 3401 | if (name == g_intern_string ("open-new-pages-in")) | 2344 | if (name == g_intern_string ("open-new-pages-in")) |
4859 | 3402 | view->open_new_pages_in = g_value_get_enum (&value); | 2345 | view->open_new_pages_in = g_value_get_enum (&value); |
4860 | 3403 | #ifndef HAVE_WEBKIT2 | ||
4861 | 3404 | else if (name == g_intern_string ("zoom-text-and-images")) | ||
4862 | 3405 | { | ||
4863 | 3406 | if (view->web_view) | ||
4864 | 3407 | webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view), | ||
4865 | 3408 | g_value_get_boolean (&value)); | ||
4866 | 3409 | } | ||
4867 | 3410 | #endif | ||
4868 | 3411 | else if (name == g_intern_string ("open-tabs-in-the-background")) | 2346 | else if (name == g_intern_string ("open-tabs-in-the-background")) |
4869 | 3412 | view->open_tabs_in_the_background = g_value_get_boolean (&value); | 2347 | view->open_tabs_in_the_background = g_value_get_boolean (&value); |
4870 | 3413 | else if (name == g_intern_string ("enable-javascript")) | 2348 | else if (name == g_intern_string ("enable-javascript")) |
4871 | @@ -3475,184 +2410,6 @@ | |||
4872 | 3475 | return midori_tab_get_progress (MIDORI_TAB (view)); | 2410 | return midori_tab_get_progress (MIDORI_TAB (view)); |
4873 | 3476 | } | 2411 | } |
4874 | 3477 | 2412 | ||
4875 | 3478 | #ifndef HAVE_WEBKIT2 | ||
4876 | 3479 | static gboolean | ||
4877 | 3480 | midori_view_inspector_window_key_press_event_cb (GtkWidget* window, | ||
4878 | 3481 | GdkEventKey* event, | ||
4879 | 3482 | gpointer user_data) | ||
4880 | 3483 | { | ||
4881 | 3484 | /* Close window on Ctrl+W */ | ||
4882 | 3485 | if (event->keyval == 'w' && (event->state & GDK_CONTROL_MASK)) | ||
4883 | 3486 | gtk_widget_destroy (window); | ||
4884 | 3487 | |||
4885 | 3488 | return FALSE; | ||
4886 | 3489 | } | ||
4887 | 3490 | |||
4888 | 3491 | static void | ||
4889 | 3492 | midori_view_web_inspector_construct_window (gpointer inspector, | ||
4890 | 3493 | WebKitWebView* web_view, | ||
4891 | 3494 | GtkWidget* inspector_view, | ||
4892 | 3495 | MidoriView* view) | ||
4893 | 3496 | { | ||
4894 | 3497 | gchar* title; | ||
4895 | 3498 | const gchar* label; | ||
4896 | 3499 | GtkWidget* window; | ||
4897 | 3500 | GtkWidget* toplevel; | ||
4898 | 3501 | const gchar* icon_name; | ||
4899 | 3502 | GtkIconTheme* icon_theme; | ||
4900 | 3503 | GdkPixbuf* icon; | ||
4901 | 3504 | GdkPixbuf* gray_icon; | ||
4902 | 3505 | #if GTK_CHECK_VERSION (3, 0, 0) | ||
4903 | 3506 | GtkWidget* scrolled; | ||
4904 | 3507 | #endif | ||
4905 | 3508 | |||
4906 | 3509 | label = midori_view_get_display_title (view); | ||
4907 | 3510 | title = g_strdup_printf (_("Inspect page - %s"), label); | ||
4908 | 3511 | window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | ||
4909 | 3512 | gtk_window_set_title (GTK_WINDOW (window), title); | ||
4910 | 3513 | g_free (title); | ||
4911 | 3514 | |||
4912 | 3515 | toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view)); | ||
4913 | 3516 | if (gtk_widget_is_toplevel (toplevel)) | ||
4914 | 3517 | { | ||
4915 | 3518 | gtk_window_set_screen (GTK_WINDOW (window), gtk_window_get_screen (GTK_WINDOW (toplevel))); | ||
4916 | 3519 | katze_window_set_sensible_default_size (GTK_WINDOW (window)); | ||
4917 | 3520 | } | ||
4918 | 3521 | |||
4919 | 3522 | /* Attempt to make a gray version of the icon on the fly */ | ||
4920 | 3523 | icon_name = gtk_window_get_icon_name (GTK_WINDOW (toplevel)); | ||
4921 | 3524 | icon_theme = gtk_icon_theme_get_for_screen ( | ||
4922 | 3525 | gtk_widget_get_screen (GTK_WIDGET (view))); | ||
4923 | 3526 | icon = gtk_icon_theme_load_icon (icon_theme, icon_name, 32, | ||
4924 | 3527 | GTK_ICON_LOOKUP_USE_BUILTIN, NULL); | ||
4925 | 3528 | if (icon) | ||
4926 | 3529 | { | ||
4927 | 3530 | gray_icon = gdk_pixbuf_copy (icon); | ||
4928 | 3531 | if (gray_icon) | ||
4929 | 3532 | { | ||
4930 | 3533 | gdk_pixbuf_saturate_and_pixelate (gray_icon, gray_icon, 0.1f, FALSE); | ||
4931 | 3534 | gtk_window_set_icon (GTK_WINDOW (window), gray_icon); | ||
4932 | 3535 | g_object_unref (gray_icon); | ||
4933 | 3536 | } | ||
4934 | 3537 | g_object_unref (icon); | ||
4935 | 3538 | } | ||
4936 | 3539 | else | ||
4937 | 3540 | gtk_window_set_icon_name (GTK_WINDOW (window), icon_name); | ||
4938 | 3541 | gtk_widget_set_size_request (GTK_WIDGET (inspector_view), 700, 100); | ||
4939 | 3542 | #if GTK_CHECK_VERSION (3, 0, 0) | ||
4940 | 3543 | scrolled = gtk_scrolled_window_new (NULL, NULL); | ||
4941 | 3544 | gtk_container_add (GTK_CONTAINER (scrolled), inspector_view); | ||
4942 | 3545 | gtk_container_add (GTK_CONTAINER (window), scrolled); | ||
4943 | 3546 | gtk_widget_show_all (scrolled); | ||
4944 | 3547 | #else | ||
4945 | 3548 | gtk_container_add (GTK_CONTAINER (window), inspector_view); | ||
4946 | 3549 | gtk_widget_show_all (inspector_view); | ||
4947 | 3550 | #endif | ||
4948 | 3551 | |||
4949 | 3552 | g_signal_connect (window, "key-press-event", | ||
4950 | 3553 | G_CALLBACK (midori_view_inspector_window_key_press_event_cb), NULL); | ||
4951 | 3554 | |||
4952 | 3555 | /* FIXME: Update window title with URI */ | ||
4953 | 3556 | } | ||
4954 | 3557 | |||
4955 | 3558 | static WebKitWebView* | ||
4956 | 3559 | midori_view_web_inspector_inspect_web_view_cb (gpointer inspector, | ||
4957 | 3560 | WebKitWebView* web_view, | ||
4958 | 3561 | MidoriView* view) | ||
4959 | 3562 | { | ||
4960 | 3563 | GtkWidget* inspector_view = webkit_web_view_new (); | ||
4961 | 3564 | midori_view_web_inspector_construct_window (inspector, | ||
4962 | 3565 | web_view, inspector_view, view); | ||
4963 | 3566 | return WEBKIT_WEB_VIEW (inspector_view); | ||
4964 | 3567 | } | ||
4965 | 3568 | |||
4966 | 3569 | static gboolean | ||
4967 | 3570 | midori_view_web_inspector_show_window_cb (WebKitWebInspector* inspector, | ||
4968 | 3571 | MidoriView* view) | ||
4969 | 3572 | { | ||
4970 | 3573 | GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector)); | ||
4971 | 3574 | GtkWidget* window = gtk_widget_get_toplevel (inspector_view); | ||
4972 | 3575 | if (!window) | ||
4973 | 3576 | return FALSE; | ||
4974 | 3577 | if (katze_object_get_boolean (view->settings, "last-inspector-attached")) | ||
4975 | 3578 | { | ||
4976 | 3579 | gboolean handled = FALSE; | ||
4977 | 3580 | g_signal_emit_by_name (inspector, "attach-window", &handled); | ||
4978 | 3581 | } | ||
4979 | 3582 | else | ||
4980 | 3583 | { | ||
4981 | 3584 | gtk_widget_show (window); | ||
4982 | 3585 | gtk_window_present (GTK_WINDOW (window)); | ||
4983 | 3586 | } | ||
4984 | 3587 | return TRUE; | ||
4985 | 3588 | } | ||
4986 | 3589 | |||
4987 | 3590 | static gboolean | ||
4988 | 3591 | midori_view_web_inspector_attach_window_cb (gpointer inspector, | ||
4989 | 3592 | MidoriView* view) | ||
4990 | 3593 | { | ||
4991 | 3594 | GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector)); | ||
4992 | 3595 | g_signal_emit_by_name (view, "attach-inspector", inspector_view); | ||
4993 | 3596 | return TRUE; | ||
4994 | 3597 | } | ||
4995 | 3598 | |||
4996 | 3599 | /** | ||
4997 | 3600 | * midori_view_web_inspector_get_own_window: | ||
4998 | 3601 | * @inspector: the inspector instance | ||
4999 | 3602 | * | ||
5000 | 3603 | * Get the widget containing the inspector, generally either a GtkWindow |
With these last changes, adblock works, but *only* if I install Midori after building. Running from the uninstalled build directory results in adblock silently not blocking ads.