Codebase list gnome-shell-extension-appindicator / b00b102
Added a small testing utility Jonas Kümmerlin 10 years ago
1 changed file(s) with 68 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #!/usr/bin/gjs
1
2 /*
3 * This creates an appindicator which contains all common menu items
4 *
5 * Requires libappindicator3 introspection data
6 */
7 const Gtk = imports.gi.Gtk;
8 const AppIndicator = imports.gi.AppIndicator3;
9 const GLib = imports.gi.GLib;
10
11 (function() {
12
13 var app = new Gtk.Application({
14 application_id: null
15 });
16
17 var window = null;
18
19 app.connect("activate", function(){
20 window.present();
21 });
22
23 app.connect("startup", function() {
24 window = new Gtk.ApplicationWindow({
25 title: "test",
26 application: app
27 });
28
29 var menu = new Gtk.Menu();
30
31 var item = Gtk.MenuItem.new_with_label("A standard item");
32 menu.append(item);
33
34 item = Gtk.MenuItem.new_with_label("Foo");
35 menu.append(item);
36
37 item = Gtk.ImageMenuItem.new_with_label("Calculator");
38 item.image = Gtk.Image.new_from_icon_name("gnome-calculator", Gtk.IconSize.MENU);
39 menu.append(item);
40
41 item = Gtk.CheckMenuItem.new_with_label("Check me!");
42 menu.append(item);
43
44 item = new Gtk.SeparatorMenuItem();
45 menu.append(item);
46
47 var group = [];
48
49 for (let i = 0; i < 5; ++i) {
50 item = Gtk.RadioMenuItem.new_with_label(group, "Example Radio "+i);
51 group = Gtk.RadioMenuItem.prototype.get_group.apply(item)//.get_group();
52 if (i == 1)
53 item.set_active(true);
54 menu.append(item);
55 }
56
57 menu.show_all();
58
59 var indicator = AppIndicator.Indicator.new("Hello", "indicator-test", AppIndicator.IndicatorCategory.APPLICATION_STATUS);
60
61 indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE);
62 indicator.set_icon("gnome-run");
63 indicator.set_menu(menu);
64 });
65 app.run(ARGV);
66
67 })();