[gnome-panel] libpanel-applet: Stop printing errors for gconf API
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] libpanel-applet: Stop printing errors for gconf API
- Date: Thu, 24 Feb 2011 23:06:12 +0000 (UTC)
commit 7f5052cf32f45a050c6c04cd0c4aa7f25594d6af
Author: Vincent Untz <vuntz gnome org>
Date: Thu Feb 24 23:44:58 2011 +0100
libpanel-applet: Stop printing errors for gconf API
If the caller doesn't care about errors, then it's not up to the library
to compensate.
libpanel-applet/panel-applet-gconf.c | 192 ++++-----------------------------
libpanel-applet/panel-applet-gconf.h | 24 ++--
libpanel-applet/panel-applet.c | 22 ++--
libpanel-applet/panel-applet.h | 2 +-
4 files changed, 48 insertions(+), 192 deletions(-)
---
diff --git a/libpanel-applet/panel-applet-gconf.c b/libpanel-applet/panel-applet-gconf.c
index f7b4575..8572d39 100644
--- a/libpanel-applet/panel-applet-gconf.c
+++ b/libpanel-applet/panel-applet-gconf.c
@@ -85,7 +85,7 @@ panel_applet_gconf_get_full_key (PanelApplet *applet,
* @applet: a #PanelApplet.
* @key: a GConf key name.
* @the_bool: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_bool() to update @key in the
* per-instance GConf directory of @applet.
@@ -94,20 +94,13 @@ void
panel_applet_gconf_set_bool (PanelApplet *applet,
const gchar *key,
gboolean the_bool,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -115,11 +108,6 @@ panel_applet_gconf_set_bool (PanelApplet *applet,
gconf_client_set_bool (client, full_key, the_bool, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
@@ -127,7 +115,7 @@ panel_applet_gconf_set_bool (PanelApplet *applet,
* @applet: a #PanelApplet.
* @key: a GConf key name.
* @the_int: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_int() to update @key in the
* per-instance GConf directory of @applet.
@@ -136,20 +124,13 @@ void
panel_applet_gconf_set_int (PanelApplet *applet,
const gchar *key,
gint the_int,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -157,11 +138,6 @@ panel_applet_gconf_set_int (PanelApplet *applet,
gconf_client_set_int (client, full_key, the_int, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
@@ -169,7 +145,7 @@ panel_applet_gconf_set_int (PanelApplet *applet,
* @applet: a #PanelApplet.
* @key: a GConf key name.
* @the_string: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_string() to update @key in the
* per-instance GConf directory of @applet.
@@ -178,20 +154,13 @@ void
panel_applet_gconf_set_string (PanelApplet *applet,
const gchar *key,
const gchar *the_string,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -199,11 +168,6 @@ panel_applet_gconf_set_string (PanelApplet *applet,
gconf_client_set_string (client, full_key, the_string, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
@@ -211,7 +175,7 @@ panel_applet_gconf_set_string (PanelApplet *applet,
* @applet: a #PanelApplet.
* @key: a GConf key name.
* @the_float: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_float() to update @key in the
* per-instance GConf directory of @applet.
@@ -220,20 +184,13 @@ void
panel_applet_gconf_set_float (PanelApplet *applet,
const gchar *key,
gdouble the_float,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -241,11 +198,6 @@ panel_applet_gconf_set_float (PanelApplet *applet,
gconf_client_set_float (client, full_key, the_float, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
@@ -254,7 +206,7 @@ panel_applet_gconf_set_float (PanelApplet *applet,
* @key: a GConf key name.
* @list_type: type of items in @list.
* @list: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_list() to update @key in the
* per-instance GConf directory of @applet.
@@ -264,20 +216,13 @@ panel_applet_gconf_set_list (PanelApplet *applet,
const gchar *key,
GConfValueType list_type,
GSList *list,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -285,11 +230,6 @@ panel_applet_gconf_set_list (PanelApplet *applet,
gconf_client_set_list (client, full_key, list_type, list, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
@@ -297,7 +237,7 @@ panel_applet_gconf_set_list (PanelApplet *applet,
* @applet: a #PanelApplet.
* @key: a GConf key name.
* @value: new value for @key.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_set_value() to update @key in the
* per-instance GConf directory of @applet.
@@ -306,20 +246,13 @@ void
panel_applet_gconf_set_value (PanelApplet *applet,
const gchar *key,
GConfValue *value,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -327,18 +260,13 @@ panel_applet_gconf_set_value (PanelApplet *applet,
gconf_client_set (client, full_key, value, error);
g_free (full_key);
-
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
}
/**
* panel_applet_gconf_get_bool:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_bool() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -348,21 +276,14 @@ panel_applet_gconf_set_value (PanelApplet *applet,
gboolean
panel_applet_gconf_get_bool (PanelApplet *applet,
const gchar *key,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
gboolean retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -371,11 +292,6 @@ panel_applet_gconf_get_bool (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
@@ -383,7 +299,7 @@ panel_applet_gconf_get_bool (PanelApplet *applet,
* panel_applet_gconf_get_int:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_int() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -393,21 +309,14 @@ panel_applet_gconf_get_bool (PanelApplet *applet,
gint
panel_applet_gconf_get_int (PanelApplet *applet,
const gchar *key,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
gint retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), -1);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -416,11 +325,6 @@ panel_applet_gconf_get_int (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
@@ -428,7 +332,7 @@ panel_applet_gconf_get_int (PanelApplet *applet,
* panel_applet_gconf_get_string:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_string() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -438,21 +342,14 @@ panel_applet_gconf_get_int (PanelApplet *applet,
gchar *
panel_applet_gconf_get_string (PanelApplet *applet,
const gchar *key,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
gchar *retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -461,11 +358,6 @@ panel_applet_gconf_get_string (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
@@ -473,7 +365,7 @@ panel_applet_gconf_get_string (PanelApplet *applet,
* panel_applet_gconf_get_float:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_float() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -483,21 +375,14 @@ panel_applet_gconf_get_string (PanelApplet *applet,
gdouble
panel_applet_gconf_get_float (PanelApplet *applet,
const gchar *key,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
gdouble retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -506,11 +391,6 @@ panel_applet_gconf_get_float (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
@@ -518,7 +398,7 @@ panel_applet_gconf_get_float (PanelApplet *applet,
* panel_applet_gconf_get_value:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_value() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -528,21 +408,14 @@ panel_applet_gconf_get_float (PanelApplet *applet,
GConfValue *
panel_applet_gconf_get_value (PanelApplet *applet,
const gchar *key,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
GConfValue *retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -551,11 +424,6 @@ panel_applet_gconf_get_value (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
@@ -563,7 +431,7 @@ panel_applet_gconf_get_value (PanelApplet *applet,
* panel_applet_gconf_get_list:
* @applet: a #PanelApplet.
* @key: a GConf key name.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Convenience wrapper around gconf_client_get_list() to get the value of @key
* in the per-instance GConf directory of @applet.
@@ -575,21 +443,14 @@ GSList *
panel_applet_gconf_get_list (PanelApplet *applet,
const gchar *key,
GConfValueType list_type,
- GError **opt_error)
+ GError **error)
{
GConfClient *client;
gchar *full_key;
GSList *retval;
- GError **error = NULL;
- GError *our_error = NULL;
g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
- if (opt_error)
- error = opt_error;
- else
- error = &our_error;
-
full_key = panel_applet_gconf_get_full_key (applet, key);
client = panel_applet_gconf_get_client ();
@@ -598,10 +459,5 @@ panel_applet_gconf_get_list (PanelApplet *applet,
g_free (full_key);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
- g_error_free (our_error);
- }
-
return retval;
}
diff --git a/libpanel-applet/panel-applet-gconf.h b/libpanel-applet/panel-applet-gconf.h
index eb6de4a..c5278a1 100644
--- a/libpanel-applet/panel-applet-gconf.h
+++ b/libpanel-applet/panel-applet-gconf.h
@@ -38,48 +38,48 @@ gchar *panel_applet_gconf_get_full_key (PanelApplet *applet,
void panel_applet_gconf_set_bool (PanelApplet *applet,
const gchar *key,
gboolean the_bool,
- GError **opt_error);
+ GError **error);
void panel_applet_gconf_set_int (PanelApplet *applet,
const gchar *key,
gint the_int,
- GError **opt_error);
+ GError **error);
void panel_applet_gconf_set_string (PanelApplet *applet,
const gchar *key,
const gchar *the_string,
- GError **opt_error);
+ GError **error);
void panel_applet_gconf_set_float (PanelApplet *applet,
const gchar *key,
gdouble the_float,
- GError **opt_error);
+ GError **error);
void panel_applet_gconf_set_list (PanelApplet *applet,
const gchar *key,
GConfValueType list_type,
GSList *list,
- GError **opt_error);
+ GError **error);
void panel_applet_gconf_set_value (PanelApplet *applet,
const gchar *key,
GConfValue *value,
- GError **opt_error);
+ GError **error);
gboolean panel_applet_gconf_get_bool (PanelApplet *applet,
const gchar *key,
- GError **opt_error);
+ GError **error);
gint panel_applet_gconf_get_int (PanelApplet *applet,
const gchar *key,
- GError **opt_error);
+ GError **error);
gchar *panel_applet_gconf_get_string (PanelApplet *applet,
const gchar *key,
- GError **opt_error);
+ GError **error);
gdouble panel_applet_gconf_get_float (PanelApplet *applet,
const gchar *key,
- GError **opt_error);
+ GError **error);
GSList *panel_applet_gconf_get_list (PanelApplet *applet,
const gchar *key,
GConfValueType list_type,
- GError **opt_error);
+ GError **error);
GConfValue *panel_applet_gconf_get_value (PanelApplet *applet,
const gchar *key,
- GError **opt_error);
+ GError **error);
G_END_DECLS
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index 2956730..80a8d0f 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -194,6 +194,8 @@ panel_applet_associate_schemas_in_dir (GConfClient *client,
{
GSList *list, *l;
+ g_assert (error != NULL);
+
list = gconf_client_all_entries (client, schema_dir, error);
if (*error != NULL)
@@ -292,7 +294,7 @@ panel_applet_associate_schemas_in_dir (GConfClient *client,
* panel_applet_add_preferences:
* @applet: a #PanelApplet.
* @schema_dir: a GConf path of a schema directory.
- * @opt_error: a #GError, or %NULL.
+ * @error: a #GError, or %NULL.
*
* Associates the per-instance GConf directory of @applet to the schemas
* defined in @schema_dir. This must be called if the applet will save
@@ -302,9 +304,9 @@ panel_applet_associate_schemas_in_dir (GConfClient *client,
void
panel_applet_add_preferences (PanelApplet *applet,
const gchar *schema_dir,
- GError **opt_error)
+ GError **error)
{
- GError **error = NULL;
+ GError **_error = NULL;
GError *our_error = NULL;
g_return_if_fail (PANEL_IS_APPLET (applet));
@@ -313,21 +315,19 @@ panel_applet_add_preferences (PanelApplet *applet,
if (!applet->priv->prefs_key)
return;
- if (opt_error)
- error = opt_error;
+ /* panel_applet_associate_schemas_in_dir() requires a non-NULL error */
+ if (error)
+ _error = error;
else
- error = &our_error;
+ _error = &our_error;
panel_applet_associate_schemas_in_dir (applet->priv->client,
applet->priv->prefs_key,
schema_dir,
- error);
+ _error);
- if (!opt_error && our_error) {
- g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'",
- schema_dir, our_error->message);
+ if (!error && our_error)
g_error_free (our_error);
- }
}
/**
diff --git a/libpanel-applet/panel-applet.h b/libpanel-applet/panel-applet.h
index 8ad64e1..de4fe4a 100644
--- a/libpanel-applet/panel-applet.h
+++ b/libpanel-applet/panel-applet.h
@@ -140,7 +140,7 @@ gchar *panel_applet_get_preferences_key (PanelApplet *applet);
void panel_applet_add_preferences (PanelApplet *applet,
const gchar *schema_dir,
- GError **opt_error);
+ GError **error);
PanelAppletFlags panel_applet_get_flags (PanelApplet *applet);
void panel_applet_set_flags (PanelApplet *applet,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]