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

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6366
Merged at revision: 6398
Proposed branch: lp:~kalikiana/midori/popup
Merge into: lp:midori
Diff against target: 152 lines (+74/-7)
3 files modified
midori/midori-browser.c (+32/-5)
midori/midori-tab.vala (+4/-0)
midori/midori-view.c (+38/-2)
To merge this branch: bzr merge lp:~kalikiana/midori/popup
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+183362@code.launchpad.net

This proposal supersedes a proposal from 2013-08-31.

Commit message

Implement dialog windows opened via javascript

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote : Posted in a previous version of this proposal

Meh, the cmake stuff shows up there. Let's hold this off for a moment.

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

FYI cmake is out of the way, can be reviewed now.

Revision history for this message
André Stösel (ivaldi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-browser.c'
2--- midori/midori-browser.c 2013-08-15 21:32:30 +0000
3+++ midori/midori-browser.c 2013-09-01 17:50:34 +0000
4@@ -1553,6 +1553,32 @@
5 gboolean user_initiated,
6 MidoriBrowser* browser)
7 {
8+ if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
9+ {
10+ /* Dialog: URL, no toolbars, no tabs */
11+ MidoriBrowser* new_browser;
12+ g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
13+ g_assert (new_browser != NULL);
14+ gtk_window_set_transient_for (GTK_WINDOW (new_browser), GTK_WINDOW (browser));
15+ gtk_window_set_destroy_with_parent (GTK_WINDOW (new_browser), TRUE);
16+ MidoriWebSettings* settings = midori_web_settings_new ();
17+ g_object_set (settings,
18+ "toolbar-items", "Location",
19+ "show-menubar", FALSE,
20+ "show-bookmarkbar", FALSE,
21+ "show-statusbar", FALSE,
22+ NULL);
23+ g_object_set (new_browser,
24+ "settings", settings,
25+ "show-tabs", FALSE,
26+ NULL);
27+ g_object_unref (settings);
28+ _action_set_visible (new_browser, "CompactMenu", FALSE);
29+ midori_browser_add_tab (new_browser, new_view);
30+ midori_browser_set_current_tab (new_browser, new_view);
31+ return;
32+ }
33+
34 if (midori_view_forward_external (new_view,
35 katze_item_get_uri (midori_view_get_proxy_item (MIDORI_VIEW (new_view))),
36 where))
37@@ -6773,7 +6799,6 @@
38 MidoriToolbarStyle toolbar_style;
39 gchar* toolbar_items;
40 gboolean close_buttons_on_tabs;
41- KatzeItem* item;
42
43 g_object_get (browser->settings,
44 "remember-last-window-size", &remember_last_window_size,
45@@ -6840,13 +6865,15 @@
46 {
47 const gchar* default_search = midori_settings_get_location_entry_search (
48 MIDORI_SETTINGS (browser->settings));
49- item = katze_array_get_nth_item (browser->search_engines,
50- browser->last_web_search);
51- if (item)
52+ KatzeItem* item;
53+
54+ if ((item = katze_array_get_nth_item (browser->search_engines,
55+ browser->last_web_search)))
56 midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
57 _action_by_name (browser, "Search")), item);
58
59- if ((item = katze_array_find_uri (browser->search_engines, default_search)))
60+ if (default_search != NULL
61+ && (item = katze_array_find_uri (browser->search_engines, default_search)))
62 midori_search_action_set_default_item (MIDORI_SEARCH_ACTION (
63 _action_by_name (browser, "Search")), item);
64 }
65
66=== modified file 'midori/midori-tab.vala'
67--- midori/midori-tab.vala 2013-07-28 15:50:26 +0000
68+++ midori/midori-tab.vala 2013-09-01 17:50:34 +0000
69@@ -92,6 +92,10 @@
70 /* Since: 0.5.5 */
71 public signal void context_menu (WebKit.HitTestResult hit_test_result, ContextAction menu);
72
73+ /* A dialog tab has a fixed size, limited GUI and is transient.
74+ Since: 0.5.6 */
75+ public bool is_dialog { get; protected set; }
76+
77 public bool is_blank () {
78 return URI.is_blank (uri);
79 }
80
81=== modified file 'midori/midori-view.c'
82--- midori/midori-view.c 2013-09-01 16:40:29 +0000
83+++ midori/midori-view.c 2013-09-01 17:50:34 +0000
84@@ -2618,16 +2618,39 @@
85
86 #ifndef HAVE_WEBKIT2
87 static gboolean
88+midori_view_web_view_close_cb (WebKitWebView* web_view,
89+ GtkWidget* view)
90+{
91+ midori_browser_close_tab (midori_browser_get_for_widget (view), view);
92+ return TRUE;
93+}
94+
95+static gboolean
96 webkit_web_view_web_view_ready_cb (GtkWidget* web_view,
97 MidoriView* view)
98 {
99 MidoriNewView where = MIDORI_NEW_VIEW_TAB;
100 GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));
101
102- /* FIXME: Open windows opened by scripts in tabs if they otherwise
103+ WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (web_view);
104+ gboolean locationbar_visible, menubar_visible, toolbar_visible;
105+ gint width, height;
106+ g_object_get (features,
107+ "locationbar-visible", &locationbar_visible,
108+ "menubar-visible", &menubar_visible,
109+ "toolbar-visible", &toolbar_visible,
110+ "width", &width,
111+ "height", &height,
112+ NULL);
113+ midori_tab_set_is_dialog (MIDORI_TAB (view),
114+ !locationbar_visible && !menubar_visible && !toolbar_visible
115+ && width > 0 && height > 0);
116+
117+ /* Open windows opened by scripts in tabs if they otherwise
118 would be replacing the page the user opened. */
119 if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
120- return TRUE;
121+ if (!midori_tab_get_is_dialog (MIDORI_TAB (view)))
122+ return TRUE;
123
124 if (view->open_new_pages_in == MIDORI_NEW_PAGE_TAB)
125 {
126@@ -2640,6 +2663,15 @@
127 gtk_widget_show (new_view);
128 g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, FALSE);
129
130+ if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
131+ {
132+ GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);
133+ if (width > 0 && height > 0)
134+ gtk_widget_set_size_request (toplevel, width, height);
135+ g_signal_connect (web_view, "close-web-view",
136+ G_CALLBACK (midori_view_web_view_close_cb), new_view);
137+ }
138+
139 return TRUE;
140 }
141
142@@ -3947,6 +3979,10 @@
143 for (i = 0; i < G_N_ELEMENTS (widgets); i++)
144 g_string_append_printf (demo, widgets[i], " class=\"fallback\"");
145 g_string_append (demo, "</div>");
146+ g_string_append (demo, "<p><a href=\"http://example.com\" target=\"wp\" "
147+ "onclick=\"javascript:window.open('http://example.com','wp',"
148+ "'width=320, height=240, toolbar=false'); return false\""
149+ ">Popup window</a></p>");
150 data = g_string_free (demo, FALSE);
151 }
152 else if (!strcmp (uri, "about:private"))

Subscribers

People subscribed via source and target branches

to all changes: