[gnome-color-manager] Add PackageKit integration so we can install shared-color-targets in the future
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add PackageKit integration so we can install shared-color-targets in the future
- Date: Wed, 16 Dec 2009 11:52:12 +0000 (UTC)
commit 22edd68c26e94d8ee62cb33a068d1af2302b5339
Author: Richard Hughes <richard hughsie com>
Date: Wed Dec 16 11:37:48 2009 +0000
Add PackageKit integration so we can install shared-color-targets in the future
src/Makefile.am | 2 ++
src/gcm-utils.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/gcm-utils.h | 3 +++
3 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 2884d05..4994a00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -120,6 +120,7 @@ gcm_apply_LDADD = \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
$(XORG_LIBS) \
+ $(DBUS_GLIB_LIBS) \
$(GTK_LIBS)
gcm_apply_CFLAGS = \
@@ -136,6 +137,7 @@ gcm_import_LDADD = \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
$(XORG_LIBS) \
+ $(DBUS_GLIB_LIBS) \
$(GTK_LIBS)
gcm_import_CFLAGS = \
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 1aa86f5..624f406 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -28,6 +28,7 @@
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/xf86vmode.h>
#include <gconf/gconf-client.h>
+#include <dbus/dbus-glib.h>
#include "gcm-utils.h"
#include "gcm-clut.h"
@@ -36,6 +37,52 @@
#include "egg-debug.h"
/**
+ * gcm_utils_install_package:
+ **/
+gboolean
+gcm_utils_install_package (const gchar *package_name, GtkWindow *window)
+{
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ gboolean ret;
+ guint32 xid = 0;
+ gchar **packages = NULL;
+
+ /* get xid of this window */
+ if (window != NULL)
+ xid = gdk_x11_drawable_get_xid (gtk_widget_get_window (GTK_WIDGET(window)));
+
+ /* we're expecting an array of packages */
+ packages = g_strsplit (package_name, "|", 1);
+
+ /* get a session bus connection */
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+ /* connect to PackageKit */
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit.Modify");
+
+ /* execute sync method */
+ ret = dbus_g_proxy_call (proxy, "InstallPackageNames", &error,
+ G_TYPE_UINT, xid,
+ G_TYPE_STRV, packages,
+ G_TYPE_STRING, "hide-confirm-search,hide-finished",
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ if (!ret) {
+ egg_warning ("failed to install package: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+out:
+ g_object_unref (proxy);
+ g_strfreev (packages);
+ return ret;
+}
+
+/**
* gcm_utils_output_is_lcd_internal:
* @output_name: the output name
*
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index a570d6b..ccf0f90 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -23,6 +23,7 @@
#define __GCM_UTILS_H
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "gcm-device.h"
#include "gcm-profile.h"
@@ -52,6 +53,8 @@ void gcm_utils_ensure_sensible_filename (gchar *string);
gchar *gcm_utils_get_default_config_location (void);
GcmProfileType gcm_utils_device_type_to_profile_type (GcmDeviceType type);
gchar *gcm_utils_format_date_time (const struct tm *created);
+gboolean gcm_utils_install_package (const gchar *package_name,
+ GtkWindow *window);
#endif /* __GCM_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]