Merge lp:~midori/midori/redundantNewTab into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6584
Merged at revision: 6584
Proposed branch: lp:~midori/midori/redundantNewTab
Merge into: lp:midori
Diff against target: 203 lines (+58/-60)
5 files modified
extensions/tab-panel.c (+10/-17)
extensions/toolbar-editor.c (+0/-4)
midori/midori-browser.c (+0/-1)
midori/midori-notebook.vala (+43/-37)
midori/midori-view.c (+5/-1)
To merge this branch: bzr merge lp:~midori/midori/redundantNewTab
Reviewer Review Type Date Requested Status
axlrose112 midori_context_action_add Approve
Paweł Forysiuk Approve
Review via email: mp+209133@code.launchpad.net

Commit message

Drop redundant TabNew from compact menu and put button in Tab Panel

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) wrote :

Code looks sensible and it seems to work ok.

review: Approve
Revision history for this message
axlrose112 (axlrose112) wrote :

i sill get a message CRITICAL **: midori_context_action_add: assertion 'self != NULL' failed

my code is:

void browser_added (Midori.Browser browser) {
    var action_group = browser.get_action_group ();
    var action = action_group.get_action ("CompactMenu") as Midori.ContextAction;
    var action1 = new Gtk.Action ("NotesCopySnippet", "Copy _snippet to notes", null, null);
    action.add(action1);
}

review: Approve (midori_context_action_add)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/tab-panel.c'
--- extensions/tab-panel.c 2013-06-21 23:18:01 +0000
+++ extensions/tab-panel.c 2014-03-03 23:41:19 +0000
@@ -289,20 +289,6 @@
289}289}
290290
291static void291static void
292tab_panel_toggle_toolbook (GtkWidget* toolbar)
293{
294 /* Hack to ensure correct toolbar visibility */
295 GtkWidget* toolbook = gtk_widget_get_parent (toolbar);
296 if (gtk_notebook_get_current_page (GTK_NOTEBOOK (toolbook))
297 == gtk_notebook_page_num (GTK_NOTEBOOK (toolbook), toolbar))
298 {
299 GList* items = gtk_container_get_children (GTK_CONTAINER (toolbar));
300 sokoke_widget_set_visible (toolbook, items != NULL);
301 g_list_free (items);
302 }
303}
304
305static void
306tab_panel_remove_view (MidoriBrowser* browser,292tab_panel_remove_view (MidoriBrowser* browser,
307 GtkWidget* view,293 GtkWidget* view,
308 gboolean minimized)294 gboolean minimized)
@@ -310,9 +296,7 @@
310 if (minimized)296 if (minimized)
311 {297 {
312 GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);298 GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
313 GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
314 gtk_widget_destroy (GTK_WIDGET (toolitem));299 gtk_widget_destroy (GTK_WIDGET (toolitem));
315 tab_panel_toggle_toolbook (toolbar);
316 }300 }
317 else301 else
318 {302 {
@@ -443,7 +427,6 @@
443 g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);427 g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
444 gtk_widget_show (GTK_WIDGET (toolitem));428 gtk_widget_show (GTK_WIDGET (toolitem));
445 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);429 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
446 tab_panel_toggle_toolbook (toolbar);
447 g_signal_connect (toolitem, "clicked",430 g_signal_connect (toolitem, "clicked",
448 G_CALLBACK (tab_panel_toolitem_clicked_cb), view);431 G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
449 g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",432 g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
@@ -574,6 +557,16 @@
574557
575 toolbar = gtk_toolbar_new ();558 toolbar = gtk_toolbar_new ();
576 g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);559 g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
560 gtk_widget_show (toolbar);
561
562 GtkActionGroup* actions = midori_browser_get_action_group (browser);
563 GtkAction* action = gtk_action_group_get_action (actions, "TabNew");
564 GtkWidget* toolitem = gtk_action_create_tool_item (action);
565 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
566
567 action = gtk_action_group_get_action (actions, "Separator");
568 toolitem = gtk_action_create_tool_item (action);
569 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
577570
578 /*571 /*
579 TODO: Implement optional thumbnail images572 TODO: Implement optional thumbnail images
580573
=== modified file 'extensions/toolbar-editor.c'
--- extensions/toolbar-editor.c 2013-06-02 02:20:41 +0000
+++ extensions/toolbar-editor.c 2014-03-03 23:41:19 +0000
@@ -112,12 +112,8 @@
112 name = items;112 name = items;
113 while (*name != NULL)113 while (*name != NULL)
114 {114 {
115 #ifdef HAVE_GRANITE
116 /* A "new tab" button is already part of the notebook */115 /* A "new tab" button is already part of the notebook */
117 if (*name[0] != '\0' && strcmp (*name, "TabNew"))116 if (*name[0] != '\0' && strcmp (*name, "TabNew"))
118 #else
119 if (*name[0] != '\0')
120 #endif
121 list = g_slist_append(list, g_strdup(*name));117 list = g_slist_append(list, g_strdup(*name));
122 name++;118 name++;
123 }119 }
124120
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2014-03-02 20:30:34 +0000
+++ midori/midori-browser.c 2014-03-03 23:41:19 +0000
@@ -3226,7 +3226,6 @@
3226{3226{
3227 MidoriContextAction* menu = midori_context_action_new ("CompactMenu", NULL, NULL, NULL);3227 MidoriContextAction* menu = midori_context_action_new ("CompactMenu", NULL, NULL, NULL);
3228 midori_context_action_add_action_group (menu, browser->action_group);3228 midori_context_action_add_action_group (menu, browser->action_group);
3229 midori_context_action_add_by_name (menu, "TabNew");
3230 midori_context_action_add_by_name (menu, "WindowNew");3229 midori_context_action_add_by_name (menu, "WindowNew");
3231 midori_context_action_add_by_name (menu, "PrivateBrowsing");3230 midori_context_action_add_by_name (menu, "PrivateBrowsing");
3232 midori_context_action_add (menu, NULL);3231 midori_context_action_add (menu, NULL);
32333232
=== modified file 'midori/midori-notebook.vala'
--- midori/midori-notebook.vala 2013-12-05 00:24:34 +0000
+++ midori/midori-notebook.vala 2014-03-03 23:41:19 +0000
@@ -335,6 +335,48 @@
335 resize (size.width);335 resize (size.width);
336 }336 }
337337
338 /* Since: 0.5.8 */
339 public ContextAction get_tab_context_action (Midori.Tab tab) {
340 var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);
341 tab_context_menu (tab, menu);
342 var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
343 action_window.activate.connect (()=>{
344 tab_detached (tab, 128, 128);
345 });
346 menu.add (action_window);
347 var action_minimize = new Midori.ContextAction ("TabMinimize", tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
348 action_minimize.activate.connect (()=>{
349 tab.minimized = !tab.minimized;
350 });
351 menu.add (action_minimize);
352 var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
353 action_right.sensitive = count > 1;
354 action_right.activate.connect (()=>{
355 bool found_tab = false;
356 foreach (var child in notebook.get_children ()) {
357 if (found_tab)
358 child.destroy ();
359 else
360 found_tab = child == tab;
361 }
362 });
363 menu.add (action_right);
364 var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
365 action_other.sensitive = count > 1;
366 action_other.activate.connect (()=>{
367 foreach (var child in notebook.get_children ())
368 if (child != tab)
369 child.destroy ();
370 });
371 menu.add (action_other);
372 var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
373 action_close.activate.connect (()=>{
374 tab.destroy ();
375 });
376 menu.add (action_close);
377 return menu;
378 }
379
338 bool tab_button_pressed (Gtk.Widget label, Gdk.EventButton event) {380 bool tab_button_pressed (Gtk.Widget label, Gdk.EventButton event) {
339 Tally tally = label as Tally;381 Tally tally = label as Tally;
340 if (event.button == 1) {382 if (event.button == 1) {
@@ -343,43 +385,7 @@
343 } else if (event.button == 2)385 } else if (event.button == 2)
344 tally.tab.destroy ();386 tally.tab.destroy ();
345 else if (event.button == 3) {387 else if (event.button == 3) {
346 var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);388 var menu = get_tab_context_action (tally.tab);
347 tab_context_menu (tally.tab, menu);
348 var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
349 action_window.activate.connect (()=>{
350 tab_detached (tally.tab, 128, 128);
351 });
352 menu.add (action_window);
353 var action_minimize = new Midori.ContextAction ("TabMinimize", tally.tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
354 action_minimize.activate.connect (()=>{
355 tally.tab.minimized = !tally.tab.minimized;
356 });
357 menu.add (action_minimize);
358 var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
359 action_right.sensitive = count > 1;
360 action_right.activate.connect (()=>{
361 bool found_tab = false;
362 foreach (var child in notebook.get_children ()) {
363 if (found_tab)
364 child.destroy ();
365 else
366 found_tab = child == tally.tab;
367 }
368 });
369 menu.add (action_right);
370 var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
371 action_other.sensitive = count > 1;
372 action_other.activate.connect (()=>{
373 foreach (var child in notebook.get_children ())
374 if (child != tally.tab)
375 child.destroy ();
376 });
377 menu.add (action_other);
378 var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
379 action_close.activate.connect (()=>{
380 tally.tab.destroy ();
381 });
382 menu.add (action_close);
383 var popup = menu.create_menu (null, false);389 var popup = menu.create_menu (null, false);
384 popup.show ();390 popup.show ();
385 popup.attach_to_widget (this, null);391 popup.attach_to_widget (this, null);
386392
=== modified file 'midori/midori-view.c'
--- midori/midori-view.c 2014-02-22 22:35:42 +0000
+++ midori/midori-view.c 2014-03-03 23:41:19 +0000
@@ -4295,7 +4295,11 @@
4295{4295{
4296 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);4296 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
42974297
4298 return gtk_menu_new ();4298 GtkWidget* notebook = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (view)));
4299 MidoriContextAction* context_action = midori_notebook_get_tab_context_action (MIDORI_NOTEBOOK (notebook), MIDORI_TAB (view));
4300 GtkMenu* menu = midori_context_action_create_menu (context_action, NULL, FALSE);
4301 g_object_unref (context_action);
4302 return GTK_WIDGET (menu);
4299}4303}
43004304
4301/**4305/**

Subscribers

People subscribed via source and target branches

to all changes: