Merge lp:~midori/midori/headerBarSupport into lp:midori
- headerBarSupport
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Paweł Forysiuk | ||||||||
Approved revision: | 6968 | ||||||||
Merged at revision: | 6961 | ||||||||
Proposed branch: | lp:~midori/midori/headerBarSupport | ||||||||
Merge into: | lp:midori | ||||||||
Diff against target: |
1091 lines (+370/-376) 12 files modified
extensions/adblock/extension.vala (+2/-5) extensions/adblock/widgets.vala (+38/-72) extensions/statusbar-features.c (+4/-7) midori/midori-browser.c (+58/-289) midori/midori-browser.h (+1/-1) midori/midori-contextaction.vala (+12/-0) midori/midori-frontend.c (+3/-1) midori/midori-panedaction.vala (+4/-0) midori/midori-preferences.c (+7/-0) midori/midori-window.vala (+239/-0) midori/midori.vapi (+1/-1) po/POTFILES.in (+1/-0) |
||||||||
To merge this branch: | bzr merge lp:~midori/midori/headerBarSupport | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paweł Forysiuk | Approve | ||
Danielle Foré (community) | ux, testing | Approve | |
Review via email: mp+260017@code.launchpad.net |
Commit message
Implement Midori.Window class with toolbar/ headerbar
Description of the change
- 6958. By Cris Dywan
-
Fix position of extra actions and paned children
- 6959. By Cris Dywan
-
Implement search entry width correctly
- 6960. By Cris Dywan
-
Use max width instead of width for URL entry
Cris Dywan (kalikiana) wrote : | # |
I'm not sure if I understand the comments fully - I changed the property used to size the URL entry so it expands fully. Is that what you meant by packing?
Right-click on buttons works perfectly for me, like with the classic toolbar, you get the menu to toggle toolbars and the toolbar editor is the last item in it.
Danielle Foré (danrabbit) wrote : | # |
URL bar looks right here now :)
Can you possibly add a 1px top and bottom margin to the url entry? It looks like without that box-shadow is clipped.
Ah, if you right click the items themselves you'll get the menu. But if you click the headerbar itself, you only get the window menu. I guess I can file this separately. I personally think it's a little counter-intuitive.
I'm not sure how much you care about the separate web search these days. I added it just for kicks and it's really tiny. Also, there's no pane handle to resize like there used to be.
- 6961. By Cris Dywan
-
Add and bottom margin to headerbar title
Danielle Foré (danrabbit) wrote : | # |
Hey Christian, the last revision didn't seem to fix the issue. The space needs to be reserved for the entry itself. So instead of headerbar.
- 6962. By Cris Dywan
-
No toolbar style without a toolbar
- 6963. By Cris Dywan
-
Use original order of actions in HeaderBar
- 6964. By Cris Dywan
-
Pixel margins for the entry
Cris Dywan (kalikiana) wrote : | # |
Right-click to edit has always been on the buttons themselves. Also it's not officially possible to extend the headerbar context menu - so I'd say that should be discussed and dealt with separately.
Cris Dywan (kalikiana) wrote : | # |
Regarding resizing of web search: I'm not sure if it's worth porting the existing design as-is because it can only work if both entries sit in the headerbar which seems conceptually wrong. If interest is there it can certainly be looked into later.
Danielle Foré (danrabbit) wrote : | # |
Yeah I'm of the opinion still that the separate web search should just be removed since that functionality is already provided in the urlbar. Just wanted to test possible cases :)
I agree the right click menu bit can/should be a different issue.
Danielle Foré (danrabbit) wrote : | # |
Crashes when enabling "statusbar features" extension:
ERROR:/
Danielle Foré (danrabbit) wrote : | # |
Thoughts on moving the extensions area of the toolbar to the right? This would seem to follow with Chrome and Firefox
- 6965. By Cris Dywan
-
Let statusbar features handle toolbar not being toolbar
- 6966. By Cris Dywan
-
Always put extra actions on the headerbar's tail
Danielle Foré (danrabbit) wrote : | # |
Everything working as expected here :D
Cody Garver (codygarver) wrote : | # |
I made some comments throughout the diff about code style inconsistencies
Be sure to update the translation template after you commit new string(s) to trunk
- 6967. By Cris Dywan
-
Fix spacing in lambdas
- 6968. By Cris Dywan
-
Only connect buttons to toolbar style
Paweł Forysiuk (tuxator) : | # |
Preview Diff
1 | === modified file 'extensions/adblock/extension.vala' |
2 | --- extensions/adblock/extension.vala 2015-04-18 21:38:47 +0000 |
3 | +++ extensions/adblock/extension.vala 2015-06-06 12:33:01 +0000 |
4 | @@ -115,8 +115,6 @@ |
5 | browser_removed (browser); |
6 | app.add_browser.disconnect (browser_added); |
7 | app.remove_browser.disconnect (browser_removed); |
8 | - foreach (var button in status_icon.toggle_buttons) |
9 | - button.destroy (); |
10 | } |
11 | |
12 | void browser_added (Midori.Browser browser) { |
13 | @@ -125,9 +123,7 @@ |
14 | browser.add_tab.connect (tab_added); |
15 | browser.remove_tab.connect (tab_removed); |
16 | |
17 | - var toggle_button = status_icon.add_button (); |
18 | - browser.statusbar.pack_end (toggle_button, false, false, 3); |
19 | - toggle_button.show (); |
20 | + browser.add_action (status_icon); |
21 | } |
22 | |
23 | void browser_removed (Midori.Browser browser) { |
24 | @@ -135,6 +131,7 @@ |
25 | tab_removed (tab); |
26 | browser.add_tab.disconnect (tab_added); |
27 | browser.remove_tab.disconnect (tab_removed); |
28 | + browser.remove_action (status_icon); |
29 | } |
30 | |
31 | void tab_added (Midori.View view) { |
32 | |
33 | === modified file 'extensions/adblock/widgets.vala' |
34 | --- extensions/adblock/widgets.vala 2014-04-03 17:07:04 +0000 |
35 | +++ extensions/adblock/widgets.vala 2015-06-06 12:33:01 +0000 |
36 | @@ -13,99 +13,65 @@ |
37 | namespace Adblock { |
38 | |
39 | |
40 | - public class StatusIcon { |
41 | + public class StatusIcon : Midori.ContextAction { |
42 | Config config; |
43 | SubscriptionManager manager; |
44 | public State state; |
45 | public bool debug_element_toggled; |
46 | - public List<IconButton> toggle_buttons; |
47 | |
48 | public StatusIcon (Adblock.Config config, SubscriptionManager manager) { |
49 | + GLib.Object (name: "AdblockStatusMenu"); |
50 | + |
51 | this.config = config; |
52 | this.manager = manager; |
53 | this.debug_element_toggled = false; |
54 | - } |
55 | - |
56 | - public void set_state (Adblock.State state) { |
57 | - this.state = state; |
58 | - update_buttons (); |
59 | - } |
60 | - |
61 | - public class IconButton : Gtk.Button { |
62 | - Gtk.Image icon; |
63 | - |
64 | - public IconButton () { |
65 | - icon = new Gtk.Image (); |
66 | - add (icon); |
67 | - icon.show (); |
68 | - } |
69 | - |
70 | - public void set_status (string status) { |
71 | - icon.set_from_file (Midori.Paths.get_res_filename ("adblock/%s.png".printf (status))); |
72 | - } |
73 | - } |
74 | - |
75 | - public IconButton add_button () { |
76 | - var button = new IconButton (); |
77 | - button.set_status (config.enabled ? "enabled" : "disabled"); |
78 | - button.clicked.connect (icon_clicked); |
79 | - button.destroy.connect (()=> { toggle_buttons.remove (button); }); |
80 | - toggle_buttons.append (button); |
81 | - return button; |
82 | - } |
83 | - |
84 | - public void update_buttons () { |
85 | - string state = ""; |
86 | - foreach (var toggle_button in toggle_buttons) { |
87 | - if (this.state == State.BLOCKED) { |
88 | - toggle_button.set_status ("blocked"); |
89 | - state = _("Blocking"); |
90 | - } |
91 | - if (this.state == State.ENABLED) { |
92 | - toggle_button.set_status ("enabled"); |
93 | - state = _("Enabled"); |
94 | - } |
95 | - if (this.state == State.DISABLED) { |
96 | - toggle_button.set_status ("disabled"); |
97 | - state = _("Disabled"); |
98 | - } |
99 | - toggle_button.set_tooltip_text (_("Adblock state: %s").printf (state)); |
100 | - } |
101 | - } |
102 | - |
103 | - public void icon_clicked (Gtk.Button toggle_button) { |
104 | - var menu = new Gtk.Menu (); |
105 | - |
106 | - var menuitem = new Gtk.ImageMenuItem.with_label (_("Preferences")); |
107 | - var image = new Gtk.Image.from_stock (Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU); |
108 | - menuitem.always_show_image = true; |
109 | - menuitem.set_image (image); |
110 | - menuitem.activate.connect (() => { |
111 | + |
112 | + var item = new Midori.ContextAction ("Preferences", |
113 | + _("Preferences"), null, Gtk.STOCK_PREFERENCES); |
114 | + item.activate.connect (() => { |
115 | manager.add_subscription (null); |
116 | }); |
117 | - menu.append (menuitem); |
118 | - |
119 | - var separator = new Gtk.SeparatorMenuItem (); |
120 | - menu.append (separator); |
121 | - |
122 | - var checkitem = new Gtk.CheckMenuItem.with_label (_("Disable")); |
123 | + add (item); |
124 | + |
125 | + add (null); |
126 | + |
127 | + var checkitem = new Gtk.ToggleAction ("Disable", _("Disable"), null, null); |
128 | checkitem.set_active (!config.enabled); |
129 | checkitem.toggled.connect (() => { |
130 | config.enabled = !checkitem.active; |
131 | set_state (config.enabled ? Adblock.State.ENABLED : Adblock.State.DISABLED); |
132 | }); |
133 | - menu.append (checkitem); |
134 | + add (checkitem); |
135 | |
136 | - var hideritem = new Gtk.CheckMenuItem.with_label (_("Display hidden elements")); |
137 | + var hideritem = new Gtk.ToggleAction ("HiddenElements", |
138 | + _("Display hidden elements"), null, null); |
139 | hideritem.set_active (debug_element_toggled); |
140 | hideritem.toggled.connect (() => { |
141 | this.debug_element_toggled = hideritem.active; |
142 | }); |
143 | - menu.append (hideritem); |
144 | - |
145 | - menu.show_all (); |
146 | - menu.attach_to_widget (toggle_button, null); |
147 | - menu.popup (null, null, null, 1, Gtk.get_current_event_time ()); |
148 | + add (hideritem); |
149 | + set_status (config.enabled ? "enabled" : "disabled"); |
150 | + } |
151 | + |
152 | + void set_status (string status) { |
153 | + gicon = new GLib.FileIcon (File.new_for_path ( |
154 | + Midori.Paths.get_res_filename ("adblock/%s.png".printf (status)))); |
155 | + } |
156 | + |
157 | + public void set_state (Adblock.State state) { |
158 | + this.state = state; |
159 | + |
160 | + if (this.state == State.BLOCKED) { |
161 | + set_status ("blocked"); |
162 | + tooltip = _("Blocking"); |
163 | + } else if (this.state == State.ENABLED) { |
164 | + set_status ("enabled"); |
165 | + tooltip = _("Enabled"); |
166 | + } else if (this.state == State.DISABLED) { |
167 | + set_status ("disabled"); |
168 | + tooltip = _("Disabled"); |
169 | + } else |
170 | + assert_not_reached (); |
171 | } |
172 | } |
173 | |
174 | |
175 | === modified file 'extensions/statusbar-features.c' |
176 | --- extensions/statusbar-features.c 2013-10-30 00:05:40 +0000 |
177 | +++ extensions/statusbar-features.c 2015-06-06 12:33:01 +0000 |
178 | @@ -153,19 +153,13 @@ |
179 | image = gtk_image_new_from_stock (STOCK_IMAGE, GTK_ICON_SIZE_MENU); |
180 | gtk_button_set_image (GTK_BUTTON (button), image); |
181 | gtk_widget_set_tooltip_text (button, _("Load images automatically")); |
182 | - statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button); |
183 | - g_signal_connect (toolbar, "notify::toolbar-style", |
184 | - G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button); |
185 | } |
186 | - if (!strcmp (property, "enable-javascript")) |
187 | + else if (!strcmp (property, "enable-javascript")) |
188 | { |
189 | g_object_set_data (G_OBJECT (button), "feature-label", _("Scripts")); |
190 | image = gtk_image_new_from_stock (STOCK_SCRIPT, GTK_ICON_SIZE_MENU); |
191 | gtk_button_set_image (GTK_BUTTON (button), image); |
192 | gtk_widget_set_tooltip_text (button, _("Enable scripts")); |
193 | - statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button); |
194 | - g_signal_connect (toolbar, "notify::toolbar-style", |
195 | - G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button); |
196 | } |
197 | else if (!strcmp (property, "enable-plugins")) |
198 | { |
199 | @@ -175,6 +169,9 @@ |
200 | image = gtk_image_new_from_stock (MIDORI_STOCK_PLUGINS, GTK_ICON_SIZE_MENU); |
201 | gtk_button_set_image (GTK_BUTTON (button), image); |
202 | gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins")); |
203 | + } |
204 | + if (GTK_IS_TOOLBAR (toolbar) && GTK_IS_BUTTON (button)) |
205 | + { |
206 | statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button); |
207 | g_signal_connect (toolbar, "notify::toolbar-style", |
208 | G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button); |
209 | |
210 | === modified file 'midori/midori-browser.c' |
211 | --- midori/midori-browser.c 2015-04-28 22:01:05 +0000 |
212 | +++ midori/midori-browser.c 2015-06-06 12:33:01 +0000 |
213 | @@ -61,7 +61,7 @@ |
214 | |
215 | struct _MidoriBrowser |
216 | { |
217 | - GtkWindow parent_instance; |
218 | + MidoriWindow parent_instance; |
219 | GtkActionGroup* action_group; |
220 | GtkWidget* menubar; |
221 | GtkWidget* throbber; |
222 | @@ -102,7 +102,7 @@ |
223 | gboolean bookmarkbar_populate; |
224 | }; |
225 | |
226 | -G_DEFINE_TYPE (MidoriBrowser, midori_browser, GTK_TYPE_WINDOW) |
227 | +G_DEFINE_TYPE (MidoriBrowser, midori_browser, MIDORI_TYPE_WINDOW) |
228 | |
229 | enum |
230 | { |
231 | @@ -192,6 +192,12 @@ |
232 | GParamSpec* pspec, |
233 | MidoriBrowser* browser); |
234 | |
235 | +static void |
236 | +midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser, |
237 | + GtkWidget* widget, |
238 | + gboolean back, |
239 | + gint x, |
240 | + gint y); |
241 | void |
242 | midori_panel_set_toolbar_style (MidoriPanel* panel, |
243 | GtkToolbarStyle style); |
244 | @@ -1710,10 +1716,6 @@ |
245 | } |
246 | |
247 | static void |
248 | -_midori_browser_set_toolbar_items (MidoriBrowser* browser, |
249 | - const gchar* items); |
250 | - |
251 | -static void |
252 | midori_view_new_view_cb (GtkWidget* view, |
253 | GtkWidget* new_view, |
254 | MidoriNewView where, |
255 | @@ -1735,7 +1737,8 @@ |
256 | sokoke_widget_set_visible (new_browser->bookmarkbar, FALSE); |
257 | sokoke_widget_set_visible (new_browser->statusbar, FALSE); |
258 | _action_set_visible (new_browser, "CompactMenu", FALSE); |
259 | - _midori_browser_set_toolbar_items (new_browser, "Location"); |
260 | + _action_set_sensitive (new_browser, "Location", FALSE); |
261 | + midori_window_set_actions (MIDORI_WINDOW (new_browser), "Location"); |
262 | sokoke_widget_set_visible (new_browser->panel, FALSE); |
263 | midori_browser_add_tab (new_browser, new_view); |
264 | midori_browser_set_current_tab (new_browser, new_view); |
265 | @@ -2463,7 +2466,7 @@ |
266 | "navigationbar", |
267 | "Navigationbar", |
268 | "The navigationbar", |
269 | - GTK_TYPE_TOOLBAR, |
270 | + GTK_TYPE_CONTAINER, |
271 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); |
272 | |
273 | g_object_class_install_property (gobject_class, |
274 | @@ -3111,22 +3114,6 @@ |
275 | midori_findbar_continue (MIDORI_FINDBAR (browser->find), FALSE); |
276 | } |
277 | |
278 | -static void |
279 | -midori_browser_navigationbar_notify_style_cb (GObject* object, |
280 | - GParamSpec* arg1, |
281 | - MidoriBrowser* browser) |
282 | -{ |
283 | - MidoriToolbarStyle toolbar_style; |
284 | - |
285 | - g_object_get (browser->settings, "toolbar-style", &toolbar_style, NULL); |
286 | - _midori_browser_set_toolbar_style (browser, toolbar_style); |
287 | -} |
288 | - |
289 | -static gboolean |
290 | -midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem, |
291 | - GdkEventButton* event, |
292 | - MidoriBrowser* browser); |
293 | - |
294 | /** |
295 | * midori_browser_get_toolbar_actions: |
296 | * |
297 | @@ -3176,7 +3163,8 @@ |
298 | MidoriContextAction* menu = midori_context_action_new ("ToolbarContextMenu", NULL, NULL, NULL); |
299 | midori_context_action_add_action_group (menu, browser->action_group); |
300 | midori_context_action_add_by_name (menu, "Menubar"); |
301 | - midori_context_action_add_by_name (menu, "Navigationbar"); |
302 | + if (GTK_IS_TOOLBAR (browser->navigationbar)) |
303 | + midori_context_action_add_by_name (menu, "Navigationbar"); |
304 | midori_context_action_add_by_name (menu, "Bookmarkbar"); |
305 | midori_context_action_add_by_name (menu, "Statusbar"); |
306 | |
307 | @@ -3460,7 +3448,7 @@ |
308 | } |
309 | |
310 | static gboolean |
311 | -midori_browser_has_native_menubar (void) |
312 | +midori_browser_has_native_menubar (MidoriBrowser* browser) |
313 | { |
314 | static const gchar* ubuntu_menuproxy = NULL; |
315 | if (ubuntu_menuproxy == NULL) |
316 | @@ -3480,51 +3468,13 @@ |
317 | MidoriBrowser* browser) |
318 | { |
319 | gboolean active = gtk_toggle_action_get_active (menubar_action); |
320 | - GtkAction* menu_action = _action_by_name (browser, "CompactMenu"); |
321 | - GString* toolbar_items; |
322 | - GList* children; |
323 | - gchar* items; |
324 | |
325 | - if (midori_browser_has_native_menubar ()) |
326 | + if (midori_browser_has_native_menubar (browser)) |
327 | active = FALSE; |
328 | - |
329 | - toolbar_items = g_string_new (NULL); |
330 | - children = gtk_container_get_children (GTK_CONTAINER (browser->navigationbar)); |
331 | - for (; children != NULL; children = g_list_next (children)) |
332 | - { |
333 | - GtkAction* action = gtk_activatable_get_related_action ( |
334 | - GTK_ACTIVATABLE (children->data)); |
335 | - if (!action) |
336 | - continue; |
337 | - if (action == ((GtkAction*)menu_action)) |
338 | - { |
339 | - if (active) |
340 | - { |
341 | - gtk_container_remove (GTK_CONTAINER (browser->navigationbar), |
342 | - GTK_WIDGET (children->data)); |
343 | - } |
344 | - continue; |
345 | - } |
346 | - else if (MIDORI_IS_PANED_ACTION (action)) |
347 | - { |
348 | - MidoriPanedAction* paned_action = MIDORI_PANED_ACTION (action); |
349 | - g_string_append_printf (toolbar_items, "%s,%s", |
350 | - midori_paned_action_get_child1_name (paned_action), |
351 | - midori_paned_action_get_child2_name (paned_action)); |
352 | - } |
353 | - else |
354 | - g_string_append (toolbar_items, gtk_action_get_name (action)); |
355 | - g_string_append_c (toolbar_items, ','); |
356 | - } |
357 | - g_list_free (children); |
358 | - |
359 | + midori_window_set_show_menubar (MIDORI_WINDOW (browser), active); |
360 | if (katze_object_get_boolean (browser->settings, "show-menubar") != active) |
361 | g_object_set (browser->settings, "show-menubar", active, NULL); |
362 | |
363 | - items = g_string_free (toolbar_items, FALSE); |
364 | - g_object_set (browser->settings, "toolbar-items", items, NULL); |
365 | - g_free (items); |
366 | - |
367 | sokoke_widget_set_visible (browser->menubar, active); |
368 | g_object_set_data (G_OBJECT (browser), "midori-toolbars-visible", |
369 | gtk_widget_get_visible (browser->menubar) |
370 | @@ -4396,6 +4346,26 @@ |
371 | midori_bookmarks_db_remove_item (browser->bookmarks, item); |
372 | } |
373 | |
374 | +static gboolean |
375 | +midori_browser_toolbar_context_menu_cb (GtkWidget* toolbar, |
376 | + GtkWidget* widget, |
377 | + GtkAction* action, |
378 | + MidoriBrowser* browser) |
379 | +{ |
380 | + const gchar* name = gtk_action_get_name (action); |
381 | + gboolean back = !g_strcmp0 (name, "Back"); |
382 | + if (back |
383 | + || g_str_has_suffix (name, "Forward")) |
384 | + { |
385 | + midori_browser_toolbar_popup_context_menu_history ( |
386 | + browser, |
387 | + widget, |
388 | + back, 0, 0); |
389 | + return TRUE; |
390 | + } |
391 | + return midori_browser_toolbar_popup_context_menu_cb (widget, 0, 0, 0, browser); |
392 | +} |
393 | + |
394 | static void |
395 | midori_browser_bookmark_popup (GtkWidget* widget, |
396 | GdkEventButton* event, |
397 | @@ -5958,7 +5928,6 @@ |
398 | GtkWidget* homepage; |
399 | GtkWidget* back; |
400 | GtkWidget* forward; |
401 | - GtkSettings* gtk_settings; |
402 | GtkWidget* hpaned; |
403 | GtkWidget* vpaned; |
404 | GtkWidget* scrolled; |
405 | @@ -5990,12 +5959,14 @@ |
406 | #endif |
407 | #endif |
408 | vbox = gtk_vbox_new (FALSE, 0); |
409 | - gtk_container_add (GTK_CONTAINER (browser), vbox); |
410 | - gtk_widget_show (vbox); |
411 | + /* gtk_container_add (GTK_CONTAINER (browser), vbox); |
412 | + gtk_widget_show (vbox); */ |
413 | + midori_window_set_contents (MIDORI_WINDOW (browser), vbox); |
414 | |
415 | /* Let us see some ui manager magic */ |
416 | browser->action_group = gtk_action_group_new ("Browser"); |
417 | gtk_action_group_set_translation_domain (browser->action_group, GETTEXT_PACKAGE); |
418 | + midori_window_add_action_group (MIDORI_WINDOW (browser), browser->action_group); |
419 | midori_browser_add_actions (browser); |
420 | ui_manager = gtk_ui_manager_new (); |
421 | accel_group = gtk_ui_manager_get_accel_group (ui_manager); |
422 | @@ -6174,9 +6145,9 @@ |
423 | |
424 | /* Create the menubar */ |
425 | browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar"); |
426 | - gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0); |
427 | + midori_window_add_toolbar (MIDORI_WINDOW (browser), browser->menubar); |
428 | gtk_widget_hide (browser->menubar); |
429 | - _action_set_visible (browser, "Menubar", !midori_browser_has_native_menubar ()); |
430 | + _action_set_visible (browser, "Menubar", !midori_browser_has_native_menubar (browser)); |
431 | g_signal_connect (browser->menubar, "button-press-event", |
432 | G_CALLBACK (midori_browser_menu_button_press_event_cb), browser); |
433 | |
434 | @@ -6235,30 +6206,18 @@ |
435 | _action_set_visible (browser, "UndoTabClose", browser->trash != NULL); |
436 | |
437 | /* Create the navigationbar */ |
438 | - browser->navigationbar = gtk_ui_manager_get_widget ( |
439 | - ui_manager, "/toolbar_navigation"); |
440 | - katze_widget_add_class (browser->navigationbar, "primary-toolbar"); |
441 | - /* FIXME: Settings should be connected with screen changes */ |
442 | - gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser)); |
443 | - if (gtk_settings) |
444 | - g_signal_connect (gtk_settings, "notify::gtk-toolbar-style", |
445 | - G_CALLBACK (midori_browser_navigationbar_notify_style_cb), browser); |
446 | - gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->navigationbar), TRUE); |
447 | - g_object_set (_action_by_name (browser, "Back"), "is-important", TRUE, NULL); |
448 | - gtk_widget_hide (browser->navigationbar); |
449 | - g_signal_connect (browser->navigationbar, "popup-context-menu", |
450 | - G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser); |
451 | - gtk_box_pack_start (GTK_BOX (vbox), browser->navigationbar, FALSE, FALSE, 0); |
452 | + browser->navigationbar = midori_window_get_toolbar (MIDORI_WINDOW (browser)); |
453 | + g_signal_connect (browser, "context-menu", |
454 | + G_CALLBACK (midori_browser_toolbar_context_menu_cb), browser); |
455 | |
456 | /* Bookmarkbar */ |
457 | browser->bookmarkbar = gtk_toolbar_new (); |
458 | - katze_widget_add_class (browser->bookmarkbar, "secondary-toolbar"); |
459 | gtk_widget_set_name (browser->bookmarkbar, "MidoriBookmarkbar"); |
460 | gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->bookmarkbar), |
461 | GTK_ICON_SIZE_MENU); |
462 | gtk_toolbar_set_style (GTK_TOOLBAR (browser->bookmarkbar), |
463 | GTK_TOOLBAR_BOTH_HORIZ); |
464 | - gtk_box_pack_start (GTK_BOX (vbox), browser->bookmarkbar, FALSE, FALSE, 0); |
465 | + midori_window_add_toolbar (MIDORI_WINDOW (browser), browser->bookmarkbar); |
466 | g_signal_connect (browser->bookmarkbar, "popup-context-menu", |
467 | G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser); |
468 | |
469 | @@ -6407,9 +6366,12 @@ |
470 | gtk_toolbar_style = GTK_TOOLBAR_BOTH_HORIZ; |
471 | } |
472 | } |
473 | - gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar), |
474 | - gtk_toolbar_style); |
475 | - gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->navigationbar), icon_size); |
476 | + if (GTK_IS_TOOLBAR (browser->navigationbar)) |
477 | + { |
478 | + gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar), |
479 | + gtk_toolbar_style); |
480 | + gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->navigationbar), icon_size); |
481 | + } |
482 | midori_panel_set_toolbar_style (MIDORI_PANEL (browser->panel), |
483 | gtk_toolbar_style); |
484 | } |
485 | @@ -6489,201 +6451,6 @@ |
486 | #endif |
487 | } |
488 | |
489 | -static gboolean |
490 | -midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem, |
491 | - GdkEventButton* event, |
492 | - MidoriBrowser* browser) |
493 | -{ |
494 | - if (MIDORI_EVENT_NEW_TAB (event)) |
495 | - { |
496 | - /* check if the middle-click was performed over reload button */ |
497 | - if (g_object_get_data (G_OBJECT (toolitem), "reload-middle-click")) |
498 | - { |
499 | - gtk_action_activate (_action_by_name (browser, "TabDuplicate")); |
500 | - } |
501 | - |
502 | - GtkWidget* parent = gtk_widget_get_parent (toolitem); |
503 | - GtkAction* action = gtk_activatable_get_related_action ( |
504 | - GTK_ACTIVATABLE (parent)); |
505 | - |
506 | - g_object_set_data (G_OBJECT (action), |
507 | - "midori-middle-click", |
508 | - GINT_TO_POINTER (1)); |
509 | - |
510 | - return _action_navigation_activate (action, browser); |
511 | - } |
512 | - else if (MIDORI_EVENT_CONTEXT_MENU (event)) |
513 | - { |
514 | - if (g_object_get_data (G_OBJECT (toolitem), "history-back")) |
515 | - { |
516 | - midori_browser_toolbar_popup_context_menu_history ( |
517 | - browser, |
518 | - GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? |
519 | - gtk_widget_get_parent (toolitem) : toolitem, |
520 | - TRUE, event->x, event->y); |
521 | - } |
522 | - else if (g_object_get_data (G_OBJECT (toolitem), "history-forward")) |
523 | - { |
524 | - midori_browser_toolbar_popup_context_menu_history ( |
525 | - browser, |
526 | - GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? |
527 | - gtk_widget_get_parent (toolitem) : toolitem, |
528 | - FALSE, event->x, event->y); |
529 | - } |
530 | - else |
531 | - { |
532 | - midori_browser_toolbar_popup_context_menu_cb ( |
533 | - GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? |
534 | - gtk_widget_get_parent (toolitem) : toolitem, |
535 | - event->x, event->y, event->button, browser); |
536 | - } |
537 | - return TRUE; |
538 | - } |
539 | - return FALSE; |
540 | -} |
541 | - |
542 | -static void |
543 | -_midori_browser_search_item_allocate_cb (GtkWidget* widget, |
544 | - GdkRectangle* allocation, |
545 | - gpointer user_data) |
546 | -{ |
547 | - MidoriBrowser* browser = MIDORI_BROWSER (user_data); |
548 | - MidoriWebSettings* settings = browser->settings; |
549 | - g_object_set (settings, "search-width", allocation->width, NULL); |
550 | -} |
551 | - |
552 | -static void |
553 | -_midori_browser_set_toolbar_items (MidoriBrowser* browser, |
554 | - const gchar* items) |
555 | -{ |
556 | - gchar** names; |
557 | - gchar** name; |
558 | - GtkAction* action; |
559 | - GtkWidget* toolitem; |
560 | - const char* token_location = g_intern_static_string ("Location"); |
561 | - const char* token_search = g_intern_static_string ("Search"); |
562 | - const char* token_dontcare = g_intern_static_string ("Dontcare"); |
563 | - const char* token_current = token_dontcare; |
564 | - const char* token_last; |
565 | - |
566 | - gtk_container_foreach (GTK_CONTAINER (browser->navigationbar), |
567 | - (GtkCallback)gtk_widget_destroy, NULL); |
568 | - |
569 | - names = g_strsplit (items ? items : "", ",", 0); |
570 | - name = names; |
571 | - for (; *name; ++name) |
572 | - { |
573 | - action = _action_by_name (browser, *name); |
574 | - if (action && strstr (*name, "CompactMenu") == NULL) |
575 | - { |
576 | - token_last = token_current; |
577 | - |
578 | - /* Decide, what kind of token (item) we got now */ |
579 | - if (name && !g_strcmp0 (*name, "Location")) |
580 | - token_current = token_location; |
581 | - else if (name && !g_strcmp0 (*name, "Search")) |
582 | - token_current = token_search; |
583 | - else |
584 | - token_current = token_dontcare; |
585 | - |
586 | - if ((token_current == token_location || token_current == token_search) && |
587 | - (token_last == token_location || token_last == token_search)) |
588 | - { |
589 | - GtkWidget* toolitem_first = gtk_action_create_tool_item ( |
590 | - _action_by_name (browser, token_last)); |
591 | - GtkWidget* toolitem_second = gtk_action_create_tool_item ( |
592 | - _action_by_name (browser, token_current)); |
593 | - MidoriPanedAction* paned_action = MIDORI_PANED_ACTION ( |
594 | - _action_by_name (browser, "LocationSearch")); |
595 | - MidoriWebSettings* midori_settings = browser->settings; |
596 | - midori_paned_action_set_child1 (paned_action, toolitem_first, token_last, |
597 | - token_last == token_search ? FALSE : TRUE, TRUE); |
598 | - midori_paned_action_set_child2 (paned_action, toolitem_second, token_current, |
599 | - token_current == token_search ? FALSE : TRUE, TRUE); |
600 | - g_signal_connect (G_OBJECT (token_current == token_search ? toolitem_second : toolitem_first), |
601 | - "size-allocate", G_CALLBACK (_midori_browser_search_item_allocate_cb), (gpointer) browser); |
602 | - |
603 | - gtk_widget_set_size_request ( |
604 | - token_last == token_search ? toolitem_first : toolitem_second, |
605 | - katze_object_get_int ((gpointer) midori_settings, |
606 | - "search-width"), |
607 | - -1); |
608 | - |
609 | - toolitem = gtk_action_create_tool_item (GTK_ACTION (paned_action)); |
610 | - token_current = token_dontcare; |
611 | - } |
612 | - else if (token_current == token_dontcare && token_last != token_dontcare) |
613 | - { |
614 | - /* There was a location or search item, but was not followed by |
615 | - the other one, that form a couple */ |
616 | - gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar), |
617 | - GTK_TOOL_ITEM (gtk_action_create_tool_item ( |
618 | - _action_by_name (browser, token_last))), |
619 | - -1); |
620 | - |
621 | - toolitem = gtk_action_create_tool_item (action); |
622 | - } |
623 | - else if (token_current != token_dontcare && token_last == token_dontcare) |
624 | - continue; |
625 | - /* A "new tab" button is already part of the notebook */ |
626 | - else if (!strcmp (gtk_action_get_name (action), "TabNew")) |
627 | - continue; |
628 | - else |
629 | - toolitem = gtk_action_create_tool_item (action); |
630 | - |
631 | - if (gtk_bin_get_child (GTK_BIN (toolitem))) |
632 | - { |
633 | - if (!g_strcmp0 (*name, "Back")) |
634 | - g_object_set_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (toolitem))), |
635 | - "history-back", (void*) 0xdeadbeef); |
636 | - else if (g_str_has_suffix (*name, "Forward")) |
637 | - g_object_set_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (toolitem))), |
638 | - "history-forward", (void*) 0xdeadbeef); |
639 | - else if (g_strcmp0 (*name, "Reload")) |
640 | - g_object_set_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (toolitem))), |
641 | - "reload-middle-click", (void*) 0xdeadbeef); |
642 | - |
643 | - g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), |
644 | - "button-press-event", |
645 | - G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb), |
646 | - browser); |
647 | - } |
648 | - else |
649 | - { |
650 | - gtk_tool_item_set_use_drag_window (GTK_TOOL_ITEM (toolitem), TRUE); |
651 | - g_signal_connect (toolitem, |
652 | - "button-press-event", |
653 | - G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb), |
654 | - browser); |
655 | - } |
656 | - gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar), |
657 | - GTK_TOOL_ITEM (toolitem), -1); |
658 | - } |
659 | - } |
660 | - g_strfreev (names); |
661 | - |
662 | - /* There was a last item, which could have formed a couple, but |
663 | - there is no item left, we add that last item to toolbar as is */ |
664 | - if (token_current != token_dontcare) |
665 | - { |
666 | - gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar), |
667 | - GTK_TOOL_ITEM (gtk_action_create_tool_item ( |
668 | - _action_by_name (browser, token_current))), -1); |
669 | - } |
670 | - |
671 | - if (!katze_object_get_boolean (browser->settings, "show-menubar")) |
672 | - { |
673 | - toolitem = gtk_action_create_tool_item ( |
674 | - GTK_ACTION (_action_by_name (browser, "CompactMenu"))); |
675 | - gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar), |
676 | - GTK_TOOL_ITEM (toolitem), -1); |
677 | - g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), |
678 | - "button-press-event", |
679 | - G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb), |
680 | - browser); |
681 | - } |
682 | -} |
683 | - |
684 | static void |
685 | _midori_browser_update_settings (MidoriBrowser* browser) |
686 | { |
687 | @@ -6758,7 +6525,7 @@ |
688 | |
689 | _midori_browser_set_toolbar_style (browser, toolbar_style); |
690 | _toggle_tabbar_smartly (browser, FALSE); |
691 | - _midori_browser_set_toolbar_items (browser, toolbar_items); |
692 | + midori_window_set_actions (MIDORI_WINDOW (browser), toolbar_items); |
693 | |
694 | if (browser->search_engines) |
695 | { |
696 | @@ -6791,7 +6558,8 @@ |
697 | GINT_TO_POINTER (last_panel_page)); |
698 | |
699 | _action_set_active (browser, "Menubar", show_menubar); |
700 | - _action_set_active (browser, "Navigationbar", browser->show_navigationbar); |
701 | + if (GTK_IS_TOOLBAR (browser->navigationbar)) |
702 | + _action_set_active (browser, "Navigationbar", browser->show_navigationbar); |
703 | _action_set_active (browser, "Bookmarkbar", show_bookmarkbar |
704 | && browser->bookmarks != NULL); |
705 | _action_set_active (browser, "Panel", show_panel); |
706 | @@ -6815,7 +6583,7 @@ |
707 | if (name == g_intern_string ("toolbar-style")) |
708 | _midori_browser_set_toolbar_style (browser, g_value_get_enum (&value)); |
709 | else if (name == g_intern_string ("toolbar-items")) |
710 | - _midori_browser_set_toolbar_items (browser, g_value_get_string (&value)); |
711 | + midori_window_set_actions (MIDORI_WINDOW (browser), g_value_get_string (&value)); |
712 | else if (name == g_intern_string ("compact-sidepanel")) |
713 | { |
714 | g_signal_handlers_block_by_func (browser->panel, |
715 | @@ -6837,7 +6605,8 @@ |
716 | else if (name == g_intern_string ("show-navigationbar")) |
717 | { |
718 | browser->show_navigationbar = g_value_get_boolean (&value); |
719 | - _action_set_active (browser, "Navigationbar", g_value_get_boolean (&value)); |
720 | + if (GTK_IS_TOOLBAR (browser->navigationbar)) |
721 | + _action_set_active (browser, "Navigationbar", g_value_get_boolean (&value)); |
722 | } |
723 | else if (name == g_intern_string ("show-bookmarkbar")) |
724 | { |
725 | |
726 | === modified file 'midori/midori-browser.h' |
727 | --- midori/midori-browser.h 2013-03-26 23:09:09 +0000 |
728 | +++ midori/midori-browser.h 2015-06-06 12:33:01 +0000 |
729 | @@ -35,7 +35,7 @@ |
730 | |
731 | struct _MidoriBrowserClass |
732 | { |
733 | - GtkWindowClass parent_class; |
734 | + MidoriWindowClass parent_class; |
735 | |
736 | /* Signals */ |
737 | void |
738 | |
739 | === modified file 'midori/midori-contextaction.vala' |
740 | --- midori/midori-contextaction.vala 2014-03-29 21:28:08 +0000 |
741 | +++ midori/midori-contextaction.vala 2015-06-06 12:33:01 +0000 |
742 | @@ -92,6 +92,18 @@ |
743 | } |
744 | #endif |
745 | |
746 | + Gtk.ToolButton toolitem; |
747 | + public override unowned Gtk.Widget create_tool_item () { |
748 | + toolitem = base.create_tool_item () as Gtk.ToolButton; |
749 | + toolitem.clicked.connect (() => { |
750 | + var popup = create_menu (null, false); |
751 | + popup.show (); |
752 | + popup.attach_to_widget (toolitem, null); |
753 | + popup.popup (null, null, null, 1, Gtk.get_current_event_time ()); |
754 | + }); |
755 | + return toolitem; |
756 | + } |
757 | + |
758 | public new Gtk.Menu create_menu (Gtk.Menu? default_menu, bool accels) { |
759 | var menu = default_menu ?? new Gtk.Menu (); |
760 | foreach (var action in children) { |
761 | |
762 | === modified file 'midori/midori-frontend.c' |
763 | --- midori/midori-frontend.c 2015-03-23 11:33:24 +0000 |
764 | +++ midori/midori-frontend.c 2015-06-06 12:33:01 +0000 |
765 | @@ -74,11 +74,13 @@ |
766 | midori_browser_set_action_visible (browser, "CompactMenu", FALSE); |
767 | midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE); |
768 | midori_browser_set_action_visible (browser, "Navigationbar", FALSE); |
769 | + GtkActionGroup* action_group = midori_browser_get_action_group (browser); |
770 | + GtkAction* action = gtk_action_group_get_action (action_group, "Location"); |
771 | + gtk_action_set_sensitive (action, FALSE); |
772 | |
773 | MidoriWebSettings* settings = midori_settings_new_full (NULL); |
774 | g_object_set (settings, |
775 | "show-menubar", FALSE, |
776 | - "show-navigationbar", FALSE, |
777 | "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage,Preferences", |
778 | "show-statusbar", FALSE, |
779 | "show-panel", FALSE, |
780 | |
781 | === modified file 'midori/midori-panedaction.vala' |
782 | --- midori/midori-panedaction.vala 2014-11-05 20:56:37 +0000 |
783 | +++ midori/midori-panedaction.vala 2015-06-06 12:33:01 +0000 |
784 | @@ -16,6 +16,10 @@ |
785 | Child child1 = new Child(); |
786 | Child child2 = new Child(); |
787 | |
788 | + public PanedAction () { |
789 | + GLib.Object (name: "LocationSearch"); |
790 | + } |
791 | + |
792 | private struct Child { |
793 | public Gtk.Widget widget; |
794 | string name; |
795 | |
796 | === modified file 'midori/midori-preferences.c' |
797 | --- midori/midori-preferences.c 2015-03-23 11:33:24 +0000 |
798 | +++ midori/midori-preferences.c 2015-06-06 12:33:01 +0000 |
799 | @@ -415,6 +415,10 @@ |
800 | |
801 | /* Page "Interface" */ |
802 | PAGE_NEW (GTK_STOCK_CONVERT, _("Browsing")); |
803 | + gboolean has_toolbar = parent && MIDORI_IS_BROWSER (parent) && GTK_IS_TOOLBAR (katze_object_get_object (parent, "toolbar")); |
804 | + #ifndef G_OS_WIN32 |
805 | + if (has_toolbar) |
806 | + #endif |
807 | FRAME_NEW (NULL); |
808 | #ifdef G_OS_WIN32 |
809 | INDENTED_ADD (gtk_label_new (_("Theme:"))); |
810 | @@ -449,9 +453,12 @@ |
811 | } |
812 | g_free (theme_path); |
813 | #endif |
814 | + if (has_toolbar) |
815 | + { |
816 | INDENTED_ADD (gtk_label_new (_("Toolbar Style:"))); |
817 | button = katze_property_proxy (settings, "toolbar-style", NULL); |
818 | SPANNED_ADD (button); |
819 | + } |
820 | FRAME_NEW (NULL); |
821 | label = gtk_label_new (_("Open new pages in:")); |
822 | INDENTED_ADD (label); |
823 | |
824 | === added file 'midori/midori-window.vala' |
825 | --- midori/midori-window.vala 1970-01-01 00:00:00 +0000 |
826 | +++ midori/midori-window.vala 2015-06-06 12:33:01 +0000 |
827 | @@ -0,0 +1,239 @@ |
828 | +/* |
829 | + Copyright (C) 2015 Christian Dywan <christian@twotoasts.de> |
830 | + |
831 | + This library is free software; you can redistribute it and/or |
832 | + modify it under the terms of the GNU Lesser General Public |
833 | + License as published by the Free Software Foundation; either |
834 | + version 2.1 of the License, or (at your option) any later version. |
835 | + |
836 | + See the file COPYING for the full license text. |
837 | +*/ |
838 | + |
839 | +namespace Midori { |
840 | + public class Window : Gtk.Window { |
841 | + Gtk.Widget? _toolbar = null; |
842 | + public Gtk.Widget? toolbar { get { |
843 | + if (_toolbar == null) { |
844 | +#if HAVE_GTK3 |
845 | + if (strcmp (Environment.get_variable ("GTK_CSD"), "1") == 0) { |
846 | + var toolbar = new Gtk.HeaderBar (); |
847 | + toolbar.show_close_button = true; |
848 | + toolbar.show (); |
849 | + toolbar.get_style_context ().add_class ("midori-titlebar"); |
850 | + _toolbar = toolbar; |
851 | + return _toolbar; |
852 | + } |
853 | +#endif |
854 | + var toolbar = new Gtk.Toolbar (); |
855 | + toolbar.show_arrow = true; |
856 | +#if HAVE_GTK3 |
857 | + toolbar.get_style_context ().add_class ("primary-toolbar"); |
858 | + hide_titlebar_when_maximized = true; |
859 | +#endif |
860 | + toolbar.popup_context_menu.connect ((x, y, button) => { |
861 | + return button == 3 && context_menu (toolbar); }); |
862 | + _toolbar = toolbar; |
863 | + } |
864 | + return _toolbar; |
865 | + } } |
866 | + |
867 | + public string actions { get; set; default = ""; } |
868 | + string extra_actions { get; set; default = ""; } |
869 | + List<Gtk.ActionGroup> action_groups; |
870 | + public signal bool context_menu (Gtk.Widget widget, Gtk.Action? action=null); |
871 | + Gtk.Box? box = null; |
872 | + List<Gtk.Widget> toolbars; |
873 | + |
874 | + Gtk.Widget? _contents = null; |
875 | + public Gtk.Widget? contents { get { |
876 | + return _contents; |
877 | + } set { |
878 | + if (_contents != null) |
879 | + box.remove (_contents); |
880 | + _contents = value; |
881 | + _contents.show (); |
882 | + if (box != null) |
883 | + box.pack_end (_contents, true, true, 0); |
884 | + } } |
885 | + |
886 | + public void add_action_group (Gtk.ActionGroup action_group) { |
887 | + action_groups.append (action_group); |
888 | + } |
889 | + |
890 | + public bool show_menubar { get; set; default = false; } |
891 | + |
892 | + [CCode (type = "GtkWidget*")] |
893 | + public Window () { |
894 | + } |
895 | + |
896 | + Gtk.ToolItem? get_tool_item (string name) { |
897 | + /* Name is the empty string if actions has ,, or trailing , */ |
898 | + if (name == "") |
899 | + return null; |
900 | + /* Shown in the notebook, no need to include in the toolbar */ |
901 | + if (name == "TabNew") |
902 | + return null; |
903 | + foreach (var action_group in action_groups) { |
904 | + var action = action_group.get_action (name); |
905 | + if (action != null) { |
906 | + return create_tool_item (action); |
907 | + } |
908 | + } |
909 | + warning ("Action %s not known to Window", name); |
910 | + return null; |
911 | + } |
912 | + |
913 | + Gtk.ToolItem create_tool_item (Gtk.Action action) { |
914 | + var toolitem = action.create_tool_item () as Gtk.ToolItem; |
915 | + /* Show label if button has no icon of any kind */ |
916 | + if (action.icon_name == null && action.stock_id == null && action.gicon == null) |
917 | + toolitem.is_important = true; |
918 | + toolitem.get_child ().button_press_event.connect ((event) => { |
919 | + return event.button == 3 && context_menu (toolitem, action); }); |
920 | + if (name == "CompactMenu") |
921 | + bind_property ("show-menubar", toolitem, "visible"); |
922 | + return toolitem; |
923 | + } |
924 | + |
925 | + /** |
926 | + * Adds an action to the (browser) window. |
927 | + * Typically it will be displayed in the primary toolbar or headerbar. |
928 | + * |
929 | + * If @action is a ContextAction a menu will be displayed. |
930 | + * |
931 | + * Since: 0.6.0 |
932 | + **/ |
933 | + public void add_action (Gtk.Action action) { |
934 | + action_groups.nth_data (0).add_action (action); |
935 | + extra_actions += "," + action.name; |
936 | + update_toolbar (); |
937 | + } |
938 | + |
939 | + /** |
940 | + * Remove an action from the (browser) window. |
941 | + * |
942 | + * Since: 0.6.0 |
943 | + **/ |
944 | + public void remove_action (Gtk.Action action) { |
945 | + action_groups.nth_data (0).remove_action (action); |
946 | + extra_actions = extra_actions.replace ("," + action.name, ""); |
947 | + update_toolbar (); |
948 | + } |
949 | + |
950 | + void update_toolbar () { |
951 | + var container = _toolbar as Gtk.Container; |
952 | + foreach (var toolitem in container.get_children ()) |
953 | + container.remove (toolitem); |
954 | + |
955 | + string[] names = actions.replace ("CompactMenu", extra_actions + ",CompactMenu").split (","); |
956 | +#if HAVE_GTK3 |
957 | + if (_toolbar is Gtk.HeaderBar) { |
958 | + var headerbar = _toolbar as Gtk.HeaderBar; |
959 | + List<Gtk.ToolItem> tail = new List<Gtk.ToolItem> (); |
960 | + foreach (string name in names) { |
961 | + var toolitem = get_tool_item (name); |
962 | + if (toolitem == null) |
963 | + continue; |
964 | + var widget = toolitem.get_child (); |
965 | + if (widget is Gtk.Alignment) |
966 | + widget = (widget as Gtk.Bin).get_child (); |
967 | + if (name == "Location") { |
968 | + widget.set ("margin-top", 1, "margin-bottom", 1); |
969 | + (widget as Gtk.Entry).max_width_chars = 256; |
970 | + headerbar.custom_title = toolitem; |
971 | + headerbar.custom_title.set ( |
972 | + "margin-start", 25, "margin-end", 25, |
973 | + "margin-top", 5, "margin-bottom", 5); |
974 | + } else if (name == "Search") { |
975 | + (widget as Gtk.Entry).width_chars = 12; |
976 | + tail.append (toolitem); |
977 | + } else if (actions.index_of (name) > actions.index_of ("Location")) |
978 | + tail.append (toolitem); |
979 | + else if (name in extra_actions) |
980 | + tail.append (toolitem); |
981 | + else |
982 | + headerbar.pack_start (toolitem); |
983 | + } |
984 | + |
985 | + /* Pack end appends, so we need to pack in reverse order */ |
986 | + tail.reverse (); |
987 | + foreach (var toolitem in tail) |
988 | + headerbar.pack_end (toolitem); |
989 | + |
990 | + set_titlebar (headerbar); |
991 | + return; |
992 | + } |
993 | +#endif |
994 | + |
995 | + var toolbar = _toolbar as Gtk.Toolbar; |
996 | + string? previous = null; |
997 | + Gtk.ToolItem? toolitem_previous = null; |
998 | + foreach (string name in names) { |
999 | + var toolitem = get_tool_item (name); |
1000 | + if (toolitem == null) |
1001 | + continue; |
1002 | + if ((name == "Location" || name == "Search") |
1003 | + && (previous == "Location" || previous == "Search")) { |
1004 | + toolitem_previous.ref (); |
1005 | + toolbar.remove (toolitem_previous); |
1006 | + var paned = new Midori.PanedAction (); |
1007 | + paned.set_child1 (toolitem_previous, previous, previous != "Search", true); |
1008 | + paned.set_child2 (toolitem, name, name != "Search", true); |
1009 | + /* Midori.Settings.search-width on Midori.Browser.settings */ |
1010 | + Midori.Settings? settings = null; |
1011 | + get ("settings", ref settings); |
1012 | + var sizeable = name == "Search" ? toolitem : toolitem_previous; |
1013 | + sizeable.size_allocate.connect ((allocation) => { |
1014 | + settings.set ("search-width", allocation.width); |
1015 | + }); |
1016 | + var requester = previous == "Search" ? toolitem_previous : toolitem; |
1017 | + requester.set_size_request (settings.search_width, -1); |
1018 | + toolitem = paned.create_tool_item () as Gtk.ToolItem; |
1019 | + previous = null; |
1020 | + toolitem_previous.unref (); |
1021 | + toolitem_previous = null; |
1022 | + } else { |
1023 | + previous = name; |
1024 | + toolitem_previous = toolitem; |
1025 | + } |
1026 | + toolbar.insert (toolitem, -1); |
1027 | + } |
1028 | + } |
1029 | + |
1030 | + public void add_toolbar (Gtk.Widget toolbar) { |
1031 | + if (toolbar is Gtk.Toolbar) { |
1032 | +#if HAVE_GTK3 |
1033 | + get_style_context ().add_class ("secondary-toolbar"); |
1034 | +#endif |
1035 | + (toolbar as Gtk.Toolbar).popup_context_menu.connect ((x, y, button) => { |
1036 | + return button == 3 && context_menu (toolbar); |
1037 | + }); |
1038 | + } |
1039 | + if (box == null) |
1040 | + toolbars.append (toolbar); |
1041 | + else |
1042 | + box.pack_start (toolbar, false, false); |
1043 | + } |
1044 | + |
1045 | + construct { |
1046 | + box = new Gtk.VBox (false, 0); |
1047 | + box.show (); |
1048 | + add (box); |
1049 | + foreach (var toolbar in toolbars) { |
1050 | + if (toolbar is Gtk.MenuBar) |
1051 | + box.pack_start (toolbar, false, false); |
1052 | + } |
1053 | + if (toolbar is Gtk.Toolbar) |
1054 | + box.pack_start (toolbar, false, false); |
1055 | + foreach (var toolbar in toolbars) { |
1056 | + if (!(toolbar is Gtk.MenuBar)) |
1057 | + box.pack_start (toolbar, false, false); |
1058 | + } |
1059 | + if (_contents != null) |
1060 | + box.pack_end (_contents, true, true, 0); |
1061 | + if (actions != "") |
1062 | + update_toolbar (); |
1063 | + notify["actions"].connect ((pspec) => { update_toolbar (); }); |
1064 | + } |
1065 | + } |
1066 | +} |
1067 | |
1068 | === modified file 'midori/midori.vapi' |
1069 | --- midori/midori.vapi 2015-03-15 17:20:46 +0000 |
1070 | +++ midori/midori.vapi 2015-06-06 12:33:01 +0000 |
1071 | @@ -62,7 +62,7 @@ |
1072 | } |
1073 | |
1074 | [CCode (cheader_filename = "midori/midori-browser.h")] |
1075 | - public class Browser : Gtk.Window { |
1076 | + public class Browser : Window { |
1077 | public Browser (); |
1078 | public unowned Gtk.Widget add_item (Katze.Item item); |
1079 | public unowned Gtk.Widget add_uri (string uri); |
1080 | |
1081 | === modified file 'po/POTFILES.in' |
1082 | --- po/POTFILES.in 2015-04-18 19:36:29 +0000 |
1083 | +++ po/POTFILES.in 2015-06-06 12:33:01 +0000 |
1084 | @@ -7,6 +7,7 @@ |
1085 | midori/midori-array.c |
1086 | midori/midori-bookmarksdatabase.vala |
1087 | midori/midori-browser.c |
1088 | +midori/midori-window.vala |
1089 | midori/midori-database.vala |
1090 | midori/midori-extension.c |
1091 | midori/midori-locationaction.c |
Packing the urlbar into the title are looks weird and means autocompletion results just aren't legible. I think it would make more sense to just pack it left and expand like you'd do in a regular toolbar.
Since the "Toolbar Editor" extension exposes itself through right clicking on the toolbar, there's now no way to use this extension. It should probably get a little settings icon like other extensions with settings have