Merge lp:~charlesk/libappindicator/fix-vala-examples into lp:libappindicator/0.5

Proposed by Charles Kerr
Status: Merged
Approved by: Charles Kerr
Approved revision: 237
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~charlesk/libappindicator/fix-vala-examples
Merge into: lp:libappindicator/0.5
Diff against target: 137 lines (+21/-21)
2 files modified
bindings/vala/examples/indicator-example.vala (+3/-3)
example/simple-client-vala.vala (+18/-18)
To merge this branch: bzr merge lp:~charlesk/libappindicator/fix-vala-examples
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
Review via email: mp+98695@code.launchpad.net

Description of the change

The vala examples were written before GMenu, so add explict namespace use here to avoid valac errors caused by namespace ambiguity between glib and gtk (ie, use 'new Gtk.Menu' instead of 'new Menu')

To post a comment you must log in.
Revision history for this message
Lars Karlitski (larsu) wrote :

I find it much better like this anyways.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bindings/vala/examples/indicator-example.vala'
--- bindings/vala/examples/indicator-example.vala 2011-09-23 15:46:27 +0000
+++ bindings/vala/examples/indicator-example.vala 2012-03-21 18:09:20 +0000
@@ -39,16 +39,16 @@
39 indicator.set_status(IndicatorStatus.ACTIVE);39 indicator.set_status(IndicatorStatus.ACTIVE);
40 indicator.set_attention_icon("indicator-messages-new");40 indicator.set_attention_icon("indicator-messages-new");
4141
42 var menu = new Menu();42 var menu = new Gtk.Menu();
4343
44 var item = new MenuItem.with_label("Foo");44 var item = new Gtk.MenuItem.with_label("Foo");
45 item.activate.connect(() => {45 item.activate.connect(() => {
46 indicator.set_status(IndicatorStatus.ATTENTION);46 indicator.set_status(IndicatorStatus.ATTENTION);
47 });47 });
48 item.show();48 item.show();
49 menu.append(item);49 menu.append(item);
5050
51 var bar = item = new MenuItem.with_label("Bar");51 var bar = item = new Gtk.MenuItem.with_label("Bar");
52 item.show();52 item.show();
53 item.activate.connect(() => {53 item.activate.connect(() => {
54 indicator.set_status(IndicatorStatus.ACTIVE);54 indicator.set_status(IndicatorStatus.ACTIVE);
5555
=== modified file 'example/simple-client-vala.vala'
--- example/simple-client-vala.vala 2012-01-29 03:38:55 +0000
+++ example/simple-client-vala.vala 2012-03-21 18:09:20 +0000
@@ -30,7 +30,7 @@
30}30}
3131
32class SimpleClient {32class SimpleClient {
33 Menu menu;33 Gtk.Menu menu;
34 Indicator ci;34 Indicator ci;
35 int percentage;35 int percentage;
36 bool active;36 bool active;
@@ -56,24 +56,24 @@
56 widget.set_sensitive(!widget.is_sensitive());56 widget.set_sensitive(!widget.is_sensitive());
57 }57 }
5858
59 private void append_submenu(MenuItem item) {59 private void append_submenu(Gtk.MenuItem item) {
60 var menu = new Menu();60 var menu = new Gtk.Menu();
61 MenuItem mi;61 Gtk.MenuItem mi;
6262
63 mi = new MenuItem.with_label("Sub 1");63 mi = new Gtk.MenuItem.with_label("Sub 1");
64 menu.append(mi);64 menu.append(mi);
65 mi.activate.connect(() => { print("Sub1\n"); });65 mi.activate.connect(() => { print("Sub1\n"); });
6666
67 MenuItem prev_mi = mi;67 Gtk.MenuItem prev_mi = mi;
68 mi = new MenuItem.with_label("Sub 2");68 mi = new Gtk.MenuItem.with_label("Sub 2");
69 menu.append(mi);69 menu.append(mi);
70 mi.activate.connect(() => { toggle_sensitivity(prev_mi); });70 mi.activate.connect(() => { toggle_sensitivity(prev_mi); });
7171
72 mi = new MenuItem.with_label("Sub 3");72 mi = new Gtk.MenuItem.with_label("Sub 3");
73 menu.append(mi);73 menu.append(mi);
74 mi.activate.connect(() => { print("Sub3\n"); });74 mi.activate.connect(() => { print("Sub3\n"); });
7575
76 mi = new MenuItem.with_label("Toggle Attention");76 mi = new Gtk.MenuItem.with_label("Toggle Attention");
77 menu.append(mi);77 menu.append(mi);
78 mi.activate.connect(() => {78 mi.activate.connect(() => {
79 if (ci.get_status() == IndicatorStatus.ATTENTION)79 if (ci.get_status() == IndicatorStatus.ATTENTION)
@@ -88,7 +88,7 @@
88 item.set_submenu(menu);88 item.set_submenu(menu);
89 }89 }
9090
91 private void label_toggle(MenuItem item) {91 private void label_toggle(Gtk.MenuItem item) {
92 can_haz_label = !can_haz_label;92 can_haz_label = !can_haz_label;
9393
94 if (can_haz_label) {94 if (can_haz_label) {
@@ -114,28 +114,28 @@
114 return true;114 return true;
115 });115 });
116116
117 menu = new Menu();117 menu = new Gtk.Menu();
118 var chk = new CheckMenuItem.with_label("1");118 var chk = new CheckMenuItem.with_label("1");
119 chk.activate.connect(() => { print("1\n"); });119 chk.activate.connect(() => { print("1\n"); });
120 menu.append(chk);120 menu.append(chk);
121 chk.show();121 chk.show();
122122
123 var radio = new RadioMenuItem.with_label(new SList<RadioMenuItem>(), "2");123 var radio = new Gtk.RadioMenuItem.with_label(new SList<RadioMenuItem>(), "2");
124 radio.activate.connect(() => { print("2\n"); });124 radio.activate.connect(() => { print("2\n"); });
125 menu.append(radio);125 menu.append(radio);
126 radio.show();126 radio.show();
127127
128 var submenu = new MenuItem.with_label("3");128 var submenu = new Gtk.MenuItem.with_label("3");
129 menu.append(submenu);129 menu.append(submenu);
130 append_submenu(submenu);130 append_submenu(submenu);
131 submenu.show();131 submenu.show();
132132
133 var toggle_item = new MenuItem.with_label("Toggle 3");133 var toggle_item = new Gtk.MenuItem.with_label("Toggle 3");
134 toggle_item.activate.connect(() => { toggle_sensitivity(submenu); });134 toggle_item.activate.connect(() => { toggle_sensitivity(submenu); });
135 menu.append(toggle_item);135 menu.append(toggle_item);
136 toggle_item.show();136 toggle_item.show();
137137
138 var imgitem = new ImageMenuItem.from_stock(Stock.NEW, null);138 var imgitem = new Gtk.ImageMenuItem.from_stock(Stock.NEW, null);
139 imgitem.activate.connect(() => {139 imgitem.activate.connect(() => {
140 Image img = (Image) imgitem.get_image();140 Image img = (Image) imgitem.get_image();
141 img.set_from_stock(Stock.OPEN, IconSize.MENU);141 img.set_from_stock(Stock.OPEN, IconSize.MENU);
@@ -143,7 +143,7 @@
143 menu.append(imgitem);143 menu.append(imgitem);
144 imgitem.show();144 imgitem.show();
145145
146 var att = new MenuItem.with_label("Get Attention");146 var att = new Gtk.MenuItem.with_label("Get Attention");
147 att.activate.connect(() => {147 att.activate.connect(() => {
148 if (active) {148 if (active) {
149 ci.set_status(IndicatorStatus.ATTENTION);149 ci.set_status(IndicatorStatus.ATTENTION);
@@ -158,13 +158,13 @@
158 menu.append(att);158 menu.append(att);
159 att.show();159 att.show();
160160
161 var show = new MenuItem.with_label("Show Label");161 var show = new Gtk.MenuItem.with_label("Show Label");
162 label_toggle(show);162 label_toggle(show);
163 show.activate.connect(() => { label_toggle(show); });163 show.activate.connect(() => { label_toggle(show); });
164 menu.append(show);164 menu.append(show);
165 show.show();165 show.show();
166166
167 var icon = new CheckMenuItem.with_label("Set Local Icon");167 var icon = new Gtk.CheckMenuItem.with_label("Set Local Icon");
168 icon.activate.connect(() => {168 icon.activate.connect(() => {
169 if (icon.get_active()) {169 if (icon.get_active()) {
170 ci.set_icon("simple-client-test-icon.png");170 ci.set_icon("simple-client-test-icon.png");

Subscribers

People subscribed via source and target branches