gnome-packagekit r305 - in trunk: . po src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r305 - in trunk: . po src
- Date: Fri, 26 Sep 2008 10:09:34 +0000 (UTC)
Author: rhughes
Date: Fri Sep 26 10:09:33 2008
New Revision: 305
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=305&view=rev
Log:
from git
Added:
trunk/src/gpk-hardware.c
trunk/src/gpk-hardware.h
Modified:
trunk/configure.ac
trunk/po/POTFILES.in
trunk/src/gpk-client-dialog.c
trunk/src/gpk-client.c
trunk/src/gpk-update-viewer.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Sep 26 10:09:33 2008
@@ -25,7 +25,7 @@
if test "$GCC" = "yes"; then
CPPFLAGS="$CPPFLAGS -Werror -Wcast-align -Wno-uninitialized"
CPPFLAGS="$CPPFLAGS -Wall -Wformat-security"
- CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES"
+# CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES"
CPPFLAGS="$CPPFLAGS -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED"
CPPFLAGS="$CPPFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE"
fi
@@ -97,7 +97,7 @@
AC_SUBST(DBUS_LIBS)
PKG_CHECK_MODULES(GTK, \
- gtk+-2.0 >= $GTK_REQUIRED)
+ gtk+-2.0 >= $GTK_REQUIRED, gdk-2.0)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Fri Sep 26 10:09:33 2008
@@ -37,6 +37,7 @@
src/gpk-dialog.c
src/gpk-error.c
src/gpk-firmware.c
+src/gpk-hardware.c
src/gpk-inhibit.c
src/gpk-install-catalog.c
src/gpk-install-local-file.c
Modified: trunk/src/gpk-client-dialog.c
==============================================================================
--- trunk/src/gpk-client-dialog.c (original)
+++ trunk/src/gpk-client-dialog.c Fri Sep 26 10:09:33 2008
@@ -189,7 +189,7 @@
if (window == NULL) {
egg_warning ("parent set NULL when already modal with another window, setting non-modal");
widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
- gtk_window_set_modal (GTK_WINDOW(widget), FALSE);
+ gtk_window_set_modal (GTK_WINDOW (widget), FALSE);
return FALSE;
}
@@ -201,7 +201,8 @@
widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
gtk_widget_realize (widget);
- gdk_window_set_transient_for (GTK_WIDGET(widget)->window, window);
+ gtk_window_set_modal (GTK_WINDOW (widget), TRUE);
+ gdk_window_set_transient_for (GTK_WIDGET (widget)->window, window);
dialog->priv->has_parent = TRUE;
return TRUE;
}
Modified: trunk/src/gpk-client.c
==============================================================================
--- trunk/src/gpk-client.c (original)
+++ trunk/src/gpk-client.c Fri Sep 26 10:09:33 2008
@@ -1073,8 +1073,6 @@
icon = "emblem-system";
title_name = g_strdup_printf ("%s %s", application_localised, title);
-
- gpk_client_dialog_set_parent (gclient->priv->dialog, gclient->priv->parent_window);
gpk_client_dialog_set_title (gclient->priv->dialog, title_name);
gpk_client_dialog_set_message (gclient->priv->dialog, message);
gpk_client_dialog_set_image (gclient->priv->dialog, icon);
@@ -2949,6 +2947,8 @@
{
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
gclient->priv->parent_window = GTK_WIDGET (window)->window;
+ egg_debug ("parent_window=%p", gclient->priv->parent_window);
+ gpk_client_dialog_set_parent (gclient->priv->dialog, gclient->priv->parent_window);
return TRUE;
}
@@ -2963,6 +2963,8 @@
display = gdk_display_get_default ();
gclient->priv->parent_window = gdk_window_foreign_new_for_display (display, xid);
+ egg_debug ("parent_window=%p", gclient->priv->parent_window);
+ gpk_client_dialog_set_parent (gclient->priv->dialog, gclient->priv->parent_window);
return TRUE;
}
Added: trunk/src/gpk-hardware.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-hardware.c Fri Sep 26 10:09:33 2008
@@ -0,0 +1,291 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Scott Reeves <sreeves novell com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+#include <libnotify/notify.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+
+#include <pk-client.h>
+#include <pk-common.h>
+#include <pk-task-list.h>
+
+#include "egg-debug.h"
+#include "egg-string.h"
+#include "egg-string-list.h"
+
+#include "gpk-client.h"
+#include "gpk-common.h"
+#include "gpk-hardware.h"
+
+static void gpk_hardware_class_init (GpkHardwareClass *klass);
+static void gpk_hardware_init (GpkHardware *hardware);
+static void gpk_hardware_finalize (GObject *object);
+
+#define GPK_HARDWARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_HARDWARE, GpkHardwarePrivate))
+#define GPK_HARDWARE_LOGIN_DELAY 50 /* seconds */
+#define GPK_HARDWARE_INSTALL_ACTION "GpkHardware - install this package"
+#define GPK_HARDWARE_DONT_PROMPT_ACTION "GpkHardware - dont prompt again"
+
+struct GpkHardwarePrivate
+{
+ GConfClient *gconf_client;
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ gchar **package_ids;
+};
+
+G_DEFINE_TYPE (GpkHardware, gpk_hardware, G_TYPE_OBJECT)
+
+/**
+ * gpk_hardware_install_package:
+ **/
+static gboolean
+gpk_hardware_install_package (GpkHardware *hardware)
+{
+ GError *error = NULL;
+ GpkClient *gclient = NULL;
+ gboolean ret;
+
+ gclient = gpk_client_new ();
+
+ ret = gpk_client_install_package_ids (gclient, hardware->priv->package_ids, &error);
+ if (!ret) {
+ egg_warning ("failed to install package: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ g_object_unref (gclient);
+ return ret;
+}
+
+/**
+ * gpk_hardware_libnotify_cb:
+ **/
+static void
+gpk_hardware_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
+{
+ GpkHardware *hardware = GPK_HARDWARE (data);
+
+ if (egg_strequal (action, GPK_HARDWARE_INSTALL_ACTION)) {
+ gpk_hardware_install_package (hardware);
+ } else if (egg_strequal (action, GPK_HARDWARE_DONT_PROMPT_ACTION)) {
+ egg_debug ("set %s to FALSE", GPK_CONF_PROMPT_HARDWARE);
+ gconf_client_set_bool (hardware->priv->gconf_client, GPK_CONF_PROMPT_HARDWARE, FALSE, NULL);
+ } else {
+ egg_warning ("unknown action id: %s", action);
+ }
+}
+
+/**
+ * gpk_hardware_check_for_driver_available:
+ **/
+static void
+gpk_hardware_check_for_driver_available (GpkHardware *hardware, const gchar *udi)
+{
+ gboolean ret;
+ guint length;
+ gchar *message = NULL;
+ gchar *body = NULL;
+ NotifyNotification *notification;
+ GError *error = NULL;
+ gchar *package = NULL;
+ PkPackageList *list = NULL;
+ const PkPackageObj *obj = NULL;
+ PkClient *client = NULL;
+
+ client = pk_client_new ();
+ pk_client_set_synchronous (client, TRUE, NULL);
+ pk_client_set_use_buffer (client, TRUE, NULL);
+ egg_debug ("start - trying to call pk_client_what_provides");
+ ret = pk_client_what_provides (client, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED),
+ PK_PROVIDES_ENUM_HARDWARE_DRIVER, udi, &error);
+ egg_debug ("done - trying to call pk_client_what_provides");
+ if (!ret) {
+ egg_warning ("Error calling pk_client_what_provides :%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ goto out;
+ }
+
+ /* If there are no driver packages available just return */
+ list = pk_client_get_package_list (client);
+ length = pk_package_list_get_size (list);
+ if (length == 0) {
+ egg_debug ("no drivers available");
+ goto out;
+ }
+
+ obj = pk_package_list_get_obj (list, 0);
+ package = g_strdup_printf ("%s-%s", obj->id->name, obj->id->version);
+ if (hardware->priv->package_ids != NULL)
+ g_strfreev (hardware->priv->package_ids);
+ hardware->priv->package_ids = pk_package_list_to_strv (list);
+
+ message = g_strdup_printf ("%s%s%s", _("Do you want to install needed drivers?"), "\n\t", package);
+ body = g_strdup_printf ("%s %s", _("New hardware attached -"), udi);
+ notification = notify_notification_new (body, message, "help-browser", NULL);
+ notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
+ notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+ notify_notification_add_action (notification, GPK_HARDWARE_INSTALL_ACTION,
+ _("Install package"), gpk_hardware_libnotify_cb, hardware, NULL);
+ notify_notification_add_action (notification, GPK_HARDWARE_DONT_PROMPT_ACTION,
+ _("Do not show this again"), gpk_hardware_libnotify_cb, hardware, NULL);
+ ret = notify_notification_show (notification, &error);
+ if (!ret) {
+ egg_warning ("error: %s", error->message);
+ g_error_free (error);
+ }
+
+out:
+ g_free (package);
+ g_free (message);
+ g_free (body);
+ if (list != NULL)
+ g_object_unref (list);
+ g_object_unref (client);
+}
+
+/**
+ * gpk_hardware_device_added_cb:
+ * FIXME - not sure about this method signature
+ **/
+static void
+gpk_hardware_device_added_cb (DBusGProxy *proxy, const gchar *udi, GpkHardware *hardware)
+{
+ egg_debug ("hardware added. udi=%s", udi);
+ gpk_hardware_check_for_driver_available (hardware, udi);
+}
+
+/**
+ * gpk_hardware_timeout_cb:
+ * @data: This class instance
+ **/
+static gboolean
+gpk_hardware_timeout_cb (gpointer data)
+{
+ egg_debug ("hardware timout callback");
+ gpk_hardware_check_for_driver_available (GPK_HARDWARE (data), "unavailable");
+ return FALSE;
+}
+
+/**
+ * gpk_hardware_init:
+ * @hardware: This class instance
+ **/
+static void
+gpk_hardware_init (GpkHardware *hardware)
+{
+ gboolean ret;
+ GError *error = NULL;
+
+ hardware->priv = GPK_HARDWARE_GET_PRIVATE (hardware);
+ hardware->priv->gconf_client = gconf_client_get_default ();
+ hardware->priv->package_ids = NULL;
+
+ /* should we check and show the user */
+ ret = gconf_client_get_bool (hardware->priv->gconf_client, GPK_CONF_PROMPT_HARDWARE, NULL);
+ if (!ret) {
+ egg_debug ("hardware driver checking disabled in GConf");
+ return;
+ }
+
+ hardware->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to bus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ hardware->priv->proxy = dbus_g_proxy_new_for_name (hardware->priv->connection,
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/Manager",
+ "org.freedesktop.Hal.Manager");
+ dbus_g_proxy_add_signal (hardware->priv->proxy, "DeviceAdded",
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (hardware->priv->proxy, "DeviceAdded",
+ G_CALLBACK (gpk_hardware_device_added_cb), hardware, NULL);
+
+ /* check at startup (plus delay) and see if there is cold plugged hardware needing drivers */
+ g_timeout_add_seconds (GPK_HARDWARE_LOGIN_DELAY, gpk_hardware_timeout_cb, hardware);
+}
+
+/**
+ * gpk_hardware_class_init:
+ * @klass: The GpkHardwareClass
+ **/
+static void
+gpk_hardware_class_init (GpkHardwareClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gpk_hardware_finalize;
+ g_type_class_add_private (klass, sizeof (GpkHardwarePrivate));
+}
+
+/**
+ * gpk_hardware_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gpk_hardware_finalize (GObject *object)
+{
+ GpkHardware *hardware;
+
+ g_return_if_fail (GPK_IS_HARDWARE (object));
+
+ hardware = GPK_HARDWARE (object);
+
+ g_return_if_fail (hardware->priv != NULL);
+ g_object_unref (hardware->priv->gconf_client);
+ g_strfreev (hardware->priv->package_ids);
+
+ G_OBJECT_CLASS (gpk_hardware_parent_class)->finalize (object);
+}
+
+/**
+ * gpk_hardware_new:
+ *
+ * Return value: a new GpkHardware object.
+ **/
+GpkHardware *
+gpk_hardware_new (void)
+{
+ GpkHardware *hardware;
+ hardware = g_object_new (GPK_TYPE_HARDWARE, NULL);
+ return GPK_HARDWARE (hardware);
+}
+
Added: trunk/src/gpk-hardware.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-hardware.h Fri Sep 26 10:09:33 2008
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Scott Reeves <sreeves novell com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GPK_HARDWARE_H
+#define __GPK_HARDWARE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GPK_TYPE_HARDWARE (gpk_hardware_get_type ())
+#define GPK_HARDWARE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPK_TYPE_HARDWARE, GpkHardware))
+#define GPK_HARDWARE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPK_TYPE_HARDWARE, GpkHardwareClass))
+#define GPK_IS_HARDWARE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPK_TYPE_HARDWARE))
+#define GPK_IS_HARDWARE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPK_TYPE_HARDWARE))
+#define GPK_HARDWARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPK_TYPE_HARDWARE, GpkHardwareClass))
+#define GPK_HARDWARE_ERROR (gpk_hardware_error_quark ())
+#define GPK_HARDWARE_TYPE_ERROR (gpk_hardware_error_get_type ())
+
+typedef struct GpkHardwarePrivate GpkHardwarePrivate;
+
+typedef struct
+{
+ GObject parent;
+ GpkHardwarePrivate *priv;
+} GpkHardware;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} GpkHardwareClass;
+
+GType gpk_hardware_get_type (void) G_GNUC_CONST;
+GpkHardware *gpk_hardware_new (void);
+
+G_END_DECLS
+
+#endif /* __GPK_HARDWARE_H */
Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c (original)
+++ trunk/src/gpk-update-viewer.c Fri Sep 26 10:09:33 2008
@@ -1934,6 +1934,7 @@
main_window = glade_xml_get_widget (glade_xml, "window_updates");
/* make GpkClient windows modal */
+ gtk_widget_realize (main_window);
gpk_client_set_parent (gclient, GTK_WINDOW (main_window));
/* hide from finished page until we have updates */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]