diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-09-30 14:17:30 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 11:57:56 +0200 |
commit | b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd (patch) | |
tree | f98a137122c20ffb08a21150dabb0e6b6f8856b2 /src | |
parent | cab9f6acc55a464bbc10638d7cb186ab41c918d6 (diff) | |
download | arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.tar.gz arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.tar.bz2 arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.zip |
Move greeter_set_env to AGUtils.
This may be a helpful method we might need in the future in a more global
context.
Diffstat (limited to 'src')
-rw-r--r-- | src/menubar.vala | 37 | ||||
-rw-r--r-- | src/util.vala | 30 |
2 files changed, 35 insertions, 32 deletions
diff --git a/src/menubar.vala b/src/menubar.vala index b9772fa..6dd802b 100644 --- a/src/menubar.vala +++ b/src/menubar.vala @@ -288,33 +288,6 @@ public class MenuBar : Gtk.MenuBar nat = HEIGHT; } - private void greeter_set_env (string key, string val) - { - GLib.Environment.set_variable (key, val, true); - - /* And also set it in the DBus activation environment so that any - * indicator services pick it up. */ - try - { - var proxy = new GLib.DBusProxy.for_bus_sync (GLib.BusType.SESSION, - GLib.DBusProxyFlags.NONE, null, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus", - null); - - var builder = new GLib.VariantBuilder (GLib.VariantType.ARRAY); - builder.add ("{ss}", key, val); - - proxy.call_sync ("UpdateActivationEnvironment", new GLib.Variant ("(a{ss})", builder), GLib.DBusCallFlags.NONE, -1, null); - } - catch (Error e) - { - warning ("Could not get set environment for indicators: %s", e.message); - return; - } - } - private Indicator.Object? load_indicator_file (string indicator_name) { string dir = Config.INDICATOR_FILE_DIR; @@ -386,20 +359,20 @@ public class MenuBar : Gtk.MenuBar private void setup_indicators () { /* Set indicators to run with reduced functionality */ - greeter_set_env ("INDICATOR_GREETER_MODE", "1"); + AGUtils.greeter_set_env ("INDICATOR_GREETER_MODE", "1"); /* Don't allow virtual file systems? */ - greeter_set_env ("GIO_USE_VFS", "local"); - greeter_set_env ("GVFS_DISABLE_FUSE", "1"); + AGUtils.greeter_set_env ("GIO_USE_VFS", "local"); + AGUtils.greeter_set_env ("GVFS_DISABLE_FUSE", "1"); /* Hint to have mate-settings-daemon run in greeter mode */ - greeter_set_env ("RUNNING_UNDER_GDM", "1"); + AGUtils.greeter_set_env ("RUNNING_UNDER_GDM", "1"); /* Let indicators know about our unique dbus name */ try { var conn = Bus.get_sync (BusType.SESSION); - greeter_set_env ("ARCTICA_GREETER_DBUS_NAME", conn.get_unique_name ()); + AGUtils.greeter_set_env ("ARCTICA_GREETER_DBUS_NAME", conn.get_unique_name ()); } catch (IOError e) { diff --git a/src/util.vala b/src/util.vala index 6b82f50..a9116f7 100644 --- a/src/util.vala +++ b/src/util.vala @@ -26,3 +26,33 @@ [CCode(cname = "GTK_IS_CONTAINER", cheader_filename="gtk/gtk.h", simple_generics = true, has_target = false)] static extern bool gtk_is_container<T> (T widget); #endif + +namespace AGUtils { + public void greeter_set_env (string key, string val) + { + GLib.Environment.set_variable (key, val, true); + + /* And also set it in the DBus activation environment so that any + * indicator services pick it up. */ + try + { + var proxy = new GLib.DBusProxy.for_bus_sync (GLib.BusType.SESSION, + GLib.DBusProxyFlags.NONE, null, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + null); + + var builder = new GLib.VariantBuilder (GLib.VariantType.ARRAY); + builder.add ("{ss}", key, val); + + debug ("Updating DBus activation environment, updating '%s' to '%s'", key, val); + proxy.call_sync ("UpdateActivationEnvironment", new GLib.Variant ("(a{ss})", builder), GLib.DBusCallFlags.NONE, -1, null); + } + catch (Error e) + { + warning ("Could not set environment variable '%s' to '%s', error was: '%s'", key, val, e.message); + return; + } + } +} |