Merge lp:~parnold-x/wingpanel-indicator-ayatana/fix_1613426 into lp:~wingpanel-devs/wingpanel-indicator-ayatana/trunk

Proposed by Djax on 2016-08-17
Status: Merged
Approved by: Cody Garver on 2016-08-18
Approved revision: 18
Merged at revision: 18
Proposed branch: lp:~parnold-x/wingpanel-indicator-ayatana/fix_1613426
Merge into: lp:~wingpanel-devs/wingpanel-indicator-ayatana/trunk
Diff against target: 162 lines (+73/-46)
1 file modified
src/AyatanaIndicator.vala (+73/-46)
To merge this branch: bzr merge lp:~parnold-x/wingpanel-indicator-ayatana/fix_1613426
Reviewer Review Type Date Requested Status
WingPanel Devs 2016-08-17 Pending
Review via email: mp+303199@code.launchpad.net

Commit message

connect widget signals

Description of the change

connect widget signals so state changes will be reflected right.

To post a comment you must log in.
18. By Djax on 2016-08-18

connect widget signals

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/AyatanaIndicator.vala'
2--- src/AyatanaIndicator.vala 2016-07-19 20:19:54 +0000
3+++ src/AyatanaIndicator.vala 2016-08-18 21:30:09 +0000
4@@ -166,7 +166,13 @@
5 if (w != null) {
6 menu_map.set (item, w);
7 main_grid.attach (w, 0, position++, 1, 1);
8- w.show ();
9+ /* menuitem not visible */
10+ if (!item.get_visible ()) {
11+ w.no_show_all = true;
12+ w.hide ();
13+ } else {
14+ w.show ();
15+ }
16 }
17 }
18
19@@ -191,16 +197,29 @@
20 return null;
21 }
22
23+ private void connect_signals (Gtk.Widget item, Gtk.Widget button) {
24+ item.show.connect (() => {
25+ button.no_show_all = false;
26+ button.show ();
27+ });
28+ item.hide.connect (() => {
29+ button.no_show_all = true;
30+ button.hide ();
31+ });
32+ item.state_changed.connect ((type) => {
33+ button.set_state (item.get_state ());
34+ });
35+ }
36+
37 /* convert the menuitems to widgets that can be shown in popovers */
38 private Gtk.Widget? convert_menu_widget (Gtk.Widget item) {
39- /* menuitem not visible */
40- if (!item.get_visible ()) {
41- return null;
42- }
43-
44 /* seperator are GTK.SeparatorMenuItem, return a separator */
45 if (item is Gtk.SeparatorMenuItem) {
46- return new Wingpanel.Widgets.Separator ();
47+ var seperator = new Wingpanel.Widgets.Separator ();
48+
49+ connect_signals (item, seperator);
50+
51+ return seperator;
52 }
53
54 /* all other items are genericmenuitems */
55@@ -216,7 +235,7 @@
56 atk.get_property ("accessible_role", ref val);
57 var item_type = val.get_int ();
58
59- var sensitive = item.get_sensitive ();
60+ var state = item.get_state ();
61 var active = (item as Gtk.CheckMenuItem).get_active ();
62
63 /* detect if it has a image */
64@@ -239,6 +258,12 @@
65
66 return false;
67 });
68+ button.set_state (state);
69+
70+ connect_signals (item, button);
71+ (item as Gtk.CheckMenuItem).toggled.connect (() => {
72+ button.set_active ((item as Gtk.CheckMenuItem).get_active ());
73+ });
74
75 return button;
76 }
77@@ -263,46 +288,48 @@
78 button = new Wingpanel.Widgets.Button (label);
79 }
80
81- button.set_sensitive (sensitive);
82-
83- if (sensitive) {
84- var submenu = (item as Gtk.MenuItem).submenu;
85-
86- if (submenu != null) {
87- int pos = 0;
88- var scroll_sub = new Gtk.ScrolledWindow (null, null);
89- scroll_sub.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
90- var sub_stack = new Gtk.Grid ();
91- scroll_sub.add (sub_stack);
92- var w = new Wingpanel.Widgets.Button (_("Back"));
93- w.clicked.connect (() => {
94- main_stack.set_visible_child (main_grid);
95- });
96- sub_stack.attach (w, 0, pos++, 1, 1);
97- sub_stack.attach (new Wingpanel.Widgets.Separator (), 0, pos++, 1, 1);
98- submenu.popup (null, null, null, 0, Gtk.get_current_event_time ());
99- submenu.insert.connect ((sub_item) => {
100- var sub_menu_item = convert_menu_widget (sub_item);
101-
102- if (sub_menu_item != null) {
103- sub_stack.attach (sub_menu_item, 0, pos++, 1, 1);
104- }
105- });
106- submenu.popdown ();
107- main_stack.add (scroll_sub);
108- button = new SubMenuButton (label);
109- button.clicked.connect (() => {
110- main_stack.set_visible_child (scroll_sub);
111- main_stack.show_all ();
112- });
113- } else {
114- button.clicked.connect (() => {
115- close ();
116- item.activate ();
117- });
118- }
119+ button.set_state (state);
120+
121+ var submenu = (item as Gtk.MenuItem).submenu;
122+
123+ if (submenu != null) {
124+ int pos = 0;
125+ var scroll_sub = new Gtk.ScrolledWindow (null, null);
126+ scroll_sub.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
127+ var sub_stack = new Gtk.Grid ();
128+ scroll_sub.add (sub_stack);
129+ var back_button = new Wingpanel.Widgets.Button (_("Back"));
130+ back_button.clicked.connect (() => {
131+ main_stack.set_visible_child (main_grid);
132+ });
133+ sub_stack.attach (back_button, 0, pos++, 1, 1);
134+ sub_stack.attach (new Wingpanel.Widgets.Separator (), 0, pos++, 1, 1);
135+ submenu.popup (null, null, null, 0, Gtk.get_current_event_time ());
136+ submenu.insert.connect ((sub_item) => {
137+ var sub_menu_item = convert_menu_widget (sub_item);
138+
139+ if (sub_menu_item != null) {
140+
141+ connect_signals (sub_item, sub_menu_item);
142+ sub_stack.attach (sub_menu_item, 0, pos++, 1, 1);
143+ }
144+ });
145+ submenu.popdown ();
146+ main_stack.add (scroll_sub);
147+ button = new SubMenuButton (label);
148+ button.clicked.connect (() => {
149+ main_stack.set_visible_child (scroll_sub);
150+ main_stack.show_all ();
151+ });
152+ } else {
153+ button.clicked.connect (() => {
154+ close ();
155+ item.activate ();
156+ });
157 }
158
159+ connect_signals (item, button);
160+
161 return button;
162 }
163

Subscribers

People subscribed via source and target branches

to all changes: