Merge lp:~midori/midori/tabsignals into lp:midori

Proposed by Christian Dywan on 2013-10-16
Status: Work in progress
Proposed branch: lp:~midori/midori/tabsignals
Merge into: lp:midori
Diff against target: 301 lines (+30/-105)
4 files modified
extensions/external-download-manager.vala (+1/-1)
midori/midori-tab.vala (+11/-0)
midori/midori-view.c (+18/-103)
midori/midori.vapi (+0/-1)
To merge this branch: bzr merge lp:~midori/midori/tabsignals
Reviewer Review Type Date Requested Status
André Stösel 2013-10-16 Needs Fixing on 2013-10-17
gue5t gue5t Approve on 2013-10-16
Review via email: mp+191517@code.launchpad.net

Commit message

Move new-tab/window/view and download_requested to Midori.Tab

Description of the change

This is required to allow the browser connect signals on any Tab which may not be a View.

To post a comment you must log in.
gue5t gue5t (gue5t) :
review: Approve
André Stösel (ivaldi) wrote :

This breaks the external download manager extension.
(The file is downloaded twice.)

review: Needs Fixing
André Stösel (ivaldi) wrote :

I think there is no signal accumulator support in vala right now.

Unmerged revisions

6437. By Christian Dywan on 2013-10-16

Move new-tab/window/view and download_requested to Midori.Tab

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/external-download-manager.vala'
2--- extensions/external-download-manager.vala 2013-05-26 18:18:40 +0000
3+++ extensions/external-download-manager.vala 2013-10-16 21:54:02 +0000
4@@ -36,7 +36,7 @@
5 private CookieJar cookie_jar;
6 private GLib.PtrArray download_managers = new GLib.PtrArray ();
7
8- public bool download_requested (Midori.View view, WebKit.Download download) {
9+ public bool download_requested (WebKit.Download download) {
10 Midori.DownloadType download_type = download.get_data<Midori.DownloadType> ("midori-download-type");
11
12 if (download_type == Midori.DownloadType.SAVE) {
13
14=== modified file 'midori/midori-tab.vala'
15--- midori/midori-tab.vala 2013-08-31 09:18:21 +0000
16+++ midori/midori-tab.vala 2013-10-16 21:54:02 +0000
17@@ -92,6 +92,17 @@
18 /* Since: 0.5.5 */
19 public signal void context_menu (WebKit.HitTestResult hit_test_result, ContextAction menu);
20
21+ public signal void new_tab (string uri, bool background);
22+ public signal void new_window (string uri);
23+ /* Since: 0.1.2
24+ Since: 0.3.4 a bool argument was added. */
25+ public signal void new_view (Tab view, NewView where, bool user_initiated);
26+ /* Emitted when a new download is requested, if a file cannot be shown
27+ or a download was initiated from the context menu.
28+ Returning @true causes the download to start otherwise it's cancelled.
29+ Since: 0.1.5 */
30+ public signal bool download_requested (WebKit.Download download);
31+
32 /* A dialog tab has a fixed size, limited GUI and is transient.
33 Since: 0.5.6 */
34 public bool is_dialog { get; protected set; }
35
36=== modified file 'midori/midori-view.c'
37--- midori/midori-view.c 2013-09-17 15:41:00 +0000
38+++ midori/midori-view.c 2013-10-16 21:54:02 +0000
39@@ -155,10 +155,6 @@
40 };
41
42 enum {
43- NEW_TAB,
44- NEW_WINDOW,
45- NEW_VIEW,
46- DOWNLOAD_REQUESTED,
47 ADD_BOOKMARK,
48 ABOUT_CONTENT,
49
50@@ -203,87 +199,6 @@
51 GtkWidgetClass* gtkwidget_class;
52 GParamFlags flags;
53
54- signals[NEW_TAB] = g_signal_new (
55- "new-tab",
56- G_TYPE_FROM_CLASS (class),
57- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
58- 0,
59- 0,
60- NULL,
61- midori_cclosure_marshal_VOID__STRING_BOOLEAN,
62- G_TYPE_NONE, 2,
63- G_TYPE_STRING,
64- G_TYPE_BOOLEAN);
65-
66- signals[NEW_WINDOW] = g_signal_new (
67- "new-window",
68- G_TYPE_FROM_CLASS (class),
69- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
70- 0,
71- 0,
72- NULL,
73- g_cclosure_marshal_VOID__STRING,
74- G_TYPE_NONE, 1,
75- G_TYPE_STRING);
76-
77- /**
78- * MidoriView::new-view:
79- * @view: the object on which the signal is emitted
80- * @new_view: a newly created view
81- * @where: where to open the view
82- * @user_initiated: %TRUE if the user actively opened the new view
83- *
84- * Emitted when a new view is created. The value of
85- * @where determines where to open the view according
86- * to how it was opened and user preferences.
87- *
88- * Since: 0.1.2
89- *
90- * Since 0.3.4 a boolean argument was added.
91- */
92- signals[NEW_VIEW] = g_signal_new (
93- "new-view",
94- G_TYPE_FROM_CLASS (class),
95- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
96- 0,
97- 0,
98- NULL,
99- midori_cclosure_marshal_VOID__OBJECT_ENUM_BOOLEAN,
100- G_TYPE_NONE, 3,
101- MIDORI_TYPE_VIEW,
102- MIDORI_TYPE_NEW_VIEW,
103- G_TYPE_BOOLEAN);
104-
105- /**
106- * MidoriView::download-requested:
107- * @view: the object on which the signal is emitted
108- * @download: a new download
109- *
110- * Emitted when a new download is requested, if a
111- * file cannot be displayed or a download was started
112- * from the context menu.
113- *
114- * If the download should be accepted, a callback
115- * has to return %TRUE, and the download will also
116- * be started automatically.
117- *
118- * Note: This requires WebKitGTK 1.1.3.
119- *
120- * Return value: %TRUE if the download was handled
121- *
122- * Since: 0.1.5
123- */
124- signals[DOWNLOAD_REQUESTED] = g_signal_new (
125- "download-requested",
126- G_TYPE_FROM_CLASS (class),
127- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
128- 0,
129- g_signal_accumulator_true_handled,
130- NULL,
131- midori_cclosure_marshal_BOOLEAN__OBJECT,
132- G_TYPE_BOOLEAN, 1,
133- G_TYPE_OBJECT);
134-
135 /**
136 * MidoriView::add-bookmark:
137 * @view: the object on which the signal is emitted
138@@ -1646,14 +1561,14 @@
139 background = view->open_tabs_in_the_background;
140 if (MIDORI_MOD_BACKGROUND (event->state))
141 background = !background;
142- g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
143+ g_signal_emit_by_name (view, "new-tab", link_uri, background);
144 view->button_press_handled = TRUE;
145 return TRUE;
146 }
147 else if (MIDORI_MOD_NEW_WINDOW (event->state))
148 {
149 /* Open link in new window */
150- g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);
151+ g_signal_emit_by_name (view, "new-window", link_uri);
152 view->button_press_handled = TRUE;
153 return TRUE;
154 }
155@@ -1668,7 +1583,7 @@
156 background = view->open_tabs_in_the_background;
157 if (MIDORI_MOD_BACKGROUND (event->state))
158 background = !background;
159- g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
160+ g_signal_emit_by_name (view, "new-tab", link_uri, background);
161 view->button_press_handled = TRUE;
162 return TRUE;
163 }
164@@ -1716,7 +1631,7 @@
165 background = view->open_tabs_in_the_background;
166 if (MIDORI_MOD_BACKGROUND (event->state))
167 background = !background;
168- g_signal_emit (view, signals[NEW_TAB], 0, uri, background);
169+ g_signal_emit_by_name (view, "new-tab", uri, background);
170 }
171 else
172 {
173@@ -1935,7 +1850,7 @@
174 gboolean background = view->open_tabs_in_the_background;
175 if (MIDORI_MOD_BACKGROUND (event->state))
176 background = !background;
177- g_signal_emit (view, signals[NEW_TAB], 0, result, background);
178+ g_signal_emit_by_name (view, "new-tab", result, background);
179 }
180 else
181 midori_view_set_uri (view, result);
182@@ -2029,7 +1944,7 @@
183 gpointer user_data)
184 {
185 MidoriView* view = user_data;
186- g_signal_emit (view, signals[NEW_WINDOW], 0, view->link_uri);
187+ g_signal_emit_by_name (view, "new-window", view->link_uri);
188 }
189
190 static void
191@@ -2057,7 +1972,7 @@
192 #endif
193 gboolean handled;
194 midori_download_set_type (download, type);
195- g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
196+ g_signal_emit_by_name (view, "download-requested", download, &handled);
197 }
198
199 static void
200@@ -2075,9 +1990,9 @@
201 MidoriView* view = user_data;
202 gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
203 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
204- g_signal_emit (view, signals[NEW_WINDOW], 0, uri);
205+ g_signal_emit_by_name (view, "new-window", uri);
206 else
207- g_signal_emit (view, signals[NEW_TAB], 0, uri,
208+ g_signal_emit_by_name (view, "new-tab", uri,
209 view->open_tabs_in_the_background);
210 g_free (uri);
211 }
212@@ -2232,7 +2147,7 @@
213 gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);
214 if (!uri)
215 uri = g_strdup (data);
216- g_signal_emit (view, signals[NEW_TAB], 0, uri,
217+ g_signal_emit_by_name (view, "new-tab", uri,
218 view->open_tabs_in_the_background);
219 g_free (uri);
220 }
221@@ -2242,7 +2157,7 @@
222 gpointer user_data)
223 {
224 MidoriView* view = user_data;
225- g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,
226+ g_signal_emit_by_name (view, "new-tab", view->link_uri,
227 !view->open_tabs_in_the_background);
228 }
229
230@@ -2258,12 +2173,12 @@
231 gchar* uri = midori_uri_for_search (search, view->selected_text);
232
233 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
234- g_signal_emit (view, signals[NEW_WINDOW], 0, uri);
235+ g_signal_emit_by_name (view, "new-window", uri);
236 /* FIXME: need a way to override behavior (middle click)
237 else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
238 midori_view_set_uri (view, uri); */
239 else
240- g_signal_emit (view, signals[NEW_TAB], 0, uri,
241+ g_signal_emit_by_name (view, "new-tab", uri,
242 view->open_tabs_in_the_background);
243
244 g_free (uri);
245@@ -2275,7 +2190,7 @@
246 gpointer user_data)
247 {
248 MidoriView* view = user_data;
249- g_signal_emit (view, signals[NEW_WINDOW], 0,
250+ g_signal_emit_by_name (view, "new-window",
251 midori_view_get_display_uri (MIDORI_VIEW (view)));
252 }
253
254@@ -2286,7 +2201,7 @@
255 {
256 MidoriView* view = user_data;
257 WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view));
258- g_signal_emit (view, signals[NEW_TAB], 0,
259+ g_signal_emit_by_name (view, "new-tab",
260 webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background);
261 }
262 #endif
263@@ -2675,7 +2590,7 @@
264 where = MIDORI_NEW_VIEW_WINDOW;
265
266 gtk_widget_show (new_view);
267- g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, FALSE);
268+ g_signal_emit_by_name (view, "new-view", new_view, where, FALSE);
269
270 if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
271 {
272@@ -2892,7 +2807,7 @@
273 "signal::failed", download_failed_cb, view,
274 NULL);
275 */
276- g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
277+ g_signal_emit_by_name (view, "download-requested", download, &handled);
278 #ifndef HAVE_WEBKIT2
279 return handled;
280 #endif
281@@ -4400,7 +4315,7 @@
282
283 MidoriNewView where = MIDORI_NEW_VIEW_TAB;
284 GtkWidget* new_view = midori_view_new_with_item (view->item, view->settings);
285- g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, TRUE);
286+ g_signal_emit_by_name (view, "new-view", new_view, where, TRUE);
287 midori_view_set_uri (MIDORI_VIEW (new_view), midori_tab_get_uri (MIDORI_TAB (view)));
288 return new_view;
289 }
290
291=== modified file 'midori/midori.vapi'
292--- midori/midori.vapi 2013-10-09 20:05:29 +0000
293+++ midori/midori.vapi 2013-10-16 21:54:02 +0000
294@@ -205,7 +205,6 @@
295 public GLib.Object net { get; }
296
297 [HasEmitter]
298- public signal bool download_requested (WebKit.Download download);
299 public signal bool about_content (string uri);
300
301 }

Subscribers

People subscribed via source and target branches

to all changes: