Skip to content

Commit

Permalink
Enable compact mode and bold appname settings. Fixes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Feb 14, 2018
1 parent 906bc8d commit f39f5ac
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 14 deletions.
3 changes: 3 additions & 0 deletions data/CMakeLists.txt
Expand Up @@ -2,14 +2,17 @@ if (ENABLE_XFCE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/appmenu.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/xfce4/panel/plugins)
endif()
if (ENABLE_MATE)
add_schema("org.valapanel.appmenu.gschema.xml")
configure_file(${CMAKE_SOURCE_DIR}/data/appmenu-mate.desktop.plugin.in ${CMAKE_SOURCE_DIR}/data/appmenu-mate.desktop.in)
configure_file(${CMAKE_SOURCE_DIR}/data/appmenu-mate.service.in ${CMAKE_BINARY_DIR}/data/appmenu-mate.serivce)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/appmenu-mate.serivce DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/dbus-1/services/ RENAME org.mate.panel.applet.AppmenuAppletFactory.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/appmenu-mate.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/mate-panel/applets/ RENAME org.vala-panel.appmenu.mate-panel-applet)
endif()
if (ENABLE_VALAPANEL)
add_schema("org.valapanel.appmenu.gschema.xml")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/appmenu.plugin DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/vala-panel/applets/)
endif()
if (ENABLE_BUDGIE)
add_schema("org.valapanel.appmenu.gschema.xml")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/appmenu-budgie.plugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/budgie-desktop/plugins/budgie-vala-panel-appmenu-plugin)
endif()
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Expand Up @@ -29,7 +29,6 @@ OPTIONS
--gresources=${CMAKE_CURRENT_SOURCE_DIR}/libappmenu.gresource.xml
--thread
${WNCK_DEFINE}
${BOLD_DEFINE}
GENERATE_VAPI
vala-panel-appmenu
)
Expand Down
21 changes: 19 additions & 2 deletions lib/budgie-plugin-appmenu.vala
Expand Up @@ -45,24 +45,41 @@ public class GlobalMenuApplet: Applet
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_all();
return dlg;
}
public override bool supports_settings()
{
return false;
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);
show_all();
}
private GLib.Settings settings;
} // End class

[ModuleInit]
Expand Down
30 changes: 28 additions & 2 deletions lib/mate-plugin-appmenu.vala
Expand Up @@ -24,12 +24,38 @@ private bool factory_callback(MatePanel.Applet applet, string iid)
if (iid != "AppmenuApplet") {
return false;
}

applet.flags = MatePanel.AppletFlags.HAS_HANDLE | MatePanel.AppletFlags.EXPAND_MAJOR;

var layout = new Appmenu.MenuWidget();
var settings = MatePanel.AppletSettings.@new(applet,"org.valapanel.appmenu");
settings.bind(Key.COMPACT_MODE,layout,Key.COMPACT_MODE,SettingsBindFlags.DEFAULT);
settings.bind(Key.BOLD_APPLICATION_NAME,layout,Key.BOLD_APPLICATION_NAME,SettingsBindFlags.DEFAULT);
applet.add(layout);
applet.show_all();
var action_group = new Gtk.ActionGroup ("AppmenuApplet Menu Actions");
action_group.set_translation_domain (Config.GETTEXT_PACKAGE);
Gtk.Action a = new Gtk.Action("AppMenuAppletPreferences",N_("_Preferences"),null,Gtk.Stock.PREFERENCES);
a.activate.connect(()=>
{
var dlg = new Gtk.Dialog.with_buttons( _("Configure AppMenu"), layout.get_toplevel() as Window,
DialogFlags.DESTROY_WITH_PARENT,
_("_Close"),
ResponseType.CLOSE,
null );
Gtk.Box dlg_vbox = dlg.get_content_area() as Gtk.Box;
var entry = new CheckButton.with_label(_("Use Compact mode (all menus in application menu"));
settings.bind(Key.COMPACT_MODE,entry,"active",SettingsBindFlags.DEFAULT);
dlg_vbox.pack_start(entry,false,false,2);
entry = new CheckButton.with_label(_("Use bold application name"));
settings.bind(Key.BOLD_APPLICATION_NAME,entry,"active",SettingsBindFlags.DEFAULT);
dlg_vbox.pack_start(entry,false,false,2);
dlg.show_all();
dlg.present();
dlg.response.connect(()=>{
dlg.destroy();
});
});
action_group.add_action (a);
applet.setup_menu("""<menuitem name="Appmenu Preferences Item" action="AppMenuAppletPreferences" />""",action_group);
return true;
}

Expand Down
15 changes: 8 additions & 7 deletions lib/menu-widget.vala
Expand Up @@ -18,6 +18,12 @@

using GLib;

namespace Key
{
public const string COMPACT_MODE = "compact-mode";
public const string BOLD_APPLICATION_NAME = "bold-application-name";
}

namespace Appmenu
{
[Compact]
Expand All @@ -35,8 +41,8 @@ namespace Appmenu
}
public class MenuWidget: Gtk.Bin
{
public bool compact_mode {get; set;}
public bool bold_application_name {get; set;}
public bool compact_mode {get; set; default = false;}
public bool bold_application_name {get; set; default = false;}
private Gtk.Adjustment? scroll_adj = null;
private Gtk.ScrolledWindow? scroller = null;
private Gtk.CssProvider provider;
Expand All @@ -51,11 +57,6 @@ namespace Appmenu
unowned Gtk.StyleContext context = this.get_style_context();
context.add_class("-vala-panel-appmenu-core");
unowned Gtk.StyleContext mcontext = mwidget.get_style_context();
#if BOLD
this.bold_application_name = true;
#else
this.bold_application_name = false;
#endif
this.notify.connect(()=>{
this.restock();
});
Expand Down
40 changes: 40 additions & 0 deletions lib/valapanel-plugin-appmenu.vala
Expand Up @@ -35,7 +35,12 @@ public class AppmenuApplet : AppletPlugin, Peas.ExtensionBase
}
}
public class GlobalMenuApplet: Applet
#if NEW
#else
, AppletConfigurable
#endif
{
unowned MenuWidget layout;
#if NEW
public GlobalMenuApplet (Toplevel top, GLib.Settings? settings, string number)
#else
Expand All @@ -44,15 +49,50 @@ public class GlobalMenuApplet: Applet
{
base(top,settings,number);
#if NEW
(this.action_group.lookup_action(AppletAction.CONFIGURE) as SimpleAction).set_enabled(true);
#else
}
public override void create()
{
#endif
var layout = new Appmenu.MenuWidget();
this.layout = 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);
show_all();
}
#if NEW
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_all();
return dlg;
}
#else
public Dialog get_config_dialog()
{
var dlg = new Gtk.Dialog.with_buttons( _("Configure AppMenu"), toplevel, DialogFlags.DESTROY_WITH_PARENT,
_("_Close"),
ResponseType.CLOSE,
null );
Gtk.Box dlg_vbox = dlg.get_content_area() as Gtk.Box;
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_vbox.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_vbox.pack_start(entry,false,false,2);
dlg_vbox.show_all();
return dlg;
}
#endif
} // End class

[ModuleInit]
Expand Down
41 changes: 39 additions & 2 deletions lib/xfce4-plugin-appmenu.vala
Expand Up @@ -17,6 +17,7 @@
*/

using GLib;
using Gtk;
using Appmenu;
using Xfce;

Expand All @@ -27,14 +28,50 @@ public class AppmenuPlugin : Xfce.PanelPlugin {
GLib.Intl.bindtextdomain(Config.GETTEXT_PACKAGE,Config.LOCALE_DIR);
GLib.Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE,"UTF-8");
GLib.Intl.textdomain(Config.GETTEXT_PACKAGE);
widget = new MenuWidget();
var layout = new MenuWidget();
widget = layout;
add(widget);
add_action_widget(widget);
this.width_request = -1;
try{
Xfconf.init();
channel = this.get_channel();
Xfconf.Property.bind(channel,this.get_property_base()+"/"+Key.COMPACT_MODE,typeof(bool),widget,Key.COMPACT_MODE);
Xfconf.Property.bind(channel,this.get_property_base()+"/"+Key.BOLD_APPLICATION_NAME,typeof(bool),widget,Key.BOLD_APPLICATION_NAME);
Xfconf.Property.bind(channel,this.get_property_base()+"/expand",typeof(bool),widget,"hexpand");
this.menu_show_configure();
} catch (Xfconf.Error e) {
stderr.printf("Xfconf init failed. Configuration will not be saved.\n");
}
this.shrink = true;
this.set_expand(true);
widget.show_all();
}
private Gtk.Widget widget;
public override void configure_plugin()
{
var dlg = new Gtk.Dialog.with_buttons( _("Configure AppMenu"), this.get_toplevel() as Window,
DialogFlags.DESTROY_WITH_PARENT,
_("_Close"),
ResponseType.CLOSE,
null );
Gtk.Box dlg_vbox = dlg.get_content_area() as Gtk.Box;
var entry = new CheckButton.with_label(_("Use Compact mode (all menus in application menu"));
entry.bind_property("active",widget,Key.COMPACT_MODE,BindingFlags.SYNC_CREATE);
dlg_vbox.pack_start(entry,false,false,2);
entry = new CheckButton.with_label(_("Use bold application name"));
entry.bind_property("active",widget,Key.BOLD_APPLICATION_NAME,BindingFlags.SYNC_CREATE);
dlg_vbox.pack_start(entry,false,false,2);
entry = new CheckButton.with_label(_("Expand plugin on panel"));
entry.bind_property("active",widget,"hexpand",BindingFlags.SYNC_CREATE);
dlg_vbox.pack_start(entry,false,false,2);
dlg.show_all();
dlg.present();
dlg.unmap.connect(()=>{
dlg.destroy();
});
}
private Xfconf.Channel channel;
private unowned MenuWidget widget;
}

[ModuleInit]
Expand Down

0 comments on commit f39f5ac

Please sign in to comment.