gnome-packagekit r285 - trunk/src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r285 - trunk/src
- Date: Tue, 16 Sep 2008 12:52:51 +0000 (UTC)
Author: rhughes
Date: Tue Sep 16 12:52:51 2008
New Revision: 285
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=285&view=rev
Log:
from git
Added:
trunk/src/gpk-client-dialog.c
trunk/src/gpk-client-dialog.h
Modified:
trunk/src/Makefile.am
trunk/src/gpk-animated-icon.c
trunk/src/gpk-application.c
trunk/src/gpk-auto-refresh.c
trunk/src/gpk-backend-status.c
trunk/src/gpk-check-update.c
trunk/src/gpk-client.c
trunk/src/gpk-client.h
trunk/src/gpk-common.c
trunk/src/gpk-dbus.c
trunk/src/gpk-dbus.h
trunk/src/gpk-dialog.c
trunk/src/gpk-error.c
trunk/src/gpk-error.h
trunk/src/gpk-firmware.c
trunk/src/gpk-interface.h
trunk/src/gpk-interface.xml
trunk/src/gpk-log.c
trunk/src/gpk-prefs.c
trunk/src/gpk-repo.c
trunk/src/gpk-self-test.c
trunk/src/gpk-update-viewer.c
trunk/src/gpk-watch.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Sep 16 12:52:51 2008
@@ -62,6 +62,8 @@
gpk-client.c \
gpk-client.h \
gpk-client-private.h \
+ gpk-client-dialog.c \
+ gpk-client-dialog.h \
gpk-client-eula.c \
gpk-client-eula.h \
gpk-client-resolve.c \
@@ -265,6 +267,8 @@
gpk-self-test.c \
egg-test.h \
egg-test.c \
+ gpk-dbus.c \
+ gpk-dbus.h \
$(shared_SOURCES) \
$(NULL)
Modified: trunk/src/gpk-animated-icon.c
==============================================================================
--- trunk/src/gpk-animated-icon.c (original)
+++ trunk/src/gpk-animated-icon.c Tue Sep 16 12:52:51 2008
@@ -52,9 +52,8 @@
}
/* free each frame */
- for (i=0; i<icon->number_frames; i++) {
+ for (i=0; i<icon->number_frames; i++)
g_object_unref (icon->frames[i]);
- }
g_free (icon->frames);
icon->frames = NULL;
return TRUE;
Modified: trunk/src/gpk-application.c
==============================================================================
--- trunk/src/gpk-application.c (original)
+++ trunk/src/gpk-application.c Tue Sep 16 12:52:51 2008
@@ -30,7 +30,6 @@
#include <libsexy/sexy-icon-entry.h>
#include <math.h>
#include <string.h>
-#include <locale.h>
#include <polkit-gnome/polkit-gnome.h>
#include "egg-debug.h"
@@ -456,7 +455,7 @@
}
/* convert to pointer array */
- array = pk_argv_to_ptr_array (files);
+ array = pk_strv_to_ptr_array (files);
g_ptr_array_sort (array, (GCompareFunc) gpk_application_strcmp_indirect);
/* title */
@@ -474,6 +473,7 @@
gtk_widget_destroy (GTK_WIDGET (dialog));
g_free (title);
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
g_ptr_array_free (array, TRUE);
g_strfreev (files);
pk_package_id_free (id);
@@ -956,7 +956,8 @@
egg_debug ("package = %s:%s:%s", pk_info_enum_to_text (obj->info), obj->id->name, obj->summary);
/* ignore progress */
- if (obj->info != PK_INFO_ENUM_INSTALLED && obj->info != PK_INFO_ENUM_AVAILABLE)
+ if (obj->info != PK_INFO_ENUM_INSTALLED && obj->info != PK_INFO_ENUM_AVAILABLE &&
+ obj->info != PK_INFO_ENUM_COLLECTION_INSTALLED && obj->info != PK_INFO_ENUM_COLLECTION_AVAILABLE)
return;
/* use the localised summary if available */
@@ -969,7 +970,7 @@
/* are we in the package list? */
in_queue = pk_package_list_contains_obj (application->priv->package_list, obj);
- installed = (obj->info == PK_INFO_ENUM_INSTALLED);
+ installed = (obj->info == PK_INFO_ENUM_INSTALLED) || (obj->info == PK_INFO_ENUM_COLLECTION_INSTALLED);
if (installed && in_queue)
state = GPK_STATE_INSTALLED_TO_BE_REMOVED;
@@ -1516,6 +1517,7 @@
package_ids = pk_package_list_to_argv (application->priv->package_list);
if (application->priv->action == PK_ACTION_INSTALL) {
+ gpk_client_show_finished (application->priv->gclient, FALSE);
ret = gpk_client_install_package_ids (application->priv->gclient, package_ids, NULL);
/* can we show the user the new application? */
if (ret) {
@@ -1530,9 +1532,8 @@
g_free (exec);
}
}
- if (application->priv->action == PK_ACTION_REMOVE) {
+ if (application->priv->action == PK_ACTION_REMOVE)
ret = gpk_client_remove_package_ids (application->priv->gclient, package_ids, NULL);
- }
g_strfreev (package_ids);
/* refresh the search as the items may have changed and the filter has not changed */
@@ -2577,7 +2578,6 @@
GtkTreeSelection *selection;
gboolean autocomplete;
gboolean enabled;
- gchar *locale; /* does not need to be freed */
guint i;
gboolean ret;
GError *error = NULL;
@@ -2671,9 +2671,9 @@
G_CALLBACK (gpk_application_allow_cancel_cb), application);
/* get bitfield */
- application->priv->roles = pk_control_get_actions (application->priv->control);
- application->priv->filters = pk_control_get_filters (application->priv->control);
- application->priv->groups = pk_control_get_groups (application->priv->control);
+ application->priv->roles = pk_control_get_actions (application->priv->control, NULL);
+ application->priv->filters = pk_control_get_filters (application->priv->control, NULL);
+ application->priv->groups = pk_control_get_groups (application->priv->control, NULL);
application->priv->pconnection = pk_connection_new ();
g_signal_connect (application->priv->pconnection, "connection-changed",
@@ -2682,13 +2682,11 @@
/* get localised data from sqlite database */
application->priv->extra = pk_extra_new ();
ret = pk_extra_set_database (application->priv->extra, NULL);
- if (!ret) {
+ if (!ret)
egg_warning ("Failure setting database");
- }
- /* set the locale */
- locale = setlocale (LC_ALL, NULL);
- pk_extra_set_locale (application->priv->extra, locale);
+ /* set the locale to default */
+ pk_extra_set_locale (application->priv->extra, NULL);
/* use custom widgets */
glade_set_custom_handler (gpk_application_create_custom_widget, application);
Modified: trunk/src/gpk-auto-refresh.c
==============================================================================
--- trunk/src/gpk-auto-refresh.c (original)
+++ trunk/src/gpk-auto-refresh.c Tue Sep 16 12:52:51 2008
@@ -589,10 +589,9 @@
arefresh->priv->control = pk_control_new ();
g_signal_connect (arefresh->priv->control, "network-state-changed",
G_CALLBACK (gpk_auto_refresh_network_status_changed_cb), arefresh);
- state = pk_control_get_network_state (arefresh->priv->control);
- if (state == PK_NETWORK_ENUM_ONLINE) {
+ state = pk_control_get_network_state (arefresh->priv->control, NULL);
+ if (state == PK_NETWORK_ENUM_ONLINE)
arefresh->priv->network_active = TRUE;
- }
/* connect to session bus */
arefresh->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
Modified: trunk/src/gpk-backend-status.c
==============================================================================
--- trunk/src/gpk-backend-status.c (original)
+++ trunk/src/gpk-backend-status.c Tue Sep 16 12:52:51 2008
@@ -113,8 +113,8 @@
loop = g_main_loop_new (NULL, FALSE);
control = pk_control_new ();
- roles = pk_control_get_actions (control);
- filters = pk_control_get_filters (control);
+ roles = pk_control_get_actions (control, NULL);
+ filters = pk_control_get_filters (control, NULL);
/* general stuff */
retval = pk_control_get_backend_detail (control, &name, &author, NULL);
Modified: trunk/src/gpk-check-update.c
==============================================================================
--- trunk/src/gpk-check-update.c (original)
+++ trunk/src/gpk-check-update.c Tue Sep 16 12:52:51 2008
@@ -121,7 +121,7 @@
/**
* gpk_check_update_about_dialog_url_cb:
**/
-static void
+static void
gpk_check_update_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpointer data)
{
GError *error = NULL;
@@ -448,6 +448,7 @@
/* save for later */
if (cupdate->priv->important_updates_array != NULL) {
+ g_ptr_array_foreach (cupdate->priv->important_updates_array, (GFunc) g_free, NULL);
g_ptr_array_free (cupdate->priv->important_updates_array, TRUE);
}
cupdate->priv->important_updates_array = g_ptr_array_new ();
@@ -793,6 +794,7 @@
g_object_unref (list);
g_string_free (status_security, TRUE);
g_string_free (status_tooltip, TRUE);
+ g_ptr_array_foreach (security_array, (GFunc) g_free, NULL);
g_ptr_array_free (security_array, TRUE);
return ret;
}
@@ -1072,6 +1074,7 @@
g_object_unref (cupdate->priv->control);
g_object_unref (cupdate->priv->gclient);
if (cupdate->priv->important_updates_array != NULL) {
+ g_ptr_array_foreach (cupdate->priv->important_updates_array, (GFunc) g_free, NULL);
g_ptr_array_free (cupdate->priv->important_updates_array, TRUE);
}
Added: trunk/src/gpk-client-dialog.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-dialog.c Tue Sep 16 12:52:51 2008
@@ -0,0 +1,763 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie 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 <errno.h>
+#include <signal.h>
+
+#include <string.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <glib/gi18n.h>
+#include <glade/glade.h>
+
+#include <pk-common.h>
+#include <pk-client.h>
+#include <pk-enum.h>
+
+#include "egg-debug.h"
+#include "egg-string.h"
+
+#include "gpk-animated-icon.h"
+#include "gpk-client-dialog.h"
+#include "gpk-common.h"
+#include "gpk-gnome.h"
+
+static void gpk_client_dialog_class_init (GpkClientDialogClass *klass);
+static void gpk_client_dialog_init (GpkClientDialog *dialog);
+static void gpk_client_dialog_finalize (GObject *object);
+
+#define GPK_CLIENT_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_CLIENT_DIALOG, GpkClientDialogPrivate))
+
+struct _GpkClientDialogPrivate
+{
+ GladeXML *glade_xml;
+ guint pulse_timer_id;
+ gboolean show_progress_files;
+ gboolean has_parent;
+ GMainLoop *loop;
+ GtkResponseType response;
+};
+
+enum {
+ GPK_CLIENT_DIALOG_CLOSE,
+ GPK_CLIENT_DIALOG_QUIT,
+ GPK_CLIENT_DIALOG_ACTION,
+ GPK_CLIENT_DIALOG_HELP,
+ GPK_CLIENT_DIALOG_CANCEL,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+G_DEFINE_TYPE (GpkClientDialog, gpk_client_dialog, G_TYPE_OBJECT)
+
+/**
+ * gpk_client_dialog_show_page:
+ **/
+gboolean
+gpk_client_dialog_show_page (GpkClientDialog *dialog, GpkClientDialogPage page, guint32 timestamp)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "label_title");
+ gtk_widget_show (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "image_status");
+ gtk_widget_show (widget);
+
+ egg_debug ("setting page: %i", page);
+ if (page == GPK_CLIENT_DIALOG_PAGE_CONFIRM) {
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_cancel");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_close");
+ gtk_widget_show (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_action");
+ gtk_widget_show (widget);
+ gtk_widget_grab_focus (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_help");
+ gtk_widget_show (widget);
+ } else if (page == GPK_CLIENT_DIALOG_PAGE_PROGRESS) {
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ gtk_widget_show (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_cancel");
+ gtk_widget_show (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_close");
+ gtk_widget_show (widget);
+ gtk_widget_grab_focus (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_action");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_help");
+ gtk_widget_show (widget);
+ } else if (page == GPK_CLIENT_DIALOG_PAGE_FINISHED || page == GPK_CLIENT_DIALOG_PAGE_WARNING) {
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_cancel");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_close");
+ gtk_widget_show (widget);
+ gtk_widget_grab_focus (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_action");
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_help");
+ gtk_widget_hide (widget);
+ } else {
+ egg_error ("unknown contant");
+ }
+
+ /* show */
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ gtk_widget_realize (widget);
+ gtk_window_present_with_time (GTK_WINDOW (widget), timestamp);
+
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_parent:
+ **/
+gboolean
+gpk_client_dialog_set_parent (GpkClientDialog *dialog, GdkWindow *window)
+{
+ GtkWidget *widget;
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ /* never set, and nothing now */
+ if (window == NULL && !dialog->priv->has_parent)
+ return TRUE;
+
+ /* not sure what to do here, should probably unparent somehow */
+ if (window == NULL) {
+ egg_warning ("parent set NULL when already modal with another window!");
+ return FALSE;
+ }
+
+ /* check we are a valid window */
+ if (!GDK_WINDOW (window)) {
+ egg_warning ("not a valid GdkWindow!");
+ return FALSE;
+ }
+
+ 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);
+ dialog->priv->has_parent = TRUE;
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_window_title:
+ **/
+gboolean
+gpk_client_dialog_set_window_title (GpkClientDialog *dialog, const gchar *title)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (title != NULL, FALSE);
+
+ egg_debug ("setting window title: %s", title);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ gtk_window_set_title (GTK_WINDOW (widget), title);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_window_icon:
+ **/
+gboolean
+gpk_client_dialog_set_window_icon (GpkClientDialog *dialog, const gchar *icon)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (icon != NULL, FALSE);
+
+ egg_debug ("setting window icon: %s", icon);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ gtk_window_set_icon_name (GTK_WINDOW (widget), icon);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_title:
+ **/
+gboolean
+gpk_client_dialog_set_title (GpkClientDialog *dialog, const gchar *title)
+{
+ GtkWidget *widget;
+ gchar *title_bold;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (title != NULL, FALSE);
+
+ title_bold = g_strdup_printf ("<b><big>%s</big></b>", title);
+ egg_debug ("setting title: %s", title_bold);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "label_title");
+ gtk_label_set_markup (GTK_LABEL (widget), title_bold);
+ g_free (title_bold);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_message:
+ **/
+gboolean
+gpk_client_dialog_set_message (GpkClientDialog *dialog, const gchar *message)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
+
+ /* infer we want to show by setting this */
+ if (!egg_strzero (message))
+ gpk_client_dialog_set_show_message (dialog, TRUE);
+
+ /* ignore this if it's uninteresting */
+ if (!dialog->priv->show_progress_files)
+ return FALSE;
+
+ egg_debug ("setting message: %s", message);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "label_message");
+ gtk_label_set_markup (GTK_LABEL (widget), message);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_action:
+ **/
+gboolean
+gpk_client_dialog_set_action (GpkClientDialog *dialog, const gchar *action)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (action != NULL, FALSE);
+
+ egg_debug ("setting action: %s", action);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_action");
+ gtk_button_set_label (GTK_BUTTON (widget), action);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_pulse_progress:
+ **/
+static gboolean
+gpk_client_dialog_pulse_progress (GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ /* debug so we can catch polling */
+ egg_debug ("polling check");
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
+
+ /* if there's no slider, optimise out the polling */
+ if (!GTK_WIDGET_VISIBLE (widget)) {
+ dialog->priv->pulse_timer_id = 0;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_make_progressbar_pulse:
+ **/
+static void
+gpk_client_dialog_make_progressbar_pulse (GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+ if (dialog->priv->pulse_timer_id == 0) {
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget ), 0.04);
+ dialog->priv->pulse_timer_id = g_timeout_add (75, (GSourceFunc) gpk_client_dialog_pulse_progress, dialog);
+ }
+}
+
+/**
+ * gpk_client_dialog_set_percentage:
+ **/
+gboolean
+gpk_client_dialog_set_percentage (GpkClientDialog *dialog, guint percentage)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ egg_debug ("setting percentage: %u", percentage);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "progressbar_percent");
+ if (dialog->priv->pulse_timer_id != 0) {
+ g_source_remove (dialog->priv->pulse_timer_id);
+ dialog->priv->pulse_timer_id = 0;
+ }
+
+ /* either pulse or set percentage */
+ if (percentage == PK_CLIENT_PERCENTAGE_INVALID)
+ gpk_client_dialog_make_progressbar_pulse (dialog);
+ else
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), (gfloat) percentage / 100.0);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_image:
+ **/
+gboolean
+gpk_client_dialog_set_image (GpkClientDialog *dialog, const gchar *image)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (image != NULL, FALSE);
+
+ egg_debug ("setting image: %s", image);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "image_status");
+ gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (widget), FALSE);
+ gtk_image_set_from_icon_name (GTK_IMAGE (widget), image, GTK_ICON_SIZE_DIALOG);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_image_status:
+ **/
+gboolean
+gpk_client_dialog_set_image_status (GpkClientDialog *dialog, PkStatusEnum status)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "image_status");
+ gpk_set_animated_icon_from_status (GPK_ANIMATED_ICON (widget), status, GTK_ICON_SIZE_DIALOG);
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_get_window:
+ **/
+GtkWindow *
+gpk_client_dialog_get_window (GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), NULL);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ return GTK_WINDOW (widget);
+}
+
+/**
+ * gpk_client_dialog_set_allow_cancel:
+ **/
+gboolean
+gpk_client_dialog_set_allow_cancel (GpkClientDialog *dialog, gboolean can_cancel)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_cancel");
+ gtk_widget_set_sensitive (widget, can_cancel);
+
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_set_show_message:
+ **/
+gboolean
+gpk_client_dialog_set_show_message (GpkClientDialog *dialog, gboolean show_message)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ egg_debug ("showing message: %i", show_message);
+
+ /* if we're never going to show it, hide the allocation */
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "hbox_message");
+ if (!show_message)
+ gtk_widget_hide (widget);
+ else
+ gtk_widget_show (widget);
+ dialog->priv->show_progress_files = show_message;
+
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_run:
+ **/
+GtkResponseType
+gpk_client_dialog_run (GpkClientDialog *dialog)
+{
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ dialog->priv->response = GTK_RESPONSE_NONE;
+ g_main_loop_run (dialog->priv->loop);
+ return dialog->priv->response;
+}
+
+/**
+ * gpk_client_dialog_close:
+ **/
+gboolean
+gpk_client_dialog_close (GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT_DIALOG (dialog), FALSE);
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ gtk_widget_hide (widget);
+
+ if (dialog->priv->pulse_timer_id != 0) {
+ g_source_remove (dialog->priv->pulse_timer_id);
+ dialog->priv->pulse_timer_id = 0;
+ }
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "image_status");
+ gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (widget), FALSE);
+
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_window_delete_cb:
+ **/
+static gboolean
+gpk_client_dialog_window_delete_cb (GtkWidget *widget, GdkEvent *event, GpkClientDialog *dialog)
+{
+ dialog->priv->response = GTK_RESPONSE_DELETE_EVENT;
+ gpk_client_dialog_close (dialog);
+ if (g_main_loop_is_running (dialog->priv->loop))
+ g_main_loop_quit (dialog->priv->loop);
+ /* do not destroy the window */
+ return TRUE;
+}
+
+/**
+ * gpk_client_dialog_button_close_cb:
+ **/
+static void
+gpk_client_dialog_button_close_cb (GtkWidget *widget_button, GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+
+ dialog->priv->response = GTK_RESPONSE_CLOSE;
+ g_main_loop_quit (dialog->priv->loop);
+
+ if (dialog->priv->pulse_timer_id != 0) {
+ g_source_remove (dialog->priv->pulse_timer_id);
+ dialog->priv->pulse_timer_id = 0;
+ }
+
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "image_status");
+ gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (widget), FALSE);
+ if (g_main_loop_is_running (dialog->priv->loop))
+ g_main_loop_quit (dialog->priv->loop);
+ else
+ g_signal_emit (dialog, signals [GPK_CLIENT_DIALOG_CLOSE], 0);
+}
+
+/**
+ * gpk_client_dialog_button_help_cb:
+ **/
+static void
+gpk_client_dialog_button_help_cb (GtkWidget *widget_button, GpkClientDialog *dialog)
+{
+ gpk_gnome_help (NULL);
+ g_signal_emit (dialog, signals [GPK_CLIENT_DIALOG_HELP], 0);
+}
+
+/**
+ * gpk_client_dialog_button_action_cb:
+ **/
+static void
+gpk_client_dialog_button_action_cb (GtkWidget *widget_button, GpkClientDialog *dialog)
+{
+ dialog->priv->response = GTK_RESPONSE_OK;
+ g_main_loop_quit (dialog->priv->loop);
+ if (g_main_loop_is_running (dialog->priv->loop))
+ g_main_loop_quit (dialog->priv->loop);
+ else
+ g_signal_emit (dialog, signals [GPK_CLIENT_DIALOG_ACTION], 0);
+}
+
+/**
+ * gpk_client_dialog_button_cancel_cb:
+ **/
+static void
+gpk_client_dialog_button_cancel_cb (GtkWidget *widget_button, GpkClientDialog *dialog)
+{
+ dialog->priv->response = GTK_RESPONSE_CANCEL;
+ if (g_main_loop_is_running (dialog->priv->loop))
+ g_main_loop_quit (dialog->priv->loop);
+ else
+ g_signal_emit (dialog, signals [GPK_CLIENT_DIALOG_CANCEL], 0);
+}
+
+/**
+ * gpk_client_create_custom_widget:
+ **/
+static GtkWidget *
+gpk_client_create_custom_widget (GladeXML *xml, gchar *func_name, gchar *name,
+ gchar *string1, gchar *string2,
+ gint int1, gint int2, gpointer user_data)
+{
+ if (egg_strequal (name, "image_status"))
+ return gpk_animated_icon_new ();
+ egg_warning ("name unknown=%s", name);
+ return NULL;
+}
+
+/**
+ * gpk_client_dialog_class_init:
+ * @klass: The GpkClientDialogClass
+ **/
+static void
+gpk_client_dialog_class_init (GpkClientDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gpk_client_dialog_finalize;
+ g_type_class_add_private (klass, sizeof (GpkClientDialogPrivate));
+ signals [GPK_CLIENT_DIALOG_QUIT] =
+ g_signal_new ("quit",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ signals [GPK_CLIENT_DIALOG_CLOSE] =
+ g_signal_new ("close",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ signals [GPK_CLIENT_DIALOG_ACTION] =
+ g_signal_new ("action",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ signals [GPK_CLIENT_DIALOG_CANCEL] =
+ g_signal_new ("cancel",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+/**
+ * gpk_client_dialog_init:
+ * @dialog: This class instance
+ **/
+static void
+gpk_client_dialog_init (GpkClientDialog *dialog)
+{
+ GtkWidget *widget;
+
+ dialog->priv = GPK_CLIENT_DIALOG_GET_PRIVATE (dialog);
+
+ /* use custom widgets */
+ glade_set_custom_handler (gpk_client_create_custom_widget, dialog);
+
+ dialog->priv->glade_xml = glade_xml_new (PK_DATA "/gpk-client.glade", NULL, NULL);
+ dialog->priv->loop = g_main_loop_new (NULL, FALSE);
+ dialog->priv->response = GTK_RESPONSE_NONE;
+ dialog->priv->pulse_timer_id = 0;
+ dialog->priv->show_progress_files = TRUE;
+ dialog->priv->has_parent = FALSE;
+
+ /* common stuff */
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "window_client");
+ g_signal_connect (widget, "delete_event", G_CALLBACK (gpk_client_dialog_window_delete_cb), dialog);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_close");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_dialog_button_close_cb), dialog);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_help");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_dialog_button_help_cb), dialog);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_action");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_dialog_button_action_cb), dialog);
+ widget = glade_xml_get_widget (dialog->priv->glade_xml, "button_cancel");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_dialog_button_cancel_cb), dialog);
+
+ /* clear status and progress text */
+ gpk_client_dialog_set_window_title (dialog, "");
+ gpk_client_dialog_set_title (dialog, "");
+ gpk_client_dialog_set_message (dialog, "");
+}
+
+/**
+ * gpk_client_dialog_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gpk_client_dialog_finalize (GObject *object)
+{
+ GpkClientDialog *dialog;
+ g_return_if_fail (GPK_IS_CLIENT_DIALOG (object));
+
+ dialog = GPK_CLIENT_DIALOG (object);
+ g_return_if_fail (dialog->priv != NULL);
+
+ /* no updates, we're about to rip the glade file up */
+ if (dialog->priv->pulse_timer_id != 0)
+ g_source_remove (dialog->priv->pulse_timer_id);
+
+ /* if it's closed, then hide */
+ gpk_client_dialog_close (dialog);
+
+ /* shouldn't be, but just in case */
+ if (g_main_loop_is_running (dialog->priv->loop)) {
+ egg_warning ("mainloop running on exit");
+ g_main_loop_quit (dialog->priv->loop);
+ }
+
+ g_object_unref (dialog->priv->glade_xml);
+ g_main_loop_unref (dialog->priv->loop);
+
+ G_OBJECT_CLASS (gpk_client_dialog_parent_class)->finalize (object);
+}
+
+/**
+ * gpk_client_dialog_new:
+ *
+ * Return value: a new GpkClientDialog object.
+ **/
+GpkClientDialog *
+gpk_client_dialog_new (void)
+{
+ GpkClientDialog *dialog;
+ dialog = g_object_new (GPK_TYPE_CLIENT_DIALOG, NULL);
+ return GPK_CLIENT_DIALOG (dialog);
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gpk_client_dialog_test (EggTest *test)
+{
+ GtkResponseType button;
+ GpkClientDialog *dialog = NULL;
+
+ if (!egg_test_start (test, "GpkClientDialog"))
+ return;
+
+ /************************************************************/
+ egg_test_title (test, "get GpkClientDialog object");
+ dialog = gpk_client_dialog_new ();
+ if (dialog != NULL)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, NULL);
+
+ /************************************************************/
+ egg_test_title (test, "help button");
+ gpk_client_dialog_set_window_title (dialog, "PackageKit self test");
+ gpk_client_dialog_set_title (dialog, "Button press test");
+ gpk_client_dialog_set_message (dialog, "Please press close");
+ gpk_client_dialog_set_image (dialog, "dialog-warning");
+ gpk_client_dialog_show_page (dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, 0);
+ button = gpk_client_dialog_run (dialog);
+ if (button == GTK_RESPONSE_CLOSE)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "got id %i", button);
+
+ /************************************************************/
+ egg_test_title (test, "confirm button");
+ gpk_client_dialog_set_title (dialog, "Button press test with a really really long title");
+ gpk_client_dialog_set_message (dialog, "Please press Uninstall\n\nThis is a really really, really,\nreally long title <i>with formatting</i>");
+ gpk_client_dialog_set_image (dialog, "dialog-information");
+ gpk_client_dialog_set_action (dialog, _("Uninstall"));
+ gpk_client_dialog_show_page (dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, 0);
+ button = gpk_client_dialog_run (dialog);
+ if (button == GTK_RESPONSE_OK)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "got id %i", button);
+
+ /************************************************************/
+ egg_test_title (test, "no message");
+ gpk_client_dialog_set_title (dialog, "Refresh cache");
+ gpk_client_dialog_set_image_status (dialog, PK_STATUS_ENUM_REFRESH_CACHE);
+ gpk_client_dialog_set_show_message (dialog, FALSE);
+ gpk_client_dialog_set_percentage (dialog, 101);
+ gpk_client_dialog_show_page (dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
+ gpk_client_dialog_run (dialog);
+ egg_test_success (test, NULL);
+
+ /************************************************************/
+ egg_test_title (test, "progress");
+ gpk_client_dialog_set_title (dialog, "Button press test");
+ gpk_client_dialog_set_message (dialog, "Please press cancel");
+ gpk_client_dialog_set_image_status (dialog, PK_STATUS_ENUM_RUNNING);
+ gpk_client_dialog_set_percentage (dialog, 50);
+ gpk_client_dialog_show_page (dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
+ button = gpk_client_dialog_run (dialog);
+ if (button == GTK_RESPONSE_CANCEL)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "got id %i", button);
+
+ /************************************************************/
+ egg_test_title (test, "progress");
+ gpk_client_dialog_set_title (dialog, "Button press test");
+ gpk_client_dialog_set_message (dialog, "Please press close");
+ gpk_client_dialog_set_image_status (dialog, PK_STATUS_ENUM_INSTALL);
+ gpk_client_dialog_set_percentage (dialog, 101);
+ gpk_client_dialog_show_page (dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
+ button = gpk_client_dialog_run (dialog);
+ if (button == GTK_RESPONSE_CLOSE)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "got id %i", button);
+
+ gpk_client_dialog_close (dialog);
+
+ g_object_unref (dialog);
+
+ egg_test_end (test);
+}
+#endif
+
Added: trunk/src/gpk-client-dialog.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-dialog.h Tue Sep 16 12:52:51 2008
@@ -0,0 +1,103 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie 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_CLIENT_DIALOG_H
+#define __GPK_CLIENT_DIALOG_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <pk-enum.h>
+
+G_BEGIN_DECLS
+
+#define GPK_TYPE_CLIENT_DIALOG (gpk_client_dialog_get_type ())
+#define GPK_CLIENT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPK_TYPE_CLIENT_DIALOG, GpkClientDialog))
+#define GPK_CLIENT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPK_TYPE_CLIENT_DIALOG, GpkClientDialogClass))
+#define GPK_IS_CLIENT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPK_TYPE_CLIENT_DIALOG))
+#define GPK_IS_CLIENT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPK_TYPE_CLIENT_DIALOG))
+#define GPK_CLIENT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPK_TYPE_CLIENT_DIALOG, GpkClientDialogClass))
+#define GPK_CLIENT_DIALOG_ERROR (gpk_client_dialog_error_quark ())
+#define GPK_CLIENT_DIALOG_TYPE_ERROR (gpk_client_dialog_error_get_type ())
+
+/**
+ * GpkClientDialogPage:
+ */
+typedef enum
+{
+ GPK_CLIENT_DIALOG_PAGE_CONFIRM,
+ GPK_CLIENT_DIALOG_PAGE_PROGRESS,
+ GPK_CLIENT_DIALOG_PAGE_FINISHED,
+ GPK_CLIENT_DIALOG_PAGE_WARNING,
+ GPK_CLIENT_DIALOG_PAGE_UNKNOWN
+} GpkClientDialogPage;
+
+typedef struct _GpkClientDialogPrivate GpkClientDialogPrivate;
+typedef struct _GpkClientDialog GpkClientDialog;
+typedef struct _GpkClientDialogClass GpkClientDialogClass;
+
+struct _GpkClientDialog
+{
+ GObject parent;
+ GpkClientDialogPrivate *priv;
+};
+
+struct _GpkClientDialogClass
+{
+ GObjectClass parent_class;
+};
+
+GQuark gpk_client_dialog_error_quark (void);
+GType gpk_client_dialog_get_type (void) G_GNUC_CONST;
+GpkClientDialog *gpk_client_dialog_new (void);
+
+gboolean gpk_client_dialog_show_page (GpkClientDialog *dialog,
+ GpkClientDialogPage page,
+ guint32 timestamp);
+gboolean gpk_client_dialog_set_parent (GpkClientDialog *dialog,
+ GdkWindow *window);
+gboolean gpk_client_dialog_set_window_title (GpkClientDialog *dialog,
+ const gchar *title);
+gboolean gpk_client_dialog_set_window_icon (GpkClientDialog *dialog,
+ const gchar *icon);
+gboolean gpk_client_dialog_set_title (GpkClientDialog *dialog,
+ const gchar *title);
+gboolean gpk_client_dialog_set_message (GpkClientDialog *dialog,
+ const gchar *message);
+gboolean gpk_client_dialog_set_action (GpkClientDialog *dialog,
+ const gchar *action);
+gboolean gpk_client_dialog_set_percentage (GpkClientDialog *dialog,
+ guint percentage);
+gboolean gpk_client_dialog_set_image (GpkClientDialog *dialog,
+ const gchar *image);
+gboolean gpk_client_dialog_set_image_status (GpkClientDialog *dialog,
+ PkStatusEnum status);
+gboolean gpk_client_dialog_set_allow_cancel (GpkClientDialog *dialog,
+ gboolean can_cancel);
+gboolean gpk_client_dialog_set_show_message (GpkClientDialog *dialog,
+ gboolean show_message);
+GtkWindow *gpk_client_dialog_get_window (GpkClientDialog *dialog);
+GtkResponseType gpk_client_dialog_run (GpkClientDialog *dialog);
+gboolean gpk_client_dialog_close (GpkClientDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GPK_CLIENT_DIALOG_H */
+
Modified: trunk/src/gpk-client.c
==============================================================================
--- trunk/src/gpk-client.c (original)
+++ trunk/src/gpk-client.c Tue Sep 16 12:52:51 2008
@@ -35,7 +35,6 @@
#include <glib/gstdio.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <polkit-gnome/polkit-gnome.h>
#include <libnotify/notify.h>
@@ -43,6 +42,7 @@
#include <pk-client.h>
#include <pk-package-id.h>
#include <pk-package-ids.h>
+#include <pk-extra.h>
#include <pk-common.h>
#include <pk-control.h>
#include <pk-catalog.h>
@@ -64,11 +64,11 @@
#include <gpk-error.h>
#include "gpk-consolekit.h"
#include "gpk-animated-icon.h"
+#include "gpk-client-dialog.h"
static void gpk_client_class_init (GpkClientClass *klass);
static void gpk_client_init (GpkClient *gclient);
static void gpk_client_finalize (GObject *object);
-static void gpk_client_done (GpkClient *gclient);
#define GPK_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_CLIENT, GpkClientPrivate))
#define GPK_CLIENT_FINISHED_AUTOCLOSE_DELAY 10 /* seconds */
@@ -82,31 +82,26 @@
PkClient *client_action;
PkClient *client_resolve;
PkClient *client_secondary;
- GladeXML *glade_xml;
GConfClient *gconf_client;
- guint pulse_timer_id;
+ GpkClientDialog *dialog;
guint finished_timer_id;
+ PkExtra *extra;
PkControl *control;
PkBitfield roles;
gboolean using_secondary_client;
gboolean retry_untrusted_value;
gboolean show_finished;
gboolean show_progress;
- gboolean show_progress_files;
GpkClientInteract interact;
- gboolean gtk_main_waiting;
gchar **files_array;
PkExitEnum exit;
- GtkWindow *parent_window;
+ GdkWindow *parent_window;
GPtrArray *upgrade_array;
+ guint timestamp;
+ gchar *application;
+ GMainLoop *loop;
};
-typedef enum {
- GPK_CLIENT_PAGE_PROGRESS,
- GPK_CLIENT_PAGE_CONFIRM,
- GPK_CLIENT_PAGE_LAST
-} GpkClientPageEnum;
-
enum {
GPK_CLIENT_QUIT,
LAST_SIGNAL
@@ -124,9 +119,8 @@
gpk_client_error_quark (void)
{
static GQuark quark = 0;
- if (!quark) {
+ if (!quark)
quark = g_quark_from_static_string ("gpk_client_error");
- }
return quark;
}
@@ -151,134 +145,23 @@
}
/**
- * gpk_client_set_page:
- **/
-static void
-gpk_client_set_page (GpkClient *gclient, GpkClientPageEnum page)
-{
- GList *list, *l;
- GtkWidget *widget;
- guint i;
-
- g_return_if_fail (GPK_IS_CLIENT (gclient));
-
- if (!gclient->priv->show_progress) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_hide (widget);
- return;
- }
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_show (widget);
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "hbox_hidden");
- list = gtk_container_get_children (GTK_CONTAINER (widget));
- for (l=list, i=0; l; l=l->next, i++) {
- if (i == page) {
- gtk_widget_show (l->data);
- } else {
- gtk_widget_hide (l->data);
- }
- }
-}
-
-/**
- * gpk_client_main_wait:
- **/
-static gboolean
-gpk_client_main_wait (GpkClient *gclient)
-{
- if (gclient->priv->gtk_main_waiting) {
- egg_warning ("already started!");
- return FALSE;
- }
- /* wait for completion */
- gclient->priv->gtk_main_waiting = TRUE;
- gtk_main ();
- gclient->priv->gtk_main_waiting = FALSE;
- return TRUE;
-}
-
-/**
- * gpk_client_main_quit:
- **/
-static gboolean
-gpk_client_main_quit (GpkClient *gclient)
-{
- if (!gclient->priv->gtk_main_waiting) {
- egg_warning ("not already started!");
- return FALSE;
- }
- gtk_main_quit ();
- return TRUE;
-}
-
-/**
- * gpk_client_updates_button_close_cb:
- **/
-static void
-gpk_client_updates_button_close_cb (GtkWidget *widget_button, GpkClient *gclient)
-{
- GtkWidget *widget;
- g_return_if_fail (GPK_IS_CLIENT (gclient));
-
- /* stop the timer */
- if (gclient->priv->finished_timer_id != 0) {
- g_source_remove (gclient->priv->finished_timer_id);
- gclient->priv->finished_timer_id = 0;
- }
-
- /* go! */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_hide (widget);
- gpk_client_done (gclient);
- g_signal_emit (gclient, signals [GPK_CLIENT_QUIT], 0);
-}
-
-/**
- * gpk_client_updates_window_delete_event_cb:
- **/
-static gboolean
-gpk_client_updates_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpkClient *gclient)
-{
- g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
-
- /* stop the timer */
- if (gclient->priv->finished_timer_id != 0) {
- g_source_remove (gclient->priv->finished_timer_id);
- gclient->priv->finished_timer_id = 0;
- }
-
- /* go! */
- gtk_widget_hide (widget);
-
- egg_debug ("quitting due to window close");
- gpk_client_main_quit (gclient);
- g_signal_emit (gclient, signals [GPK_CLIENT_QUIT], 0);
- return FALSE;
-}
-
-/**
* gpk_install_finished_timeout:
**/
static gboolean
gpk_install_finished_timeout (gpointer data)
{
- GtkWidget *widget;
GpkClient *gclient = (GpkClient *) data;
/* debug so we can catch polling */
egg_debug ("polling check");
/* hide window manually to get it out of the way */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_hide (widget);
+ gpk_client_dialog_close (gclient->priv->dialog);
/* the timer will be done */
gclient->priv->finished_timer_id = 0;
egg_debug ("quitting due to timeout");
- gpk_client_main_quit (gclient);
g_signal_emit (gclient, signals [GPK_CLIENT_QUIT], 0);
return FALSE;
}
@@ -307,9 +190,8 @@
gclient->priv->show_progress = (interact == GPK_CLIENT_INTERACT_ALWAYS);
/* normally, if we don't want to show progress then we don't want finished */
- if (gclient->priv->show_progress) {
+ if (gclient->priv->show_progress)
gclient->priv->show_finished = FALSE;
- }
}
/**
@@ -341,9 +223,8 @@
} else if (egg_strequal (action, "restart-computer")) {
/* restart using gnome-power-manager */
ret = gpk_restart_system ();
- if (!ret) {
+ if (!ret)
egg_warning ("failed to reboot");
- }
} else {
egg_warning ("unknown action id: %s", action);
}
@@ -407,9 +288,8 @@
message = gpk_restart_enum_to_localised_text (restart);
/* add a gap if we are putting both */
- if (skipped_number > 0) {
+ if (skipped_number > 0)
g_string_append (message_text, "\n");
- }
g_string_append (message_text, message);
g_string_append_c (message_text, '\n');
@@ -454,7 +334,6 @@
static void
gpk_client_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, GpkClient *gclient)
{
- GtkWidget *widget;
PkRoleEnum role = PK_ROLE_ENUM_UNKNOWN;
g_return_if_fail (GPK_IS_CLIENT (gclient));
@@ -463,13 +342,14 @@
gclient->priv->exit = exit;
/* stop timers, animations and that sort of thing */
- gpk_client_done (gclient);
pk_client_get_role (client, &role, NULL, NULL);
/* do nothing */
- if (role == PK_ROLE_ENUM_GET_UPDATES) {
+ if (role == PK_ROLE_ENUM_GET_UPDATES)
goto out;
- }
+
+ /* stop spinning */
+ gpk_client_dialog_set_percentage (gclient->priv->dialog, 100);
/* do we show a libnotify window instead? */
if (!gclient->priv->show_progress) {
@@ -479,91 +359,29 @@
if (exit == PK_EXIT_ENUM_SUCCESS &&
gclient->priv->show_finished) {
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_CONFIRM);
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close2");
- gtk_widget_grab_default (widget);
+ gpk_client_dialog_set_message (gclient->priv->dialog, "");
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_FINISHED, 0);
gclient->priv->finished_timer_id = g_timeout_add_seconds (GPK_CLIENT_FINISHED_AUTOCLOSE_DELAY,
gpk_install_finished_timeout, gclient);
} else {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_hide (widget);
+ gpk_client_dialog_close (gclient->priv->dialog);
}
out:
/* only quit if there is not another transaction scheduled to be finished */
if (!gclient->priv->using_secondary_client) {
egg_debug ("quitting due to finished");
- gpk_client_main_quit (gclient);
+ if (g_main_loop_is_running (gclient->priv->loop))
+ g_main_loop_quit (gclient->priv->loop);
}
}
/**
- * gpk_client_pulse_progress:
- **/
-static gboolean
-gpk_client_pulse_progress (GpkClient *gclient)
-{
- GtkWidget *widget;
-
- g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
-
- /* debug so we can catch polling */
- egg_debug ("polling check");
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
- gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
- return TRUE;
-}
-
-/**
- * gpk_client_make_progressbar_pulse:
- **/
-static void
-gpk_client_make_progressbar_pulse (GpkClient *gclient)
-{
- GtkWidget *widget;
- if (gclient->priv->pulse_timer_id == 0) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
- gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget ), 0.04);
- gclient->priv->pulse_timer_id = g_timeout_add (75, (GSourceFunc) gpk_client_pulse_progress, gclient);
- }
-}
-
-/**
- * gpk_client_set_percentage:
- **/
-gboolean
-gpk_client_set_percentage (GpkClient *gclient, guint percentage)
-{
- GtkWidget *widget;
-
- g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
- if (gclient->priv->pulse_timer_id != 0) {
- g_source_remove (gclient->priv->pulse_timer_id);
- gclient->priv->pulse_timer_id = 0;
- }
-
- /* either pulse or set percentage */
- if (percentage == PK_CLIENT_PERCENTAGE_INVALID) {
- gpk_client_make_progressbar_pulse (gclient);
- } else {
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), (gfloat) percentage / 100.0);
- }
- return TRUE;
-}
-
-/**
* gpk_client_set_status:
**/
gboolean
gpk_client_set_status (GpkClient *gclient, PkStatusEnum status)
{
- GtkWidget *widget;
- gchar *text;
-
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
/* do we force progress? */
@@ -576,67 +394,42 @@
status == PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO ||
status == PK_STATUS_ENUM_REFRESH_CACHE) {
gclient->priv->show_progress = TRUE;
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
}
}
+ /* ignore */
+ if (!gclient->priv->show_progress)
+ return FALSE;
+
/* set icon */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "image_status");
- gpk_set_animated_icon_from_status (GPK_ANIMATED_ICON (widget), status, GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (widget);
+ gpk_client_dialog_set_image_status (gclient->priv->dialog, status);
/* set label */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progress_part_label");
- text = g_strdup_printf ("<b>%s</b>", gpk_status_enum_to_localised_text (status));
- gtk_label_set_markup (GTK_LABEL (widget), text);
- g_free (text);
+ gpk_client_dialog_set_title (gclient->priv->dialog, gpk_status_enum_to_localised_text (status));
/* spin */
- if (status == PK_STATUS_ENUM_WAIT) {
- gpk_client_make_progressbar_pulse (gclient);
- }
+ if (status == PK_STATUS_ENUM_WAIT)
+ gpk_client_dialog_set_percentage (gclient->priv->dialog, PK_CLIENT_PERCENTAGE_INVALID);
/* do visual stuff when finished */
if (status == PK_STATUS_ENUM_FINISHED) {
/* make insensitive */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
- gtk_widget_set_sensitive (widget, FALSE);
+ gpk_client_dialog_set_allow_cancel (gclient->priv->dialog, FALSE);
/* stop spinning */
- if (gclient->priv->pulse_timer_id != 0) {
- g_source_remove (gclient->priv->pulse_timer_id);
- gclient->priv->pulse_timer_id = 0;
- }
-
- /* set to 100% */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), 1.0f);
+ gpk_client_dialog_set_percentage (gclient->priv->dialog, 100);
}
return TRUE;
}
/**
- * gpk_client_set_package_label:
- **/
-gboolean
-gpk_client_set_package_label (GpkClient *gclient, const gchar *text)
-{
- GtkWidget *widget;
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "label_package");
- gtk_widget_show (widget);
- gtk_label_set_markup (GTK_LABEL (widget), text);
- return TRUE;
-}
-
-/**
* gpk_client_set_title:
**/
gboolean
gpk_client_set_title (GpkClient *gclient, const gchar *title)
{
- GtkWidget *widget;
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_window_set_title (GTK_WINDOW (widget), title);
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, title);
return TRUE;
}
@@ -647,7 +440,10 @@
gpk_client_progress_changed_cb (PkClient *client, guint percentage, guint subpercentage,
guint elapsed, guint remaining, GpkClient *gclient)
{
- gpk_client_set_percentage (gclient, percentage);
+ /* ignore */
+ if (!gclient->priv->show_progress)
+ return;
+ gpk_client_dialog_set_percentage (gclient->priv->dialog, percentage);
}
/**
@@ -656,7 +452,8 @@
static void
gpk_client_status_changed_cb (PkClient *client, PkStatusEnum status, GpkClient *gclient)
{
- gpk_client_set_status (gclient, status);
+ if (gclient->priv->show_progress)
+ gpk_client_set_status (gclient, status);
}
/**
@@ -705,7 +502,7 @@
title = gpk_error_enum_to_localised_text (code);
message = gpk_error_enum_to_localised_message (code);
if (gclient->priv->show_progress) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
gpk_error_dialog_modal (GTK_WINDOW (widget), title, message, details);
return;
}
@@ -730,13 +527,11 @@
gchar *text;
g_return_if_fail (GPK_IS_CLIENT (gclient));
- /* ignore this if it's uninteresting */
- if (!gclient->priv->show_progress_files) {
+ if (!gclient->priv->show_progress)
return;
- }
text = gpk_package_id_format_twoline (obj->id, obj->summary);
- gpk_client_set_package_label (gclient, text);
+ gpk_client_dialog_set_message (gclient->priv->dialog, text);
g_free (text);
}
@@ -781,22 +576,21 @@
static void
gpk_client_allow_cancel_cb (PkClient *client, gboolean allow_cancel, GpkClient *gclient)
{
- GtkWidget *widget;
-
- g_return_if_fail (GPK_IS_CLIENT (gclient));
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
- gtk_widget_set_sensitive (widget, allow_cancel);
+ gpk_client_dialog_set_allow_cancel (gclient->priv->dialog, allow_cancel);
}
/**
- * gpk_client_button_help_cb:
+ * pk_client_button_close_cb:
**/
static void
-gpk_client_button_help_cb (GtkWidget *widget, GpkClient *gclient)
+pk_client_button_close_cb (GtkWidget *widget, GpkClient *gclient)
{
- g_return_if_fail (GPK_IS_CLIENT (gclient));
- gpk_gnome_help (NULL);
+ /* stop the timers if running */
+ if (gclient->priv->finished_timer_id != 0)
+ g_source_remove (gclient->priv->finished_timer_id);
+
+ /* close, don't abort */
+ gpk_client_dialog_close (gclient->priv->dialog);
}
/**
@@ -822,12 +616,11 @@
static void
gpk_client_error_msg (GpkClient *gclient, const gchar *title, const gchar *message, const gchar *details)
{
- GtkWidget *widget;
+ GtkWindow *window;
/* hide the main window */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_hide (widget);
- gpk_error_dialog_modal (GTK_WINDOW (widget), title, message, details);
+ window = gpk_client_dialog_get_window (gclient->priv->dialog);
+ gpk_error_dialog_modal_with_time (window, title, message, details, gclient->priv->timestamp);
}
/**
@@ -881,12 +674,6 @@
guint length;
const gchar *title;
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
@@ -898,9 +685,11 @@
/* install local file */
ret = pk_client_install_files (gclient->priv->client_action, trusted, files_rel, &error_local);
- if (ret) {
+ if (ret)
return TRUE;
- }
+
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* check if we got a permission denied */
if (g_str_has_prefix (error_local->message, "org.freedesktop.packagekit.")) {
@@ -920,125 +709,48 @@
}
/**
- * gpk_client_done:
- **/
-static void
-gpk_client_done (GpkClient *gclient)
-{
- GtkWidget *widget;
-
- /* we're done */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "image_status");
- gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (widget), FALSE);
- if (gclient->priv->pulse_timer_id != 0) {
- g_source_remove (gclient->priv->pulse_timer_id);
- gclient->priv->pulse_timer_id = 0;
- }
-}
-
-/**
- * gpk_client_setup_window:
- **/
-static gboolean
-gpk_client_setup_window (GpkClient *gclient, const gchar *title)
-{
- GtkRequisition requisition;
- GtkWidget *widget;
-
- g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
-
- /* set title */
- gpk_client_set_title (gclient, title);
-
- /* clear status and progress text */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progress_part_label");
- gtk_label_set_label (GTK_LABEL (widget), "The Linux kernel (the Linux operating system)");
- gtk_widget_show (widget);
-
- /* set the correct width of the label to stop the window jumping around */
- gtk_widget_size_request (widget, &requisition);
- gtk_widget_set_size_request (widget, requisition.width * 1.1f, requisition.height);
- gtk_label_set_label (GTK_LABEL (widget), "");
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "label_package");
- gtk_label_set_label (GTK_LABEL (widget), "The Linux kernel (the core of the Linux operating system)\n\n\n");
- gtk_widget_show (widget);
-
- /* set the correct height of the label to stop the window jumping around */
- gtk_widget_size_request (widget, &requisition);
- gtk_widget_set_size_request (widget, requisition.width, requisition.height);
- gtk_label_set_label (GTK_LABEL (widget), "");
-
- /* start with the progressbar pulsing */
- gpk_client_make_progressbar_pulse (gclient);
-
- return TRUE;
-}
-
-/**
* gpk_client_set_error_from_exit_enum:
**/
static gboolean
gpk_client_set_error_from_exit_enum (PkExitEnum exit, GError **error)
{
/* trivial case */
- if (exit == PK_EXIT_ENUM_SUCCESS) {
+ if (exit == PK_EXIT_ENUM_SUCCESS)
return TRUE;
- }
/* set the correct error type */
- if (exit == PK_EXIT_ENUM_FAILED) {
+ if (exit == PK_EXIT_ENUM_FAILED)
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Unspecified failure");
- } else if (exit == PK_EXIT_ENUM_CANCELLED) {
+ else if (exit == PK_EXIT_ENUM_CANCELLED)
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Transaction was cancelled");
- } else if (exit == PK_EXIT_ENUM_KEY_REQUIRED) {
+ else if (exit == PK_EXIT_ENUM_KEY_REQUIRED)
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "A key was required but not provided");
- } else if (exit == PK_EXIT_ENUM_EULA_REQUIRED) {
+ else if (exit == PK_EXIT_ENUM_EULA_REQUIRED)
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "A EULA was not agreed to");
- } else if (exit == PK_EXIT_ENUM_KILLED) {
+ else if (exit == PK_EXIT_ENUM_KILLED)
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "The transaction was killed");
- } else {
+ else
egg_error ("unknown exit code");
- }
return FALSE;
}
/**
- * gpk_client_set_progress_files:
- **/
-static void
-gpk_client_set_progress_files (GpkClient *gclient, gboolean enabled)
-{
- GtkWidget *widget;
-
- /* if we're never going to show it, hide the allocation */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "label_package");
- if (!enabled) {
- gtk_widget_hide (widget);
- } else {
- gtk_widget_show (widget);
- }
- gclient->priv->show_progress_files = enabled;
-}
-
-/**
- * gpk_client_file_array_to_list:
+ * _g_ptr_array_to_bullets:
*
- * splits the files up nicely
+ * splits the strings up nicely
*
* Return value: a newly allocated string
**/
static gchar *
-gpk_client_file_array_to_list (GPtrArray *array, const gchar *prefix)
+_g_ptr_array_to_bullets (GPtrArray *array, const gchar *prefix)
{
GString *string;
guint i;
gchar *text;
string = g_string_new (prefix);
- if (prefix != NULL) {
+ if (prefix != NULL)
g_string_append_c (string, '\n');
- }
/* prefix with bullet and suffix with newline */
for (i=0; i<array->len; i++) {
@@ -1132,7 +844,6 @@
const gchar *message_part;
const gchar *title;
gchar *message;
- GtkWidget *dialog;
GtkResponseType button;
/* see if root has access to this file, in case we have to copy it
@@ -1152,22 +863,19 @@
message_part = ngettext (_("One package file has to be copied to a non-private location so it can be installed:"),
_("Some package files have to be copied to a non-private location so they can be installed:"),
array_missing->len);
- message = gpk_client_file_array_to_list (array_missing, message_part);
+ message = _g_ptr_array_to_bullets (array_missing, message_part);
/* show UI */
- dialog = gtk_message_dialog_new (gclient->priv->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,
- "%s", title);
- /* add a specialist button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Copy file"), GTK_RESPONSE_OK);
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, message);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-warning");
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Copy file"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, gclient->priv->timestamp);
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
g_free (message);
- button = gtk_dialog_run (GTK_DIALOG (dialog));
-
/* did we click no or exit the window? */
+ button = gpk_client_dialog_run (gclient->priv->dialog);
if (button != GTK_RESPONSE_OK) {
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Aborted the copy");
ret = FALSE;
@@ -1230,17 +938,19 @@
if (!ret) {
title = ngettext (_("The file could not be copied"),
_("The files could not be copied"), array_missing->len);
- dialog = gtk_message_dialog_new (gclient->priv->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
- "%s", title);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ /* show UI */
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, "");
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-warning");
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, gclient->priv->timestamp);
+ gpk_client_dialog_run (gclient->priv->dialog);
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "files not copied");
ret = FALSE;
goto out;
}
out:
+ g_ptr_array_foreach (array_missing, (GFunc) g_free, NULL);
g_ptr_array_free (array_missing, TRUE);
return ret;
}
@@ -1255,7 +965,6 @@
static gboolean
gpk_client_install_local_files_verify (GpkClient *gclient, GPtrArray *array, GError **error)
{
- GtkWidget *dialog;
GtkResponseType button;
const gchar *title;
gchar *message;
@@ -1263,32 +972,26 @@
title = ngettext (_("Do you want to install this file?"),
_("Do you want to install these files?"), array->len);
- message = gpk_client_file_array_to_list (array, NULL);
+ message = _g_ptr_array_to_bullets (array, NULL);
/* show UI */
- dialog = gtk_message_dialog_new (gclient->priv->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,
- "%s", title);
- /* add a specialist button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Install"), GTK_RESPONSE_OK);
-
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
-
- button = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, message);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-question");
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, gclient->priv->timestamp);
+ button = gpk_client_dialog_run (gclient->priv->dialog);
g_free (message);
/* did we click no or exit the window? */
if (button != GTK_RESPONSE_OK) {
title = ngettext (_("The file was not installed"),
_("The files were not installed"), array->len);
- dialog = gtk_message_dialog_new (gclient->priv->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
- "%s", title);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, "");
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-warning");
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, gclient->priv->timestamp);
+ gpk_client_dialog_run (gclient->priv->dialog);
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Aborted");
ret = FALSE;
goto out;
@@ -1314,7 +1017,6 @@
const gchar *message_part;
const gchar *title;
gchar *message;
- GtkWidget *dialog;
array_missing = g_ptr_array_new ();
@@ -1334,29 +1036,76 @@
message_part = ngettext (_("The following file was not found:"),
_("The following files were not found:"), array_missing->len);
- message = gpk_client_file_array_to_list (array_missing, message_part);
+ message = _g_ptr_array_to_bullets (array_missing, message_part);
/* show UI */
- dialog = gtk_message_dialog_new (gclient->priv->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
- "%s", title);
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, message);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-warning");
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, gclient->priv->timestamp);
+ gpk_client_dialog_run (gclient->priv->dialog);
+
g_free (message);
- /* run */
- gtk_dialog_run (GTK_DIALOG (dialog));
ret = FALSE;
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "some files did not exist");
goto out;
}
out:
+ g_ptr_array_foreach (array_missing, (GFunc) g_free, NULL);
g_ptr_array_free (array_missing, TRUE);
return ret;
}
/**
+ * gpk_client_confirm_action:
+ * @gclient: a valid #GpkClient instance
+ **/
+static gboolean
+gpk_client_confirm_action (GpkClient *gclient, const gchar *title, const gchar *message)
+{
+ GtkResponseType button;
+ gchar *title_name;
+ const gchar *icon = NULL;
+ const gchar *application_localised = NULL;
+
+ /* get localised name and icon if available */
+ if (gclient->priv->application != NULL) {
+ application_localised = pk_extra_get_summary (gclient->priv->extra, gclient->priv->application);
+ if (application_localised == NULL)
+ application_localised = gclient->priv->application;
+ icon = pk_extra_get_icon_name (gclient->priv->extra, gclient->priv->application);
+ }
+
+ /* fallbacks */
+ if (application_localised == NULL)
+ application_localised = _("A program");
+ if (icon == NULL)
+ 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);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, gclient->priv->timestamp);
+
+ g_free (title_name);
+
+ button = gpk_client_dialog_run (gclient->priv->dialog);
+
+ /* close, we're going to fail the method */
+ if (button != GTK_RESPONSE_OK) {
+ gpk_client_dialog_close (gclient->priv->dialog);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
* gpk_client_install_local_files:
* @gclient: a valid #GpkClient instance
* @file_rel: a file such as <literal>./hal-devel-0.10.0.rpm</literal>
@@ -1377,52 +1126,44 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (files_rel != NULL, FALSE);
- array = pk_argv_to_ptr_array (files_rel);
+ array = pk_strv_to_ptr_array (files_rel);
/* check the user wanted to call this method */
ret = gpk_client_install_local_files_verify (gclient, array, error);
- if (!ret) {
+ if (!ret)
goto out;
- }
/* check all files exist and are readable by the local user */
ret = gpk_client_install_local_files_check_exists (gclient, array, error);
- if (!ret) {
+ if (!ret)
goto out;
- }
/* check all files exist and are readable by the local user */
ret = gpk_client_install_local_files_copy_private (gclient, array, error);
- if (!ret) {
+ if (!ret)
goto out;
- }
- files = pk_ptr_array_to_argv (array);
+ files = pk_ptr_array_to_strv (array);
gclient->priv->retry_untrusted_value = FALSE;
ret = gpk_client_install_local_files_internal (gclient, TRUE, files, error);
- if (!ret) {
+ if (!ret)
goto out;
- }
/* set title */
- gpk_client_setup_window (gclient, _("Install local file"));
-
- /* setup the UI */
- gpk_client_set_progress_files (gclient, TRUE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Install local file"));
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_FINISHED, 0);
- gpk_client_main_wait (gclient);
+ /* wait */
+ g_main_loop_run (gclient->priv->loop);
/* do we need to try again with better auth? */
if (gclient->priv->retry_untrusted_value) {
ret = gpk_client_install_local_files_internal (gclient, FALSE, files, error);
- if (!ret) {
+ if (!ret)
goto out;
- }
/* wait again */
- gclient->priv->gtk_main_waiting = TRUE;
- gtk_main ();
- gclient->priv->gtk_main_waiting = FALSE;
+ g_main_loop_run (gclient->priv->loop);
}
/* fail the transaction and set the correct error */
@@ -1430,8 +1171,8 @@
out:
g_strfreev (files);
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
g_ptr_array_free (array, TRUE);
- gpk_client_done (gclient);
return ret;
}
@@ -1453,18 +1194,12 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* set title */
- gpk_client_setup_window (gclient, _("Remove packages"));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Remove packages"));
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
/* are we dumb and can't check for depends? */
if (!pk_bitfield_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_REQUIRES)) {
@@ -1492,7 +1227,7 @@
}
/* try to remove the package_ids */
- gpk_client_set_progress_files (gclient, TRUE);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
ret = pk_client_remove_packages (gclient->priv->client_action, package_ids, TRUE, FALSE, &error_local);
if (!ret) {
/* check if we got a permission denied */
@@ -1511,16 +1246,16 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, TRUE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- gpk_client_done (gclient);
return ret;
}
@@ -1531,7 +1266,7 @@
gpk_client_get_window (GpkClient *gclient)
{
GtkWidget *widget;
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
return GTK_WINDOW (widget);
}
@@ -1553,18 +1288,12 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* set title */
- gpk_client_setup_window (gclient, _("Install packages"));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Installing packages"));
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
/* are we dumb and can't check for depends? */
if (!pk_bitfield_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_DEPENDS)) {
@@ -1575,7 +1304,6 @@
ret = gpk_client_depends_show (gclient, package_ids);
/* did we click no or exit the window? */
if (!ret) {
- gpk_client_error_msg (gclient, _("Failed to install package"), _("Additional packages were not downloaded"), NULL);
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "user did not agree to additional deps");
ret = FALSE;
goto out;
@@ -1592,8 +1320,8 @@
}
/* try to install the package_id */
- gpk_client_set_title (gclient, _("Installing packages"));
- gpk_client_set_progress_files (gclient, TRUE);
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("Installing packages"));
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
ret = pk_client_install_packages (gclient->priv->client_action, package_ids, &error_local);
if (!ret) {
/* check if we got a permission denied */
@@ -1611,13 +1339,13 @@
goto out;
}
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- gpk_client_done (gclient);
return ret;
}
@@ -1642,8 +1370,18 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (packages != NULL, FALSE);
+ /* check user wanted operation */
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("Package installer"));
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ ret = gpk_client_confirm_action (gclient, _("wants to install packages"), package_ids[0]);
+ if (!ret) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to search");
+ ret = FALSE;
+ goto out;
+ }
+
/* resolve a 2D array to package_id's */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
package_ids = gpk_client_resolve_show (GTK_WINDOW (widget), packages);
if (package_ids == NULL) {
/* generic error message */
@@ -1661,9 +1399,8 @@
}
out:
- if (error_local != NULL) {
+ if (error_local != NULL)
g_error_free (error_local);
- }
g_strfreev (package_ids);
return ret;
}
@@ -1696,6 +1433,16 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (full_path != NULL, FALSE);
+ /* check user wanted operation */
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("File installer"));
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ ret = gpk_client_confirm_action (gclient, _("wants to install a file"), full_path);
+ if (!ret) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to search");
+ ret = FALSE;
+ goto out;
+ }
+
ret = pk_client_search_file (gclient->priv->client_resolve, PK_FILTER_ENUM_NONE, full_path, &error_local);
if (!ret) {
text = g_strdup_printf ("%s: %s", _("Incorrect response from search"), error_local->message);
@@ -1751,15 +1498,231 @@
package_ids = pk_package_ids_from_id (package_id);
ret = gpk_client_install_package_ids (gclient, package_ids, error);
out:
- if (list != NULL) {
+ if (list != NULL)
g_object_unref (list);
- }
g_strfreev (package_ids);
g_free (package_id);
return ret;
}
/**
+ * gpk_client_install_gstreamer_codec_part:
+ **/
+PkPackageObj *
+gpk_client_install_gstreamer_codec_part (GpkClient *gclient, const gchar *codec_name, const gchar *codec_desc, GError **error)
+{
+ PkPackageList *list = NULL;
+ gboolean ret;
+ PkPackageObj *new_obj = NULL;
+ const PkPackageObj *obj;
+ guint len;
+ gchar *title;
+ gchar *codec_name_formatted;
+
+ /* reset */
+ ret = pk_client_reset (gclient->priv->client_resolve, error);
+ if (!ret)
+ return NULL;
+
+ codec_name_formatted = g_strdup_printf ("<i>%s</i>", codec_name);
+ title = g_strdup_printf (_("Searching for codec: %s"), codec_name_formatted);
+ gpk_client_dialog_set_message (gclient->priv->dialog, title);
+ g_free (title);
+ g_free (codec_name_formatted);
+
+ /* get codec packages */
+ ret = pk_client_what_provides (gclient->priv->client_resolve, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), PK_PROVIDES_ENUM_CODEC, codec_desc, error);
+ if (!ret)
+ return NULL;
+
+ list = pk_client_get_package_list (gclient->priv->client_resolve);
+ len = pk_package_list_get_size (list);
+
+ /* found nothing? */
+ if (len == 0) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "failed to find: %s", codec_desc);
+ goto out;
+ }
+
+ /* gstreamer-ffmpeg and gstreamer-plugins-ugly both provice mp3 playback, choose one */
+ if (len > 1)
+ egg_warning ("choosing one of the provides as more than one match");
+
+ /* always use the first one */
+ obj = pk_package_list_get_obj (list, 0);
+ if (obj == NULL)
+ egg_error ("obj cannot be NULL");
+
+ /* copy the object */
+ new_obj = pk_package_obj_copy (obj);
+out:
+ if (list != NULL)
+ g_object_unref (list);
+ return new_obj;
+}
+
+/**
+ * gpk_client_install_gstreamer_codecs_confirm:
+ **/
+static gboolean
+gpk_client_install_gstreamer_codecs_confirm (GpkClient *gclient, gchar **codec_name_strings)
+{
+ guint i;
+ guint len;
+ gchar *text;
+ gchar **parts;
+ gboolean ret;
+ GString *string;
+
+ string = g_string_new ("");
+ g_string_append_printf (string, "%s\n%s\n\n", _("Additional plugins are required to play this content."), _("The following codecs are required:"));
+ len = g_strv_length (codec_name_strings);
+ for (i=0; i<len; i++) {
+ parts = g_strsplit (codec_name_strings[i], "|", 2);
+ g_string_append_printf (string, "â <i>%s</i>\n", parts[0]);
+ g_strfreev (parts);
+ }
+
+ /* trailer */
+ g_string_append_printf (string, "\n%s\n", _("Do you want to search for these now?"));
+
+ /* remove last \n */
+ g_string_set_size (string, string->len - 1);
+
+ /* display messagebox */
+ text = g_string_free (string, FALSE);
+
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("Codec installer"));
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Search"));
+ ret = gpk_client_confirm_action (gclient, _("requires additional plugins"), text);
+ g_free (text);
+
+ return ret;
+}
+
+/**
+ * gpk_client_install_gstreamer_codecs:
+ * @gclient: a valid #GpkClient instance
+ * @codecs: a codec_type such as <literal>application/text</literal>
+ * @error: a %GError to put the error code and message in, or %NULL
+ *
+ * Install a application to handle a mime type
+ *
+ * Return value: %TRUE if the method succeeded
+ **/
+gboolean
+gpk_client_install_gstreamer_codecs (GpkClient *gclient, gchar **codec_name_strings, GError **error)
+{
+ guint i;
+ guint len;
+ const PkPackageObj *obj;
+ PkPackageObj *obj_new;
+ gboolean ret = TRUE;
+ gchar **parts;
+ GError *error_local = NULL;
+ GtkResponseType button;
+ PkPackageList *list = NULL;
+ GString *string;
+ gchar *text;
+ gchar **package_ids = NULL;
+
+ /* confirm */
+ ret = gpk_client_install_gstreamer_codecs_confirm (gclient, codec_name_strings);
+ if (!ret) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to search");
+ ret = FALSE;
+ goto out;
+ }
+
+ /* set title */
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Searching for codecs"));
+ gpk_client_dialog_set_image_status (gclient->priv->dialog, PK_STATUS_ENUM_WAIT);
+
+ /* setup the UI */
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
+
+ /* save the objects to download in a list */
+ list = pk_package_list_new ();
+
+ len = g_strv_length (codec_name_strings);
+ for (i=0; i<len; i++) {
+ parts = g_strsplit (codec_name_strings[i], "|", 2);
+ if (g_strv_length (parts) != 2) {
+ egg_warning ("invalid line '%s', expecting a | delimiter", codec_name_strings[i]);
+ continue;
+ }
+ egg_debug ("codec name=%s", parts[0]);
+ egg_debug ("codec description=%s", parts[1]);
+ obj_new = gpk_client_install_gstreamer_codec_part (gclient, parts[0], parts[1], &error_local);
+ if (obj_new == NULL) {
+ gpk_client_error_msg (gclient, _("Failed to search for codec"), _("Could not find codec in any configured software source"), error_local->message);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ ret = FALSE;
+ }
+ if (obj_new != NULL)
+ pk_package_list_add_obj (list, obj_new);
+ pk_package_obj_free (obj_new);
+ g_strfreev (parts);
+ if (!ret)
+ break;
+ }
+
+ /* don't prompt to install if any failed */
+ //TODO: install partial
+ if (!ret)
+ goto out;
+
+ /* process package list */
+ string = g_string_new (_("The following packages can installed:"));
+ g_string_append (string, "\n\n");
+ len = pk_package_list_get_size (list);
+ for (i=0; i<len; i++) {
+ obj = pk_package_list_get_obj (list, i);
+ text = gpk_package_id_format_oneline (obj->id, obj->summary);
+ g_string_append_printf (string, "%s\n", text);
+ g_free (text);
+ }
+
+ g_string_append_printf (string, "\n%s\n", _("Do you want to install these now?"));
+
+ /* remove last \n */
+ g_string_set_size (string, string->len - 1);
+
+ /* display messagebox */
+ text = g_string_free (string, FALSE);
+
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Install the following codecs"));
+ gpk_client_dialog_set_message (gclient->priv->dialog, text);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-information");
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, gclient->priv->timestamp);
+ g_free (text);
+
+ button = gpk_client_dialog_run (gclient->priv->dialog);
+
+ /* close, we're going to fail the method */
+ if (button != GTK_RESPONSE_OK) {
+ gpk_client_dialog_close (gclient->priv->dialog);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to download");
+ ret = FALSE;
+ goto out;
+ }
+
+ /* convert to list of package id's */
+ package_ids = pk_package_list_to_argv (list);
+ ret = gpk_client_install_package_ids (gclient, package_ids, error);
+
+out:
+ if (!ret)
+ gpk_client_dialog_close (gclient->priv->dialog);
+ g_strfreev (package_ids);
+ if (list != NULL)
+ g_object_unref (list);
+ return ret;
+}
+
+/**
* gpk_client_install_mime_type:
* @gclient: a valid #GpkClient instance
* @mime_type: a mime_type such as <literal>application/text</literal>
@@ -1783,7 +1746,26 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (mime_type != NULL, FALSE);
- ret = pk_client_what_provides (gclient->priv->client_resolve, PK_FILTER_ENUM_NOT_INSTALLED,
+ /* make sure the user wants to do action */
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("Mime type installer"));
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Search"));
+ ret = gpk_client_confirm_action (gclient, _("requires a new mime type"), mime_type);
+ if (!ret) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to search");
+ ret = FALSE;
+ goto out;
+ }
+
+ /* reset */
+ ret = pk_client_reset (gclient->priv->client_resolve, &error_local);
+ if (!ret) {
+ gpk_client_error_msg (gclient, _("Failed to reset client"), _("Failed to reset client"), error_local->message);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ goto out;
+ }
+
+ /* action */
+ ret = pk_client_what_provides (gclient->priv->client_resolve, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED),
PK_PROVIDES_ENUM_MIMETYPE, mime_type, &error_local);
if (!ret) {
gpk_client_error_msg (gclient, _("Failed to search for provides"), _("Incorrect response from search"), error_local->message);
@@ -1798,13 +1780,13 @@
if (len == 0) {
gpk_client_error_msg (gclient, _("Failed to find software"),
_("No new applications can be found to handle this type of file"), NULL);
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, NULL);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "nothing was found to handle mime type");
ret = FALSE;
goto out;
}
/* populate a chooser */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
package_id = gpk_client_chooser_show (GTK_WINDOW (widget), list, _("Applications that can open this type of file"));
/* selected nothing */
@@ -1819,9 +1801,8 @@
package_ids = g_strsplit (package_id, "|", 1);
ret = gpk_client_install_package_ids (gclient, package_ids, error);
out:
- if (list != NULL) {
+ if (list != NULL)
g_object_unref (list);
- }
g_strfreev (package_ids);
g_free (package_id);
return ret;
@@ -1851,7 +1832,26 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (font_desc != NULL, FALSE);
- ret = pk_client_what_provides (gclient->priv->client_resolve, PK_FILTER_ENUM_NOT_INSTALLED,
+ /* check user wanted operation */
+ gpk_client_dialog_set_window_title (gclient->priv->dialog, _("Font installer"));
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Search"));
+ ret = gpk_client_confirm_action (gclient, _("wants to install a font"), font_desc);
+ if (!ret) {
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "did not agree to search");
+ ret = FALSE;
+ goto out;
+ }
+
+ /* reset */
+ ret = pk_client_reset (gclient->priv->client_resolve, &error_local);
+ if (!ret) {
+ gpk_client_error_msg (gclient, _("Failed to reset client"), _("Failed to reset client"), error_local->message);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ goto out;
+ }
+
+ /* action */
+ ret = pk_client_what_provides (gclient->priv->client_resolve, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED),
PK_PROVIDES_ENUM_FONT, font_desc, &error_local);
if (!ret) {
gpk_client_error_msg (gclient, _("Failed to search for provides"), _("Incorrect response from search"), error_local->message);
@@ -1872,7 +1872,7 @@
}
/* populate a chooser */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
package_id = gpk_client_chooser_show (GTK_WINDOW (widget), list, _("Available fonts for this document"));
/* selected nothing */
@@ -1887,9 +1887,8 @@
package_ids = g_strsplit (package_id, "|", 1);
ret = gpk_client_install_package_ids (gclient, package_ids, error);
out:
- if (list != NULL) {
+ if (list != NULL)
g_object_unref (list);
- }
g_strfreev (package_ids);
g_free (package_id);
return ret;
@@ -1905,16 +1904,15 @@
g_return_if_fail (GPK_IS_CLIENT (gclient));
- if (mode == PK_CATALOG_PROGRESS_PACKAGES) {
+ if (mode == PK_CATALOG_PROGRESS_PACKAGES)
message = g_strdup_printf (_("Finding package name: %s"), text);
- } else if (mode == PK_CATALOG_PROGRESS_FILES) {
+ else if (mode == PK_CATALOG_PROGRESS_FILES)
message = g_strdup_printf (_("Finding file name: %s"), text);
- } else if (mode == PK_CATALOG_PROGRESS_PROVIDES) {
+ else if (mode == PK_CATALOG_PROGRESS_PROVIDES)
message = g_strdup_printf (_("Finding a package to provide: %s"), text);
- }
gpk_client_set_status (gclient, PK_STATUS_ENUM_QUERY);
- gpk_client_set_package_label (gclient, message);
+ gpk_client_dialog_set_message (gclient->priv->dialog, message);
g_free (message);
}
@@ -1924,8 +1922,6 @@
gboolean
gpk_client_install_catalogs (GpkClient *gclient, gchar **filenames, GError **error)
{
- GtkWidget *dialog;
- GtkWidget *widget;
GtkResponseType button;
gchar **package_ids = NULL;
gchar *message;
@@ -1939,12 +1935,6 @@
guint len;
guint i;
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
len = g_strv_length (filenames);
title = ngettext (_("Do you want to install this catalog?"),
@@ -1952,53 +1942,41 @@
message = g_strjoinv ("\n", filenames);
/* show UI */
- dialog = gtk_message_dialog_new (gclient->priv->parent_window, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, "%s", title);
-
- /* add a specialist button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Install"), GTK_RESPONSE_OK);
-
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
-
- button = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gpk_client_dialog_set_title (gclient->priv->dialog, title);
+ gpk_client_dialog_set_message (gclient->priv->dialog, message);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-question");
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_CONFIRM, gclient->priv->timestamp);
+ button = gpk_client_dialog_run (gclient->priv->dialog);
g_free (message);
/* did we click no or exit the window? */
- if (button != GTK_RESPONSE_OK) {
- title = ngettext (_("The catalog was not installed"),
- _("The catalogs were not installed"), len);
- dialog = gtk_message_dialog_new (gclient->priv->parent_window, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", title);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ if (button != GTK_RESPONSE_OK)
return FALSE;
- }
/* set title */
- gpk_client_setup_window (gclient, _("Install catalogs"));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Install catalogs"));
gpk_client_set_status (gclient, PK_STATUS_ENUM_WAIT);
/* setup the UI */
- gpk_client_set_progress_files (gclient, TRUE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
/* get files to be installed */
catalog = pk_catalog_new ();
g_signal_connect (catalog, "progress", G_CALLBACK (gpk_client_catalog_progress_cb), gclient);
- gclient->priv->gtk_main_waiting = TRUE;
list = pk_catalog_process_files (catalog, filenames);
- gclient->priv->gtk_main_waiting = FALSE;
g_object_unref (catalog);
/* nothing to do? */
len = pk_package_list_get_size (list);
if (len == 0) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK, _("No packages need to be installed"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ /* show UI */
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("No packages need to be installed"));
+ gpk_client_dialog_set_message (gclient->priv->dialog, "");
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-warning");
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, gclient->priv->timestamp);
+ gpk_client_dialog_run (gclient->priv->dialog);
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "No packages need to be installed");
ret = FALSE;
goto out;
@@ -2020,29 +1998,17 @@
text = g_string_free (string, FALSE);
/* show UI */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,
- "%s", _("Install packages in catalog?"));
- /* add a specialist button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Install"), GTK_RESPONSE_OK);
-
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", text);
- button = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Install packages in catalog?"));
+ gpk_client_dialog_set_message (gclient->priv->dialog, text);
+ gpk_client_dialog_set_image (gclient->priv->dialog, "dialog-question");
+ gpk_client_dialog_set_action (gclient->priv->dialog, _("Install"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_WARNING, gclient->priv->timestamp);
+ button = gpk_client_dialog_run (gclient->priv->dialog);
+
g_free (text);
/* did we click no or exit the window? */
if (button != GTK_RESPONSE_OK) {
- len = g_strv_length (filenames);
- title = ngettext (_("The catalog was not installed"),
- _("The catalogs were not installed"), len);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", title);
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "Action was cancelled");
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Action was cancelled");
ret = FALSE;
goto out;
@@ -2073,22 +2039,16 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
- gpk_client_error_msg (gclient, _("Failed to reset client"), _("Failed to reset resolve"), error_local->message);
+ gpk_client_error_msg (gclient, _("Failed to reset client"), _("Failed to reset client"), error_local->message);
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
goto out;
}
/* set title */
- gpk_client_setup_window (gclient, _("System update"));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("System update"));
/* wrap update, but handle all the GPG and EULA stuff */
ret = pk_client_update_system (gclient->priv->client_action, &error_local);
@@ -2108,8 +2068,8 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, TRUE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
/* if we are not showing UI, then notify the user what we are doing (just on the active terminal) */
ret = gconf_client_get_bool (gclient->priv->gconf_client, GPK_CONF_NOTIFY_CRITICAL, NULL);
@@ -2131,15 +2091,15 @@
}
}
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- if (error_local != NULL) {
+ if (error_local != NULL)
g_error_free (error_local);
- }
g_free (message);
g_free (text);
return ret;
@@ -2158,12 +2118,6 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
@@ -2173,7 +2127,7 @@
}
/* set title */
- gpk_client_setup_window (gclient, _("Refresh package lists"));
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Refresh package lists"));
/* wrap update, but handle all the GPG and EULA stuff */
ret = pk_client_refresh_cache (gclient->priv->client_action, TRUE, &error_local);
@@ -2193,18 +2147,18 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- if (error_local != NULL) {
+ if (error_local != NULL)
g_error_free (error_local);
- }
g_free (message);
g_free (text);
return ret;
@@ -2222,12 +2176,6 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
@@ -2237,9 +2185,6 @@
return FALSE;
}
- /* set title */
- gpk_client_setup_window (gclient, _("Getting update lists"));
-
/* wrap update, but handle all the GPG and EULA stuff */
ret = pk_client_get_updates (gclient->priv->client_action, PK_FILTER_ENUM_NONE, &error_local);
if (!ret) {
@@ -2249,10 +2194,16 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+
+ /* ignore this if it's uninteresting */
+ if (gclient->priv->show_progress) {
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Getting update lists"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
+ }
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* copy from client to local */
list = pk_client_get_package_list (gclient->priv->client_action);
@@ -2271,12 +2222,6 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* are we not able to do this? */
if (!pk_bitfield_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_DISTRO_UPGRADES)) {
gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Backend does not support GetDistroUpgrades");
@@ -2292,12 +2237,11 @@
return FALSE;
}
- /* set title */
- gpk_client_setup_window (gclient, _("Getting distribution upgrade information"));
-
/* clear old data */
- g_ptr_array_foreach (gclient->priv->upgrade_array, (GFunc) pk_distro_upgrade_obj_free, NULL);
- g_ptr_array_remove_range (gclient->priv->upgrade_array, 0, gclient->priv->upgrade_array->len);
+ if (gclient->priv->upgrade_array->len > 0) {
+ g_ptr_array_foreach (gclient->priv->upgrade_array, (GFunc) pk_distro_upgrade_obj_free, NULL);
+ g_ptr_array_remove_range (gclient->priv->upgrade_array, 0, gclient->priv->upgrade_array->len);
+ }
/* wrap update, but handle all the GPG and EULA stuff */
ret = pk_client_get_distro_upgrades (gclient->priv->client_action, &error_local);
@@ -2309,10 +2253,12 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Getting distribution upgrade information"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
out:
return gclient->priv->upgrade_array;
}
@@ -2329,12 +2275,6 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
@@ -2344,9 +2284,6 @@
return FALSE;
}
- /* set title */
- gpk_client_setup_window (gclient, _("Getting file lists"));
-
/* wrap get files */
package_ids = pk_package_ids_from_id (package_id);
ret = pk_client_get_files (gclient->priv->client_action, package_ids, &error_local);
@@ -2358,18 +2295,20 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, FALSE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Getting file lists"));
+ if (gclient->priv->show_progress)
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- if (error_local != NULL) {
+ if (error_local != NULL)
g_error_free (error_local);
- }
/* return the file list */
return g_strdupv (gclient->priv->files_array);
@@ -2388,12 +2327,6 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- /* check if we are already waiting */
- if (gclient->priv->gtk_main_waiting) {
- gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "Already waiting on this GpkClient");
- return FALSE;
- }
-
/* reset */
ret = pk_client_reset (gclient->priv->client_action, &error_local);
if (!ret) {
@@ -2402,9 +2335,6 @@
goto out;
}
- /* set title */
- gpk_client_setup_window (gclient, _("Update packages"));
-
/* wrap update, but handle all the GPG and EULA stuff */
ret = pk_client_update_packages (gclient->priv->client_action, package_ids, &error_local);
if (!ret) {
@@ -2423,18 +2353,19 @@
}
/* setup the UI */
- gpk_client_set_progress_files (gclient, TRUE);
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
+ gpk_client_dialog_set_title (gclient->priv->dialog, _("Update packages"));
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
/* fail the transaction and set the correct error */
ret = gpk_client_set_error_from_exit_enum (gclient->priv->exit, error);
out:
- if (error_local != NULL) {
+ if (error_local != NULL)
g_error_free (error_local);
- }
g_free (message);
g_free (text);
return ret;
@@ -2458,15 +2389,14 @@
ret = gpk_client_signature_show (package_id, repository_name, key_url, key_userid,
key_id, key_fingerprint, key_timestamp);
/* disagreed with auth */
- if (!ret) {
+ if (!ret)
return;
- }
/* install signature */
egg_debug ("install signature %s", key_id);
ret = pk_client_reset (gclient->priv->client_secondary, &error);
if (!ret) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
gpk_error_dialog_modal (GTK_WINDOW (widget), _("Failed to install signature"),
_("The client could not be reset"), error->message);
g_error_free (error);
@@ -2477,7 +2407,7 @@
key_id, package_id, &error);
gclient->priv->using_secondary_client = ret;
if (!ret) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
gpk_error_dialog_modal (GTK_WINDOW (widget), _("Failed to install signature"),
_("The method failed"), error->message);
g_error_free (error);
@@ -2496,19 +2426,17 @@
GtkWidget *widget;
/* do a helper */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
ret = gpk_client_eula_show (GTK_WINDOW (widget), eula_id, package_id, vendor_name, license_agreement);
/* disagreed with auth */
- if (!ret) {
+ if (!ret)
return;
- }
/* install signature */
egg_debug ("accept EULA %s", eula_id);
ret = pk_client_reset (gclient->priv->client_secondary, &error);
if (!ret) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
gpk_error_dialog_modal (GTK_WINDOW (widget), _("Failed to accept EULA"),
_("The client could not be reset"), error->message);
g_error_free (error);
@@ -2516,10 +2444,8 @@
}
/* this is asynchronous, else we get into livelock */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
ret = pk_client_accept_eula (gclient->priv->client_secondary, eula_id, &error);
if (!ret) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
gpk_error_dialog_modal (GTK_WINDOW (widget), _("Failed to accept EULA"),
_("The method failed"), error->message);
g_error_free (error);
@@ -2540,13 +2466,13 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
/* go back to the UI */
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
gclient->priv->using_secondary_client = FALSE;
egg_debug ("trying to requeue install");
ret = pk_client_requeue (gclient->priv->client_action, &error);
if (!ret) {
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ widget = GTK_WIDGET (gpk_client_dialog_get_window (gclient->priv->dialog));
gpk_error_dialog_modal (GTK_WINDOW (widget), _("Failed to install"),
_("The install task could not be requeued"), error->message);
g_error_free (error);
@@ -2590,11 +2516,10 @@
/* backup */
role_text = gpk_role_enum_to_localised_present (role);
- if (!egg_strzero (text) && role != PK_ROLE_ENUM_UPDATE_PACKAGES) {
+ if (!egg_strzero (text) && role != PK_ROLE_ENUM_UPDATE_PACKAGES)
message = g_strdup_printf ("%s: %s", role_text, text);
- } else {
+ else
message = g_strdup_printf ("%s", role_text);
- }
g_free (text);
return message;
@@ -2606,7 +2531,6 @@
gboolean
gpk_client_monitor_tid (GpkClient *gclient, const gchar *tid)
{
- GtkWidget *widget;
PkStatusEnum status;
gboolean ret;
gboolean allow_cancel;
@@ -2630,7 +2554,7 @@
/* fill in role */
text = pk_common_get_role_text (gclient->priv->client_action);
- gpk_client_setup_window (gclient, text);
+ gpk_client_dialog_set_title (gclient->priv->dialog, text);
g_free (text);
/* coldplug */
@@ -2644,8 +2568,7 @@
/* are we cancellable? */
pk_client_get_allow_cancel (gclient->priv->client_action, &allow_cancel, NULL);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
- gtk_widget_set_sensitive (widget, allow_cancel);
+ gpk_client_dialog_set_allow_cancel (gclient->priv->dialog, allow_cancel);
/* coldplug */
ret = pk_client_get_progress (gclient->priv->client_action,
@@ -2689,45 +2612,65 @@
role == PK_ROLE_ENUM_SEARCH_FILE ||
role == PK_ROLE_ENUM_SEARCH_NAME ||
role == PK_ROLE_ENUM_GET_UPDATES) {
- gpk_client_set_progress_files (gclient, FALSE);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, FALSE);
} else {
- gpk_client_set_progress_files (gclient, TRUE);
+ gpk_client_dialog_set_show_message (gclient->priv->dialog, TRUE);
}
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+ gpk_client_dialog_show_page (gclient->priv->dialog, GPK_CLIENT_DIALOG_PAGE_PROGRESS, 0);
- gpk_client_main_wait (gclient);
- gpk_client_done (gclient);
+ /* wait for an answer */
+ g_main_loop_run (gclient->priv->loop);
return TRUE;
}
/**
+ * gpk_client_set_application:
+ *
+ * This sets the package name of the application that is trying to install
+ * software, e.g. "totem" and is used for the PkExtra lookup to provide
+ * a translated name and icon.
+ **/
+gboolean
+gpk_client_set_application (GpkClient *gclient, const gchar *application)
+{
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ g_free (gclient->priv->application);
+ gclient->priv->application = g_strdup (application);
+ return TRUE;
+}
+
+/**
* gpk_client_set_parent:
**/
gboolean
gpk_client_set_parent (GpkClient *gclient, GtkWindow *window)
{
- GtkWidget *widget;
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_window_set_transient_for (GTK_WINDOW (widget), window);
- gclient->priv->parent_window = window;
+ gclient->priv->parent_window = GTK_WIDGET (window)->window;
return TRUE;
}
/**
- * gpk_client_create_custom_widget:
+ * gpk_client_set_parent_xid:
**/
-static GtkWidget *
-gpk_client_create_custom_widget (GladeXML *xml, gchar *func_name, gchar *name,
- gchar *string1, gchar *string2,
- gint int1, gint int2, gpointer user_data)
+gboolean
+gpk_client_set_parent_xid (GpkClient *gclient, guint32 xid)
{
- if (egg_strequal (name, "image_status")) {
- return gpk_animated_icon_new ();
- }
- egg_warning ("name unknown=%s", name);
- return NULL;
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ gclient->priv->parent_window = gdk_window_foreign_new (xid);
+ return TRUE;
+}
+
+/**
+ * gpk_client_update_timestamp:
+ **/
+gboolean
+gpk_client_update_timestamp (GpkClient *gclient, guint32 timestamp)
+{
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ gclient->priv->timestamp = timestamp;
+ return TRUE;
}
/**
@@ -2756,36 +2699,39 @@
static void
gpk_client_init (GpkClient *gclient)
{
- GtkWidget *widget;
+ gboolean ret;
gclient->priv = GPK_CLIENT_GET_PRIVATE (gclient);
- gclient->priv->glade_xml = NULL;
gclient->priv->files_array = NULL;
gclient->priv->parent_window = NULL;
- gclient->priv->pulse_timer_id = 0;
+ gclient->priv->application = NULL;
gclient->priv->using_secondary_client = FALSE;
- gclient->priv->gtk_main_waiting = FALSE;
gclient->priv->exit = PK_EXIT_ENUM_FAILED;
gclient->priv->interact = GPK_CLIENT_INTERACT_NEVER;
gclient->priv->show_finished = TRUE;
gclient->priv->show_progress = TRUE;
- gclient->priv->show_progress_files = TRUE;
gclient->priv->finished_timer_id = 0;
+ gclient->priv->timestamp = 0;
+ gclient->priv->loop = g_main_loop_new (NULL, FALSE);
/* add application specific icons to search path */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
PK_DATA G_DIR_SEPARATOR_S "icons");
- /* use custom widgets */
- glade_set_custom_handler (gpk_client_create_custom_widget, gclient);
+ gclient->priv->dialog = gpk_client_dialog_new ();
+ gpk_client_dialog_set_window_icon (gclient->priv->dialog, "pk-package-installed");
+ g_signal_connect (gclient->priv->dialog, "cancel",
+ G_CALLBACK (pk_client_button_cancel_cb), gclient);
+ g_signal_connect (gclient->priv->dialog, "close",
+ G_CALLBACK (pk_client_button_close_cb), gclient);
/* use gconf for session settings */
gclient->priv->gconf_client = gconf_client_get_default ();
/* get actions */
gclient->priv->control = pk_control_new ();
- gclient->priv->roles = pk_control_get_actions (gclient->priv->control);
+ gclient->priv->roles = pk_control_get_actions (gclient->priv->control, NULL);
gclient->priv->client_action = pk_client_new ();
pk_client_set_use_buffer (gclient->priv->client_action, TRUE, NULL);
@@ -2821,39 +2767,15 @@
g_signal_connect (gclient->priv->client_secondary, "finished",
G_CALLBACK (gpk_client_secondary_finished_cb), gclient);
- gclient->priv->glade_xml = glade_xml_new (PK_DATA "/gpk-client.glade", NULL, NULL);
-
- /* common stuff */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- g_signal_connect (widget, "delete_event", G_CALLBACK (gpk_client_updates_window_delete_event_cb), gclient);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_updates_button_close_cb), gclient);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close2");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_updates_button_close_cb), gclient);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close3");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_updates_button_close_cb), gclient);
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_client_button_cancel_cb), gclient);
- gtk_widget_set_sensitive (widget, FALSE);
-
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help3");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (gpk_client_button_help_cb), gclient);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help4");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (gpk_client_button_help_cb), gclient);
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help5");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (gpk_client_button_help_cb), gclient);
+ /* used for icons and translations */
+ gclient->priv->extra = pk_extra_new ();
+ ret = pk_extra_set_database (gclient->priv->extra, NULL);
+ if (!ret)
+ egg_warning ("failed to set extra database");
+ pk_extra_set_locale (gclient->priv->extra, NULL);
/* cache the upgrade array */
gclient->priv->upgrade_array = g_ptr_array_new ();
-
- /* set the label blank initially */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "progress_part_label");
- gtk_label_set_label (GTK_LABEL (widget), "");
}
/**
@@ -2871,13 +2793,10 @@
g_return_if_fail (gclient->priv != NULL);
/* stop the timers if running */
- if (gclient->priv->finished_timer_id != 0) {
+ if (gclient->priv->finished_timer_id != 0)
g_source_remove (gclient->priv->finished_timer_id);
- }
- if (gclient->priv->pulse_timer_id != 0) {
- g_source_remove (gclient->priv->pulse_timer_id);
- }
+ g_free (gclient->priv->application);
g_ptr_array_foreach (gclient->priv->upgrade_array, (GFunc) pk_distro_upgrade_obj_free, NULL);
g_ptr_array_free (gclient->priv->upgrade_array, TRUE);
g_strfreev (gclient->priv->files_array);
@@ -2885,7 +2804,10 @@
g_object_unref (gclient->priv->client_resolve);
g_object_unref (gclient->priv->client_secondary);
g_object_unref (gclient->priv->control);
+ g_object_unref (gclient->priv->extra);
g_object_unref (gclient->priv->gconf_client);
+ g_object_unref (gclient->priv->dialog);
+ g_main_loop_unref (gclient->priv->loop);
G_OBJECT_CLASS (gpk_client_parent_class)->finalize (object);
}
Modified: trunk/src/gpk-client.h
==============================================================================
--- trunk/src/gpk-client.h (original)
+++ trunk/src/gpk-client.h Tue Sep 16 12:52:51 2008
@@ -87,6 +87,9 @@
gboolean gpk_client_install_mime_type (GpkClient *gclient,
const gchar *mime_type,
GError **error);
+gboolean gpk_client_install_gstreamer_codecs (GpkClient *gclient,
+ gchar **codec_name_strings,
+ GError **error);
gboolean gpk_client_install_font (GpkClient *gclient,
const gchar *font_desc,
GError **error);
@@ -122,8 +125,14 @@
GError **error);
gboolean gpk_client_monitor_tid (GpkClient *gclient,
const gchar *tid);
+gboolean gpk_client_set_application (GpkClient *gclient,
+ const gchar *application);
gboolean gpk_client_set_parent (GpkClient *gclient,
GtkWindow *window);
+gboolean gpk_client_set_parent_xid (GpkClient *gclient,
+ guint xid);
+gboolean gpk_client_update_timestamp (GpkClient *gclient,
+ guint timestamp);
G_END_DECLS
Modified: trunk/src/gpk-common.c
==============================================================================
--- trunk/src/gpk-common.c (original)
+++ trunk/src/gpk-common.c Tue Sep 16 12:52:51 2008
@@ -60,6 +60,8 @@
{PK_INFO_ENUM_REMOVING, "pk-package-delete"},
{PK_INFO_ENUM_OBSOLETING, "pk-package-cleanup"},
{PK_INFO_ENUM_CLEANUP, "pk-package-cleanup"},
+ {PK_INFO_ENUM_COLLECTION_INSTALLED, "pk-collection-installed"},
+ {PK_INFO_ENUM_COLLECTION_AVAILABLE, "pk-collection-available"},
{0, NULL}
};
@@ -156,7 +158,7 @@
{PK_GROUP_ENUM_SCIENCE, "application-certificate"},
{PK_GROUP_ENUM_DOCUMENTATION, "x-office-address-book"},
{PK_GROUP_ENUM_ELECTRONICS, "video-display"},
- {PK_GROUP_ENUM_META_PACKAGES, "pk-collection-installed"},
+ {PK_GROUP_ENUM_COLLECTIONS, "pk-collection-installed"},
{0, NULL}
};
@@ -928,9 +930,11 @@
text = _("Blocked update");
break;
case PK_INFO_ENUM_INSTALLED:
+ case PK_INFO_ENUM_COLLECTION_INSTALLED:
text = _("Installed");
break;
case PK_INFO_ENUM_AVAILABLE:
+ case PK_INFO_ENUM_COLLECTION_AVAILABLE:
text = _("Available");
break;
default:
@@ -1314,7 +1318,7 @@
case PK_GROUP_ENUM_ELECTRONICS:
text = _("Electronics");
break;
- case PK_GROUP_ENUM_META_PACKAGES:
+ case PK_GROUP_ENUM_COLLECTIONS:
text = _("Package collections");
break;
case PK_GROUP_ENUM_UNKNOWN:
@@ -1392,11 +1396,10 @@
uid = getuid ();
if (uid == 0) {
- if (application_name == NULL) {
+ if (application_name == NULL)
title = g_strdup (_("This application is running as a privileged user"));
- } else {
+ else
title = g_strdup_printf (_("%s is running as a privileged user"), application_name);
- }
message = g_strjoin ("\n",
_("Running graphical applications as a privileged user should be avoided for security reasons."),
_("PackageKit applications are security sensitive and therefore this application will now close."), NULL);
@@ -1422,14 +1425,12 @@
gboolean ret = TRUE;
/* trivial case */
- if (egg_strzero (icon)) {
+ if (egg_strzero (icon))
return FALSE;
- }
/* no unref required */
- if (icon_theme == NULL) {
+ if (icon_theme == NULL)
icon_theme = gtk_icon_theme_get_default ();
- }
/* default to 32x32 */
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 32, GTK_ICON_LOOKUP_USE_BUILTIN);
@@ -1495,9 +1496,8 @@
}
/* stop spinning */
- if (status == PK_STATUS_ENUM_FINISHED) {
+ if (status == PK_STATUS_ENUM_FINISHED)
gpk_animated_icon_enable_animation (icon, FALSE);
- }
return TRUE;
}
@@ -1606,9 +1606,8 @@
/* trivial case */
length = g_strv_length (array);
- if (length == 0) {
+ if (length == 0)
return g_strdup ("none");
- }
/* try and get a print format */
if (length == 1) {
Modified: trunk/src/gpk-dbus.c
==============================================================================
--- trunk/src/gpk-dbus.c (original)
+++ trunk/src/gpk-dbus.c Tue Sep 16 12:52:51 2008
@@ -38,10 +38,13 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <polkit/polkit.h>
+#include <polkit-dbus/polkit-dbus.h>
#include <pk-common.h>
#include <pk-package-id.h>
#include <pk-package-ids.h>
+#include <pk-client.h>
#include <pk-enum.h>
#include "egg-debug.h"
#include <pk-package-list.h>
@@ -57,6 +60,7 @@
struct GpkDbusPrivate
{
+ PkClient *client;
GpkClient *gclient;
};
@@ -70,9 +74,8 @@
gpk_dbus_error_quark (void)
{
static GQuark quark = 0;
- if (!quark) {
+ if (!quark)
quark = g_quark_from_static_string ("gpk_dbus_error");
- }
return quark;
}
@@ -97,16 +100,132 @@
}
/**
+ * gpk_dbus_get_exec_for_sender:
+ **/
+static gchar *
+gpk_dbus_get_exec_for_sender (const gchar *sender)
+{
+ pid_t pid;
+ gchar exec[128];
+ PolKitCaller *caller = NULL;
+ DBusError dbus_error;
+ gboolean ret = FALSE;
+ gint retval;
+ DBusConnection *connection;
+ gchar *sender_exe = NULL;
+
+ /* get a connection */
+ connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+ if (connection == NULL)
+ egg_error ("fatal, no system dbus");
+
+ dbus_error_init (&dbus_error);
+ caller = polkit_caller_new_from_dbus_name (connection, sender, &dbus_error);
+ if (caller == NULL) {
+ egg_warning ("cannot get caller from sender %s: %s", sender, dbus_error.message);
+ dbus_error_free (&dbus_error);
+ goto out;
+ }
+
+ ret = polkit_caller_get_pid (caller, &pid);
+ if (!ret) {
+ egg_warning ("cannot get pid from sender %p", sender);
+ goto out;
+ }
+
+ retval = polkit_sysdeps_get_exe_for_pid (pid, exec, 128);
+ if (retval == -1) {
+ egg_warning ("cannot get exec for pid %i", pid);
+ goto out;
+ }
+
+ /* make a copy */
+ sender_exe = g_strdup (exec);
+
+out:
+ if (caller != NULL)
+ polkit_caller_unref (caller);
+ return sender_exe;
+}
+
+/**
+ * gpk_dbus_get_application_for_sender:
+ **/
+static gchar *
+gpk_dbus_get_application_for_sender (GpkDbus *dbus, const gchar *sender)
+{
+ gchar *exec;
+ gchar *application = NULL;
+ gboolean ret;
+ GError *error = NULL;
+ guint length;
+ PkPackageList *list = NULL;
+ const PkPackageObj *obj;
+
+ exec = gpk_dbus_get_exec_for_sender (sender);
+ if (exec == NULL) {
+ egg_warning ("could not get exec name for %s", sender);
+ goto out;
+ }
+ egg_debug ("got application path %s", exec);
+
+ /* reset client */
+ ret = pk_client_reset (dbus->priv->client, &error);
+ if (!ret) {
+ egg_warning ("failed to reset client: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* find the package name */
+ ret = pk_client_search_file (dbus->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, &error);
+ if (!ret) {
+ egg_warning ("failed to search file: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* get the list of packages */
+ list = pk_client_get_package_list (dbus->priv->client);
+ length = pk_package_list_get_size (list);
+
+ /* nothing found */
+ if (length == 0) {
+ egg_debug ("cannot find installed package that provides : %s", exec);
+ goto out;
+ }
+
+ /* check we have one */
+ if (length != 1)
+ egg_warning ("not one return, using first");
+
+ /* copy name */
+ obj = pk_package_list_get_obj (list, 0);
+ application = g_strdup (obj->id->name);
+ egg_debug ("got application package %s", application);
+
+out:
+ /* use the exec name if we can't find an installed package */
+ if (application == NULL && exec != NULL)
+ application = g_strdup (exec);
+ if (list != NULL)
+ g_object_unref (list);
+ g_free (exec);
+ return application;
+}
+
+/**
* gpk_dbus_install_local_file:
**/
void
-gpk_dbus_install_local_file (GpkDbus *dbus, const gchar *full_path, DBusGMethodInvocation *context)
+gpk_dbus_install_local_file (GpkDbus *dbus, guint32 xid, guint32 timestamp, const gchar *full_path, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
GError *error_local = NULL;
gchar *sender;
gchar **full_paths;
+ gchar *application;
g_return_if_fail (PK_IS_DBUS (dbus));
@@ -114,10 +233,20 @@
/* check sender */
sender = dbus_g_method_get_sender (context);
- egg_warning ("sender=%s", sender);
+ egg_debug ("sender=%s", sender);
/* just convert from char* to char** */
full_paths = g_strsplit (full_path, "|", 1);
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+
+ /* do the action */
ret = gpk_client_install_local_files (dbus->priv->gclient, full_paths, &error_local);
g_strfreev (full_paths);
if (!ret) {
@@ -135,12 +264,13 @@
* gpk_dbus_install_provide_file:
**/
void
-gpk_dbus_install_provide_file (GpkDbus *dbus, const gchar *full_path, DBusGMethodInvocation *context)
+gpk_dbus_install_provide_file (GpkDbus *dbus, guint32 xid, guint32 timestamp, const gchar *full_path, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
GError *error_local = NULL;
gchar *sender;
+ gchar *application;
g_return_if_fail (PK_IS_DBUS (dbus));
@@ -148,8 +278,18 @@
/* check sender */
sender = dbus_g_method_get_sender (context);
- egg_warning ("sender=%s", sender);
+ egg_debug ("sender=%s", sender);
+
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+ /* do the action */
ret = gpk_client_install_provide_file (dbus->priv->gclient, full_path, &error_local);
if (!ret) {
error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_DENIED,
@@ -166,13 +306,14 @@
* gpk_dbus_install_package_name:
**/
void
-gpk_dbus_install_package_name (GpkDbus *dbus, const gchar *package_name, DBusGMethodInvocation *context)
+gpk_dbus_install_package_name (GpkDbus *dbus, guint32 xid, guint32 timestamp, const gchar *package_name, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
GError *error_local = NULL;
gchar *sender;
gchar **package_names;
+ gchar *application;
g_return_if_fail (PK_IS_DBUS (dbus));
@@ -180,10 +321,20 @@
/* check sender */
sender = dbus_g_method_get_sender (context);
- egg_warning ("sender=%s", sender);
+ egg_debug ("sender=%s", sender);
/* just convert from char* to char** */
package_names = g_strsplit (package_name, "|", 1);
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+
+ /* do the action */
ret = gpk_client_install_package_names (dbus->priv->gclient, package_names, &error_local);
g_strfreev (package_names);
@@ -202,12 +353,13 @@
* gpk_dbus_install_mime_type:
**/
void
-gpk_dbus_install_mime_type (GpkDbus *dbus, const gchar *mime_type, DBusGMethodInvocation *context)
+gpk_dbus_install_mime_type (GpkDbus *dbus, guint32 xid, guint32 timestamp, const gchar *mime_type, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
GError *error_local = NULL;
gchar *sender;
+ gchar *application;
g_return_if_fail (PK_IS_DBUS (dbus));
@@ -215,8 +367,18 @@
/* check sender */
sender = dbus_g_method_get_sender (context);
- egg_warning ("sender=%s", sender);
+ egg_debug ("sender=%s", sender);
+
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+ /* do the action */
ret = gpk_client_install_mime_type (dbus->priv->gclient, mime_type, &error_local);
if (!ret) {
error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_DENIED,
@@ -230,15 +392,88 @@
}
/**
+ * gpk_dbus_install_gstreamer_codecs:
+ **/
+void
+gpk_dbus_install_gstreamer_codecs (GpkDbus *dbus, guint32 xid, guint32 timestamp, GPtrArray *codecs, DBusGMethodInvocation *context)
+{
+ gboolean ret;
+ GError *error;
+ GError *error_local = NULL;
+ gchar *sender;
+ gchar *application;
+
+ g_return_if_fail (PK_IS_DBUS (dbus));
+
+ guint i;
+ GValue *value;
+ gchar *description;
+ gchar *detail;
+ gchar *encoded;
+ GPtrArray *array;
+ GValueArray *varray;
+ gchar **codec_strings;
+
+ egg_debug ("InstallGStreamerCodecs method called");
+
+ /* check sender */
+ sender = dbus_g_method_get_sender (context);
+ egg_debug ("sender=%s", sender);
+
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+
+ /* unwrap and turn into a GPtrArray */
+ array = g_ptr_array_new ();
+ for (i=0; i<codecs->len; i++) {
+ varray = (GValueArray *) g_ptr_array_index (codecs, 0);
+ value = g_value_array_get_nth (varray, 0);
+ description = g_value_dup_string (value);
+ value = g_value_array_get_nth (varray, 1);
+ detail = g_value_dup_string (value);
+ encoded = g_strdup_printf ("%s|%s", description, detail);
+ g_ptr_array_add (array, encoded);
+ g_free (description);
+ g_free (detail);
+ }
+
+ /* convert to an strv */
+ codec_strings = pk_ptr_array_to_strv (array);
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
+ g_ptr_array_free (array, TRUE);
+
+ /* do the action */
+ ret = gpk_client_install_gstreamer_codecs (dbus->priv->gclient, codec_strings, &error_local);
+ g_strfreev (codec_strings);
+
+ if (!ret) {
+ error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_DENIED,
+ "Method failed: %s", error_local->message);
+ g_error_free (error_local);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ dbus_g_method_return (context);
+}
+
+/**
* gpk_dbus_install_font:
**/
void
-gpk_dbus_install_font (GpkDbus *dbus, const gchar *font_desc, DBusGMethodInvocation *context)
+gpk_dbus_install_font (GpkDbus *dbus, guint32 xid, guint32 timestamp, const gchar *font_desc, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
GError *error_local = NULL;
gchar *sender;
+ gchar *application;
g_return_if_fail (PK_IS_DBUS (dbus));
@@ -246,8 +481,18 @@
/* check sender */
sender = dbus_g_method_get_sender (context);
- egg_warning ("sender=%s", sender);
+ egg_debug ("sender=%s", sender);
+
+ gpk_client_set_parent_xid (dbus->priv->gclient, xid);
+ gpk_client_update_timestamp (dbus->priv->gclient, timestamp);
+ /* get the program name and set */
+ application = gpk_dbus_get_application_for_sender (dbus, sender);
+ gpk_client_set_application (dbus->priv->gclient, application);
+ g_free (sender);
+ g_free (application);
+
+ /* do the action */
ret = gpk_client_install_font (dbus->priv->gclient, font_desc, &error_local);
if (!ret) {
error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_DENIED,
@@ -281,6 +526,10 @@
{
dbus->priv = GPK_DBUS_GET_PRIVATE (dbus);
dbus->priv->gclient = gpk_client_new ();
+ dbus->priv->client = pk_client_new ();
+ pk_client_set_synchronous (dbus->priv->client, TRUE, NULL);
+ pk_client_set_use_buffer (dbus->priv->client, TRUE, NULL);
+
}
/**
@@ -295,6 +544,7 @@
dbus = GPK_DBUS (object);
g_return_if_fail (dbus->priv != NULL);
+ g_object_unref (dbus->priv->client);
g_object_unref (dbus->priv->gclient);
G_OBJECT_CLASS (gpk_dbus_parent_class)->finalize (object);
@@ -320,25 +570,20 @@
#include "egg-test.h"
void
-egg_test_dbus (EggTest *test)
+gpk_dbus_test (EggTest *test)
{
GpkDbus *dbus = NULL;
- gboolean ret;
- const gchar *temp;
- GError *error = NULL;
- if (egg_test_start (test, "GpkDbus") == FALSE) {
+ if (!egg_test_start (test, "GpkDbus"))
return;
- }
/************************************************************/
egg_test_title (test, "get GpkDbus object");
dbus = gpk_dbus_new ();
- if (dbus != NULL) {
+ if (dbus != NULL)
egg_test_success (test, NULL);
- } else {
+ else
egg_test_failed (test, NULL);
- }
g_object_unref (dbus);
Modified: trunk/src/gpk-dbus.h
==============================================================================
--- trunk/src/gpk-dbus.h (original)
+++ trunk/src/gpk-dbus.h Tue Sep 16 12:52:51 2008
@@ -61,18 +61,33 @@
GpkDbus *gpk_dbus_new (void);
void gpk_dbus_install_local_file (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
const gchar *full_path,
DBusGMethodInvocation *context);
void gpk_dbus_install_provide_file (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
const gchar *full_path,
DBusGMethodInvocation *context);
void gpk_dbus_install_package_name (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
const gchar *package_name,
DBusGMethodInvocation *context);
void gpk_dbus_install_mime_type (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
const gchar *mime_type,
DBusGMethodInvocation *context);
+void gpk_dbus_install_gstreamer_codecs (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
+ GPtrArray *codecs,
+ DBusGMethodInvocation *context);
void gpk_dbus_install_font (GpkDbus *dbus,
+ guint32 xid,
+ guint32 timestamp,
const gchar *font_desc,
DBusGMethodInvocation *context);
Modified: trunk/src/gpk-dialog.c
==============================================================================
--- trunk/src/gpk-dialog.c (original)
+++ trunk/src/gpk-dialog.c Tue Sep 16 12:52:51 2008
@@ -68,12 +68,12 @@
g_ptr_array_add (array, g_strdup (ident->name));
pk_package_id_free (ident);
}
- array_strv = pk_ptr_array_to_argv (array);
+ array_strv = pk_ptr_array_to_strv (array);
text = gpk_strv_join_locale (array_strv);
g_strfreev (array_strv);
- if (text == NULL) {
+ if (text == NULL)
text = g_strdup (_("many packages"));
- }
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
g_ptr_array_free (array, TRUE);
return text;
}
@@ -226,7 +226,7 @@
gchar *text;
/* split and show */
- array = pk_ptr_array_to_argv (files);
+ array = pk_ptr_array_to_strv (files);
text = g_strjoinv ("\n", array);
if (egg_strzero (text)) {
Modified: trunk/src/gpk-error.c
==============================================================================
--- trunk/src/gpk-error.c (original)
+++ trunk/src/gpk-error.c Tue Sep 16 12:52:51 2008
@@ -35,7 +35,7 @@
#include "gpk-common.h"
/**
- * gpk_error_dialog_modal:
+ * gpk_error_dialog_modal_with_time:
* @window: the parent dialog
* @title: the localised text to put in bold as a title
* @message: the localised text to put as a message
@@ -44,7 +44,7 @@
* Shows a modal error, and blocks until the user clicks close
**/
gboolean
-gpk_error_dialog_modal (GtkWindow *window, const gchar *title, const gchar *message, const gchar *details)
+gpk_error_dialog_modal_with_time (GtkWindow *window, const gchar *title, const gchar *message, const gchar *details, guint timestamp)
{
GtkWidget *widget;
GladeXML *glade_xml;
@@ -95,7 +95,7 @@
/* show window */
widget = glade_xml_get_widget (glade_xml, "window_error");
- gtk_widget_show (widget);
+ gtk_window_present_with_time (GTK_WINDOW (widget), timestamp);
/* wait for button press */
gtk_main ();
@@ -110,6 +110,21 @@
}
/**
+ * gpk_error_dialog_modal:
+ * @window: the parent dialog
+ * @title: the localised text to put in bold as a title
+ * @message: the localised text to put as a message
+ * @details: the geeky text to in the expander, or %NULL if nothing
+ *
+ * Shows a modal error, and blocks until the user clicks close
+ **/
+gboolean
+gpk_error_dialog_modal (GtkWindow *window, const gchar *title, const gchar *message, const gchar *details)
+{
+ return gpk_error_dialog_modal_with_time (window, title, message, details, 0);
+}
+
+/**
* gpk_error_dialog:
* @title: the localised text to put in bold as a title
* @message: the localised text to put as a message
Modified: trunk/src/gpk-error.h
==============================================================================
--- trunk/src/gpk-error.h (original)
+++ trunk/src/gpk-error.h Tue Sep 16 12:52:51 2008
@@ -33,6 +33,11 @@
const gchar *title,
const gchar *message,
const gchar *details);
+gboolean gpk_error_dialog_modal_with_time (GtkWindow *window,
+ const gchar *title,
+ const gchar *message,
+ const gchar *details,
+ guint timestamp);
G_END_DECLS
Modified: trunk/src/gpk-firmware.c
==============================================================================
--- trunk/src/gpk-firmware.c (original)
+++ trunk/src/gpk-firmware.c Tue Sep 16 12:52:51 2008
@@ -87,7 +87,7 @@
filename = egg_str_list_index (array, i);
ret = gpk_client_install_provide_file (gclient, filename, &error);
if (!ret) {
- egg_warning ("failed to open directory: %s", error->message);
+ egg_warning ("failed to install provide file: %s", error->message);
g_error_free (error);
error = NULL;
}
Modified: trunk/src/gpk-interface.h
==============================================================================
--- trunk/src/gpk-interface.h (original)
+++ trunk/src/gpk-interface.h Tue Sep 16 12:52:51 2008
@@ -53,30 +53,32 @@
#endif /* !G_ENABLE_DEBUG */
-/* NONE:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.DVLEGU:1) */
-extern void dbus_glib_marshal_gpk_dbus_VOID__STRING_POINTER (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
+/* NONE:UINT,UINT,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.7W8JHU:1) */
+extern void dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
void
-dbus_glib_marshal_gpk_dbus_VOID__STRING_POINTER (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
+dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
{
- typedef void (*GMarshalFunc_VOID__STRING_POINTER) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_POINTER callback;
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_STRING_POINTER) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_STRING_POINTER callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
- g_return_if_fail (n_param_values == 3);
+ g_return_if_fail (n_param_values == 5);
if (G_CCLOSURE_SWAP_DATA (closure))
{
@@ -88,14 +90,64 @@
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
- callback = (GMarshalFunc_VOID__STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+ callback = (GMarshalFunc_VOID__UINT_UINT_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
callback (data1,
- g_marshal_value_peek_string (param_values + 1),
- g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
data2);
}
-#define dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER dbus_glib_marshal_gpk_dbus_VOID__STRING_POINTER
+#define dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_STRING_POINTER
+
+/* NONE:UINT,UINT,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.7W8JHU:2) */
+extern void dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_BOXED_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_BOXED_POINTER) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+}
+#define dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_BOXED_POINTER dbus_glib_marshal_gpk_dbus_VOID__UINT_UINT_BOXED_POINTER
G_END_DECLS
@@ -103,18 +155,19 @@
#include <dbus/dbus-glib.h>
static const DBusGMethodInfo dbus_glib_gpk_dbus_methods[] = {
- { (GCallback) gpk_dbus_install_local_file, dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER, 0 },
- { (GCallback) gpk_dbus_install_provide_file, dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER, 61 },
- { (GCallback) gpk_dbus_install_package_name, dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER, 124 },
- { (GCallback) gpk_dbus_install_mime_type, dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER, 190 },
- { (GCallback) gpk_dbus_install_font, dbus_glib_marshal_gpk_dbus_NONE__STRING_POINTER, 250 },
+ { (GCallback) gpk_dbus_install_local_file, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER, 0 },
+ { (GCallback) gpk_dbus_install_provide_file, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER, 83 },
+ { (GCallback) gpk_dbus_install_package_name, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER, 168 },
+ { (GCallback) gpk_dbus_install_mime_type, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER, 256 },
+ { (GCallback) gpk_dbus_install_gstreamer_codecs, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_BOXED_POINTER, 338 },
+ { (GCallback) gpk_dbus_install_font, dbus_glib_marshal_gpk_dbus_NONE__UINT_UINT_STRING_POINTER, 428 },
};
const DBusGObjectInfo dbus_glib_gpk_dbus_object_info = {
0,
dbus_glib_gpk_dbus_methods,
- 5,
-"org.freedesktop.PackageKit\0InstallLocalFile\0A\0full_path\0I\0s\0\0org.freedesktop.PackageKit\0InstallProvideFile\0A\0full_path\0I\0s\0\0org.freedesktop.PackageKit\0InstallPackageName\0A\0package_name\0I\0s\0\0org.freedesktop.PackageKit\0InstallMimeType\0A\0mime_type\0I\0s\0\0org.freedesktop.PackageKit\0InstallFont\0A\0font_desc\0I\0s\0\0\0",
+ 6,
+"org.freedesktop.PackageKit\0InstallLocalFile\0A\0xid\0I\0u\0timestamp\0I\0u\0full_path\0I\0s\0\0org.freedesktop.PackageKit\0InstallProvideFile\0A\0xid\0I\0u\0timestamp\0I\0u\0full_path\0I\0s\0\0org.freedesktop.PackageKit\0InstallPackageName\0A\0xid\0I\0u\0timestamp\0I\0u\0package_name\0I\0s\0\0org.freedesktop.PackageKit\0InstallMimeType\0A\0xid\0I\0u\0timestamp\0I\0u\0mime_type\0I\0s\0\0org.freedesktop.PackageKit\0InstallGStreamerCodecs\0A\0xid\0I\0u\0timestamp\0I\0u\0codecs\0I\0a(ss)\0\0org.freedesktop.PackageKit\0InstallFont\0A\0xid\0I\0u\0timestamp\0I\0u\0font_desc\0I\0s\0\0\0",
"\0",
"\0"
};
Modified: trunk/src/gpk-interface.xml
==============================================================================
--- trunk/src/gpk-interface.xml (original)
+++ trunk/src/gpk-interface.xml Tue Sep 16 12:52:51 2008
@@ -3,22 +3,38 @@
<interface name="org.freedesktop.PackageKit">
<method name="InstallLocalFile">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
<arg type="s" name="full_path" direction="in"/>
</method>
<method name="InstallProvideFile">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
<arg type="s" name="full_path" direction="in"/>
</method>
<method name="InstallPackageName">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
<arg type="s" name="package_name" direction="in"/>
</method>
<method name="InstallMimeType">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
<arg type="s" name="mime_type" direction="in"/>
</method>
+ <method name="InstallGStreamerCodecs">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
+ <arg type="a(ss)" name="codecs" direction="in"/>
+ </method>
<method name="InstallFont">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="xid" direction="in"/>
+ <arg type="u" name="timestamp" direction="in"/>
<arg type="s" name="font_desc" direction="in"/>
</method>
</interface>
Modified: trunk/src/gpk-log.c
==============================================================================
--- trunk/src/gpk-log.c (original)
+++ trunk/src/gpk-log.c Tue Sep 16 12:52:51 2008
@@ -405,7 +405,7 @@
/* get actions */
control = pk_control_new ();
- roles = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control, NULL);
g_object_unref (control);
glade_xml = glade_xml_new (PK_DATA "/gpk-log.glade", NULL, NULL);
Modified: trunk/src/gpk-prefs.c
==============================================================================
--- trunk/src/gpk-prefs.c (original)
+++ trunk/src/gpk-prefs.c Tue Sep 16 12:52:51 2008
@@ -394,7 +394,7 @@
/* get actions */
control = pk_control_new ();
- roles = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control, NULL);
g_object_unref (control);
glade_xml = glade_xml_new (PK_DATA "/gpk-prefs.glade", NULL, NULL);
Modified: trunk/src/gpk-repo.c
==============================================================================
--- trunk/src/gpk-repo.c (original)
+++ trunk/src/gpk-repo.c Tue Sep 16 12:52:51 2008
@@ -389,7 +389,7 @@
control = pk_control_new ();
g_signal_connect (control, "repo-list-changed",
G_CALLBACK (gpk_repo_repo_list_changed_cb), NULL);
- roles = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control, NULL);
/* use custom widgets */
glade_set_custom_handler (gpk_repo_create_custom_widget, NULL);
Modified: trunk/src/gpk-self-test.c
==============================================================================
--- trunk/src/gpk-self-test.c (original)
+++ trunk/src/gpk-self-test.c Tue Sep 16 12:52:51 2008
@@ -26,6 +26,8 @@
#include "gpk-common.h"
void egg_string_test (EggTest *test);
+void gpk_dbus_test (EggTest *test);
+void gpk_client_dialog_test (EggTest *test);
int
main (int argc, char **argv)
@@ -35,12 +37,15 @@
if (! g_thread_supported ())
g_thread_init (NULL);
g_type_init ();
+ gtk_init (&argc, &argv);
test = egg_test_init ();
egg_debug_init (TRUE);
/* tests go here */
egg_string_test (test);
gpk_common_test (test);
+ gpk_dbus_test (test);
+ gpk_client_dialog_test (test);
return egg_test_finish (test);
}
Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c (original)
+++ trunk/src/gpk-update-viewer.c Tue Sep 16 12:52:51 2008
@@ -276,6 +276,7 @@
}
/* get rid of the array, and free the contents */
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
g_ptr_array_free (array, TRUE);
}
@@ -1893,7 +1894,7 @@
G_CALLBACK (gpk_update_viewer_error_code_cb), NULL);
/* get actions */
- roles = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control, NULL);
/* monitor for other updates in progress */
tlist = pk_task_list_new ();
Modified: trunk/src/gpk-watch.c
==============================================================================
--- trunk/src/gpk-watch.c (original)
+++ trunk/src/gpk-watch.c Tue Sep 16 12:52:51 2008
@@ -42,7 +42,6 @@
#include <pk-control.h>
#include <pk-client.h>
-#include <pk-task-list.h>
#include <pk-common.h>
#include <pk-task-list.h>
#include <pk-connection.h>
@@ -490,7 +489,7 @@
/**
* gpk_watch_about_dialog_url_cb:
**/
-static void
+static void
gpk_watch_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpointer data)
{
GError *error = NULL;
@@ -520,7 +519,7 @@
cmdline = g_strconcat ("gnome-open ", url, NULL);
ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
g_free (cmdline);
-
+
if (!ret) {
gpk_error_dialog (_("Internal error"), _("Failed to show url"), error->message);
g_error_free (error);
@@ -1001,6 +1000,7 @@
gchar *proxy_http;
gchar *proxy_ftp;
gboolean ret;
+ GError *error = NULL;
g_return_val_if_fail (GPK_IS_WATCH (watch), FALSE);
@@ -1011,9 +1011,10 @@
proxy_ftp = gpk_watch_get_proxy_ftp (watch);
egg_debug ("set proxy_http=%s, proxy_ftp=%s", proxy_http, proxy_ftp);
- ret = pk_control_set_proxy (watch->priv->control, proxy_http, proxy_ftp);
+ ret = pk_control_set_proxy (watch->priv->control, proxy_http, proxy_ftp, &error);
if (!ret) {
- egg_warning ("setting proxy failed");
+ egg_warning ("setting proxy failed: %s", error->message);
+ g_error_free (error);
}
g_free (proxy_http);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]