[gnome-packagekit: 1/2] Set the install root at session startup



commit 214d295907e00a465a40a9f5acb727d4c6f623fb
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 6 16:09:12 2010 +0100

    Set the install root at session startup

 data/gnome-packagekit.schemas.in |   15 ++++++++++++
 src/gpk-common.h                 |    1 +
 src/gpk-watch.c                  |   48 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/data/gnome-packagekit.schemas.in b/data/gnome-packagekit.schemas.in
index 9205cef..958dd8a 100644
--- a/data/gnome-packagekit.schemas.in
+++ b/data/gnome-packagekit.schemas.in
@@ -591,6 +591,21 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/gnome-packagekit/install_root</key>
+      <applyto>/apps/gnome-packagekit/install_root</applyto>
+      <owner>gnome-packagekit</owner>
+      <type>string</type>
+      <default>/</default>
+      <locale name="C">
+        <short>
+	  <!-- TRANSLATORS: The install root is the base directory used in the filesystem -->
+	  The install root used when installing and removing packages.
+	</short>
+        <long>Allow the user to change the install root when processing packages, for instance when using LTSP.</long>
+      </locale>
+    </schema>
+
   </schemalist>
 </gconfschemafile>
 
diff --git a/src/gpk-common.h b/src/gpk-common.h
index ff0b794..2851b92 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
 #define GPK_CONF_ENABLE_CHECK_FIRMWARE		"/apps/gnome-packagekit/enable_check_firmware"
 #define GPK_CONF_ENABLE_CHECK_HARDWARE		"/apps/gnome-packagekit/enable_check_hardware"
 #define GPK_CONF_IGNORED_DBUS_REQUESTS		"/apps/gnome-packagekit/ignored_dbus_requests"
+#define GPK_CONF_INSTALL_ROOT			"/apps/gnome-packagekit/install_root"
 #define GPK_CONF_REPO_SHOW_DETAILS		"/apps/gnome-packagekit/repo/show_details"
 #define GPK_CONF_CONNECTION_USE_MOBILE		"/apps/gnome-packagekit/update-icon/connection_use_mobile"
 #define GPK_CONF_CONNECTION_USE_WIFI		"/apps/gnome-packagekit/update-icon/connection_use_wifi"
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index 7ab51c7..353ee82 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -1159,6 +1159,50 @@ gpk_watch_set_proxies (GpkWatch *watch)
 	return TRUE;
 }
 
+#if PK_CHECK_VERSION(0,6,4)
+/**
+ * gpk_watch_set_root_cb:
+ **/
+static void
+gpk_watch_set_root_cb (GObject *object, GAsyncResult *res, GpkWatch *watch)
+{
+	PkControl *control = PK_CONTROL (object);
+	GError *error = NULL;
+	gboolean ret;
+
+	/* get the result */
+	ret = pk_control_set_root_finish (control, res, &error);
+	if (!ret) {
+		egg_warning ("failed to set install root: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+}
+
+/**
+ * gpk_watch_set_root:
+ **/
+static void
+gpk_watch_set_root (GpkWatch *watch)
+{
+	gchar *root;
+
+	/* get from GConf */
+	root = gconf_client_get_string (watch->priv->gconf_client, GPK_CONF_INSTALL_ROOT, NULL);
+	if (root == NULL) {
+		egg_warning ("could not read install root");
+		goto out;
+	}
+
+	pk_control_set_root_async (watch->priv->control, root, watch->priv->cancellable,
+				   (GAsyncReadyCallback) gpk_watch_set_root_cb, watch);
+out:
+	g_free (root);
+}
+#else
+static void gpk_watch_set_root (GpkWatch *watch) {}
+#endif
+
 /**
  * gpk_watch_gconf_key_changed_cb:
  *
@@ -1168,8 +1212,8 @@ static void
 gpk_watch_gconf_key_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, GpkWatch *watch)
 {
 	egg_debug ("keys have changed");
-	/* set the proxy */
 	gpk_watch_set_proxies (watch);
+	gpk_watch_set_root (watch);
 }
 
 /**
@@ -1207,6 +1251,7 @@ gpk_watch_set_connected (GpkWatch *watch, gboolean connected)
 	gpk_watch_refresh_icon (watch);
 	gpk_watch_refresh_tooltip (watch);
 	gpk_watch_set_proxies (watch);
+	gpk_watch_set_root (watch);
 }
 
 /**
@@ -1801,6 +1846,7 @@ gpk_watch_init (GpkWatch *watch)
 
 	/* set the proxy */
 	gpk_watch_set_proxies (watch);
+	gpk_watch_set_root (watch);
 }
 
 /**



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