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
=== modified file 'extensions/external-download-manager.vala'
--- extensions/external-download-manager.vala 2013-05-26 18:18:40 +0000
+++ extensions/external-download-manager.vala 2013-10-16 21:54:02 +0000
@@ -36,7 +36,7 @@
36 private CookieJar cookie_jar;36 private CookieJar cookie_jar;
37 private GLib.PtrArray download_managers = new GLib.PtrArray ();37 private GLib.PtrArray download_managers = new GLib.PtrArray ();
3838
39 public bool download_requested (Midori.View view, WebKit.Download download) {39 public bool download_requested (WebKit.Download download) {
40 Midori.DownloadType download_type = download.get_data<Midori.DownloadType> ("midori-download-type");40 Midori.DownloadType download_type = download.get_data<Midori.DownloadType> ("midori-download-type");
4141
42 if (download_type == Midori.DownloadType.SAVE) {42 if (download_type == Midori.DownloadType.SAVE) {
4343
=== modified file 'midori/midori-tab.vala'
--- midori/midori-tab.vala 2013-08-31 09:18:21 +0000
+++ midori/midori-tab.vala 2013-10-16 21:54:02 +0000
@@ -92,6 +92,17 @@
92 /* Since: 0.5.5 */92 /* Since: 0.5.5 */
93 public signal void context_menu (WebKit.HitTestResult hit_test_result, ContextAction menu);93 public signal void context_menu (WebKit.HitTestResult hit_test_result, ContextAction menu);
9494
95 public signal void new_tab (string uri, bool background);
96 public signal void new_window (string uri);
97 /* Since: 0.1.2
98 Since: 0.3.4 a bool argument was added. */
99 public signal void new_view (Tab view, NewView where, bool user_initiated);
100 /* Emitted when a new download is requested, if a file cannot be shown
101 or a download was initiated from the context menu.
102 Returning @true causes the download to start otherwise it's cancelled.
103 Since: 0.1.5 */
104 public signal bool download_requested (WebKit.Download download);
105
95 /* A dialog tab has a fixed size, limited GUI and is transient.106 /* A dialog tab has a fixed size, limited GUI and is transient.
96 Since: 0.5.6 */107 Since: 0.5.6 */
97 public bool is_dialog { get; protected set; }108 public bool is_dialog { get; protected set; }
98109
=== modified file 'midori/midori-view.c'
--- midori/midori-view.c 2013-09-17 15:41:00 +0000
+++ midori/midori-view.c 2013-10-16 21:54:02 +0000
@@ -155,10 +155,6 @@
155};155};
156156
157enum {157enum {
158 NEW_TAB,
159 NEW_WINDOW,
160 NEW_VIEW,
161 DOWNLOAD_REQUESTED,
162 ADD_BOOKMARK,158 ADD_BOOKMARK,
163 ABOUT_CONTENT,159 ABOUT_CONTENT,
164160
@@ -203,87 +199,6 @@
203 GtkWidgetClass* gtkwidget_class;199 GtkWidgetClass* gtkwidget_class;
204 GParamFlags flags;200 GParamFlags flags;
205201
206 signals[NEW_TAB] = g_signal_new (
207 "new-tab",
208 G_TYPE_FROM_CLASS (class),
209 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
210 0,
211 0,
212 NULL,
213 midori_cclosure_marshal_VOID__STRING_BOOLEAN,
214 G_TYPE_NONE, 2,
215 G_TYPE_STRING,
216 G_TYPE_BOOLEAN);
217
218 signals[NEW_WINDOW] = g_signal_new (
219 "new-window",
220 G_TYPE_FROM_CLASS (class),
221 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
222 0,
223 0,
224 NULL,
225 g_cclosure_marshal_VOID__STRING,
226 G_TYPE_NONE, 1,
227 G_TYPE_STRING);
228
229 /**
230 * MidoriView::new-view:
231 * @view: the object on which the signal is emitted
232 * @new_view: a newly created view
233 * @where: where to open the view
234 * @user_initiated: %TRUE if the user actively opened the new view
235 *
236 * Emitted when a new view is created. The value of
237 * @where determines where to open the view according
238 * to how it was opened and user preferences.
239 *
240 * Since: 0.1.2
241 *
242 * Since 0.3.4 a boolean argument was added.
243 */
244 signals[NEW_VIEW] = g_signal_new (
245 "new-view",
246 G_TYPE_FROM_CLASS (class),
247 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
248 0,
249 0,
250 NULL,
251 midori_cclosure_marshal_VOID__OBJECT_ENUM_BOOLEAN,
252 G_TYPE_NONE, 3,
253 MIDORI_TYPE_VIEW,
254 MIDORI_TYPE_NEW_VIEW,
255 G_TYPE_BOOLEAN);
256
257 /**
258 * MidoriView::download-requested:
259 * @view: the object on which the signal is emitted
260 * @download: a new download
261 *
262 * Emitted when a new download is requested, if a
263 * file cannot be displayed or a download was started
264 * from the context menu.
265 *
266 * If the download should be accepted, a callback
267 * has to return %TRUE, and the download will also
268 * be started automatically.
269 *
270 * Note: This requires WebKitGTK 1.1.3.
271 *
272 * Return value: %TRUE if the download was handled
273 *
274 * Since: 0.1.5
275 */
276 signals[DOWNLOAD_REQUESTED] = g_signal_new (
277 "download-requested",
278 G_TYPE_FROM_CLASS (class),
279 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
280 0,
281 g_signal_accumulator_true_handled,
282 NULL,
283 midori_cclosure_marshal_BOOLEAN__OBJECT,
284 G_TYPE_BOOLEAN, 1,
285 G_TYPE_OBJECT);
286
287 /**202 /**
288 * MidoriView::add-bookmark:203 * MidoriView::add-bookmark:
289 * @view: the object on which the signal is emitted204 * @view: the object on which the signal is emitted
@@ -1646,14 +1561,14 @@
1646 background = view->open_tabs_in_the_background;1561 background = view->open_tabs_in_the_background;
1647 if (MIDORI_MOD_BACKGROUND (event->state))1562 if (MIDORI_MOD_BACKGROUND (event->state))
1648 background = !background;1563 background = !background;
1649 g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);1564 g_signal_emit_by_name (view, "new-tab", link_uri, background);
1650 view->button_press_handled = TRUE;1565 view->button_press_handled = TRUE;
1651 return TRUE;1566 return TRUE;
1652 }1567 }
1653 else if (MIDORI_MOD_NEW_WINDOW (event->state))1568 else if (MIDORI_MOD_NEW_WINDOW (event->state))
1654 {1569 {
1655 /* Open link in new window */1570 /* Open link in new window */
1656 g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);1571 g_signal_emit_by_name (view, "new-window", link_uri);
1657 view->button_press_handled = TRUE;1572 view->button_press_handled = TRUE;
1658 return TRUE;1573 return TRUE;
1659 }1574 }
@@ -1668,7 +1583,7 @@
1668 background = view->open_tabs_in_the_background;1583 background = view->open_tabs_in_the_background;
1669 if (MIDORI_MOD_BACKGROUND (event->state))1584 if (MIDORI_MOD_BACKGROUND (event->state))
1670 background = !background;1585 background = !background;
1671 g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);1586 g_signal_emit_by_name (view, "new-tab", link_uri, background);
1672 view->button_press_handled = TRUE;1587 view->button_press_handled = TRUE;
1673 return TRUE;1588 return TRUE;
1674 }1589 }
@@ -1716,7 +1631,7 @@
1716 background = view->open_tabs_in_the_background;1631 background = view->open_tabs_in_the_background;
1717 if (MIDORI_MOD_BACKGROUND (event->state))1632 if (MIDORI_MOD_BACKGROUND (event->state))
1718 background = !background;1633 background = !background;
1719 g_signal_emit (view, signals[NEW_TAB], 0, uri, background);1634 g_signal_emit_by_name (view, "new-tab", uri, background);
1720 }1635 }
1721 else1636 else
1722 {1637 {
@@ -1935,7 +1850,7 @@
1935 gboolean background = view->open_tabs_in_the_background;1850 gboolean background = view->open_tabs_in_the_background;
1936 if (MIDORI_MOD_BACKGROUND (event->state))1851 if (MIDORI_MOD_BACKGROUND (event->state))
1937 background = !background;1852 background = !background;
1938 g_signal_emit (view, signals[NEW_TAB], 0, result, background);1853 g_signal_emit_by_name (view, "new-tab", result, background);
1939 }1854 }
1940 else1855 else
1941 midori_view_set_uri (view, result);1856 midori_view_set_uri (view, result);
@@ -2029,7 +1944,7 @@
2029 gpointer user_data)1944 gpointer user_data)
2030{1945{
2031 MidoriView* view = user_data;1946 MidoriView* view = user_data;
2032 g_signal_emit (view, signals[NEW_WINDOW], 0, view->link_uri);1947 g_signal_emit_by_name (view, "new-window", view->link_uri);
2033}1948}
20341949
2035static void1950static void
@@ -2057,7 +1972,7 @@
2057#endif1972#endif
2058 gboolean handled;1973 gboolean handled;
2059 midori_download_set_type (download, type);1974 midori_download_set_type (download, type);
2060 g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);1975 g_signal_emit_by_name (view, "download-requested", download, &handled);
2061}1976}
20621977
2063static void1978static void
@@ -2075,9 +1990,9 @@
2075 MidoriView* view = user_data;1990 MidoriView* view = user_data;
2076 gchar* uri = katze_object_get_string (view->hit_test, "image-uri");1991 gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
2077 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)1992 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
2078 g_signal_emit (view, signals[NEW_WINDOW], 0, uri);1993 g_signal_emit_by_name (view, "new-window", uri);
2079 else1994 else
2080 g_signal_emit (view, signals[NEW_TAB], 0, uri,1995 g_signal_emit_by_name (view, "new-tab", uri,
2081 view->open_tabs_in_the_background);1996 view->open_tabs_in_the_background);
2082 g_free (uri);1997 g_free (uri);
2083}1998}
@@ -2232,7 +2147,7 @@
2232 gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);2147 gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);
2233 if (!uri)2148 if (!uri)
2234 uri = g_strdup (data);2149 uri = g_strdup (data);
2235 g_signal_emit (view, signals[NEW_TAB], 0, uri,2150 g_signal_emit_by_name (view, "new-tab", uri,
2236 view->open_tabs_in_the_background);2151 view->open_tabs_in_the_background);
2237 g_free (uri);2152 g_free (uri);
2238}2153}
@@ -2242,7 +2157,7 @@
2242 gpointer user_data)2157 gpointer user_data)
2243{2158{
2244 MidoriView* view = user_data;2159 MidoriView* view = user_data;
2245 g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,2160 g_signal_emit_by_name (view, "new-tab", view->link_uri,
2246 !view->open_tabs_in_the_background);2161 !view->open_tabs_in_the_background);
2247}2162}
22482163
@@ -2258,12 +2173,12 @@
2258 gchar* uri = midori_uri_for_search (search, view->selected_text);2173 gchar* uri = midori_uri_for_search (search, view->selected_text);
22592174
2260 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)2175 if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
2261 g_signal_emit (view, signals[NEW_WINDOW], 0, uri);2176 g_signal_emit_by_name (view, "new-window", uri);
2262 /* FIXME: need a way to override behavior (middle click)2177 /* FIXME: need a way to override behavior (middle click)
2263 else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)2178 else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
2264 midori_view_set_uri (view, uri); */2179 midori_view_set_uri (view, uri); */
2265 else2180 else
2266 g_signal_emit (view, signals[NEW_TAB], 0, uri,2181 g_signal_emit_by_name (view, "new-tab", uri,
2267 view->open_tabs_in_the_background);2182 view->open_tabs_in_the_background);
22682183
2269 g_free (uri);2184 g_free (uri);
@@ -2275,7 +2190,7 @@
2275 gpointer user_data)2190 gpointer user_data)
2276{2191{
2277 MidoriView* view = user_data;2192 MidoriView* view = user_data;
2278 g_signal_emit (view, signals[NEW_WINDOW], 0,2193 g_signal_emit_by_name (view, "new-window",
2279 midori_view_get_display_uri (MIDORI_VIEW (view)));2194 midori_view_get_display_uri (MIDORI_VIEW (view)));
2280}2195}
22812196
@@ -2286,7 +2201,7 @@
2286{2201{
2287 MidoriView* view = user_data;2202 MidoriView* view = user_data;
2288 WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view));2203 WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view));
2289 g_signal_emit (view, signals[NEW_TAB], 0,2204 g_signal_emit_by_name (view, "new-tab",
2290 webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background);2205 webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background);
2291}2206}
2292#endif2207#endif
@@ -2675,7 +2590,7 @@
2675 where = MIDORI_NEW_VIEW_WINDOW;2590 where = MIDORI_NEW_VIEW_WINDOW;
26762591
2677 gtk_widget_show (new_view);2592 gtk_widget_show (new_view);
2678 g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, FALSE);2593 g_signal_emit_by_name (view, "new-view", new_view, where, FALSE);
26792594
2680 if (midori_tab_get_is_dialog (MIDORI_TAB (view)))2595 if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
2681 {2596 {
@@ -2892,7 +2807,7 @@
2892 "signal::failed", download_failed_cb, view,2807 "signal::failed", download_failed_cb, view,
2893 NULL);2808 NULL);
2894 */2809 */
2895 g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);2810 g_signal_emit_by_name (view, "download-requested", download, &handled);
2896#ifndef HAVE_WEBKIT22811#ifndef HAVE_WEBKIT2
2897 return handled;2812 return handled;
2898#endif2813#endif
@@ -4400,7 +4315,7 @@
44004315
4401 MidoriNewView where = MIDORI_NEW_VIEW_TAB;4316 MidoriNewView where = MIDORI_NEW_VIEW_TAB;
4402 GtkWidget* new_view = midori_view_new_with_item (view->item, view->settings);4317 GtkWidget* new_view = midori_view_new_with_item (view->item, view->settings);
4403 g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, TRUE);4318 g_signal_emit_by_name (view, "new-view", new_view, where, TRUE);
4404 midori_view_set_uri (MIDORI_VIEW (new_view), midori_tab_get_uri (MIDORI_TAB (view)));4319 midori_view_set_uri (MIDORI_VIEW (new_view), midori_tab_get_uri (MIDORI_TAB (view)));
4405 return new_view;4320 return new_view;
4406}4321}
44074322
=== modified file 'midori/midori.vapi'
--- midori/midori.vapi 2013-10-09 20:05:29 +0000
+++ midori/midori.vapi 2013-10-16 21:54:02 +0000
@@ -205,7 +205,6 @@
205 public GLib.Object net { get; }205 public GLib.Object net { get; }
206206
207 [HasEmitter]207 [HasEmitter]
208 public signal bool download_requested (WebKit.Download download);
209 public signal bool about_content (string uri);208 public signal bool about_content (string uri);
210209
211 }210 }

Subscribers

People subscribed via source and target branches

to all changes: