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
1=== modified file 'midori/midori-window.vala'
2--- midori/midori-window.vala 2015-06-06 12:20:44 +0000
3+++ midori/midori-window.vala 2015-06-11 22:57:19 +0000
4@@ -73,7 +73,7 @@
5 /* Shown in the notebook, no need to include in the toolbar */
6 if (name == "TabNew")
7 return null;
8- foreach (var action_group in action_groups) {
9+ foreach (unowned Gtk.ActionGroup action_group in action_groups) {
10 var action = action_group.get_action (name);
11 if (action != null) {
12 return create_tool_item (action);
13@@ -84,7 +84,7 @@
14 }
15
16 Gtk.ToolItem create_tool_item (Gtk.Action action) {
17- var toolitem = action.create_tool_item () as Gtk.ToolItem;
18+ var toolitem = (Gtk.ToolItem)action.create_tool_item ();
19 /* Show label if button has no icon of any kind */
20 if (action.icon_name == null && action.stock_id == null && action.gicon == null)
21 toolitem.is_important = true;
22@@ -121,31 +121,31 @@
23 }
24
25 void update_toolbar () {
26- var container = _toolbar as Gtk.Container;
27- foreach (var toolitem in container.get_children ())
28+ var container = (Gtk.Container)_toolbar;
29+ foreach (unowned Gtk.Widget toolitem in container.get_children ())
30 container.remove (toolitem);
31
32 string[] names = actions.replace ("CompactMenu", extra_actions + ",CompactMenu").split (",");
33 #if HAVE_GTK3
34- if (_toolbar is Gtk.HeaderBar) {
35- var headerbar = _toolbar as Gtk.HeaderBar;
36- List<Gtk.ToolItem> tail = new List<Gtk.ToolItem> ();
37- foreach (string name in names) {
38+ var headerbar = _toolbar as Gtk.HeaderBar;
39+ if (headerbar != null) {
40+ var tail = new List<Gtk.ToolItem> ();
41+ foreach (unowned string name in names) {
42 var toolitem = get_tool_item (name);
43 if (toolitem == null)
44 continue;
45 var widget = toolitem.get_child ();
46 if (widget is Gtk.Alignment)
47- widget = (widget as Gtk.Bin).get_child ();
48+ widget = ((Gtk.Bin)widget).get_child ();
49 if (name == "Location") {
50 widget.set ("margin-top", 1, "margin-bottom", 1);
51- (widget as Gtk.Entry).max_width_chars = 256;
52+ ((Gtk.Entry)widget).max_width_chars = 256;
53 headerbar.custom_title = toolitem;
54 headerbar.custom_title.set (
55 "margin-start", 25, "margin-end", 25,
56 "margin-top", 5, "margin-bottom", 5);
57 } else if (name == "Search") {
58- (widget as Gtk.Entry).width_chars = 12;
59+ ((Gtk.Entry)widget).width_chars = 12;
60 tail.append (toolitem);
61 } else if (actions.index_of (name) > actions.index_of ("Location"))
62 tail.append (toolitem);
63@@ -157,7 +157,7 @@
64
65 /* Pack end appends, so we need to pack in reverse order */
66 tail.reverse ();
67- foreach (var toolitem in tail)
68+ foreach (unowned Gtk.ToolItem toolitem in tail)
69 headerbar.pack_end (toolitem);
70
71 set_titlebar (headerbar);
72@@ -188,7 +188,7 @@
73 });
74 var requester = previous == "Search" ? toolitem_previous : toolitem;
75 requester.set_size_request (settings.search_width, -1);
76- toolitem = paned.create_tool_item () as Gtk.ToolItem;
77+ toolitem = (Gtk.ToolItem)paned.create_tool_item ();
78 previous = null;
79 toolitem_previous.unref ();
80 toolitem_previous = null;
81@@ -201,11 +201,12 @@
82 }
83
84 public void add_toolbar (Gtk.Widget toolbar) {
85- if (toolbar is Gtk.Toolbar) {
86+ var _toolbar = (Gtk.Toolbar)toolbar;
87+ if (_toolbar != null) {
88 #if HAVE_GTK3
89 get_style_context ().add_class ("secondary-toolbar");
90 #endif
91- (toolbar as Gtk.Toolbar).popup_context_menu.connect ((x, y, button) => {
92+ _toolbar.popup_context_menu.connect ((x, y, button) => {
93 return button == 3 && context_menu (toolbar);
94 });
95 }
96@@ -219,13 +220,13 @@
97 box = new Gtk.VBox (false, 0);
98 box.show ();
99 add (box);
100- foreach (var toolbar in toolbars) {
101+ foreach (unowned Gtk.Widget toolbar in toolbars) {
102 if (toolbar is Gtk.MenuBar)
103 box.pack_start (toolbar, false, false);
104 }
105 if (toolbar is Gtk.Toolbar)
106 box.pack_start (toolbar, false, false);
107- foreach (var toolbar in toolbars) {
108+ foreach (unowned Gtk.Widget toolbar in toolbars) {
109 if (!(toolbar is Gtk.MenuBar))
110 box.pack_start (toolbar, false, false);
111 }

Subscribers

People subscribed via source and target branches

to all changes: