[gnome-control-center] info: Set the transient hostname too



commit 7889482576449d71f56cb4ab77e6b3b3818e99f1
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 16 19:59:14 2012 +0100

    info: Set the transient hostname too
    
    As we need that to get the right name from "hostname".

 panels/common/gnome-control-center.rules |    3 ++-
 panels/info/cc-info-panel.c              |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/panels/common/gnome-control-center.rules b/panels/common/gnome-control-center.rules
index b141312..d5cff46 100644
--- a/panels/common/gnome-control-center.rules
+++ b/panels/common/gnome-control-center.rules
@@ -1,5 +1,6 @@
 polkit.addRule(function(action, subject) {
-	if (action.id == "org.freedesktop.hostname1.set-static-hostname" &&
+	if ((action.id == "org.freedesktop.hostname1.set-static-hostname" ||
+	     action.id == "org.freedesktop.hostname1.set-hostname") &&
 	    subject.local &&
 	    subject.active &&
 	    subject.isInGroup ("wheel")) {
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index e5ff4d2..d2225dd 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -1651,7 +1651,7 @@ info_panel_set_hostname (CcInfoPanel *self)
       g_variant_unref (variant);
     }
 
-  /* Set the static hostname */
+  /* Set the static and transient hostname */
   hostname = pretty_hostname_to_static (text, FALSE);
   g_assert (hostname);
 
@@ -1670,6 +1670,22 @@ info_panel_set_hostname (CcInfoPanel *self)
     {
       g_variant_unref (variant);
     }
+
+  g_debug ("Setting Hostname to '%s'", hostname);
+  variant = g_dbus_proxy_call_sync (self->priv->hostnamed_proxy,
+                                    "SetHostname",
+                                    g_variant_new ("(sb)", hostname, FALSE),
+                                    G_DBUS_CALL_FLAGS_NONE,
+                                    -1, NULL, &error);
+  if (variant == NULL)
+    {
+      g_warning ("Could not set Hostname: %s", error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      g_variant_unref (variant);
+    }
   g_free (hostname);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]