summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-07-12 17:08:10 +0200
committerinfirit <[email protected]>2014-07-12 18:13:22 +0200
commita896fafa010af32149f84c3942995bee3981add5 (patch)
treed2ef836769d0e24bce0d30689f1a04dcc00c0dd4
parentbdab60d6e3517a0d347f0bf532c133ac547668d3 (diff)
downloadmate-settings-daemon-a896fafa010af32149f84c3942995bee3981add5.tar.bz2
mate-settings-daemon-a896fafa010af32149f84c3942995bee3981add5.tar.xz
Add ability to enable/disable debug with GSettings
Based on similar commit in mate-session-manager.
-rw-r--r--mate-settings-daemon/Makefile.am2
-rw-r--r--mate-settings-daemon/main.c35
2 files changed, 37 insertions, 0 deletions
diff --git a/mate-settings-daemon/Makefile.am b/mate-settings-daemon/Makefile.am
index 7fb6fdc..91e4c78 100644
--- a/mate-settings-daemon/Makefile.am
+++ b/mate-settings-daemon/Makefile.am
@@ -73,6 +73,7 @@ mate_settings_daemon_CPPFLAGS = \
$(AM_CPPFLAGS)
mate_settings_daemon_CFLAGS = \
+ $(MATE_DESKTOP_CFLAGS) \
$(AM_CFLAGS)
mate_settings_daemon_LDFLAGS = \
@@ -81,6 +82,7 @@ mate_settings_daemon_LDFLAGS = \
mate_settings_daemon_LDADD = \
libmsd-profile.la \
$(SETTINGS_DAEMON_LIBS) \
+ $(MATE_DESKTOP_LIBS) \
$(LIBNOTIFY_LIBS)
EXTRA_DIST = \
diff --git a/mate-settings-daemon/main.c b/mate-settings-daemon/main.c
index f2a0bb8..0ecfb13 100644
--- a/mate-settings-daemon/main.c
+++ b/mate-settings-daemon/main.c
@@ -42,8 +42,13 @@
#include "mate-settings-manager.h"
#include "mate-settings-profile.h"
+#include <libmate-desktop/mate-gsettings.h>
+
#define MSD_DBUS_NAME "org.mate.SettingsDaemon"
+#define DEBUG_KEY "mate-settings-daemon"
+#define DEBUG_SCHEMA "org.mate.debug"
+
#define MATE_SESSION_DBUS_NAME "org.mate.SessionManager"
#define MATE_SESSION_DBUS_OBJECT "/org/mate/SessionManager"
#define MATE_SESSION_DBUS_INTERFACE "org.mate.SessionManager"
@@ -443,6 +448,18 @@ parse_args (int *argc, char ***argv)
g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
}
+static void debug_changed (GSettings *settings, gchar *key, gpointer user_data)
+{
+ debug = g_settings_get_boolean (settings, DEBUG_KEY);
+ if (debug) {
+ g_debug ("Enable DEBUG");
+ g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
+ } else {
+ g_debug ("Disable DEBUG");
+ g_unsetenv ("G_MESSAGES_DEBUG");
+ }
+}
+
int
main (int argc, char *argv[])
{
@@ -450,6 +467,7 @@ main (int argc, char *argv[])
DBusGConnection *bus;
gboolean res;
GError *error;
+ GSettings *debug_settings = NULL;
manager = NULL;
@@ -462,6 +480,19 @@ main (int argc, char *argv[])
parse_args (&argc, &argv);
+ /* Allows to enable/disable debug from GSettings only if it is not set from argument */
+ if (mate_gsettings_schema_exists (DEBUG_SCHEMA))
+ {
+ debug_settings = g_settings_new (DEBUG_SCHEMA);
+ debug = g_settings_get_boolean (debug_settings, DEBUG_KEY);
+
+ if (debug) {
+ g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
+ }
+
+ g_signal_connect (debug_settings, "changed::" DEBUG_KEY, G_CALLBACK (debug_changed), NULL);
+ }
+
mate_settings_profile_start ("opening gtk display");
if (! gtk_init_check (NULL, NULL)) {
g_warning ("Unable to initialize GTK+");
@@ -523,6 +554,10 @@ main (int argc, char *argv[])
g_object_unref (manager);
}
+ if (debug_settings != NULL) {
+ g_object_unref (debug_settings);
+ }
+
#ifdef HAVE_LIBNOTIFY
if (notify_is_initted ())
notify_uninit ();