[gnome-control-center] info: Do fallback correctly when reading hostnames
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] info: Do fallback correctly when reading hostnames
- Date: Sun, 18 Sep 2011 12:20:31 +0000 (UTC)
commit 97af2049fd49e8ea04a7f006e07cc26685e024c1
Author: Bastien Nocera <hadess hadess net>
Date: Sun Sep 18 13:17:58 2011 +0100
info: Do fallback correctly when reading hostnames
We need to read the hostname when the pretty hostname is
undefined, as it would be on default installations.
panels/info/cc-info-panel.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index 6cf42c7..ba3a15a 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -1506,13 +1506,14 @@ info_panel_setup_selector (CcInfoPanel *self)
}
static char *
-info_panel_get_hostname (CcInfoPanel *self)
+get_hostname_property (CcInfoPanel *self,
+ const char *property)
{
GVariant *variant;
char *str;
variant = g_dbus_proxy_get_cached_property (self->priv->hostnamed_proxy,
- "PrettyHostname");
+ property);
if (!variant)
{
GError *error = NULL;
@@ -1522,14 +1523,14 @@ info_panel_get_hostname (CcInfoPanel *self)
* the property value when changing values */
variant = g_dbus_proxy_call_sync (self->priv->hostnamed_proxy,
"org.freedesktop.DBus.Properties.Get",
- g_variant_new ("(ss)", "org.freedesktop.hostname1", "PrettyHostname"),
+ g_variant_new ("(ss)", "org.freedesktop.hostname1", property),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if (variant == NULL)
{
- g_warning ("Failed to get property 'PrettyHostname': %s", error->message);
+ g_warning ("Failed to get property '%s': %s", property, error->message);
g_error_free (error);
return NULL;
}
@@ -1544,12 +1545,22 @@ info_panel_get_hostname (CcInfoPanel *self)
g_variant_unref (variant);
}
+ return str;
+}
+
+static char *
+info_panel_get_hostname (CcInfoPanel *self)
+{
+ char *str;
+
+ str = get_hostname_property (self, "PrettyHostname");
+
/* Empty strings means that we need to fallback */
if (str != NULL &&
*str == '\0')
{
g_free (str);
- str = NULL;
+ str = get_hostname_property (self, "Hostname");
}
return str;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]