Page MenuHomeSolus

No OneTemporary

diff --git a/src/daemon/main.vala b/src/daemon/main.vala
index df76581..a8d4727 100644
--- a/src/daemon/main.vala
+++ b/src/daemon/main.vala
@@ -1,92 +1,94 @@
/*
* This file is part of budgie-desktop
*
* Copyright (C) 2016-2017 Ikey Doherty <ikey@solus-project.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
/**
* Whether we need to replace an existing daemon
*/
static bool replace = false;
const GLib.OptionEntry[] options = {
{ "replace", 0, 0, OptionArg.NONE, ref replace, "Replace currently running daemon" },
{ null }
};
namespace Budgie {
bool setup = false;
bool spammed = false;
void DaemonNameLost(DBusConnection conn, string name)
{
warning("budgie-daemon lost d-bus name %s", name);
if (!spammed) {
if (setup) {
message("Replaced existing budgie-daemon");
} else {
message("Another instance of budgie-daemon is running. Use --replace");
}
spammed = true;
}
Gtk.main_quit();
}
}
/**
* Main entry for the daemon
*/
public static int main(string[] args)
{
Gtk.init(ref args);
OptionContext ctx;
Budgie.ServiceManager? manager = null;
Budgie.EndSessionDialog? end_dialog = null;
+ Budgie.SettingsManager? settings = null;
Wnck.Screen? screen = null;
Intl.setlocale(LocaleCategory.ALL, "");
Intl.bindtextdomain(Budgie.GETTEXT_PACKAGE, Budgie.LOCALEDIR);
Intl.bind_textdomain_codeset(Budgie.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain(Budgie.GETTEXT_PACKAGE);
ctx = new OptionContext("- Budgie Daemon");
ctx.set_help_enabled(true);
ctx.add_main_entries(options, null);
ctx.add_group(Gtk.get_option_group(false));
try {
ctx.parse(ref args);
} catch (Error e) {
stderr.printf("Error: %s\n", e.message);
return 0;
}
/* Initialise wnck properly post gtk-start */
Idle.add(()=> {
screen = Wnck.Screen.get_default();
if (screen != null) {
screen.force_update();
}
return false;
});
manager = new Budgie.ServiceManager(replace);
end_dialog = new Budgie.EndSessionDialog(replace);
+ settings = new Budgie.SettingsManager();
/* Enter main loop */
Gtk.main();
/* Deref - clean */
manager = null;
end_dialog = null;
Wnck.shutdown();
return 0;
}
diff --git a/src/daemon/meson.build b/src/daemon/meson.build
index d4334b3..ab78950 100644
--- a/src/daemon/meson.build
+++ b/src/daemon/meson.build
@@ -1,61 +1,62 @@
# Provides budgie-daemon component
custom_target('desktop-file-daemon',
input : 'budgie-daemon.desktop.in',
output : 'budgie-daemon.desktop',
command : [intltool, '--desktop-style', podir, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : join_paths(datadir, 'applications'))
# Compile the assets into the binary
daemon_resources = gnome.compile_resources(
'budgie-daemon-resources',
'budgie-daemon.gresource.xml',
source_dir: '.',
c_name: 'budgie_polkit',
)
daemon_sources = [
'endsession.vala',
'main.vala',
'manager.vala',
'menus.vala',
'osd.vala',
+ 'settings.vala',
'tabswitcher.vala',
daemon_resources,
]
daemon_deps = [
dep_gtk3,
dep_gdkx11,
dep_wnck,
link_libconfig,
link_libtheme,
link_libsession,
]
# Need absolute path to gresource
gresource = join_paths(meson.current_source_dir(), 'budgie-daemon.gresource.xml')
executable(
'budgie-daemon', daemon_sources,
dependencies: daemon_deps,
vala_args: [
'--vapidir', dir_libtheme,
'--vapidir', dir_libconfig,
'--pkg', 'theme',
'--pkg', 'budgie-config',
'--pkg', 'gio-unix-2.0',
'--pkg', 'gtk+-3.0',
'--pkg', 'gdk-x11-3.0',
'--pkg', 'libwnck-3.0',
# Make gresource work
'--target-glib=2.38',
'--gresources=' + gresource,
],
c_args: [
'-DWNCK_I_KNOW_THIS_IS_UNSTABLE',
],
install: true,
)
diff --git a/src/daemon/settings.vala b/src/daemon/settings.vala
new file mode 100644
index 0000000..62f0e70
--- /dev/null
+++ b/src/daemon/settings.vala
@@ -0,0 +1,100 @@
+/*
+ * This file is part of budgie-desktop
+ *
+ * Copyright (C) 2017 Ikey Doherty <ikey@solus-project.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+namespace Budgie
+{
+
+/**
+ * The button layout style as set in budgie
+ */
+public enum ButtonPosition {
+ LEFT = 1 << 0,
+ TRADITIONAL = 1 << 1,
+}
+/**
+ * The SettingsManager currently only has a very simple job, and looks for
+ * session wide settings changes to respond to
+ */
+public class SettingsManager
+{
+ private GLib.Settings? wm_settings = null;
+ private GLib.Settings? xoverrides = null;
+
+ /**
+ * Create a new xsettings override based on the *Existing* key so that
+ * we don't dump any settings like Gdk/ScaleFactor, etc.
+ */
+ private Variant? new_filtered_xsetting(string button_layout)
+ {
+ /* These are the two new keys we want */
+ var builder = new VariantBuilder(new VariantType("a{sv}"));
+ builder.add("{sv}", "Gtk/ShellShowsAppMenu", new Variant.int32(0));
+ builder.add("{sv}", "Gtk/DecorationLayout", new Variant.string(button_layout));
+
+ Variant existing_vars = this.xoverrides.get_value("overrides");
+ VariantIter it = existing_vars.iterator();
+ string? k = null;
+ Variant? v = null;
+ while (it.next("{sv}", &k, &v)) {
+ if (k == "Gtk/ShellShowsAppMenu" || k == "Gtk/DecorationLayout") {
+ continue;
+ }
+ builder.add("{sv}", k, v);
+ }
+ return builder.end();
+ }
+
+ public SettingsManager()
+ {
+ /* Settings we need to write to */
+ xoverrides = new GLib.Settings("org.gnome.settings-daemon.plugins.xsettings");
+
+ wm_settings = new GLib.Settings("com.solus-project.budgie-wm");
+ wm_settings.changed.connect(this.on_wm_settings_changed);
+ this.on_wm_settings_changed("button-style");
+ }
+
+ private void on_wm_settings_changed(string key)
+ {
+ if (key != "button-style") {
+ return;
+ }
+
+ ButtonPosition style = (ButtonPosition)wm_settings.get_enum(key);
+ this.set_button_style(style);
+ }
+
+ /**
+ * Set the button layout to one of left or traditional
+ */
+ void set_button_style(ButtonPosition style)
+ {
+ Variant? xset = null;
+ string? wm_set = null;
+
+ switch (style) {
+ case ButtonPosition.LEFT:
+ xset = this.new_filtered_xsetting("close,minimize,maximize,menu:");
+ wm_set = "close,maximize,minimize,appmenu";
+ break;
+ case ButtonPosition.TRADITIONAL:
+ default:
+ xset = this.new_filtered_xsetting("menu:minimize,maximize,close");
+ wm_set = "appmenu:minimize,maximize,close";
+ break;
+ }
+ this.xoverrides.set_value("overrides", xset);
+ this.wm_settings.set_string("button-layout", wm_set);
+ }
+
+} /* End class SettingsManager (BudgieSettingsManager) */
+
+} /* End namespace Budgie */

File Metadata

Mime Type
text/x-diff
Expires
Thu, Aug 10, 11:37 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5894598
Default Alt Text
(7 KB)

Event Timeline