diff options
author | Thomas James Alexander Thurman <tthurman@src.gnome.org> | 2008-05-20 04:32:44 +0000 |
---|---|---|
committer | Thomas James Alexander Thurman <tthurman@src.gnome.org> | 2008-05-20 04:32:44 +0000 |
commit | f9dd0d59f935af98b60d27e1ab1f40c0d7984aff (patch) | |
tree | 5264d6888ac22d734606222dd648396a5a9652a7 | |
parent | 969475cc95d74800412f06080896a3617e08f57b (diff) | |
download | metacity-f9dd0d59f935af98b60d27e1ab1f40c0d7984aff.tar.gz |
Partial checkin
svn path=/branches/test-system/; revision=3719
-rw-r--r-- | src/core/prefs.c | 87 | ||||
-rw-r--r-- | src/core/testing.c | 13 | ||||
-rw-r--r-- | src/core/testing.h | 2 | ||||
-rw-r--r-- | test/basic-test.py | 4 |
4 files changed, 96 insertions, 10 deletions
diff --git a/src/core/prefs.c b/src/core/prefs.c index 7a1473f9..db0b348b 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -32,6 +32,10 @@ #include <string.h> #include <stdlib.h> +#ifdef USING_TESTING +#include "testing.h" +#endif /* USING_TESTING */ + #define MAX_REASONABLE_WORKSPACES 36 #define MAX_COMMANDS (32 + NUM_EXTRA_COMMANDS) @@ -126,6 +130,11 @@ static gboolean update_workspace_name (const char *name, const char *value); static gboolean update_cursor_size (int size); +static void handle_configuration_update (const char *key, + GConfValue *value); + +static char* prefs_testing_handler (char type, char *details); + static void change_notify (GConfClient *client, guint cnxn_id, GConfEntry *entry, @@ -913,6 +922,15 @@ meta_prefs_init (void) /* workspace names */ init_workspace_names (); +#ifdef USING_TESTING + + meta_warning ("We could call %p or %p\n", prefs_testing_handler, change_notify); + + /* testing, if we're doing testing */ + meta_testing_register (prefs_testing_handler); + +#endif /* USING_TESTING */ + } #ifdef HAVE_GCONF @@ -924,18 +942,77 @@ gboolean (*preference_update_handler[]) (const gchar*, GConfValue*) = { NULL }; +#ifdef USING_TESTING +static char* +prefs_testing_handler (char type, char *details) +{ +#ifdef HAVE_GCONF + GConfValue value; + char *space_position = NULL; + char *key = NULL; + + if (type!='C' || strlen(details)<3 || details[1]!=' ') + return NULL; + + space_position = strchr (details+2, ' '); + + if (space_position==NULL || *(space_position+1)==0) + return NULL; + + key = g_strndup (details+2, (space_position-details)-2); + + meta_warning ("Key is [%s], value is [%s]\n", key, space_position+1); + + /* FIXME: Does gconf_value_set_* set the type too? */ + switch (details[0]) + { + case 'I': + value.type = GCONF_VALUE_INT; + /* gconf_value_set_int (value, xxx atoi or something FIXME */ + break; + + case 'S': + value.type = GCONF_VALUE_STRING; + break; + + case 'B': + value.type = GCONF_VALUE_BOOL; + gconf_valu + break; + + default: + meta_verbose ("Strange configuration type: %s\n", details); + return NULL; + } + + handle_configuration_update (key, &value); + + return g_strdup("Y"); /* success */ + +#else /* HAVE_GCONF */ + + return g_strdup("N"); /* impossible! */ + +#endif /* HAVE_GCONF */ + +} +#endif /* USING_TESTING */ + static void change_notify (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) { - const char *key; - GConfValue *value; + handle_configuration_update (gconf_entry_get_key (entry), + gconf_entry_get_value (entry)); +} + +static void +handle_configuration_update (const char *key, + GConfValue *value) +{ gint i=0; - - key = gconf_entry_get_key (entry); - value = gconf_entry_get_value (entry); /* First, search for a handler that might know what to do. */ diff --git a/src/core/testing.c b/src/core/testing.c index 650a397a..74450b73 100644 --- a/src/core/testing.c +++ b/src/core/testing.c @@ -33,9 +33,11 @@ static GSList *handlers = NULL; void -meta_testing_register (MetaTestingHandler *handler) +meta_testing_register (MetaTestingHandler handler) { handlers = g_slist_prepend (handlers, handler); + + g_warning ("New testing handler registered: %p\n", handler); } char * @@ -51,20 +53,27 @@ meta_testing_notify (char type, char *details) GSList *cursor = handlers; + g_warning ("We are notifying.\n"); + g_warning ("The type is %c and the details are [%s].\n", type, details); + while (cursor) { char *possible_result; + MetaTestingHandler handler = (MetaTestingHandler) cursor->data; - possible_result = (*((MetaTestingHandler*)cursor->data)) (type, details); + g_warning ("What about %p?\n", handler); + possible_result = (*handler) (type, details); if (possible_result) { + g_warning ("Yes. The answer is [%s].\n", possible_result); return possible_result; } cursor = g_slist_next (cursor); } + g_warning ("No. Giving up with the testing.\n"); return NULL; /* Give up. */ } diff --git a/src/core/testing.h b/src/core/testing.h index 23dd5aff..9bf26b39 100644 --- a/src/core/testing.h +++ b/src/core/testing.h @@ -48,7 +48,7 @@ typedef char* (* MetaTestingHandler) (char type, char *details); * * \param handler The handler. */ -void meta_testing_register (MetaTestingHandler *handler); +void meta_testing_register (MetaTestingHandler handler); /** * After a __METACITY_TESTING property has been set, this function runs diff --git a/test/basic-test.py b/test/basic-test.py index ac1adb1b..5f6b7d95 100644 --- a/test/basic-test.py +++ b/test/basic-test.py @@ -51,7 +51,7 @@ def query_window_manager (type, details): return result[2:] -query = '1' +query = 'B /apps/metacity/general/disable_workarounds 1' print 'Querying window manager with the query: ',query -print 'Received result: ',query_window_manager ('A', query) +print 'Received result: ',query_window_manager ('C', query) |