diff options
author | Stefano Karapetsas <[email protected]> | 2014-07-12 11:13:18 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-07-12 11:13:18 +0200 |
commit | 72a1935f882ff450d19f56d0b8393c4d735ee708 (patch) | |
tree | 6ae59cd2061f9c9c726fb91dcfa1f087703e5efe /mate-session | |
parent | ad90ed5acad435c056d12d5cf9e4480ca2e21e6a (diff) | |
download | mate-session-manager-72a1935f882ff450d19f56d0b8393c4d735ee708.tar.bz2 mate-session-manager-72a1935f882ff450d19f56d0b8393c4d735ee708.tar.xz |
Add ability to enable/disable debug with GSettings
Diffstat (limited to 'mate-session')
-rw-r--r-- | mate-session/main.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/mate-session/main.c b/mate-session/main.c index b57be06..5f123fd 100644 --- a/mate-session/main.c +++ b/mate-session/main.c @@ -61,6 +61,9 @@ #define ACCESSIBILITY_KEY "accessibility" #define ACCESSIBILITY_SCHEMA "org.mate.interface" +#define DEBUG_KEY "mate-session" +#define DEBUG_SCHEMA "org.mate.debug" + #define VISUAL_SCHEMA "org.mate.applications-at-visual" #define VISUAL_KEY "exec" #define VISUAL_STARTUP_KEY "startup" @@ -524,6 +527,47 @@ static gboolean require_dbus_session(int argc, char** argv, GError** error) return TRUE; } +// Copied from mate-desktop +gboolean +_gsettings_schema_exists (const gchar* schema) +{ +#if GLIB_CHECK_VERSION (2, 40, 0) + GSettingsSchemaSource *schema_source; + GSettingsSchema *schema_schema; +#else + const char * const *schemas; + gint i; +#endif + gboolean schema_exists; + +#if GLIB_CHECK_VERSION (2, 40, 0) + schema_source = g_settings_schema_source_get_default(); + schema_schema = g_settings_schema_source_lookup (schema_source, schema, FALSE); + schema_exists = (schema_schema != NULL); + if (schema_schema) + g_settings_schema_unref (schema_schema); +#else + schemas = g_settings_list_schemas (); + schema_exists = FALSE; + + for (i = 0; schemas[i] != NULL; i++) { + if (g_strcmp0 (schemas[i], schema) == 0) { + schema_exists = TRUE; + break; + } + } +#endif + + return schema_exists; +} + + +void debug_changed (GSettings *settings, gchar *key, gpointer user_data) +{ + debug = g_settings_get_boolean (settings, DEBUG_KEY); + mdm_log_set_debug (debug); +} + int main(int argc, char** argv) { struct sigaction sa; @@ -532,6 +576,7 @@ int main(int argc, char** argv) GsmManager* manager; GsmStore* client_store; GsmXsmpServer* xsmp_server; + GSettings* debug_settings = NULL; GSettings* accessibility_settings; MdmSignalHandler* signal_handler; static char** override_autostart_dirs = NULL; @@ -574,6 +619,14 @@ int main(int argc, char** argv) exit(1); } + /* Allows to enable/disable debug from GSettings only if it is not set from argument */ + if (!debug && _gsettings_schema_exists(DEBUG_SCHEMA)) + { + debug_settings = g_settings_new (DEBUG_SCHEMA); + debug = g_settings_get_boolean (debug_settings, DEBUG_KEY); + g_signal_connect (debug_settings, "changed::" DEBUG_KEY, G_CALLBACK (debug_changed), NULL); + } + mdm_log_init(); mdm_log_set_debug(debug); @@ -656,6 +709,11 @@ int main(int argc, char** argv) g_object_unref(client_store); } + if (debug_settings != NULL) + { + g_object_unref(debug_settings); + } + msm_gnome_stop(); mdm_log_shutdown(); |