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
1=== modified file 'extensions/tab-panel.c'
2--- extensions/tab-panel.c 2013-06-21 23:18:01 +0000
3+++ extensions/tab-panel.c 2014-03-03 23:41:19 +0000
4@@ -289,20 +289,6 @@
5 }
6
7 static void
8-tab_panel_toggle_toolbook (GtkWidget* toolbar)
9-{
10- /* Hack to ensure correct toolbar visibility */
11- GtkWidget* toolbook = gtk_widget_get_parent (toolbar);
12- if (gtk_notebook_get_current_page (GTK_NOTEBOOK (toolbook))
13- == gtk_notebook_page_num (GTK_NOTEBOOK (toolbook), toolbar))
14- {
15- GList* items = gtk_container_get_children (GTK_CONTAINER (toolbar));
16- sokoke_widget_set_visible (toolbook, items != NULL);
17- g_list_free (items);
18- }
19-}
20-
21-static void
22 tab_panel_remove_view (MidoriBrowser* browser,
23 GtkWidget* view,
24 gboolean minimized)
25@@ -310,9 +296,7 @@
26 if (minimized)
27 {
28 GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
29- GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
30 gtk_widget_destroy (GTK_WIDGET (toolitem));
31- tab_panel_toggle_toolbook (toolbar);
32 }
33 else
34 {
35@@ -443,7 +427,6 @@
36 g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
37 gtk_widget_show (GTK_WIDGET (toolitem));
38 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
39- tab_panel_toggle_toolbook (toolbar);
40 g_signal_connect (toolitem, "clicked",
41 G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
42 g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
43@@ -574,6 +557,16 @@
44
45 toolbar = gtk_toolbar_new ();
46 g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
47+ gtk_widget_show (toolbar);
48+
49+ GtkActionGroup* actions = midori_browser_get_action_group (browser);
50+ GtkAction* action = gtk_action_group_get_action (actions, "TabNew");
51+ GtkWidget* toolitem = gtk_action_create_tool_item (action);
52+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
53+
54+ action = gtk_action_group_get_action (actions, "Separator");
55+ toolitem = gtk_action_create_tool_item (action);
56+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
57
58 /*
59 TODO: Implement optional thumbnail images
60
61=== modified file 'extensions/toolbar-editor.c'
62--- extensions/toolbar-editor.c 2013-06-02 02:20:41 +0000
63+++ extensions/toolbar-editor.c 2014-03-03 23:41:19 +0000
64@@ -112,12 +112,8 @@
65 name = items;
66 while (*name != NULL)
67 {
68- #ifdef HAVE_GRANITE
69 /* A "new tab" button is already part of the notebook */
70 if (*name[0] != '\0' && strcmp (*name, "TabNew"))
71- #else
72- if (*name[0] != '\0')
73- #endif
74 list = g_slist_append(list, g_strdup(*name));
75 name++;
76 }
77
78=== modified file 'midori/midori-browser.c'
79--- midori/midori-browser.c 2014-03-02 20:30:34 +0000
80+++ midori/midori-browser.c 2014-03-03 23:41:19 +0000
81@@ -3226,7 +3226,6 @@
82 {
83 MidoriContextAction* menu = midori_context_action_new ("CompactMenu", NULL, NULL, NULL);
84 midori_context_action_add_action_group (menu, browser->action_group);
85- midori_context_action_add_by_name (menu, "TabNew");
86 midori_context_action_add_by_name (menu, "WindowNew");
87 midori_context_action_add_by_name (menu, "PrivateBrowsing");
88 midori_context_action_add (menu, NULL);
89
90=== modified file 'midori/midori-notebook.vala'
91--- midori/midori-notebook.vala 2013-12-05 00:24:34 +0000
92+++ midori/midori-notebook.vala 2014-03-03 23:41:19 +0000
93@@ -335,6 +335,48 @@
94 resize (size.width);
95 }
96
97+ /* Since: 0.5.8 */
98+ public ContextAction get_tab_context_action (Midori.Tab tab) {
99+ var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);
100+ tab_context_menu (tab, menu);
101+ var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
102+ action_window.activate.connect (()=>{
103+ tab_detached (tab, 128, 128);
104+ });
105+ menu.add (action_window);
106+ var action_minimize = new Midori.ContextAction ("TabMinimize", tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
107+ action_minimize.activate.connect (()=>{
108+ tab.minimized = !tab.minimized;
109+ });
110+ menu.add (action_minimize);
111+ var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
112+ action_right.sensitive = count > 1;
113+ action_right.activate.connect (()=>{
114+ bool found_tab = false;
115+ foreach (var child in notebook.get_children ()) {
116+ if (found_tab)
117+ child.destroy ();
118+ else
119+ found_tab = child == tab;
120+ }
121+ });
122+ menu.add (action_right);
123+ var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
124+ action_other.sensitive = count > 1;
125+ action_other.activate.connect (()=>{
126+ foreach (var child in notebook.get_children ())
127+ if (child != tab)
128+ child.destroy ();
129+ });
130+ menu.add (action_other);
131+ var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
132+ action_close.activate.connect (()=>{
133+ tab.destroy ();
134+ });
135+ menu.add (action_close);
136+ return menu;
137+ }
138+
139 bool tab_button_pressed (Gtk.Widget label, Gdk.EventButton event) {
140 Tally tally = label as Tally;
141 if (event.button == 1) {
142@@ -343,43 +385,7 @@
143 } else if (event.button == 2)
144 tally.tab.destroy ();
145 else if (event.button == 3) {
146- var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);
147- tab_context_menu (tally.tab, menu);
148- var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
149- action_window.activate.connect (()=>{
150- tab_detached (tally.tab, 128, 128);
151- });
152- menu.add (action_window);
153- var action_minimize = new Midori.ContextAction ("TabMinimize", tally.tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
154- action_minimize.activate.connect (()=>{
155- tally.tab.minimized = !tally.tab.minimized;
156- });
157- menu.add (action_minimize);
158- var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
159- action_right.sensitive = count > 1;
160- action_right.activate.connect (()=>{
161- bool found_tab = false;
162- foreach (var child in notebook.get_children ()) {
163- if (found_tab)
164- child.destroy ();
165- else
166- found_tab = child == tally.tab;
167- }
168- });
169- menu.add (action_right);
170- var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
171- action_other.sensitive = count > 1;
172- action_other.activate.connect (()=>{
173- foreach (var child in notebook.get_children ())
174- if (child != tally.tab)
175- child.destroy ();
176- });
177- menu.add (action_other);
178- var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
179- action_close.activate.connect (()=>{
180- tally.tab.destroy ();
181- });
182- menu.add (action_close);
183+ var menu = get_tab_context_action (tally.tab);
184 var popup = menu.create_menu (null, false);
185 popup.show ();
186 popup.attach_to_widget (this, null);
187
188=== modified file 'midori/midori-view.c'
189--- midori/midori-view.c 2014-02-22 22:35:42 +0000
190+++ midori/midori-view.c 2014-03-03 23:41:19 +0000
191@@ -4295,7 +4295,11 @@
192 {
193 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
194
195- return gtk_menu_new ();
196+ GtkWidget* notebook = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (view)));
197+ MidoriContextAction* context_action = midori_notebook_get_tab_context_action (MIDORI_NOTEBOOK (notebook), MIDORI_TAB (view));
198+ GtkMenu* menu = midori_context_action_create_menu (context_action, NULL, FALSE);
199+ g_object_unref (context_action);
200+ return GTK_WIDGET (menu);
201 }
202
203 /**

Subscribers

People subscribed via source and target branches

to all changes: