Merge lp:~midori/midori/unownedMidoriWindow into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6964
Merged at revision: 6969
Proposed branch: lp:~midori/midori/unownedMidoriWindow
Merge into: lp:midori
Diff against target: 111 lines (+18/-17)
1 file modified
midori/midori-window.vala (+18/-17)
To merge this branch: bzr merge lp:~midori/midori/unownedMidoriWindow
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+261792@code.launchpad.net

Commit message

Use unowned in foreach loops in Midori.Window

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'midori/midori-window.vala'
--- midori/midori-window.vala 2015-06-06 12:20:44 +0000
+++ midori/midori-window.vala 2015-06-11 22:57:19 +0000
@@ -73,7 +73,7 @@
73 /* Shown in the notebook, no need to include in the toolbar */73 /* Shown in the notebook, no need to include in the toolbar */
74 if (name == "TabNew")74 if (name == "TabNew")
75 return null;75 return null;
76 foreach (var action_group in action_groups) {76 foreach (unowned Gtk.ActionGroup action_group in action_groups) {
77 var action = action_group.get_action (name);77 var action = action_group.get_action (name);
78 if (action != null) {78 if (action != null) {
79 return create_tool_item (action);79 return create_tool_item (action);
@@ -84,7 +84,7 @@
84 }84 }
8585
86 Gtk.ToolItem create_tool_item (Gtk.Action action) {86 Gtk.ToolItem create_tool_item (Gtk.Action action) {
87 var toolitem = action.create_tool_item () as Gtk.ToolItem;87 var toolitem = (Gtk.ToolItem)action.create_tool_item ();
88 /* Show label if button has no icon of any kind */88 /* Show label if button has no icon of any kind */
89 if (action.icon_name == null && action.stock_id == null && action.gicon == null)89 if (action.icon_name == null && action.stock_id == null && action.gicon == null)
90 toolitem.is_important = true;90 toolitem.is_important = true;
@@ -121,31 +121,31 @@
121 }121 }
122122
123 void update_toolbar () {123 void update_toolbar () {
124 var container = _toolbar as Gtk.Container;124 var container = (Gtk.Container)_toolbar;
125 foreach (var toolitem in container.get_children ())125 foreach (unowned Gtk.Widget toolitem in container.get_children ())
126 container.remove (toolitem);126 container.remove (toolitem);
127127
128 string[] names = actions.replace ("CompactMenu", extra_actions + ",CompactMenu").split (",");128 string[] names = actions.replace ("CompactMenu", extra_actions + ",CompactMenu").split (",");
129#if HAVE_GTK3129#if HAVE_GTK3
130 if (_toolbar is Gtk.HeaderBar) {130 var headerbar = _toolbar as Gtk.HeaderBar;
131 var headerbar = _toolbar as Gtk.HeaderBar;131 if (headerbar != null) {
132 List<Gtk.ToolItem> tail = new List<Gtk.ToolItem> ();132 var tail = new List<Gtk.ToolItem> ();
133 foreach (string name in names) {133 foreach (unowned string name in names) {
134 var toolitem = get_tool_item (name);134 var toolitem = get_tool_item (name);
135 if (toolitem == null)135 if (toolitem == null)
136 continue;136 continue;
137 var widget = toolitem.get_child ();137 var widget = toolitem.get_child ();
138 if (widget is Gtk.Alignment)138 if (widget is Gtk.Alignment)
139 widget = (widget as Gtk.Bin).get_child ();139 widget = ((Gtk.Bin)widget).get_child ();
140 if (name == "Location") {140 if (name == "Location") {
141 widget.set ("margin-top", 1, "margin-bottom", 1);141 widget.set ("margin-top", 1, "margin-bottom", 1);
142 (widget as Gtk.Entry).max_width_chars = 256;142 ((Gtk.Entry)widget).max_width_chars = 256;
143 headerbar.custom_title = toolitem;143 headerbar.custom_title = toolitem;
144 headerbar.custom_title.set (144 headerbar.custom_title.set (
145 "margin-start", 25, "margin-end", 25,145 "margin-start", 25, "margin-end", 25,
146 "margin-top", 5, "margin-bottom", 5);146 "margin-top", 5, "margin-bottom", 5);
147 } else if (name == "Search") {147 } else if (name == "Search") {
148 (widget as Gtk.Entry).width_chars = 12;148 ((Gtk.Entry)widget).width_chars = 12;
149 tail.append (toolitem);149 tail.append (toolitem);
150 } else if (actions.index_of (name) > actions.index_of ("Location"))150 } else if (actions.index_of (name) > actions.index_of ("Location"))
151 tail.append (toolitem);151 tail.append (toolitem);
@@ -157,7 +157,7 @@
157157
158 /* Pack end appends, so we need to pack in reverse order */158 /* Pack end appends, so we need to pack in reverse order */
159 tail.reverse ();159 tail.reverse ();
160 foreach (var toolitem in tail)160 foreach (unowned Gtk.ToolItem toolitem in tail)
161 headerbar.pack_end (toolitem);161 headerbar.pack_end (toolitem);
162162
163 set_titlebar (headerbar);163 set_titlebar (headerbar);
@@ -188,7 +188,7 @@
188 });188 });
189 var requester = previous == "Search" ? toolitem_previous : toolitem;189 var requester = previous == "Search" ? toolitem_previous : toolitem;
190 requester.set_size_request (settings.search_width, -1);190 requester.set_size_request (settings.search_width, -1);
191 toolitem = paned.create_tool_item () as Gtk.ToolItem;191 toolitem = (Gtk.ToolItem)paned.create_tool_item ();
192 previous = null;192 previous = null;
193 toolitem_previous.unref ();193 toolitem_previous.unref ();
194 toolitem_previous = null;194 toolitem_previous = null;
@@ -201,11 +201,12 @@
201 }201 }
202202
203 public void add_toolbar (Gtk.Widget toolbar) {203 public void add_toolbar (Gtk.Widget toolbar) {
204 if (toolbar is Gtk.Toolbar) {204 var _toolbar = (Gtk.Toolbar)toolbar;
205 if (_toolbar != null) {
205#if HAVE_GTK3206#if HAVE_GTK3
206 get_style_context ().add_class ("secondary-toolbar");207 get_style_context ().add_class ("secondary-toolbar");
207#endif208#endif
208 (toolbar as Gtk.Toolbar).popup_context_menu.connect ((x, y, button) => {209 _toolbar.popup_context_menu.connect ((x, y, button) => {
209 return button == 3 && context_menu (toolbar);210 return button == 3 && context_menu (toolbar);
210 });211 });
211 }212 }
@@ -219,13 +220,13 @@
219 box = new Gtk.VBox (false, 0);220 box = new Gtk.VBox (false, 0);
220 box.show ();221 box.show ();
221 add (box);222 add (box);
222 foreach (var toolbar in toolbars) {223 foreach (unowned Gtk.Widget toolbar in toolbars) {
223 if (toolbar is Gtk.MenuBar)224 if (toolbar is Gtk.MenuBar)
224 box.pack_start (toolbar, false, false);225 box.pack_start (toolbar, false, false);
225 }226 }
226 if (toolbar is Gtk.Toolbar)227 if (toolbar is Gtk.Toolbar)
227 box.pack_start (toolbar, false, false);228 box.pack_start (toolbar, false, false);
228 foreach (var toolbar in toolbars) {229 foreach (unowned Gtk.Widget toolbar in toolbars) {
229 if (!(toolbar is Gtk.MenuBar))230 if (!(toolbar is Gtk.MenuBar))
230 box.pack_start (toolbar, false, false);231 box.pack_start (toolbar, false, false);
231 }232 }

Subscribers

People subscribed via source and target branches

to all changes: