1/* 2 * vala-panel-appmenu 3 * Copyright (C) 2016 Konstantin Pugin <ria.freelander@gmail.com> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19using Gtk; 20using GLib; 21using Appmenu; 22private bool factory_callback(MatePanel.Applet applet, string iid) 23{ 24 if (iid != "AppmenuApplet") { 25 return false; 26 } 27 applet.flags = MatePanel.AppletFlags.HAS_HANDLE | MatePanel.AppletFlags.EXPAND_MAJOR | MatePanel.AppletFlags.EXPAND_MINOR; 28 var layout = new Appmenu.MenuWidget(); 29 var settings = MatePanel.AppletSettings.@new(applet,"org.valapanel.appmenu"); 30 settings.bind(Key.COMPACT_MODE,layout,Key.COMPACT_MODE,SettingsBindFlags.DEFAULT); 31 settings.bind(Key.BOLD_APPLICATION_NAME,layout,Key.BOLD_APPLICATION_NAME,SettingsBindFlags.DEFAULT); 32 applet.add(layout); 33 layout.show(); 34 applet.show(); 35 var action_group = new Gtk.ActionGroup ("AppmenuApplet Menu Actions"); 36 action_group.set_translation_domain (Config.GETTEXT_PACKAGE); 37 Gtk.Action a = new Gtk.Action("AppMenuAppletPreferences",N_("_Preferences"),null,Gtk.Stock.PREFERENCES); 38 a.activate.connect(()=> 39 { 40 var dlg = new Gtk.Dialog.with_buttons( dgettext(Config.GETTEXT_PACKAGE,"Configure AppMenu"), layout.get_toplevel() as Window, 41 DialogFlags.DESTROY_WITH_PARENT, 42 null ); 43 Gtk.Box dlg_vbox = dlg.get_content_area() as Gtk.Box; 44 var entry = new CheckButton.with_label(dgettext(Config.GETTEXT_PACKAGE,"Use Compact mode (all menus in application menu)")); 45 settings.bind(Key.COMPACT_MODE,entry,"active",SettingsBindFlags.DEFAULT); 46 dlg_vbox.pack_start(entry,false,false,2); 47 entry.show(); 48 entry = new CheckButton.with_label(dgettext(Config.GETTEXT_PACKAGE,"Use bold application name")); 49 settings.bind(Key.BOLD_APPLICATION_NAME,entry,"active",SettingsBindFlags.DEFAULT); 50 dlg_vbox.pack_start(entry,false,false,2); 51 entry.show(); 52 dlg.show(); 53 dlg.present(); 54 dlg.response.connect(()=>{ 55 dlg.destroy(); 56 }); 57 }); 58 action_group.add_action (a); 59 applet.setup_menu("""<menuitem name="Appmenu Preferences Item" action="AppMenuAppletPreferences" />""",action_group); 60 return true; 61} 62 63 64public int _mate_panel_applet_shlib_factory() 65{ 66// GLib.Intl.bindtextdomain(Config.GETTEXT_PACKAGE,Config.LOCALE_DIR); 67// GLib.Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE,"UTF-8"); 68 return MatePanel.Applet.factory_setup_in_process("AppmenuAppletFactory", typeof (MatePanel.Applet), factory_callback); 69} 70 71//void main(string[] args) { 72// Gtk.init(ref args); 73// MatePanel.Applet.factory_main("SNTrayAppletFactory", true, typeof (MatePanel.Applet), StatusNotifier.factory_callback); 74//} 75