File: budgie-plugin-appmenu.vala

package info (click to toggle)
vala-panel-appmenu 0.7.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,336 kB
  • sloc: ansic: 2,309; xml: 83; makefile: 56; sh: 7
file content (92 lines) | stat: -rw-r--r-- 3,407 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * vala-panel-appmenu
 * Copyright (C) 2015 Konstantin Pugin <ria.freelander@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 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 General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using Gtk;
using GLib;
using Budgie;

public class AppmenuApplet : Plugin, Peas.ExtensionBase
{
    public Applet get_panel_widget(string uid)
    {
        return new GlobalMenuApplet(uid);
    }
}
public class GlobalMenuApplet: Applet
{
    public string uuid { public set ; public get; }
    private void add_budgie_style(Gtk.Bin layout)
    {
        layout.get_child().notify.connect((pspec)=>{
            foreach(unowned Gtk.Widget ch in (layout.get_child() as Container).get_children())
            {
                unowned Gtk.StyleContext context = ch.get_style_context();
                context.add_class("budgie-menubar");
            }
        });
        foreach(unowned Gtk.Widget ch in (layout.get_child() as Container).get_children())
        {
            unowned Gtk.StyleContext context = ch.get_style_context();
            context.add_class("budgie-menubar");
        }
    }
    public override Widget? get_settings_ui()
    {
        var dlg = new Gtk.Box(Gtk.Orientation.VERTICAL,0);
        var entry = new CheckButton.with_label(_("Use Compact mode (all menus in application menu)"));
        this.settings.bind(Key.COMPACT_MODE,entry,"active",SettingsBindFlags.DEFAULT);
        dlg.pack_start(entry,false,false,2);
        entry = new CheckButton.with_label(_("Use bold application name"));
        this.settings.bind(Key.BOLD_APPLICATION_NAME,entry,"active",SettingsBindFlags.DEFAULT);
        dlg.pack_start(entry,false,false,2);
        dlg.show();
        return dlg;
    }
    public override bool supports_settings()
    {
        return true;
    }
    public GlobalMenuApplet (string uuid)
    {
        Object(uuid: uuid);
        settings_schema = "org.valapanel.appmenu";
        settings_prefix = "/com/solus-project/budgie-panel/instance/appmenu";
        settings = get_applet_settings(uuid);
        var layout = new Appmenu.MenuWidget();
        layout.add.connect_after((w)=>{
            add_budgie_style(layout);
        });
        settings.bind(Key.COMPACT_MODE,layout,Key.COMPACT_MODE,SettingsBindFlags.DEFAULT);
        settings.bind(Key.BOLD_APPLICATION_NAME,layout,Key.BOLD_APPLICATION_NAME,SettingsBindFlags.DEFAULT);
        this.add(layout);
        this.hexpand_set = true;
        this.vexpand_set = true;
        add_budgie_style(layout);
        layout.show();
        this.show();
    }
    private GLib.Settings settings;
} // End class

[ModuleInit]
public void peas_register_types(TypeModule module)
{
    // boilerplate - all modules need this
    var objmodule = module as Peas.ObjectModule;
    objmodule.register_extension_type(typeof(Budgie.Plugin), typeof(AppmenuApplet));
}