diff options
author | Havoc Pennington <hp@redhat.com> | 2002-03-20 19:08:30 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2002-03-20 19:08:30 +0000 |
commit | eb4089ef63a462bb78efca1505086e58877e8f0e (patch) | |
tree | 401dd44fb2028387c203368d3d412c35e6bd7581 | |
parent | 9801c9685c8853ae6a0439026663841a6c8dddba (diff) | |
download | gconf-eb4089ef63a462bb78efca1505086e58877e8f0e.tar.gz |
change all the "getters" to be functions not macros, so we can add
2002-03-20 Havoc Pennington <hp@redhat.com>
* gconf/gconf-value.c: change all the "getters" to be functions
not macros, so we can add g_return_if_fail and be typesafe and
generally suck less. Suggested most recently by Jody.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | doc/gconf/tmpl/gconf-value.sgml | 80 | ||||
-rw-r--r-- | gconf/gconf-sanity-check.c | 2 | ||||
-rw-r--r-- | gconf/gconf-value.c | 148 | ||||
-rw-r--r-- | gconf/gconf-value.h | 55 | ||||
-rw-r--r-- | gconf/gconfd.c | 6 |
6 files changed, 253 insertions, 44 deletions
@@ -1,3 +1,9 @@ +2002-03-20 Havoc Pennington <hp@redhat.com> + + * gconf/gconf-value.c: change all the "getters" to be functions + not macros, so we can add g_return_if_fail and be typesafe and + generally suck less. Suggested most recently by Jody. + 2002-03-19 Havoc Pennington <hp@pobox.com> * backends/xml-cache.c (dircmp): fix bad assertion reported diff --git a/doc/gconf/tmpl/gconf-value.sgml b/doc/gconf/tmpl/gconf-value.sgml index 31b8df1a..889c474f 100644 --- a/doc/gconf/tmpl/gconf-value.sgml +++ b/doc/gconf/tmpl/gconf-value.sgml @@ -107,7 +107,7 @@ inside the #GConfValue (such as lists, pair members, strings, and schemas). @value: a #GConfValue to destroy. -<!-- ##### MACRO gconf_value_get_string ##### --> +<!-- ##### FUNCTION gconf_value_get_string ##### --> <para> Returns a <symbol>const gchar*</symbol> for a #GConfValue with type %GCONF_VALUE_STRING. The returned string is <emphasis>not</emphasis> a @@ -122,35 +122,47 @@ gconf_value_set_string()) then the string may be uninitialized #GConfValue. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_int ##### --> +<!-- ##### FUNCTION gconf_value_get_int ##### --> <para> Returns a #gint for a #GConfValue with type %GCONF_VALUE_INT. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_float ##### --> +<!-- ##### FUNCTION gconf_value_get_float ##### --> <para> Returns a #gdouble for a #GConfValue with type %GCONF_VALUE_DOUBLE. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_list_type ##### --> +<!-- ##### FUNCTION gconf_value_get_list_type ##### --> <para> Returns the type of the list elements in a #GConfValue with type %GCONF_VALUE_LIST. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_list ##### --> +<!-- ##### FUNCTION gconf_value_get_list ##### --> <para> Returns a #GSList containing #GConfValue objects. Each #GConfValue in the returned list will have the type returned by @@ -159,10 +171,13 @@ gconf_value_get_list_type(). Remember that the empty #GSList is equal to #GConfValue and will be destroyed when the #GConfValue is destroyed. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_car ##### --> +<!-- ##### FUNCTION gconf_value_get_car ##### --> <para> Returns the first member (car) of a #GConfValue with type %GCONF_VALUE_PAIR. The car is another #GConfValue, with a primitive @@ -174,10 +189,13 @@ The returned value is not a copy; it is "owned" by the pair and will be destroyed when the pair is destroyed. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_cdr ##### --> +<!-- ##### FUNCTION gconf_value_get_cdr ##### --> <para> Returns the second member (cdr) of a #GConfValue with type %GCONF_VALUE_PAIR. The cdr is another #GConfValue, with a primitive @@ -189,18 +207,24 @@ The returned value is not a copy; it is "owned" by the pair and will be destroyed when the pair is destroyed. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_bool ##### --> +<!-- ##### FUNCTION gconf_value_get_bool ##### --> <para> Returns a #gboolean for a #GConfValue with type %GCONF_VALUE_BOOL. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. -<!-- ##### MACRO gconf_value_get_schema ##### --> +<!-- ##### FUNCTION gconf_value_get_schema ##### --> <para> Returns a #GConfSchema for a #GConfValue with type %GCONF_VALUE_SCHEMA. If the #GConfValue is uninitialized, it @@ -214,6 +238,9 @@ The returned value is not a copy; it is "owned" by the #GConfValue and will be destroyed when the #GConfValue is destroyed. </para> +@value: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfValue. @@ -406,27 +433,36 @@ with g_free(). @gcmi: -<!-- ##### MACRO gconf_meta_info_get_schema ##### --> +<!-- ##### FUNCTION gconf_meta_info_get_schema ##### --> <para> </para> +@gcmi: +@Returns: +<!-- # Unused Parameters # --> @x: -<!-- ##### MACRO gconf_meta_info_get_mod_user ##### --> +<!-- ##### FUNCTION gconf_meta_info_get_mod_user ##### --> <para> </para> +@gcmi: +@Returns: +<!-- # Unused Parameters # --> @x: -<!-- ##### MACRO gconf_meta_info_mod_time ##### --> +<!-- ##### FUNCTION gconf_meta_info_mod_time ##### --> <para> </para> +@gcmi: +@Returns: +<!-- # Unused Parameters # --> @x: @@ -506,16 +542,19 @@ Destroys a #GConfEntry, freeing the key, the value, and the entry itself. @entry: a #GConfEntry to free. -<!-- ##### MACRO gconf_entry_get_key ##### --> +<!-- ##### FUNCTION gconf_entry_get_key ##### --> <para> Accesses the @key field of a #GConfEntry. The returned key is not a copy, and should not be freed or modified. </para> +@entry: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfEntry. -<!-- ##### MACRO gconf_entry_get_value ##### --> +<!-- ##### FUNCTION gconf_entry_get_value ##### --> <para> Accesses the @value field of a #GConfEntry. The returned value is not a copy, and should not be freed or modified. If you have called @@ -523,6 +562,9 @@ gconf_entry_steal_value(), the returned value will be <symbol>NULL</symbol>. </para> +@entry: +@Returns: +<!-- # Unused Parameters # --> @x: a #GConfEntry. @@ -538,19 +580,25 @@ gconf_entry_steal_value() assumes ownership of it. @Returns: a #GConfValue that the caller must free. -<!-- ##### MACRO gconf_entry_get_is_default ##### --> +<!-- ##### FUNCTION gconf_entry_get_is_default ##### --> <para> </para> +@entry: +@Returns: +<!-- # Unused Parameters # --> @x: -<!-- ##### MACRO gconf_entry_get_schema_name ##### --> +<!-- ##### FUNCTION gconf_entry_get_schema_name ##### --> <para> </para> +@entry: +@Returns: +<!-- # Unused Parameters # --> @x: diff --git a/gconf/gconf-sanity-check.c b/gconf/gconf-sanity-check.c index 9d6dfebb..b1892a82 100644 --- a/gconf/gconf-sanity-check.c +++ b/gconf/gconf-sanity-check.c @@ -259,7 +259,7 @@ show_fatal_error_dialog (const char *format, if (!ensure_gtk ()) { - g_printerr ("%s", str); + g_printerr ("%s\n", str); return; } diff --git a/gconf/gconf-value.c b/gconf/gconf-value.c index 35961270..bd1016d6 100644 --- a/gconf/gconf-value.c +++ b/gconf/gconf-value.c @@ -791,6 +791,89 @@ gconf_value_free(GConfValue* value) g_free(value); } +const char* +gconf_value_get_string (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, NULL); + g_return_val_if_fail (value->type == GCONF_VALUE_STRING, NULL); + + return value->d.string_data; +} + +int +gconf_value_get_int (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, 0); + g_return_val_if_fail (value->type == GCONF_VALUE_INT, 0); + + return value->d.int_data; +} + +double +gconf_value_get_float (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, 0.0); + g_return_val_if_fail (value->type == GCONF_VALUE_FLOAT, 0.0); + + return value->d.float_data; +} + +GConfValueType +gconf_value_get_list_type (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, GCONF_VALUE_INVALID); + g_return_val_if_fail (value->type == GCONF_VALUE_LIST, GCONF_VALUE_INVALID); + + return value->d.list_data.type; +} + +GSList* +gconf_value_get_list (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, NULL); + g_return_val_if_fail (value->type == GCONF_VALUE_LIST, NULL); + + return value->d.list_data.list; +} + + +GConfValue* +gconf_value_get_car (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, NULL); + g_return_val_if_fail (value->type == GCONF_VALUE_PAIR, NULL); + + return value->d.pair_data.car; +} + +GConfValue* +gconf_value_get_cdr (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, NULL); + g_return_val_if_fail (value->type == GCONF_VALUE_PAIR, NULL); + + return value->d.pair_data.cdr; +} + + +gboolean +gconf_value_get_bool (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (value->type == GCONF_VALUE_BOOL, FALSE); + + return value->d.bool_data; +} + +GConfSchema* +gconf_value_get_schema (const GConfValue *value) +{ + g_return_val_if_fail (value != NULL, NULL); + g_return_val_if_fail (value->type == GCONF_VALUE_SCHEMA, NULL); + + return value->d.schema_data; +} + void gconf_value_set_int(GConfValue* value, gint the_int) { @@ -1168,6 +1251,30 @@ gconf_meta_info_free(GConfMetaInfo* gcmi) g_free(gcmi); } +const char* +gconf_meta_info_get_schema (GConfMetaInfo *gcmi) +{ + g_return_val_if_fail (gcmi != NULL, NULL); + + return gcmi->schema; +} + +const char* +gconf_meta_info_get_mod_user (GConfMetaInfo *gcmi) +{ + g_return_val_if_fail (gcmi != NULL, NULL); + + return gcmi->mod_user; +} + +GTime +gconf_meta_info_mod_time (GConfMetaInfo *gcmi) +{ + g_return_val_if_fail (gcmi != NULL, 0); + + return gcmi->mod_time; +} + void gconf_meta_info_set_schema (GConfMetaInfo* gcmi, const gchar* schema_name) @@ -1305,6 +1412,47 @@ gconf_entry_steal_value (GConfEntry* entry) return val; } +const char* +gconf_entry_get_key (const GConfEntry *entry) +{ + g_return_val_if_fail (entry != NULL, NULL); + + return entry->key; +} + +GConfValue* +gconf_entry_get_value (const GConfEntry *entry) +{ + g_return_val_if_fail (entry != NULL, NULL); + + return entry->value; +} + +const char* +gconf_entry_get_schema_name (const GConfEntry *entry) +{ + g_return_val_if_fail (entry != NULL, NULL); + + return entry->schema_name; +} + +gboolean +gconf_entry_get_is_default (const GConfEntry *entry) +{ + g_return_val_if_fail (entry != NULL, FALSE); + + return entry->is_default; +} + +gboolean +gconf_entry_get_is_writable (const GConfEntry *entry) +{ + g_return_val_if_fail (entry != NULL, FALSE); + + return entry->is_writable; +} + + void gconf_entry_set_value (GConfEntry *entry, const GConfValue *val) diff --git a/gconf/gconf-value.h b/gconf/gconf-value.h index 7c97402b..3077bb57 100644 --- a/gconf/gconf-value.h +++ b/gconf/gconf-value.h @@ -72,15 +72,15 @@ struct _GConfValue { } d; }; -#define gconf_value_get_string(x) ((const gchar*)(((GConfValue*)(x))->d.string_data)) -#define gconf_value_get_int(x) (((GConfValue*)(x))->d.int_data) -#define gconf_value_get_float(x) (((GConfValue*)(x))->d.float_data) -#define gconf_value_get_list_type(x) (((GConfValue*)(x))->d.list_data.type) -#define gconf_value_get_list(x) (((GConfValue*)(x))->d.list_data.list) -#define gconf_value_get_car(x) (((GConfValue*)(x))->d.pair_data.car) -#define gconf_value_get_cdr(x) (((GConfValue*)(x))->d.pair_data.cdr) -#define gconf_value_get_bool(x) (((GConfValue*)(x))->d.bool_data) -#define gconf_value_get_schema(x) (((GConfValue*)(x))->d.schema_data) +const char* gconf_value_get_string (const GConfValue *value); +int gconf_value_get_int (const GConfValue *value); +double gconf_value_get_float (const GConfValue *value); +GConfValueType gconf_value_get_list_type (const GConfValue *value); +GSList* gconf_value_get_list (const GConfValue *value); +GConfValue* gconf_value_get_car (const GConfValue *value); +GConfValue* gconf_value_get_cdr (const GConfValue *value); +gboolean gconf_value_get_bool (const GConfValue *value); +GConfSchema* gconf_value_get_schema (const GConfValue *value); GConfValue* gconf_value_new (GConfValueType type); @@ -127,6 +127,10 @@ gchar* gconf_value_to_string (const GConfValue* value); * that may apply to this key. */ +/* FIXME GConfMetaInfo is basically deprecated in favor of stuffing this + * info into GConfEntry, though the transition isn't complete. + */ + typedef struct _GConfMetaInfo GConfMetaInfo; struct _GConfMetaInfo { @@ -135,18 +139,19 @@ struct _GConfMetaInfo { GTime mod_time; /* time of the modification */ }; -#define gconf_meta_info_get_schema(x) ((const gchar*)((GConfMetaInfo*)(x))->schema) -#define gconf_meta_info_get_mod_user(x) (((GConfMetaInfo*)(x))->mod_user) -#define gconf_meta_info_mod_time(x) (((GConfMetaInfo*)(x))->mod_time) +const char* gconf_meta_info_get_schema (GConfMetaInfo *gcmi); +const char* gconf_meta_info_get_mod_user (GConfMetaInfo *gcmi); +GTime gconf_meta_info_mod_time (GConfMetaInfo *gcmi); + +GConfMetaInfo* gconf_meta_info_new (void); +void gconf_meta_info_free (GConfMetaInfo *gcmi); +void gconf_meta_info_set_schema (GConfMetaInfo *gcmi, + const gchar *schema_name); +void gconf_meta_info_set_mod_user (GConfMetaInfo *gcmi, + const gchar *mod_user); +void gconf_meta_info_set_mod_time (GConfMetaInfo *gcmi, + GTime mod_time); -GConfMetaInfo* gconf_meta_info_new (void); -void gconf_meta_info_free (GConfMetaInfo* gcmi); -void gconf_meta_info_set_schema (GConfMetaInfo* gcmi, - const gchar* schema_name); -void gconf_meta_info_set_mod_user(GConfMetaInfo* gcmi, - const gchar* mod_user); -void gconf_meta_info_set_mod_time(GConfMetaInfo* gcmi, - GTime mod_time); /* Key-value pairs; used to list the contents of @@ -171,11 +176,11 @@ struct _GConfEntry { guint pad7 : 1; }; -#define gconf_entry_get_key(x) ((const gchar*)((GConfEntry*)(x))->key) -#define gconf_entry_get_value(x) (((GConfEntry*)(x))->value) -#define gconf_entry_get_schema_name(x) ((const gchar*)((GConfEntry*)(x))->schema_name) -#define gconf_entry_get_is_default(x) (((GConfEntry*)(x))->is_default) -#define gconf_entry_get_is_writable(x) (((GConfEntry*)(x))->is_writable) +const char* gconf_entry_get_key (const GConfEntry *entry); +GConfValue* gconf_entry_get_value (const GConfEntry *entry); +const char* gconf_entry_get_schema_name (const GConfEntry *entry); +gboolean gconf_entry_get_is_default (const GConfEntry *entry); +gboolean gconf_entry_get_is_writable (const GConfEntry *entry); GConfEntry* gconf_entry_new (const gchar *key, const GConfValue *val); diff --git a/gconf/gconfd.c b/gconf/gconfd.c index cea16fb4..d70c6ebe 100644 --- a/gconf/gconfd.c +++ b/gconf/gconfd.c @@ -2310,7 +2310,9 @@ gconf_handle_segv (int signum) { /* Eeeek! Can't show dialog */ fprintf (stderr, _("Segmentation fault!\n" - "Cannot display crash dialog\n")); + "Cannot display crash dialog: %s\n"), + strerror (errno)); + fflush (stderr); /* Don't use app attributes here - a lot of things are probably hosed */ if (g_getenv ("GNOME_DUMP_CORE")) @@ -2341,7 +2343,7 @@ gconf_handle_segv (int signum) g_snprintf (buf, sizeof (buf), "%d", signum); /* Child process */ - execl (GCONF_BINDIR "/gnome_segv2", GCONF_BINDIR "/gnome_segv", + execl (GCONF_BINDIR "/gnome_segv2", GCONF_BINDIR "/gnome_segv2", GCONFD, buf, VERSION, NULL); |