File tree 2 files changed +47
-0
lines changed 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: GPL-2.0-or-later
3
+ * SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
4
+ */
5
+
6
+ /**
7
+ * PopoverMenuItem is a {@link Gtk.Button} subclass for use as a MenuItem in {@link Gtk.Popover}
8
+ *
9
+ * It will automatically call {@link Gtk.Popover.popdown} on its parent when clicked
10
+ *
11
+ * It contains a {@link Granite.AccelLabel} which will automatically show
12
+ * accelerators for the {@link GLib.Action} assigned to #this
13
+ *
14
+ * @since 8.0.0
15
+ */
16
+ [Version (since = " 8.0.0" )]
17
+ public class Wingpanel.PopoverMenuItem : Gtk .Button {
18
+ /**
19
+ * The label for the button
20
+ */
21
+ public string text {
22
+ set {
23
+ child = new Granite .AccelLabel (value ) {
24
+ action_name = this . action_name
25
+ };
26
+
27
+ update_property (Gtk . AccessibleProperty . LABEL , value , - 1 );
28
+ }
29
+ }
30
+
31
+ class construct {
32
+ set_css_name ("modelbutton ");
33
+ }
34
+
35
+ construct {
36
+ accessible_role = MENU_ITEM ;
37
+
38
+ clicked. connect (() = > {
39
+ var popover = (Gtk . Popover ) get_ancestor (typeof (Gtk . Popover ));
40
+ if (popover != null ) {
41
+ popover. popdown ();
42
+ }
43
+ });
44
+ }
45
+ }
Original file line number Diff line number Diff line change @@ -17,12 +17,14 @@ libwingpanel_deps = [
17
17
gmodule_dep,
18
18
gee_dep,
19
19
gtk_dep,
20
+ granite_dep
20
21
]
21
22
22
23
libwingpanel_lib = library (
23
24
' wingpanel-8' ,
24
25
' Indicator.vala' ,
25
26
' IndicatorManager.vala' ,
27
+ ' PopoverMenuItem.vala' ,
26
28
config_header,
27
29
dependencies : [libwingpanel_deps, config_vapi],
28
30
vala_header : ' wingpanel-8.h' ,
You can’t perform that action at this time.
0 commit comments