This repository has been archived by the owner on Apr 2, 2022. It is now read-only.
forked from elementary/wingpanel-indicator-ayatana
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSubMenuButton.vala
62 lines (51 loc) · 2.06 KB
/
SubMenuButton.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*-
* Copyright (c) 2015 Wingpanel Developers (http://launchpad.net/wingpanel)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class AyatanaCompatibility.SubMenuButton : Gtk.Button {
private Gtk.Label button_label;
private new Gtk.Image image;
public SubMenuButton (string caption) {
this.hexpand = true;
var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
box.hexpand = true;
button_label = new Gtk.Label.with_mnemonic (caption);
button_label.set_mnemonic_widget (this);
button_label.use_markup = true;
button_label.margin_start = 6;
image = new Gtk.Image ();
image.halign = Gtk.Align.END;
try {
Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default ();
image.pixbuf = icon_theme.load_icon ("pan-end-symbolic", 16, 0);
} catch (Error e) {
warning (e.message);
}
image.margin_end = 6;
box.add (button_label);
box.pack_end (image);
this.add (box);
var style_context = this.get_style_context ();
style_context.add_class (Gtk.STYLE_CLASS_MENUITEM);
style_context.remove_class (Gtk.STYLE_CLASS_BUTTON);
style_context.remove_class ("text-button");
}
public void set_caption (string caption) {
button_label.set_label (Markup.escape_text (caption));
}
public string get_caption () {
return button_label.get_label ();
}
}