gnome-packagekit r193 - trunk/src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r193 - trunk/src
- Date: Wed, 30 Apr 2008 14:29:02 +0100 (BST)
Author: rhughes
Date: Wed Apr 30 13:29:01 2008
New Revision: 193
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=193&view=rev
Log:
from git
Modified:
trunk/src/Makefile.am
trunk/src/gpk-application-main.c
trunk/src/gpk-application.c
trunk/src/gpk-client.c
trunk/src/gpk-client.h
trunk/src/gpk-notify.c
trunk/src/gpk-prefs.c
trunk/src/gpk-repo.c
trunk/src/gpk-update-icon.c
trunk/src/gpk-update-viewer.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Apr 30 13:29:01 2008
@@ -42,10 +42,21 @@
gpk-backend-status \
$(NULL)
-gpk_install_provide_file_SOURCES = \
- gpk-install-provide-file.c \
+shared_SOURCES = \
+ gpk-marshal.c \
+ gpk-marshal.h \
+ gpk-consolekit.c \
+ gpk-consolekit.h \
gpk-client.c \
gpk-client.h \
+ gpk-client-eula.c \
+ gpk-client-eula.h \
+ gpk-client-signature.c \
+ gpk-client-signature.h \
+ gpk-client-untrusted.c \
+ gpk-client-untrusted.h \
+ gpk-smart-icon.c \
+ gpk-smart-icon.h \
gpk-gnome.c \
gpk-gnome.h \
gpk-common.c \
@@ -54,58 +65,42 @@
gpk-error.h \
$(NULL)
-gpk_install_provide_file_LDADD = \
+shared_LIBS = \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GCONF_LIBS) \
$(LIBGLADE_LIBS) \
$(GTK_LIBS) \
+ $(LIBNOTIFY_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
$(NULL)
+gpk_install_provide_file_SOURCES = \
+ gpk-install-provide-file.c \
+ $(shared_SOURCES) \
+ $(NULL)
+
+gpk_install_provide_file_LDADD = \
+ $(shared_LIBS) \
+ $(NULL)
+
gpk_install_local_file_SOURCES = \
gpk-install-local-file.c \
- gpk-client.c \
- gpk-client.h \
- gpk-gnome.c \
- gpk-gnome.h \
- gpk-common.c \
- gpk-common.h \
- gpk-error.c \
- gpk-error.h \
+ $(shared_SOURCES) \
$(NULL)
gpk_install_local_file_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(GCONF_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_install_package_name_SOURCES = \
gpk-install-package-name.c \
- gpk-client.c \
- gpk-client.h \
- gpk-gnome.c \
- gpk-gnome.h \
- gpk-common.c \
- gpk-common.h \
- gpk-error.c \
- gpk-error.h \
+ $(shared_SOURCES) \
$(NULL)
gpk_install_package_name_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(GCONF_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_update_icon_SOURCES = \
@@ -122,60 +117,27 @@
gpk-inhibit.h \
gpk-dbus.c \
gpk-dbus.h \
- gpk-smart-icon.c \
- gpk-smart-icon.h \
- gpk-marshal.c \
- gpk-marshal.h \
- gpk-consolekit.c \
- gpk-consolekit.h \
gpk-progress.c \
gpk-progress.h \
- gpk-common.c \
- gpk-common.h \
- gpk-client.c \
- gpk-client.h \
- gpk-gnome.c \
- gpk-gnome.h \
- gpk-error.c \
- gpk-error.h \
+ $(shared_SOURCES) \
$(NULL)
gpk_update_icon_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBNOTIFY_LIBS) \
- $(GTK_LIBS) \
- $(GCONF_LIBS) \
- $(LIBGLADE_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_application_SOURCES = \
gpk-application-main.c \
gpk-application.c \
gpk-application.h \
- gpk-common.c \
- gpk-common.h \
- gpk-gnome.c \
- gpk-gnome.h \
- gpk-error.c \
- gpk-error.h \
- gpk-client.c \
- gpk-client.h \
gpk-statusbar.c \
gpk-statusbar.h \
+ $(shared_SOURCES) \
$(NULL)
gpk_application_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(GCONF_LIBS) \
- $(LIBGLADE_LIBS) \
+ $(shared_LIBS) \
$(LIBSEXY_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(NULL)
gpk_prefs_SOURCES = \
@@ -185,41 +147,20 @@
$(NULL)
gpk_prefs_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GCONF_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_update_viewer_SOURCES = \
gpk-update-viewer.c \
gpk-statusbar.c \
gpk-statusbar.h \
- gpk-consolekit.c \
- gpk-consolekit.h \
- gpk-client.c \
- gpk-client.h \
- gpk-gnome.c \
- gpk-gnome.h \
- gpk-common.c \
- gpk-common.h \
- gpk-error.c \
- gpk-error.h \
gpk-cell-renderer-uri.c \
gpk-cell-renderer-uri.h \
+ $(shared_SOURCES) \
$(NULL)
gpk_update_viewer_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GTK_LIBS) \
- $(GCONF_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_repo_SOURCES = \
@@ -235,13 +176,7 @@
$(NULL)
gpk_repo_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GCONF_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_log_SOURCES = \
@@ -253,12 +188,7 @@
$(NULL)
gpk_log_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_backend_status_SOURCES = \
@@ -266,11 +196,7 @@
$(NULL)
gpk_backend_status_LDADD = \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBGLADE_LIBS) \
- $(GTK_LIBS) \
- $(PACKAGEKIT_LIBS) \
+ $(shared_LIBS) \
$(NULL)
BUILT_SOURCES = \
@@ -306,13 +232,7 @@
$(NULL)
gpk_self_test_LDADD = \
- $(GLIB_LIBS) \
- $(GTK_LIBS) \
- $(DBUS_LIBS) \
- $(SELFTEST_LIBS) \
- $(PK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(shared_LIBS) \
$(NULL)
gpk_self_test_CPPFLAGS = -DPK_BUILD_TESTS
Modified: trunk/src/gpk-application-main.c
==============================================================================
--- trunk/src/gpk-application-main.c (original)
+++ trunk/src/gpk-application-main.c Wed Apr 30 13:29:01 2008
@@ -53,7 +53,6 @@
int
main (int argc, char *argv[])
{
- GMainLoop *loop;
gboolean verbose = FALSE;
gboolean program_version = FALSE;
GpkApplication *application = NULL;
@@ -98,9 +97,9 @@
g_signal_connect (application, "action-close",
G_CALLBACK (gpk_application_close_cb), NULL);
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ /* wait */
+ gtk_main ();
+
g_object_unref (application);
return 0;
Modified: trunk/src/gpk-application.c
==============================================================================
--- trunk/src/gpk-application.c (original)
+++ trunk/src/gpk-application.c Wed Apr 30 13:29:01 2008
@@ -82,6 +82,7 @@
PkClient *client_action;
PkClient *client_description;
PkClient *client_files;
+ GpkClient *gclient;
PkConnection *pconnection;
GpkStatusbar *statusbar;
PkExtra *extra;
@@ -127,6 +128,8 @@
G_DEFINE_TYPE (GpkApplication, gpk_application, G_TYPE_OBJECT)
+static gboolean gpk_application_refresh_search_results (GpkApplication *application);
+
/**
* gpk_application_class_init:
* @klass: This graph class instance
@@ -226,43 +229,15 @@
gpk_application_install (GpkApplication *application, const gchar *package_id)
{
gboolean ret;
- GError *error = NULL;
-
g_return_val_if_fail (PK_IS_APPLICATION (application), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
pk_debug ("install %s", application->priv->package);
+ ret = gpk_client_install_package_id (application->priv->gclient, package_id, NULL);
- /* TODO: this is hacky code for testing only */
-// GpkClient *gclient;
-// gclient = gpk_client_new ();
-// ret = gpk_client_install_package_id (gclient, package_id, NULL);
-// g_object_unref (gclient);
-// return ret;
-
- ret = pk_client_reset (application->priv->client_action, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- /* do the install */
- ret = pk_client_install_package (application->priv->client_action,
- application->priv->package, &error);
- if (!ret) {
- pk_warning ("failed to install package: %s", error->message);
- if (strcmp (error->message, "org.freedesktop.packagekit.install no") == 0) {
- gpk_error_dialog (_("The package could not be installed"),
- _("You don't have the necessary privileges to install packages"), NULL);
- } else if (g_str_has_prefix (error->message, "org.freedesktop.packagekit.install")) {
- /* canceled auth dialog, be silent */
- } else {
- /* ick, we failed so pretend we didn't do the action */
- gpk_error_dialog (_("The package could not be installed"),
- _("The package could not be installed"), error->message);
- }
- g_error_free (error);
+ /* refresh the search as the items may have changed and the filter has not changed */
+ if (ret) {
+ gpk_application_refresh_search_results (application);
}
return ret;
}
@@ -289,163 +264,28 @@
* gpk_application_homepage_cb:
**/
static void
-gpk_application_homepage_cb (GtkWidget *widget,
- GpkApplication *application)
+gpk_application_homepage_cb (GtkWidget *widget, GpkApplication *application)
{
g_return_if_fail (PK_IS_APPLICATION (application));
gpk_gnome_open (application->priv->url);
}
/**
- * gpk_application_remove_only:
- **/
-static gboolean
-gpk_application_remove_only (GpkApplication *application, gboolean force)
-{
- gboolean ret;
- GError *error = NULL;
- GtkWidget *widget;
-
- g_return_val_if_fail (PK_IS_APPLICATION (application), FALSE);
-
- pk_debug ("remove %s", application->priv->package);
-
- /* hide and show the right things */
- polkit_gnome_action_set_visible (application->priv->remove_action, FALSE);
- widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel2");
- gtk_widget_show (widget);
-
- ret = pk_client_reset (application->priv->client_action, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- /* do the remove */
- ret = pk_client_remove_package (application->priv->client_action,
- application->priv->package, force, FALSE, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- /* ick, we failed so pretend we didn't do the action */
- gpk_error_dialog (_("The package could not be removed"),
- _("Running the transaction failed"), error->message);
- g_error_free (error);
- }
- return ret;
-}
-
-/**
- * gpk_application_requires_dialog_cb:
- **/
-static void
-gpk_application_requires_dialog_cb (GtkDialog *dialog, gint id, GpkApplication *application)
-{
- g_return_if_fail (PK_IS_APPLICATION (application));
-
- if (id == -9) {
- pk_debug ("the user clicked no");
- } else if (id == -8) {
- pk_debug ("the user clicked yes, remove with deps");
- gpk_application_remove_only (application, TRUE);
- } else {
- pk_warning ("id unknown=%i", id);
- }
-}
-
-/**
- * gpk_application_requires_finished_cb:
- **/
-static void
-gpk_application_requires_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, GpkApplication *application)
-{
- guint length;
- gchar *title;
- gchar *message;
- gchar *package_name;
- GString *text;
- PkPackageItem *item;
- GtkWidget *main_window;
- GtkWidget *dialog;
- guint i;
-
- g_return_if_fail (PK_IS_APPLICATION (application));
-
- /* see how many packages there are */
- length = pk_client_package_buffer_get_size (client);
-
- /* if there are no required packages, just do the remove */
- if (length == 0) {
- pk_debug ("no requires");
- gpk_application_remove_only (application, FALSE);
- g_object_unref (client);
- return;
- }
-
- /* present this to the user */
- text = g_string_new (_("The following packages have to be removed:"));
- g_string_append (text, "\n\n");
- for (i=0; i<length; i++) {
- item = pk_client_package_buffer_get_item (client, i);
- message = gpk_package_id_format_oneline (item->package_id, item->summary);
- g_string_append_printf (text, "%s\n", message);
- g_free (message);
- }
-
- /* remove last \n */
- g_string_set_size (text, text->len - 1);
-
- /* display messagebox */
- message = g_string_free (text, FALSE);
- package_name = gpk_package_get_name (application->priv->package);
- title = g_strdup_printf (_("Other software depends on %s"), package_name);
- g_free (package_name);
-
- main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
- dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, "%s", title);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Remove all packages"), -8, NULL);
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
- g_signal_connect (dialog, "response", G_CALLBACK (gpk_application_requires_dialog_cb), application);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_free (message);
- g_object_unref (client);
-}
-
-/**
* gpk_application_remove_cb:
**/
static void
-gpk_application_remove_cb (PolKitGnomeAction *action,
- GpkApplication *application)
+gpk_application_remove_cb (PolKitGnomeAction *action, GpkApplication *application)
{
gboolean ret;
- PkClient *client;
- GError *error = NULL;
-
g_return_if_fail (PK_IS_APPLICATION (application));
- /* are we dumb and can't check for requires? */
- if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_REQUIRES) == FALSE) {
- /* no, just try to remove it without deps */
- gpk_application_remove_only (application, FALSE);
- return;
- }
+ ret = gpk_client_remove_package_id (application->priv->gclient, application->priv->package, NULL);
- /* see if any packages require this one */
- client = pk_client_new ();
- pk_client_set_use_buffer (client, TRUE, NULL);
- g_signal_connect (client, "finished",
- G_CALLBACK (gpk_application_requires_finished_cb), application);
-
- /* do the requires */
- pk_debug ("getting requires for %s", application->priv->package);
- ret = pk_client_get_requires (client, PK_FILTER_ENUM_INSTALLED, application->priv->package, TRUE, &error);
- if (!ret) {
- pk_warning ("failed to get requires: %s", error->message);
- g_error_free (error);
+ /* refresh the search as the items may have changed and the filter has not changed */
+ if (ret) {
+ gpk_application_refresh_search_results (application);
}
+ return;
}
/**
@@ -675,6 +515,9 @@
g_free (summary_new);
g_free (icon);
g_free (text);
+
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
}
/**
@@ -1332,8 +1175,7 @@
* gpk_application_packages_treeview_clicked_cb:
**/
static void
-gpk_application_packages_treeview_clicked_cb (GtkTreeSelection *selection,
- GpkApplication *application)
+gpk_application_packages_treeview_clicked_cb (GtkTreeSelection *selection, GpkApplication *application)
{
GtkWidget *widget;
GtkTreeModel *model;
@@ -1425,10 +1267,16 @@
gchar *string1, gchar *string2,
gint int1, gint int2, gpointer user_data)
{
+ GpkApplication *application = GPK_APPLICATION (user_data);
if (pk_strequal (name, "entry_text")) {
- pk_debug ("creating sexy icon=%s", name);
return sexy_icon_entry_new ();
}
+ if (pk_strequal (name, "button_install")) {
+ return polkit_gnome_action_create_button (application->priv->install_action);
+ }
+ if (pk_strequal (name, "button_remove")) {
+ return polkit_gnome_action_create_button (application->priv->remove_action);
+ }
pk_warning ("name unknown=%s", name);
return NULL;
}
@@ -2071,6 +1919,63 @@
}
/**
+ * gpk_application_setup_policykit:
+ *
+ * We have to do this before the glade stuff if done as the custom handler needs the actions setup
+ **/
+static void
+gpk_application_setup_policykit (GpkApplication *application)
+{
+ PolKitAction *pk_action;
+
+ g_return_if_fail (PK_IS_APPLICATION (application));
+
+ /* install */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.install");
+ application->priv->install_action = polkit_gnome_action_new_default ("install", pk_action,
+ _("_Install"),
+ _("Install selected package"));
+ g_object_set (application->priv->install_action,
+ "no-icon-name", GTK_STOCK_FLOPPY,
+ "auth-icon-name", GTK_STOCK_FLOPPY,
+ "yes-icon-name", GTK_STOCK_FLOPPY,
+ "self-blocked-icon-name", GTK_STOCK_FLOPPY,
+ NULL);
+ polkit_action_unref (pk_action);
+ g_signal_connect (application->priv->install_action, "activate",
+ G_CALLBACK (gpk_application_install_cb), application);
+
+ /* remove */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.remove");
+ application->priv->remove_action = polkit_gnome_action_new_default ("remove", pk_action,
+ _("_Remove"),
+ _("Remove selected package"));
+ g_object_set (application->priv->remove_action,
+ "no-icon-name", GTK_STOCK_DIALOG_ERROR,
+ "auth-icon-name", GTK_STOCK_DIALOG_ERROR,
+ "yes-icon-name", GTK_STOCK_DIALOG_ERROR,
+ "self-blocked-icon-name", GTK_STOCK_DIALOG_ERROR,
+ NULL);
+ polkit_action_unref (pk_action);
+
+ /* refresh-cache */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
+ application->priv->refresh_action = polkit_gnome_action_new_default ("refresh", pk_action,
+ _("_Refresh application lists"),
+ NULL);
+ g_object_set (application->priv->refresh_action,
+ "no-icon-name", "gtk-redo-ltr",
+ "auth-icon-name", "gtk-redo-ltr",
+ "yes-icon-name", "gtk-redo-ltr",
+ "self-blocked-icon-name", "gtk-redo-ltr",
+ NULL);
+ polkit_action_unref (pk_action);
+}
+
+/**
* gpk_application_init:
**/
static void
@@ -2088,8 +1993,6 @@
guint page;
guint i;
gboolean ret;
- PolKitAction *pk_action;
- GtkWidget *button;
GtkWidget *item;
GError *error = NULL;
@@ -2109,10 +2012,12 @@
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
PK_DATA G_DIR_SEPARATOR_S "icons");
- /* use a sexy widget */
+ /* use custom widgets */
glade_set_custom_handler (gpk_application_create_custom_widget, application);
application->priv->control = pk_control_new ();
+ application->priv->gclient = gpk_client_new ();
+ gpk_client_show_finished (application->priv->gclient, FALSE);
application->priv->client_search = pk_client_new ();
g_signal_connect (application->priv->client_search, "package",
@@ -2193,6 +2098,9 @@
locale = setlocale (LC_ALL, NULL);
pk_extra_set_locale (application->priv->extra, locale);
+ /* we have to do this before we connect up the glade file */
+ gpk_application_setup_policykit (application);
+
application->priv->glade_xml = glade_xml_new (PK_DATA "/gpk-application.glade", NULL, NULL);
main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
@@ -2204,47 +2112,7 @@
g_signal_connect (main_window, "delete_event",
G_CALLBACK (gpk_application_delete_event_cb), application);
- widget = glade_xml_get_widget (application->priv->glade_xml, "hbox_package");
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.install");
- application->priv->install_action = polkit_gnome_action_new_default ("install",
- pk_action,
- _("_Install"),
- _("Install selected package"));
- g_object_set (application->priv->install_action,
- "no-icon-name", GTK_STOCK_FLOPPY,
- "auth-icon-name", GTK_STOCK_FLOPPY,
- "yes-icon-name", GTK_STOCK_FLOPPY,
- "self-blocked-icon-name", GTK_STOCK_FLOPPY,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (application->priv->install_action, "activate",
- G_CALLBACK (gpk_application_install_cb), application);
- button = polkit_gnome_action_create_button (application->priv->install_action);
-
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.remove");
- application->priv->remove_action = polkit_gnome_action_new_default ("remove",
- pk_action,
- _("_Remove"),
- _("Remove selected package"));
- g_object_set (application->priv->remove_action,
- "no-icon-name", GTK_STOCK_DIALOG_ERROR,
- "auth-icon-name", GTK_STOCK_DIALOG_ERROR,
- "yes-icon-name", GTK_STOCK_DIALOG_ERROR,
- "self-blocked-icon-name", GTK_STOCK_DIALOG_ERROR,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (application->priv->remove_action, "activate",
- G_CALLBACK (gpk_application_remove_cb), application);
- button = polkit_gnome_action_create_button (application->priv->remove_action);
-
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 1);
-
+ /* connect normal buttons */
widget = glade_xml_get_widget (application->priv->glade_xml, "button_homepage");
g_signal_connect (widget, "clicked",
G_CALLBACK (gpk_application_homepage_cb), application);
@@ -2258,26 +2126,18 @@
g_signal_connect (widget, "activate",
G_CALLBACK (gpk_application_menu_help_cb), application);
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
- application->priv->refresh_action = polkit_gnome_action_new_default ("refresh",
- pk_action,
- _("_Refresh application lists"),
- NULL);
- g_object_set (application->priv->refresh_action,
- "no-icon-name", "gtk-redo-ltr",
- "auth-icon-name", "gtk-redo-ltr",
- "yes-icon-name", "gtk-redo-ltr",
- "self-blocked-icon-name", "gtk-redo-ltr",
- NULL);
- polkit_action_unref (pk_action);
+ /* connect up PolicyKit buttons */
+ g_signal_connect (application->priv->remove_action, "activate",
+ G_CALLBACK (gpk_application_remove_cb), application);
g_signal_connect (application->priv->refresh_action, "activate",
G_CALLBACK (gpk_application_menu_refresh_cb), application);
- item = gtk_action_create_menu_item (GTK_ACTION (application->priv->refresh_action));
+ /* connect up a PolicyKit menuitem */
+ item = gtk_action_create_menu_item (GTK_ACTION (application->priv->refresh_action));
widget = glade_xml_get_widget (application->priv->glade_xml, "menu_system");
gtk_menu_shell_prepend (GTK_MENU_SHELL (widget), item);
+ /* connect up the other menuitems */
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_sources");
g_signal_connect (widget, "activate",
G_CALLBACK (gpk_application_menu_sources_cb), application);
@@ -2613,6 +2473,7 @@
g_object_unref (application->priv->install_action);
g_object_unref (application->priv->remove_action);
g_object_unref (application->priv->refresh_action);
+ g_object_unref (application->priv->gclient);
g_free (application->priv->url);
g_free (application->priv->group);
Modified: trunk/src/gpk-client.c
==============================================================================
--- trunk/src/gpk-client.c (original)
+++ trunk/src/gpk-client.c Wed Apr 30 13:29:01 2008
@@ -42,9 +42,14 @@
#include <pk-control.h>
#include <gpk-client.h>
+#include <gpk-client-eula.h>
+#include <gpk-client-signature.h>
+#include <gpk-client-untrusted.h>
#include <gpk-common.h>
#include <gpk-gnome.h>
#include <gpk-error.h>
+#include "gpk-smart-icon.h"
+#include "gpk-consolekit.h"
static void gpk_client_class_init (GpkClientClass *klass);
static void gpk_client_init (GpkClient *gclient);
@@ -63,19 +68,22 @@
PkClient *client_action;
PkClient *client_resolve;
PkClient *client_signature;
+ GpkSmartIcon *sicon;
GladeXML *glade_xml;
GConfClient *gconf_client;
- gint pulse_timeout;
+ guint pulse_timer_id;
+ guint finished_timer_id;
PkControl *control;
PkRoleEnum roles;
gboolean do_key_auth;
gboolean retry_untrusted_value;
+ gboolean show_finished;
+ gboolean show_progress;
};
typedef enum {
GPK_CLIENT_PAGE_PROGRESS,
GPK_CLIENT_PAGE_CONFIRM,
- GPK_CLIENT_PAGE_ERROR,
GPK_CLIENT_PAGE_LAST
} GpkClientPageEnum;
@@ -128,6 +136,15 @@
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++) {
@@ -140,6 +157,46 @@
}
/**
+ * 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_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);
+ gtk_main_quit ();
+ return FALSE;
+}
+
+/**
* gpk_install_finished_timeout:
**/
static gboolean
@@ -150,6 +207,111 @@
}
/**
+ * gpk_client_show_finished:
+ **/
+void
+gpk_client_show_finished (GpkClient *gclient, gboolean enabled)
+{
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+ gclient->priv->show_finished = enabled;
+}
+
+/**
+ * gpk_client_show_progress:
+ **/
+void
+gpk_client_show_progress (GpkClient *gclient, gboolean enabled)
+{
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+ gclient->priv->show_progress = enabled;
+}
+
+/**
+ * gpk_client_finished_no_progress:
+ **/
+static void
+gpk_client_finished_no_progress (PkClient *client, PkExitEnum exit_code, guint runtime, GpkClient *gclient)
+{
+ PkRestartEnum restart;
+ guint i;
+ guint length;
+ PkPackageId *ident;
+ PkPackageItem *item;
+ GString *message_text;
+ guint skipped_number = 0;
+ const gchar *message;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ /* check we got some packages */
+ length = pk_client_package_buffer_get_size (client);
+ pk_debug ("length=%i", length);
+ if (length == 0) {
+ pk_debug ("no updates");
+ return;
+ }
+
+ message_text = g_string_new ("");
+
+ /* find any we skipped */
+ for (i=0; i<length; i++) {
+ item = pk_client_package_buffer_get_item (client, i);
+ pk_debug ("%s, %s, %s", pk_info_enum_to_text (item->info),
+ item->package_id, item->summary);
+ ident = pk_package_id_new_from_string (item->package_id);
+ if (item->info == PK_INFO_ENUM_BLOCKED) {
+ skipped_number++;
+ g_string_append_printf (message_text, "<b>%s</b> - %s\n",
+ ident->name, item->summary);
+ }
+ pk_package_id_free (ident);
+ }
+
+ /* notify the user if there were skipped entries */
+ if (skipped_number > 0) {
+ message = ngettext (_("One package was skipped:"),
+ _("Some packages were skipped:"), skipped_number);
+ g_string_prepend (message_text, message);
+ g_string_append_c (message_text, '\n');
+ }
+
+ /* add a message that we need to restart */
+ restart = pk_client_get_require_restart (client);
+ if (restart != PK_RESTART_ENUM_NONE) {
+ message = gpk_restart_enum_to_localised_text (restart);
+
+ /* add a gap if we are putting both */
+ if (skipped_number > 0) {
+ g_string_append (message_text, "\n");
+ }
+
+ g_string_append (message_text, message);
+ g_string_append_c (message_text, '\n');
+ }
+
+ /* trim off extra newlines */
+ if (message_text->len != 0) {
+ g_string_set_size (message_text, message_text->len-1);
+ }
+
+ /* this will not show if specified in gconf */
+ gpk_smart_icon_notify_new (gclient->priv->sicon,
+ _("The system update has completed"), message_text->str,
+ "software-update-available",
+ GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+ if (restart == PK_RESTART_ENUM_SYSTEM) {
+ gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_RESTART_COMPUTER, NULL);
+ gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+ GPK_CONF_NOTIFY_UPDATE_COMPLETE_RESTART);
+ } else {
+ gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+ GPK_CONF_NOTIFY_UPDATE_COMPLETE);
+ }
+ gpk_smart_icon_notify_show (gclient->priv->sicon);
+ g_string_free (message_text, TRUE);
+}
+
+/**
* gpk_client_finished_cb:
**/
static void
@@ -159,15 +321,23 @@
g_return_if_fail (GPK_IS_CLIENT (gclient));
- if (exit == PK_EXIT_ENUM_SUCCESS) {
+ /* do we show a libnotify window instead? */
+ if (!gclient->priv->show_progress) {
+ gpk_client_finished_no_progress (client, exit, runtime, gclient);
+ gtk_main_quit ();
+ return;
+ }
+
+ 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);
-
- g_timeout_add_seconds (30, gpk_install_finished_timeout, gclient);
+ gclient->priv->finished_timer_id = g_timeout_add_seconds (30, gpk_install_finished_timeout, gclient);
} else {
- gtk_main_quit ();
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_widget_hide (widget);
}
/* make insensitive */
@@ -177,6 +347,7 @@
/* 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);
+ gtk_main_quit ();
}
/**
@@ -191,9 +362,9 @@
g_return_if_fail (GPK_IS_CLIENT (gclient));
widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
- if (gclient->priv->pulse_timeout != 0) {
- g_source_remove (gclient->priv->pulse_timeout);
- gclient->priv->pulse_timeout = 0;
+ if (gclient->priv->pulse_timer_id != 0) {
+ g_source_remove (gclient->priv->pulse_timer_id);
+ gclient->priv->pulse_timer_id = 0;
}
if (percentage != PK_CLIENT_PERCENTAGE_INVALID) {
@@ -233,119 +404,16 @@
g_free (text);
if (status == PK_STATUS_ENUM_WAIT) {
- if (gclient->priv->pulse_timeout == 0) {
+ 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_timeout = g_timeout_add (75, (GSourceFunc) gpk_client_pulse_progress, gclient);
+ gclient->priv->pulse_timer_id = g_timeout_add (75, (GSourceFunc) gpk_client_pulse_progress, gclient);
}
}
}
/**
- * gpk_client_button_retry_untrusted:
- **/
-static void
-gpk_client_button_retry_untrusted (PolKitGnomeAction *action, GpkClient *gclient)
-{
- pk_debug ("need to retry...");
- gclient->priv->retry_untrusted_value = TRUE;
- gtk_main_quit ();
-}
-
-/**
- * gpk_client_error_dialog_retry_untrusted:
- **/
-static gboolean
-gpk_client_error_dialog_retry_untrusted (GpkClient *gclient, PkErrorCodeEnum code, const gchar *details)
-{
- GtkWidget *widget;
- GtkWidget *button;
- PolKitAction *pk_action;
- GladeXML *glade_xml;
- GtkTextBuffer *buffer = NULL;
- gchar *text;
- const gchar *title;
- const gchar *message;
- PolKitGnomeAction *update_system_action;
-
- title = gpk_error_enum_to_localised_text (code);
- message = gpk_error_enum_to_localised_message (code);
-
- glade_xml = glade_xml_new (PK_DATA "/gpk-error.glade", NULL, NULL);
-
- /* connect up actions */
- widget = glade_xml_get_widget (glade_xml, "window_error");
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-
- /* set icon name */
- gtk_window_set_icon_name (GTK_WINDOW (widget), PK_STOCK_WINDOW_ICON);
-
- /* close button */
- widget = glade_xml_get_widget (glade_xml, "button_close");
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-
- /* title */
- widget = glade_xml_get_widget (glade_xml, "label_title");
- text = g_strdup_printf ("<b><big>%s</big></b>", title);
- gtk_label_set_label (GTK_LABEL (widget), text);
- g_free (text);
-
- /* message */
- widget = glade_xml_get_widget (glade_xml, "label_message");
- gtk_label_set_label (GTK_LABEL (widget), message);
-
- /* show text in the expander */
- if (pk_strzero (details)) {
- widget = glade_xml_get_widget (glade_xml, "expander_details");
- gtk_widget_hide (widget);
- } else {
- buffer = gtk_text_buffer_new (NULL);
- gtk_text_buffer_insert_at_cursor (buffer, details, strlen (details));
- widget = glade_xml_get_widget (glade_xml, "textview_details");
- gtk_text_view_set_buffer (GTK_TEXT_VIEW (widget), buffer);
- }
-
- /* add the extra button and connect up to a Policykit action */
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.localinstall-untrusted");
- update_system_action = polkit_gnome_action_new_default ("localinstall-untrusted",
- pk_action,
- _("_Force install"),
- _("Force installing package"));
- g_object_set (update_system_action,
- "no-icon-name", GTK_STOCK_APPLY,
- "auth-icon-name", GTK_STOCK_APPLY,
- "yes-icon-name", GTK_STOCK_APPLY,
- "self-blocked-icon-name", GTK_STOCK_APPLY,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (update_system_action, "activate",
- G_CALLBACK (gpk_client_button_retry_untrusted), gclient);
- button = polkit_gnome_action_create_button (update_system_action);
- widget = glade_xml_get_widget (glade_xml, "hbuttonbox2");
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 0);
-
- /* show window */
- widget = glade_xml_get_widget (glade_xml, "window_error");
- gtk_widget_show (widget);
-
- /* wait for button press */
- gtk_main ();
-
- /* hide window */
- if (GTK_IS_WIDGET (widget)) {
- gtk_widget_hide (widget);
- }
- g_object_unref (glade_xml);
- if (buffer != NULL) {
- g_object_unref (buffer);
- }
- return TRUE;
-}
-
-/**
* gpk_client_error_code_cb:
**/
static void
@@ -354,9 +422,10 @@
g_return_if_fail (GPK_IS_CLIENT (gclient));
/* have we handled? */
- if (code == PK_ERROR_ENUM_GPG_FAILURE) {
+ if (code == PK_ERROR_ENUM_GPG_FAILURE ||
+ code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
if (gclient->priv->do_key_auth) {
- pk_debug ("ignoring GPG error as handled");
+ pk_debug ("ignoring error as handled");
return;
}
pk_warning ("did not auth");
@@ -366,13 +435,11 @@
if (code == PK_ERROR_ENUM_BAD_GPG_SIGNATURE ||
code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE) {
pk_debug ("handle and requeue");
- gpk_client_error_dialog_retry_untrusted (gclient, code, details);
+ gclient->priv->retry_untrusted_value = gpk_client_untrusted_show (code);
return;
}
pk_debug ("code was %s", pk_error_enum_to_text (code));
-
- //remove GPK_CLIENT_PAGE_ERROR?
gpk_error_dialog (gpk_error_enum_to_localised_text (code),
gpk_error_enum_to_localised_message (code), details);
}
@@ -391,6 +458,7 @@
text = gpk_package_id_format_twoline (package_id, summary);
widget = glade_xml_get_widget (gclient->priv->glade_xml, "label_package");
+ gtk_widget_show (widget);
gtk_label_set_markup (GTK_LABEL (widget), text);
g_free (text);
}
@@ -536,6 +604,19 @@
}
/**
+ * gpk_client_done:
+ **/
+static void
+gpk_client_done (GpkClient *gclient)
+{
+ /* we're done */
+ if (gclient->priv->pulse_timer_id != 0) {
+ g_source_remove (gclient->priv->pulse_timer_id);
+ gclient->priv->pulse_timer_id = 0;
+ }
+}
+
+/**
* gpk_client_install_local_file:
* @gclient: a valid #GpkClient instance
* @file_rel: a file such as <literal>./hal-devel-0.10.0.rpm</literal>
@@ -555,16 +636,19 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (file_rel != NULL, FALSE);
- /* show window */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_show (widget);
-
gclient->priv->retry_untrusted_value = FALSE;
ret = gpk_client_install_local_file_internal (gclient, TRUE, file_rel, error);
if (!ret) {
goto out;
}
+ /* set title */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_window_set_title (GTK_WINDOW (widget), _("Install local file"));
+
+ /* setup the UI */
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+
/* wait for completion */
gtk_main ();
@@ -579,10 +663,7 @@
}
/* we're done */
- if (gclient->priv->pulse_timeout != 0) {
- g_source_remove (gclient->priv->pulse_timeout);
- gclient->priv->pulse_timeout = 0;
- }
+ gpk_client_done (gclient);
out:
return ret;
}
@@ -604,6 +685,142 @@
}
/**
+ * gpk_client_remove_package_id:
+ * @gclient: a valid #GpkClient instance
+ * @package_id: a package_id such as <literal>hal-info;0.20;i386;fedora</literal>
+ * @error: a %GError to put the error code and message in, or %NULL
+ *
+ * Return value: %TRUE if the method succeeded
+ **/
+gboolean
+gpk_client_remove_package_id (GpkClient *gclient, const gchar *package_id, GError **error)
+{
+ GtkWidget *widget;
+ GtkWidget *dialog;
+ GtkResponseType button;
+ gboolean ret;
+ GError *error_local = NULL;
+ gchar *text = NULL;
+ gchar *title = NULL;
+ gchar *package_name = NULL;
+ guint len;
+ guint i;
+ GString *string;
+ PkPackageItem *item;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ g_return_val_if_fail (package_id != NULL, FALSE);
+
+ /* set title */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_window_set_title (GTK_WINDOW (widget), _("Remove packages"));
+
+ /* are we dumb and can't check for depends? */
+ if (!pk_enums_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_DEPENDS)) {
+ pk_warning ("skipping depends check");
+ goto skip_checks;
+ }
+
+ /* 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 resolve"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ ret = FALSE;
+ goto out;
+ }
+
+ /* find out if this would drag in other packages */
+ ret = pk_client_get_requires (gclient->priv->client_resolve, PK_FILTER_ENUM_NOT_INSTALLED, package_id, TRUE, &error_local);
+ if (!ret) {
+ text = g_strdup_printf ("%s: %s", _("Could not work out what packages would be also removeed"), error_local->message);
+ gpk_client_error_msg (gclient, _("Failed to get depends"), text);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ ret = FALSE;
+ goto out;
+ }
+
+ /* any additional packages? */
+ len = pk_client_package_buffer_get_size (gclient->priv->client_resolve);
+ if (len == 0) {
+ pk_debug ("no additional requires");
+ goto skip_checks;
+ }
+
+ /* process package list */
+ string = g_string_new (_("The following packages have to be removed:"));
+ g_string_append (string, "\n\n");
+ for (i=0; i<len; i++) {
+ item = pk_client_package_buffer_get_item (gclient->priv->client_resolve, i);
+ text = gpk_package_id_format_oneline (item->package_id, item->summary);
+ g_string_append_printf (string, "%s\n", text);
+ g_free (text);
+ }
+ /* remove last \n */
+ g_string_set_size (string, string->len - 1);
+
+ /* display messagebox */
+ text = g_string_free (string, FALSE);
+ pk_debug ("text=%s", text);
+
+ /* show UI */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ package_name = gpk_package_get_name (package_id);
+ title = g_strdup_printf (_("Other software depends on %s"), package_name);
+ g_free (package_name);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, "%s", title);
+ g_free (title);
+
+ /* add a specialist button */
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Remove all packages"), 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));
+ g_free (text);
+
+ /* did we click no or exit the window? */
+ if (button != GTK_RESPONSE_OK) {
+ gpk_client_error_msg (gclient, _("Failed to remove package"), _("Additional packages were also not removed"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, "user did not agree to additional requires");
+ ret = FALSE;
+ goto out;
+ }
+
+skip_checks:
+ /* try to remove the package_id */
+ ret = pk_client_remove_package (gclient->priv->client_action, package_id, TRUE, FALSE, &error_local);
+ if (!ret) {
+ /* check if we got a permission denied */
+ if (g_str_has_prefix (error_local->message, "org.freedesktop.packagekit.")) {
+ gpk_client_error_msg (gclient, _("Failed to remove package"),
+ _("You don't have the necessary privileges to remove packages"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ } else {
+ text = g_markup_escape_text (error_local->message, -1);
+ gpk_client_error_msg (gclient, _("Failed to remove package"), text);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ g_free (text);
+ }
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* setup the UI */
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+
+ /* wait for completion */
+ gtk_main ();
+
+ /* we're done */
+ gpk_client_done (gclient);
+out:
+ return ret;
+}
+
+/**
* gpk_client_install_package_id:
* @gclient: a valid #GpkClient instance
* @package_id: a package_id such as <literal>hal-info;0.20;i386;fedora</literal>
@@ -628,9 +845,9 @@
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
- /* show window */
+ /* set title */
widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_show (widget);
+ gtk_window_set_title (GTK_WINDOW (widget), _("Install packages"));
/* are we dumb and can't check for depends? */
if (!pk_enums_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_DEPENDS)) {
@@ -716,6 +933,15 @@
}
skip_checks:
+ /* 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"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ g_error_free (error_local);
+ return FALSE;
+ }
+
/* try to install the package_id */
ret = pk_client_install_package (gclient->priv->client_action, package_id, &error_local);
if (!ret) {
@@ -738,10 +964,7 @@
gtk_main ();
/* we're done */
- if (gclient->priv->pulse_timeout != 0) {
- g_source_remove (gclient->priv->pulse_timeout);
- gclient->priv->pulse_timeout = 0;
- }
+ gpk_client_done (gclient);
out:
return ret;
}
@@ -766,15 +989,10 @@
gboolean already_installed = FALSE;
gchar *package_id = NULL;
PkPackageItem *item;
- GtkWidget *widget;
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (package != NULL, FALSE);
- /* show window */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_show (widget);
-
ret = pk_client_resolve (gclient->priv->client_resolve, PK_FILTER_ENUM_NONE, package, &error_local);
if (!ret) {
gpk_client_error_msg (gclient, _("Failed to resolve package"), _("Incorrect response from search"));
@@ -850,15 +1068,10 @@
PkPackageItem *item;
PkPackageId *ident;
gchar *text;
- GtkWidget *widget;
g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
g_return_val_if_fail (full_path != NULL, FALSE);
- /* show window */
- widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- gtk_widget_show (widget);
-
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);
@@ -920,25 +1133,129 @@
}
/**
- * gpk_client_sig_button_yes:
+ * gpk_client_update_system:
**/
-static void
-gpk_client_sig_button_yes (GtkWidget *widget, GpkClient *gclient)
+gboolean
+gpk_client_update_system (GpkClient *gclient, GError **error)
{
- g_return_if_fail (GPK_IS_CLIENT (gclient));
- gclient->priv->do_key_auth = TRUE;
- gtk_main_quit ();
+ gboolean ret;
+ GtkWidget *widget;
+ GError *error_local = NULL;
+ gchar *text = NULL;
+ gchar *message = NULL;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), 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"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ g_error_free (error_local);
+ return FALSE;
+ }
+
+ /* set title */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_window_set_title (GTK_WINDOW (widget), _("System update"));
+
+ /* wrap update, but handle all the GPG and EULA stuff */
+ ret = pk_client_update_system (gclient->priv->client_action, &error_local);
+ if (!ret) {
+ /* print a proper error if we have it */
+ if (error_local->code == PK_CLIENT_ERROR_FAILED_AUTH) {
+ message = g_strdup (_("Authorisation could not be obtained"));
+ } else {
+ message = g_strdup_printf (_("The error was: %s"), error_local->message);
+ }
+
+ /* display and set */
+ text = g_strdup_printf ("%s: %s", _("Failed to update system"), message);
+ gpk_client_error_msg (gclient, _("Failed to update system"), text);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, message);
+ goto out;
+ }
+
+ /* setup the UI */
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+
+ /* if we are not showing UI, then notify the user what we are doing (just on the active terminal) */
+ if (!gclient->priv->show_progress) {
+ /* this will not show if specified in gconf */
+ gpk_smart_icon_notify_new (gclient->priv->sicon,
+ _("Updates are being installed"),
+ _("Updates are being automatically installed on your computer"),
+ "software-update-urgent",
+ GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+ gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_CANCEL_UPDATE, NULL);
+ gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+ GPK_CONF_NOTIFY_UPDATE_STARTED);
+ gpk_smart_icon_notify_show (gclient->priv->sicon);
+ }
+
+ /* wait for completion */
+ gtk_main ();
+
+out:
+ g_free (message);
+ g_free (text);
+ return FALSE;
}
/**
- * gpk_client_button_help:
+ * gpk_client_update_packages:
**/
-static void
-gpk_client_button_help (GtkWidget *widget, GpkClient *gclient)
+gboolean
+gpk_client_update_packages (GpkClient *gclient, gchar **package_ids, GError **error)
{
- g_return_if_fail (GPK_IS_CLIENT (gclient));
- /* TODO: need a whole section on this! */
- gpk_gnome_help (NULL);
+ gboolean ret;
+ GtkWidget *widget;
+ GError *error_local = NULL;
+ gchar *text = NULL;
+ gchar *message = NULL;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), 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"));
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, error_local->message);
+ g_error_free (error_local);
+ return FALSE;
+ }
+
+ /* set title */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_window_set_title (GTK_WINDOW (widget), _("Update packages"));
+
+ /* wrap update, but handle all the GPG and EULA stuff */
+ ret = pk_client_update_packages_strv (gclient->priv->client_action, package_ids, &error_local);
+ if (!ret) {
+ /* print a proper error if we have it */
+ if (error_local->code == PK_CLIENT_ERROR_FAILED_AUTH) {
+ message = g_strdup (_("Authorisation could not be obtained"));
+ } else {
+ message = g_strdup_printf (_("The error was: %s"), error_local->message);
+ }
+
+ /* display and set */
+ text = g_strdup_printf ("%s: %s", _("Failed to update packages"), message);
+ gpk_client_error_msg (gclient, _("Failed to update packages"), text);
+ gpk_client_error_set (error, GPK_CLIENT_ERROR_FAILED, message);
+ goto out;
+ }
+
+ /* setup the UI */
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+
+ /* wait for completion */
+ gtk_main ();
+
+out:
+ g_free (message);
+ g_free (text);
+ return FALSE;
}
/**
@@ -952,54 +1269,13 @@
{
gboolean ret;
GError *error = NULL;
- GtkWidget *widget;
- GladeXML *glade_xml;
g_return_if_fail (GPK_IS_CLIENT (gclient));
- glade_xml = glade_xml_new (PK_DATA "/gpk-signature.glade", NULL, NULL);
-
- /* connect up default actions */
- widget = glade_xml_get_widget (glade_xml, "window_gpg");
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
- widget = glade_xml_get_widget (glade_xml, "button_no");
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-
- /* set icon name */
- gtk_window_set_icon_name (GTK_WINDOW (widget), PK_STOCK_WINDOW_ICON);
-
- /* connect up buttons */
- widget = glade_xml_get_widget (glade_xml, "button_yes");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_sig_button_yes), gclient);
- widget = glade_xml_get_widget (glade_xml, "button_help");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_button_help), gclient);
-
- /* show correct text */
- widget = glade_xml_get_widget (glade_xml, "label_name");
- gtk_label_set_label (GTK_LABEL (widget), repository_name);
- widget = glade_xml_get_widget (glade_xml, "label_url");
- gtk_label_set_label (GTK_LABEL (widget), key_url);
- widget = glade_xml_get_widget (glade_xml, "label_user");
- gtk_label_set_label (GTK_LABEL (widget), key_userid);
- widget = glade_xml_get_widget (glade_xml, "label_id");
- gtk_label_set_label (GTK_LABEL (widget), key_id);
-
- /* show window */
- widget = glade_xml_get_widget (glade_xml, "window_gpg");
- gtk_widget_show (widget);
-
- /* wait for button press */
- gclient->priv->do_key_auth = FALSE;
- gtk_main ();
-
- /* hide window */
- if (GTK_IS_WIDGET (widget)) {
- gtk_widget_hide (widget);
- }
- g_object_unref (glade_xml);
-
+ ret = gpk_client_signature_show (package_id, repository_name, key_url, key_userid,
+ key_id, key_fingerprint, key_timestamp);
/* disagreed with auth */
- if (!gclient->priv->do_key_auth) {
+ if (!ret) {
return;
}
@@ -1014,10 +1290,10 @@
/* this is asynchronous, else we get into livelock */
ret = pk_client_install_signature (gclient->priv->client_signature, PK_SIGTYPE_ENUM_GPG,
key_id, package_id, &error);
+ gclient->priv->do_key_auth = ret;
if (!ret) {
gpk_error_dialog (_("Failed to install signature"), _("The method failed"), error->message);
g_error_free (error);
- gclient->priv->do_key_auth = FALSE;
}
}
@@ -1030,64 +1306,12 @@
{
gboolean ret;
GError *error = NULL;
- GtkWidget *widget;
- GladeXML *glade_xml;
- GtkTextBuffer *buffer;
- gchar *text;
- PkPackageId *ident;
-
- g_return_if_fail (GPK_IS_CLIENT (gclient));
-
- glade_xml = glade_xml_new (PK_DATA "/gpk-eula.glade", NULL, NULL);
-
- /* connect up default actions */
- widget = glade_xml_get_widget (glade_xml, "window_eula");
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
- widget = glade_xml_get_widget (glade_xml, "button_cancel");
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-
- /* set icon name */
- gtk_window_set_icon_name (GTK_WINDOW (widget), PK_STOCK_WINDOW_ICON);
-
- /* connect up buttons */
- widget = glade_xml_get_widget (glade_xml, "button_agree");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_sig_button_yes), gclient);
- widget = glade_xml_get_widget (glade_xml, "button_help");
- g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_button_help), gclient);
-
- /* title */
- widget = glade_xml_get_widget (glade_xml, "label_title");
- ident = pk_package_id_new_from_string (package_id);
- text = g_strdup_printf ("<b><big>License required for %s by %s</big></b>", ident->name, vendor_name);
- gtk_label_set_label (GTK_LABEL (widget), text);
- pk_package_id_free (ident);
- g_free (text);
-
- buffer = gtk_text_buffer_new (NULL);
- gtk_text_buffer_insert_at_cursor (buffer, license_agreement, strlen (license_agreement));
- widget = glade_xml_get_widget (glade_xml, "textview_details");
- gtk_text_view_set_buffer (GTK_TEXT_VIEW (widget), buffer);
-
- /* set minimum size a bit bigger */
- gtk_widget_set_size_request (widget, 100, 200);
- /* show window */
- widget = glade_xml_get_widget (glade_xml, "window_eula");
- gtk_widget_show (widget);
-
- /* wait for button press */
- gclient->priv->do_key_auth = FALSE;
- gtk_main ();
-
- /* hide window */
- if (GTK_IS_WIDGET (widget)) {
- gtk_widget_hide (widget);
- }
- g_object_unref (glade_xml);
- g_object_unref (buffer);
+ /* do a helper */
+ ret = gpk_client_eula_show (eula_id, package_id, vendor_name, license_agreement);
/* disagreed with auth */
- if (!gclient->priv->do_key_auth) {
+ if (!ret) {
return;
}
@@ -1105,8 +1329,8 @@
if (!ret) {
gpk_error_dialog (_("Failed to accept EULA"), _("The method failed"), error->message);
g_error_free (error);
- gclient->priv->do_key_auth = FALSE;
}
+ gclient->priv->do_key_auth = ret;
}
/**
@@ -1123,12 +1347,44 @@
pk_debug ("trying to requeue install");
ret = pk_client_requeue (gclient->priv->client_action, &error);
if (!ret) {
- gpk_error_dialog (_("Failed to install"), _("The install task could not be requeued"), error->message);
+ gpk_error_dialog (_("Failed to install"), _("The install task could not be requeued"), error ? error->message : _("Error details not available"));
g_error_free (error);
}
}
/**
+ * gpk_client_smart_icon_notify_button:
+ **/
+static void
+gpk_client_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button,
+ const gchar *data, GpkClient *gclient)
+{
+ gboolean ret;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ pk_debug ("got: %i with data %s", button, data);
+ /* find the localised text */
+ if (button == GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN ||
+ button == GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN) {
+ if (data == NULL) {
+ pk_warning ("data NULL");
+ } else {
+ pk_debug ("setting %s to FALSE", data);
+ gconf_client_set_bool (gclient->priv->gconf_client, data, FALSE, NULL);
+ }
+ } else if (button == GPK_NOTIFY_BUTTON_CANCEL_UPDATE) {
+ pk_client_button_cancel_cb (NULL, gclient);
+ } else if (button == GPK_NOTIFY_BUTTON_RESTART_COMPUTER) {
+ /* restart using gnome-power-manager */
+ ret = gpk_restart_system ();
+ if (!ret) {
+ pk_warning ("failed to reboot");
+ }
+ }
+}
+
+/**
* gpk_client_class_init:
* @klass: The #GpkClientClass
**/
@@ -1152,8 +1408,11 @@
gclient->priv = GPK_CLIENT_GET_PRIVATE (gclient);
gclient->priv->glade_xml = NULL;
- gclient->priv->pulse_timeout = 0;
+ gclient->priv->pulse_timer_id = 0;
gclient->priv->do_key_auth = FALSE;
+ gclient->priv->show_finished = TRUE;
+ gclient->priv->show_progress = TRUE;
+ gclient->priv->finished_timer_id = 0;
/* add application specific icons to search path */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -1184,6 +1443,10 @@
g_signal_connect (gclient->priv->client_action, "eula-required",
G_CALLBACK (gpk_client_eula_required_cb), gclient);
+ gclient->priv->sicon = gpk_smart_icon_new ();
+ g_signal_connect (gclient->priv->sicon, "notification-button",
+ G_CALLBACK (gpk_client_smart_icon_notify_button), gclient);
+
gclient->priv->client_resolve = pk_client_new ();
g_signal_connect (gclient->priv->client_resolve, "status-changed",
G_CALLBACK (gpk_client_status_changed_cb), gclient);
@@ -1197,17 +1460,15 @@
gclient->priv->glade_xml = glade_xml_new (PK_DATA "/gpk-client.glade", NULL, NULL);
- /* Get the main window quit */
+ /* common stuff */
widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-
- /* just close */
+ 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_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ 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_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ 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_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ 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",
@@ -1227,8 +1488,6 @@
/* set the label blank initially */
widget = glade_xml_get_widget (gclient->priv->glade_xml, "progress_part_label");
gtk_label_set_label (GTK_LABEL (widget), "");
-
- gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
}
/**
@@ -1244,11 +1503,18 @@
gclient = GPK_CLIENT (object);
g_return_if_fail (gclient->priv != NULL);
+
+ /* stop the timer if running */
+ if (gclient->priv->finished_timer_id != 0) {
+ g_source_remove (gclient->priv->finished_timer_id);
+ }
+
g_object_unref (gclient->priv->client_action);
g_object_unref (gclient->priv->client_resolve);
g_object_unref (gclient->priv->client_signature);
g_object_unref (gclient->priv->control);
g_object_unref (gclient->priv->gconf_client);
+ g_object_unref (gclient->priv->sicon);
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 Wed Apr 30 13:29:01 2008
@@ -68,20 +68,28 @@
gboolean gpk_client_install_local_file (GpkClient *gclient,
const gchar *file_rel,
- GError **error)
- G_GNUC_WARN_UNUSED_RESULT;
+ GError **error);
gboolean gpk_client_install_provide_file (GpkClient *gclient,
const gchar *full_path,
- GError **error)
- G_GNUC_WARN_UNUSED_RESULT;
+ GError **error);
gboolean gpk_client_install_package_name (GpkClient *gclient,
const gchar *package,
- GError **error)
- G_GNUC_WARN_UNUSED_RESULT;
+ GError **error);
gboolean gpk_client_install_package_id (GpkClient *gclient,
const gchar *package_id,
- GError **error)
- G_GNUC_WARN_UNUSED_RESULT;
+ GError **error);
+gboolean gpk_client_remove_package_id (GpkClient *gclient,
+ const gchar *package_id,
+ GError **error);
+gboolean gpk_client_update_system (GpkClient *gclient,
+ GError **error);
+gboolean gpk_client_update_packages (GpkClient *gclient,
+ gchar **package_ids,
+ GError **error);
+void gpk_client_show_finished (GpkClient *gclient,
+ gboolean enabled);
+void gpk_client_show_progress (GpkClient *gclient,
+ gboolean enabled);
G_END_DECLS
Modified: trunk/src/gpk-notify.c
==============================================================================
--- trunk/src/gpk-notify.c (original)
+++ trunk/src/gpk-notify.c Wed Apr 30 13:29:01 2008
@@ -52,7 +52,7 @@
#include "gpk-smart-icon.h"
#include "gpk-auto-refresh.h"
-#include "gpk-consolekit.h"
+#include "gpk-client.h"
#include "gpk-notify.h"
static void gpk_notify_class_init (GpkNotifyClass *klass);
@@ -65,10 +65,10 @@
{
GpkSmartIcon *sicon;
PkConnection *pconnection;
- PkClient *client_update_system;
PkTaskList *tlist;
- GpkAutoRefresh *arefresh;
PkControl *control;
+ GpkAutoRefresh *arefresh;
+ GpkClient *gclient;
GConfClient *gconf_client;
gboolean cache_okay;
gboolean cache_update_in_progress;
@@ -283,130 +283,19 @@
static gboolean gpk_notify_query_updates (GpkNotify *notify);
/**
- * gpk_notify_update_system_finished_cb:
- **/
-static void
-gpk_notify_update_system_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, GpkNotify *notify)
-{
- PkRestartEnum restart;
- guint i;
- guint length;
- PkPackageId *ident;
- PkPackageItem *item;
- GString *message_text;
- guint skipped_number = 0;
- const gchar *message;
-
- g_return_if_fail (GPK_IS_NOTIFY (notify));
-
- /* we failed, show the icon */
- if (exit_code != PK_EXIT_ENUM_SUCCESS) {
- gpk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
- /* we failed, so re-get the update list */
- gpk_notify_query_updates (notify);
- }
-
- /* check we got some packages */
- length = pk_client_package_buffer_get_size (client);
- pk_debug ("length=%i", length);
- if (length == 0) {
- pk_debug ("no updates");
- return;
- }
-
- message_text = g_string_new ("");
-
- /* find any we skipped */
- for (i=0; i<length; i++) {
- item = pk_client_package_buffer_get_item (client, i);
- pk_debug ("%s, %s, %s", pk_info_enum_to_text (item->info),
- item->package_id, item->summary);
- ident = pk_package_id_new_from_string (item->package_id);
- if (item->info == PK_INFO_ENUM_BLOCKED) {
- skipped_number++;
- g_string_append_printf (message_text, "<b>%s</b> - %s\n",
- ident->name, item->summary);
- }
- pk_package_id_free (ident);
- }
-
- /* notify the user if there were skipped entries */
- if (skipped_number > 0) {
- message = ngettext (_("One package was skipped:"),
- _("Some packages were skipped:"), skipped_number);
- g_string_prepend (message_text, message);
- g_string_append_c (message_text, '\n');
- }
-
- /* add a message that we need to restart */
- restart = pk_client_get_require_restart (client);
- if (restart != PK_RESTART_ENUM_NONE) {
- message = gpk_restart_enum_to_localised_text (restart);
-
- /* add a gap if we are putting both */
- if (skipped_number > 0) {
- g_string_append (message_text, "\n");
- }
-
- g_string_append (message_text, message);
- g_string_append_c (message_text, '\n');
- }
-
- /* trim off extra newlines */
- if (message_text->len != 0) {
- g_string_set_size (message_text, message_text->len-1);
- }
-
- /* this will not show if specified in gconf */
- gpk_smart_icon_notify_new (notify->priv->sicon,
- _("The system update has completed"), message_text->str,
- "software-update-available",
- GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
- if (restart == PK_RESTART_ENUM_SYSTEM) {
- gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_RESTART_COMPUTER, NULL);
- gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
- GPK_CONF_NOTIFY_UPDATE_COMPLETE_RESTART);
- } else {
- gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
- GPK_CONF_NOTIFY_UPDATE_COMPLETE);
- }
- gpk_smart_icon_notify_show (notify->priv->sicon);
- g_string_free (message_text, TRUE);
-}
-
-/**
* gpk_notify_update_system:
**/
static gboolean
gpk_notify_update_system (GpkNotify *notify)
{
gboolean ret;
- GError *error = NULL;
- gchar *message;
+ ret = gpk_client_update_system (notify->priv->gclient, NULL);
- g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
-
- pk_debug ("install updates");
- ret = pk_client_reset (notify->priv->client_update_system, &error);
+ /* we failed, show the icon */
if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- ret = pk_client_update_system (notify->priv->client_update_system, &error);
- if (ret) {
gpk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
- } else {
- message = g_strdup_printf (_("The error was: %s"), error->message);
- pk_warning ("%s", message);
- g_error_free (error);
- gpk_smart_icon_notify_new (notify->priv->sicon, _("Failed to update system"), message,
- "process-stop", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
- g_free (message);
- gpk_smart_icon_notify_button (notify->priv->sicon,
- GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
- GPK_CONF_NOTIFY_UPDATE_FAILED);
- gpk_smart_icon_notify_show (notify->priv->sicon);
+ /* we failed, so re-get the update list */
+ gpk_notify_query_updates (notify);
}
return ret;
}
@@ -419,6 +308,8 @@
{
GpkNotify *notify = GPK_NOTIFY (data);
g_return_if_fail (GPK_IS_NOTIFY (notify));
+ gpk_client_show_finished (notify->priv->gclient, TRUE);
+ gpk_client_show_progress (notify->priv->gclient, TRUE);
gpk_notify_update_system (notify);
}
@@ -517,26 +408,6 @@
}
/**
- * gpk_notify_auto_update_message:
- **/
-static void
-gpk_notify_auto_update_message (GpkNotify *notify)
-{
- g_return_if_fail (GPK_IS_NOTIFY (notify));
-
- /* this will not show if specified in gconf */
- gpk_smart_icon_notify_new (notify->priv->sicon,
- _("Updates are being installed"),
- _("Updates are being automatically installed on your computer"),
- "software-update-urgent",
- GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
- gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_CANCEL_UPDATE, NULL);
- gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
- GPK_CONF_NOTIFY_UPDATE_STARTED);
- gpk_smart_icon_notify_show (notify->priv->sicon);
-}
-
-/**
* gpk_notify_client_info_to_enums:
**/
static PkInfoEnum
@@ -607,27 +478,33 @@
static gboolean
gpk_notify_check_on_battery (GpkNotify *notify)
{
- gboolean on_battery;
- gboolean conf_update_battery;
gboolean ret;
g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
- on_battery = gpk_auto_refresh_get_on_battery (notify->priv->arefresh);
- conf_update_battery = gconf_client_get_bool (notify->priv->gconf_client, GPK_CONF_UPDATE_BATTERY, NULL);
- if (!conf_update_battery && on_battery) {
- /* this will not show if specified in gconf */
- gpk_smart_icon_notify_new (notify->priv->sicon,
- _("Will not install updates"),
- _("Automatic updates are not being installed as the computer is on battery power"),
- "dialog-information",
- GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
- gpk_smart_icon_notify_button (notify->priv->sicon,
- GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
- GPK_CONF_NOTIFY_UPDATE_NOT_BATTERY);
- ret = gpk_smart_icon_notify_show (notify->priv->sicon);
+ ret = gconf_client_get_bool (notify->priv->gconf_client, GPK_CONF_UPDATE_BATTERY, NULL);
+ if (ret) {
+ pk_debug ("okay to update due to policy");
+ return TRUE;
}
- return ret;
+
+ ret = gpk_auto_refresh_get_on_battery (notify->priv->arefresh);
+ if (!ret) {
+ pk_debug ("okay to update as on AC");
+ return TRUE;
+ }
+
+ /* this will not show if specified in gconf */
+ gpk_smart_icon_notify_new (notify->priv->sicon,
+ _("Will not install updates"),
+ _("Automatic updates are not being installed as the computer is on battery power"),
+ "dialog-information",
+ GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+ gpk_smart_icon_notify_button (notify->priv->sicon,
+ GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+ GPK_CONF_NOTIFY_UPDATE_NOT_BATTERY);
+ gpk_smart_icon_notify_show (notify->priv->sicon);
+ return FALSE;
}
/**
@@ -756,20 +633,17 @@
goto out;
}
- pk_debug ("just process security updates");
- ret = pk_client_reset (notify->priv->client_update_system, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
/* convert */
package_ids = pk_package_ids_from_array (security_array);
- ret = pk_client_update_packages_strv (notify->priv->client_update_system, package_ids, &error);
+ gpk_client_show_finished (notify->priv->gclient, FALSE);
+ gpk_client_show_progress (notify->priv->gclient, FALSE);
+ ret = gpk_client_update_packages (notify->priv->gclient, package_ids, &error);
if (!ret) {
pk_warning ("Individual updates failed: %s", error->message);
g_error_free (error);
+
+ /* we failed, so re-get the update list */
+ gpk_notify_query_updates (notify);
}
g_strfreev (package_ids);
goto out;
@@ -778,12 +652,9 @@
/* just do everything */
if (update == PK_UPDATE_ENUM_ALL) {
pk_debug ("we should do the update automatically!");
- ret = gpk_notify_update_system (notify);
- if (ret) {
- gpk_notify_auto_update_message (notify);
- } else {
- pk_warning ("update failed");
- }
+ gpk_client_show_finished (notify->priv->gclient, FALSE);
+ gpk_client_show_progress (notify->priv->gclient, FALSE);
+ g_idle_add ((GSourceFunc) gpk_notify_update_system, notify);
goto out;
}
@@ -1003,8 +874,6 @@
gpk_notify_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button,
const gchar *data, GpkNotify *notify)
{
- gboolean ret;
-
g_return_if_fail (GPK_IS_NOTIFY (notify));
pk_debug ("got: %i with data %s", button, data);
@@ -1018,24 +887,9 @@
gconf_client_set_bool (notify->priv->gconf_client, data, FALSE, NULL);
}
} else if (button == GPK_NOTIFY_BUTTON_CANCEL_UPDATE) {
- gboolean ret;
- ret = pk_client_cancel (notify->priv->client_update_system, NULL);
- if (ret == FALSE) {
- pk_warning ("cancelling updates failed");
- gpk_smart_icon_notify_new (notify->priv->sicon,
- _("Could not stop"),
- _("Could not cancel the system update"), "process-stop",
- GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
- gpk_smart_icon_notify_show (notify->priv->sicon);
- }
+ pk_warning ("unable to cancel!");
} else if (button == GPK_NOTIFY_BUTTON_UPDATE_COMPUTER) {
gpk_notify_update_system (notify);
- } else if (button == GPK_NOTIFY_BUTTON_RESTART_COMPUTER) {
- /* restart using gnome-power-manager */
- ret = gpk_restart_system ();
- if (!ret) {
- pk_warning ("failed to reboot");
- }
}
}
@@ -1071,6 +925,11 @@
G_CALLBACK (gpk_notify_activate_update_cb),
notify, 0);
+ /* install stuff using the gnome helpers */
+ notify->priv->gclient = gpk_client_new ();
+ gpk_client_show_finished (notify->priv->gclient, TRUE);
+ gpk_client_show_progress (notify->priv->gclient, TRUE);
+
notify->priv->pconnection = pk_connection_new ();
g_signal_connect (notify->priv->pconnection, "connection-changed",
G_CALLBACK (pk_connection_changed_cb), notify);
@@ -1078,13 +937,6 @@
pk_connection_changed_cb (notify->priv->pconnection, TRUE, notify);
}
- notify->priv->client_update_system = pk_client_new ();
- pk_client_set_use_buffer (notify->priv->client_update_system, TRUE, NULL);
- g_signal_connect (notify->priv->client_update_system, "finished",
- G_CALLBACK (gpk_notify_update_system_finished_cb), notify);
- g_signal_connect (notify->priv->client_update_system, "error-code",
- G_CALLBACK (gpk_notify_error_code_cb), notify);
-
notify->priv->control = pk_control_new ();
g_signal_connect (notify->priv->control, "updates-changed",
G_CALLBACK (gpk_notify_updates_changed_cb), notify);
@@ -1118,11 +970,11 @@
g_object_unref (notify->priv->sicon);
g_object_unref (notify->priv->pconnection);
- g_object_unref (notify->priv->client_update_system);
g_object_unref (notify->priv->tlist);
g_object_unref (notify->priv->arefresh);
g_object_unref (notify->priv->gconf_client);
g_object_unref (notify->priv->control);
+ g_object_unref (notify->priv->gclient);
G_OBJECT_CLASS (gpk_notify_parent_class)->finalize (object);
}
Modified: trunk/src/gpk-prefs.c
==============================================================================
--- trunk/src/gpk-prefs.c (original)
+++ trunk/src/gpk-prefs.c Wed Apr 30 13:29:01 2008
@@ -60,17 +60,6 @@
}
/**
- * pk_button_close_cb:
- **/
-static void
-pk_button_close_cb (GtkWidget *widget, gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
- g_main_loop_quit (loop);
- pk_debug ("emitting action-close");
-}
-
-/**
* pk_button_checkbutton_clicked_cb:
**/
static void
@@ -91,20 +80,6 @@
}
/**
- * pk_window_delete_event_cb:
- * @event: The event type, unused.
- **/
-static gboolean
-pk_window_delete_event_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
- g_main_loop_quit (loop);
- return FALSE;
-}
-
-/**
* pk_prefs_freq_combo_changed:
**/
static void
@@ -284,7 +259,6 @@
int
main (int argc, char *argv[])
{
- GMainLoop *loop;
gboolean verbose = FALSE;
gboolean program_version = FALSE;
GOptionContext *context;
@@ -328,8 +302,6 @@
pk_debug_init (verbose);
gtk_init (&argc, &argv);
- loop = g_main_loop_new (NULL, FALSE);
-
client = pk_client_new ();
/* get actions */
@@ -345,8 +317,7 @@
gtk_window_set_icon_name (GTK_WINDOW (main_window), "system-installer");
/* Get the main window quit */
- g_signal_connect (main_window, "delete_event",
- G_CALLBACK (pk_window_delete_event_cb), loop);
+ g_signal_connect_swapped (main_window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
widget = glade_xml_get_widget (glade_xml, "checkbutton_notify_updates");
pk_prefs_notify_checkbutton_setup (widget, GPK_CONF_NOTIFY_AVAILABLE);
@@ -358,8 +329,7 @@
pk_prefs_notify_checkbutton_setup (widget, GPK_CONF_UPDATE_BATTERY);
widget = glade_xml_get_widget (glade_xml, "button_close");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_button_close_cb), loop);
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
widget = glade_xml_get_widget (glade_xml, "button_help");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_button_help_cb), NULL);
@@ -370,8 +340,8 @@
gtk_widget_show (main_window);
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ /* wait */
+ gtk_main ();
g_object_unref (glade_xml);
g_object_unref (client);
Modified: trunk/src/gpk-repo.c
==============================================================================
--- trunk/src/gpk-repo.c (original)
+++ trunk/src/gpk-repo.c Wed Apr 30 13:29:01 2008
@@ -68,19 +68,6 @@
gpk_gnome_help ("software-sources");
}
-/**
- * pk_button_close_cb:
- **/
-static void
-pk_button_close_cb (GtkWidget *widget,
- gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
-
- g_main_loop_quit (loop);
- pk_debug ("emitting action-close");
-}
-
static void
pk_misc_installed_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
{
@@ -153,21 +140,6 @@
}
/**
- * pk_window_delete_event_cb:
- * @event: The event type, unused.
- **/
-static gboolean
-pk_window_delete_event_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
-
- g_main_loop_quit (loop);
- return FALSE;
-}
-
-/**
* pk_treeview_add_columns:
**/
static void
@@ -300,7 +272,6 @@
int
main (int argc, char *argv[])
{
- GMainLoop *loop;
gboolean verbose = FALSE;
GOptionContext *context;
GtkWidget *main_window;
@@ -335,8 +306,6 @@
pk_debug_init (verbose);
gtk_init (&argc, &argv);
- loop = g_main_loop_new (NULL, FALSE);
-
gconf_client = gconf_client_get_default ();
client = pk_client_new ();
@@ -359,12 +328,10 @@
gtk_window_set_icon_name (GTK_WINDOW (main_window), "pk-package-sources");
/* Get the main window quit */
- g_signal_connect (main_window, "delete_event",
- G_CALLBACK (pk_window_delete_event_cb), loop);
+ g_signal_connect_swapped (main_window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
widget = glade_xml_get_widget (glade_xml, "button_close");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_button_close_cb), loop);
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
widget = glade_xml_get_widget (glade_xml, "button_help");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_button_help_cb), NULL);
@@ -418,8 +385,8 @@
gtk_widget_set_sensitive (widget, FALSE);
}
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ /* wait */
+ gtk_main ();
g_object_unref (glade_xml);
g_object_unref (list_store);
Modified: trunk/src/gpk-update-icon.c
==============================================================================
--- trunk/src/gpk-update-icon.c (original)
+++ trunk/src/gpk-update-icon.c Wed Apr 30 13:29:01 2008
@@ -97,9 +97,8 @@
static void
pk_dbus_connection_replaced_cb (LibGBus *libgbus, gpointer data)
{
- GMainLoop *loop = (GMainLoop *) data;
- pk_warning ("exiting the mainloop as we have been replaced");
- g_main_loop_quit (loop);
+ pk_warning ("exiting as we have been replaced");
+ gtk_main_quit ();
}
/**
@@ -108,11 +107,11 @@
int
main (int argc, char *argv[])
{
- GMainLoop *loop;
gboolean verbose = FALSE;
gboolean program_version = FALSE;
GpkNotify *notify = NULL;
GpkWatch *watch = NULL;
+ GpkDbus *dbus = NULL;
GpkFirmware *firmware = NULL;
GOptionContext *context;
GError *error = NULL;
@@ -160,16 +159,16 @@
PK_DATA G_DIR_SEPARATOR_S "icons");
/* create new objects */
+ dbus = gpk_dbus_new ();
notify = gpk_notify_new ();
watch = gpk_watch_new ();
firmware = gpk_firmware_new ();
- loop = g_main_loop_new (NULL, FALSE);
/* find out when we are replaced */
libgbus = libgbus_new ();
libgbus_assign (libgbus, LIBGBUS_SESSION, PK_DBUS_SERVICE);
g_signal_connect (libgbus, "connection-replaced",
- G_CALLBACK (pk_dbus_connection_replaced_cb), loop);
+ G_CALLBACK (pk_dbus_connection_replaced_cb), NULL);
/* get the bus */
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
@@ -180,17 +179,17 @@
}
/* try to register */
- ret = gpk_object_register (connection, G_OBJECT (notify));
+ ret = gpk_object_register (connection, G_OBJECT (dbus));
if (!ret) {
pk_warning ("failed to replace running instance.");
goto out;
}
- /* wait until loop killed */
- g_main_loop_run (loop);
+ /* wait */
+ gtk_main ();
out:
- g_main_loop_unref (loop);
+ g_object_unref (dbus);
g_object_unref (notify);
g_object_unref (watch);
g_object_unref (firmware);
Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c (original)
+++ trunk/src/gpk-update-viewer.c Wed Apr 30 13:29:01 2008
@@ -49,6 +49,7 @@
#include "gpk-statusbar.h"
#include "gpk-consolekit.h"
#include "gpk-cell-renderer-uri.h"
+#include "gpk-client.h"
static GladeXML *glade_xml = NULL;
static GtkListStore *list_store_preview = NULL;
@@ -59,6 +60,8 @@
static PkControl *control = NULL;
static PkTaskList *tlist = NULL;
static gchar *cached_package_id = NULL;
+static GpkClient *gclient = NULL;
+static gboolean are_updates_available = FALSE;
static PolKitGnomeAction *refresh_action = NULL;
static PolKitGnomeAction *update_system_action = NULL;
@@ -108,7 +111,6 @@
PAGE_DETAILS,
PAGE_PROGRESS,
PAGE_CONFIRM,
- PAGE_ERROR,
PAGE_LAST
} PkPageEnum;
@@ -165,8 +167,6 @@
static void
pk_update_viewer_update_system_cb (PolKitGnomeAction *action, gpointer data)
{
- gboolean ret;
- GError *error = NULL;
GtkWidget *widget;
pk_debug ("Doing the system update");
@@ -175,22 +175,9 @@
gtk_widget_hide (widget);
/* set correct view */
- pk_update_viewer_set_page (PAGE_PROGRESS);
+// pk_update_viewer_set_page (PAGE_PROGRESS);
- /* reset */
- ret = pk_client_reset (client_action, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- return;
- }
-
- /* update system */
- ret = pk_client_update_system (client_action, &error);
- if (!ret) {
- pk_warning ("failed to update system: %s", error->message);
- g_error_free (error);
- }
+ gpk_client_update_system (gclient, NULL);
}
/**
@@ -209,8 +196,6 @@
gchar *package_id;
GPtrArray *array;
gchar **package_ids;
- gboolean ret;
- GError *error = NULL;
pk_debug ("Doing the package updates");
array = g_ptr_array_new ();
@@ -256,26 +241,15 @@
gtk_widget_show (widget);
}
+ pk_update_viewer_set_page (PAGE_LAST);
+
/* set correct view */
- pk_update_viewer_set_page (PAGE_PROGRESS);
package_ids = pk_package_ids_from_array (array);
-
- /* reset */
- ret = pk_client_reset (client_action, &error);
- if (!ret) {
- pk_warning ("failed to reset client: %s", error->message);
- g_error_free (error);
- return;
- }
-
- /* update a list */
- ret = pk_client_update_packages_strv (client_action, package_ids, &error);
- if (!ret) {
- gpk_error_dialog (_("Failed to update"), _("Individual updates failed"), error->message);
- g_error_free (error);
- }
+ gpk_client_update_packages (gclient, package_ids, NULL);
g_strfreev (package_ids);
+ pk_update_viewer_set_page (PAGE_PROGRESS);
+
/* get rid of the array, and free the contents */
g_ptr_array_free (array, TRUE);
}
@@ -565,8 +539,6 @@
gboolean ret;
GError *error = NULL;
- GMainLoop *loop = (GMainLoop *) data;
-
/* we might have a transaction running */
ret = pk_client_cancel (client_action, &error);
if (!ret) {
@@ -574,19 +546,7 @@
g_error_free (error);
}
- g_main_loop_quit (loop);
-}
-
-/**
- * pk_update_viewer_close_cb:
- **/
-static void
-pk_update_viewer_close_cb (GtkWidget *widget, gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
-
- /* just close the UI, let the installation continue */
- g_main_loop_quit (loop);
+ gtk_main_quit ();
}
/**
@@ -630,13 +590,6 @@
length = pk_client_package_buffer_get_size (client_query);
if (length == 0) {
pk_update_viewer_add_preview_item ("dialog-information", _("There are no updates available!"), TRUE);
-
- /* if no updates then hide apply */
- widget = glade_xml_get_widget (glade_xml, "button_review");
- gtk_widget_set_sensitive (widget, FALSE);
- polkit_gnome_action_set_sensitive (update_system_action, FALSE);
- polkit_gnome_action_set_sensitive (update_packages_action, FALSE);
-
widget = glade_xml_get_widget (glade_xml, "button_close3");
gtk_widget_grab_default (widget);
} else {
@@ -743,6 +696,7 @@
g_error_free (error);
return;
}
+
pk_update_viewer_populate_preview ();
}
@@ -985,18 +939,6 @@
}
/**
- * pk_update_viewer_window_delete_event_cb:
- * @event: The event type, unused.
- **/
-static gboolean
-pk_update_viewer_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- GMainLoop *loop = (GMainLoop *) data;
- g_main_loop_quit (loop);
- return FALSE;
-}
-
-/**
* pk_update_viewer_treeview_update_toggled:
**/
static void
@@ -1340,6 +1282,7 @@
GtkWidget *widget;
PkRoleEnum role;
PkRestartEnum restart;
+ guint length;
pk_client_get_role (client, &role, NULL, NULL);
@@ -1349,6 +1292,24 @@
return;
}
+ /* update sensitivities */
+ if (role == PK_ROLE_ENUM_GET_UPDATES) {
+ pk_warning ("are_updates_available=%i", are_updates_available);
+ length = pk_client_package_buffer_get_size (client_query);
+ if (length == 0) {
+ are_updates_available = FALSE;
+ } else {
+ are_updates_available = TRUE;
+ }
+
+ /* make the buttons non-clickable until we get completion */
+ polkit_gnome_action_set_sensitive (refresh_action, are_updates_available);
+ polkit_gnome_action_set_sensitive (update_system_action, are_updates_available);
+ polkit_gnome_action_set_sensitive (update_packages_action, are_updates_available);
+ widget = glade_xml_get_widget (glade_xml, "button_review");
+ gtk_widget_set_sensitive (widget, are_updates_available);
+ }
+
/* stop the throbber */
pk_update_viewer_preview_animation_stop ();
@@ -1468,11 +1429,11 @@
pk_update_viewer_preview_animation_stop ();
/* show apply, review and refresh */
- polkit_gnome_action_set_sensitive (update_system_action, TRUE);
- polkit_gnome_action_set_sensitive (update_packages_action, TRUE);
- polkit_gnome_action_set_sensitive (refresh_action, TRUE);
+ polkit_gnome_action_set_sensitive (update_system_action, are_updates_available);
+ polkit_gnome_action_set_sensitive (update_packages_action, are_updates_available);
+ polkit_gnome_action_set_sensitive (refresh_action, are_updates_available);
widget = glade_xml_get_widget (glade_xml, "button_review");
- gtk_widget_set_sensitive (widget, TRUE);
+ gtk_widget_set_sensitive (widget, are_updates_available);
}
}
@@ -1482,31 +1443,8 @@
static void
pk_update_viewer_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, gpointer data)
{
- GtkWidget *widget;
- const gchar *title;
- gchar *title_bold;
- gchar *details_safe;
-
- /* set bold title */
- widget = glade_xml_get_widget (glade_xml, "label_error_title");
- title = gpk_error_enum_to_localised_text (code);
- title_bold = g_strdup_printf ("<b>%s</b>", title);
- gtk_label_set_label (GTK_LABEL (widget), title_bold);
- g_free (title_bold);
-
- widget = glade_xml_get_widget (glade_xml, "label_error_message");
- gtk_label_set_label (GTK_LABEL (widget), gpk_error_enum_to_localised_message (code));
-
- widget = glade_xml_get_widget (glade_xml, "label_error_details");
- details_safe = g_markup_escape_text (details, -1);
- gtk_label_set_label (GTK_LABEL (widget), details_safe);
- g_free (details_safe);
-
- widget = glade_xml_get_widget (glade_xml, "button_close5");
- gtk_widget_grab_default (widget);
-
- /* set correct view */
- pk_update_viewer_set_page (PAGE_ERROR);
+ gpk_error_dialog (gpk_error_enum_to_localised_text (code),
+ gpk_error_enum_to_localised_message (code), details);
}
/**
@@ -1708,17 +1646,104 @@
if (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
role == PK_ROLE_ENUM_REFRESH_CACHE) {
+ pk_warning ("getting new");
pk_update_viewer_get_new_update_list ();
}
}
/**
+ * gpk_update_viewer_create_custom_widget:
+ **/
+static GtkWidget *
+gpk_update_viewer_create_custom_widget (GladeXML *xml, gchar *func_name, gchar *name,
+ gchar *string1, gchar *string2,
+ gint int1, gint int2, gpointer user_data)
+{
+ if (pk_strequal (name, "button_refresh")) {
+ return polkit_gnome_action_create_button (refresh_action);
+ }
+ if (pk_strequal (name, "button_restart")) {
+ return polkit_gnome_action_create_button (restart_action);
+ }
+ if (pk_strequal (name, "button_update_system")) {
+ return polkit_gnome_action_create_button (update_system_action);
+ }
+ if (pk_strequal (name, "button_update_packages")) {
+ return polkit_gnome_action_create_button (update_packages_action);
+ }
+ pk_warning ("name unknown=%s", name);
+ return NULL;
+}
+
+/**
+ * gpk_update_viewer_setup_policykit:
+ *
+ * We have to do this before the glade stuff if done as the custom handler needs the actions setup
+ **/
+static void
+gpk_update_viewer_setup_policykit (void)
+{
+ PolKitAction *pk_action;
+
+ /* refresh */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
+ refresh_action = polkit_gnome_action_new_default ("refresh", pk_action,
+ _("Refresh"),
+ _("Refreshing is not normally required but will retrieve the latest application and update lists"));
+ g_object_set (refresh_action, "auth-icon-name", NULL, NULL);
+ polkit_action_unref (pk_action);
+
+ /* restart */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.consolekit.system.restart");
+ restart_action = polkit_gnome_action_new_default ("restart-system", pk_action,
+ _("_Restart computer now"), NULL);
+ g_object_set (restart_action,
+ "no-icon-name", GTK_STOCK_REFRESH,
+ "auth-icon-name", GTK_STOCK_REFRESH,
+ "yes-icon-name", GTK_STOCK_REFRESH,
+ "self-blocked-icon-name", GTK_STOCK_REFRESH,
+ "no-visible", FALSE,
+ "master-visible", FALSE,
+ NULL);
+ polkit_action_unref (pk_action);
+
+ /* update-package */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-package");
+ update_packages_action = polkit_gnome_action_new_default ("update-package", pk_action,
+ _("_Apply Updates"),
+ _("Apply the selected updates"));
+ g_object_set (update_packages_action,
+ "no-icon-name", GTK_STOCK_APPLY,
+ "auth-icon-name", GTK_STOCK_APPLY,
+ "yes-icon-name", GTK_STOCK_APPLY,
+ "self-blocked-icon-name", GTK_STOCK_APPLY,
+ NULL);
+ polkit_action_unref (pk_action);
+
+ /* update-system */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-system");
+ update_system_action = polkit_gnome_action_new_default ("update-system", pk_action,
+ _("_Update System"),
+ _("Apply all updates"));
+ g_object_set (update_system_action,
+ "no-icon-name", GTK_STOCK_APPLY,
+ "auth-icon-name", GTK_STOCK_APPLY,
+ "yes-icon-name", GTK_STOCK_APPLY,
+ "self-blocked-icon-name", GTK_STOCK_APPLY,
+ NULL);
+ polkit_action_unref (pk_action);
+}
+
+/**
* main:
**/
int
main (int argc, char *argv[])
{
- GMainLoop *loop;
gboolean verbose = FALSE;
gboolean program_version = FALSE;
GOptionContext *context;
@@ -1728,8 +1753,6 @@
PkRoleEnum roles;
gboolean ret;
GtkSizeGroup *size_group;
- GtkWidget *button;
- PolKitAction *pk_action;
GError *error = NULL;
const GOptionEntry options[] = {
@@ -1770,7 +1793,11 @@
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
PK_DATA G_DIR_SEPARATOR_S "icons");
- loop = g_main_loop_new (NULL, FALSE);
+ /* we have to do this before we connect up the glade file */
+ gpk_update_viewer_setup_policykit ();
+
+ /* use custom widgets */
+ glade_set_custom_handler (gpk_update_viewer_create_custom_widget, NULL);
control = pk_control_new ();
g_signal_connect (control, "repo-list-changed",
@@ -1815,6 +1842,10 @@
/* monitor for other updates in progress */
tlist = pk_task_list_new ();
+ /* install stuff using the gnome helpers */
+ gclient = gpk_client_new ();
+ gpk_client_show_finished (gclient, FALSE);
+
glade_xml = glade_xml_new (PK_DATA "/gpk-update-viewer.glade", NULL, NULL);
main_window = glade_xml_get_widget (glade_xml, "window_updates");
@@ -1826,51 +1857,29 @@
widget = glade_xml_get_widget (glade_xml, "hbox_restart");
gtk_widget_hide (widget);
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.consolekit.system.restart");
- restart_action = polkit_gnome_action_new_default ("restart-system", pk_action,
- _("_Restart computer now"), NULL);
- g_object_set (restart_action,
- "no-icon-name", GTK_STOCK_REFRESH,
- "auth-icon-name", GTK_STOCK_REFRESH,
- "yes-icon-name", GTK_STOCK_REFRESH,
- "self-blocked-icon-name", GTK_STOCK_REFRESH,
- "no-visible", FALSE,
- "master-visible", FALSE,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (restart_action, "activate",
- G_CALLBACK (pk_update_viewer_restart_cb), loop);
- button = polkit_gnome_action_create_button (restart_action);
- widget = glade_xml_get_widget (glade_xml, "buttonbox_confirm");
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 1);
-
/* Get the main window quit */
- g_signal_connect (main_window, "delete_event",
- G_CALLBACK (pk_update_viewer_window_delete_event_cb), loop);
+ g_signal_connect_swapped (main_window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
/* button_close2 and button_close3 are on the overview/review
* screens, where we want to cancel transactions when closing
*/
widget = glade_xml_get_widget (glade_xml, "button_close2");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_button_close_and_cancel_cb), loop);
+ G_CALLBACK (pk_update_viewer_button_close_and_cancel_cb), NULL);
widget = glade_xml_get_widget (glade_xml, "button_close3");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_button_close_and_cancel_cb), loop);
+ G_CALLBACK (pk_update_viewer_button_close_and_cancel_cb), NULL);
+
+ /* normal close buttons */
widget = glade_xml_get_widget (glade_xml, "button_close");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_close_cb), loop);
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
widget = glade_xml_get_widget (glade_xml, "button_close4");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_close_cb), loop);
- widget = glade_xml_get_widget (glade_xml, "button_close5");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_close_cb), loop);
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+
+ /* cancel button */
widget = glade_xml_get_widget (glade_xml, "button_cancel");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_button_cancel_cb), loop);
+ G_CALLBACK (pk_update_viewer_button_cancel_cb), NULL);
gtk_widget_set_sensitive (widget, FALSE);
/* can we ever do the action? */
@@ -1878,85 +1887,31 @@
gtk_widget_hide (widget);
}
+ /* connect up PolicyKit actions */
+ g_signal_connect (refresh_action, "activate",
+ G_CALLBACK (pk_update_viewer_refresh_cb), NULL);
+ g_signal_connect (restart_action, "activate",
+ G_CALLBACK (pk_update_viewer_restart_cb), NULL);
+ g_signal_connect (update_packages_action, "activate",
+ G_CALLBACK (pk_update_viewer_apply_cb), NULL);
+ g_signal_connect (update_system_action, "activate",
+ G_CALLBACK (pk_update_viewer_update_system_cb), NULL);
+
widget = glade_xml_get_widget (glade_xml, "button_review");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_review_cb), loop);
+ G_CALLBACK (pk_update_viewer_review_cb), NULL);
gtk_widget_set_tooltip_text(widget, _("Review the update list"));
widget = glade_xml_get_widget (glade_xml, "button_overview");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_overview_cb), loop);
+ G_CALLBACK (pk_update_viewer_overview_cb), NULL);
gtk_widget_set_tooltip_text(widget, _("Back to overview"));
widget = glade_xml_get_widget (glade_xml, "button_overview2");
g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_button_more_installs_cb), loop);
+ G_CALLBACK (pk_button_more_installs_cb), NULL);
gtk_widget_set_tooltip_text (widget, _("Back to overview"));
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-package");
- update_packages_action = polkit_gnome_action_new_default ("update-package",
- pk_action,
- _("_Apply Updates"),
- _("Apply the selected updates"));
- g_object_set (update_packages_action,
- "no-icon-name", GTK_STOCK_APPLY,
- "auth-icon-name", GTK_STOCK_APPLY,
- "yes-icon-name", GTK_STOCK_APPLY,
- "self-blocked-icon-name", GTK_STOCK_APPLY,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (update_packages_action, "activate",
- G_CALLBACK (pk_update_viewer_apply_cb), loop);
- button = polkit_gnome_action_create_button (update_packages_action);
- widget = glade_xml_get_widget (glade_xml, "buttonbox_review");
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 2);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-system");
- update_system_action = polkit_gnome_action_new_default ("update-system",
- pk_action,
- _("_Update System"),
- _("Apply all updates"));
- g_object_set (update_system_action,
- "no-icon-name", GTK_STOCK_APPLY,
- "auth-icon-name", GTK_STOCK_APPLY,
- "yes-icon-name", GTK_STOCK_APPLY,
- "self-blocked-icon-name", GTK_STOCK_APPLY,
- NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (update_system_action, "activate",
- G_CALLBACK (pk_update_viewer_update_system_cb), loop);
- button = polkit_gnome_action_create_button (update_system_action);
- widget = glade_xml_get_widget (glade_xml, "buttonbox_overview");
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (widget), button, 1);
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
-
- widget = glade_xml_get_widget (glade_xml, "alignment_refresh");
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
- refresh_action = polkit_gnome_action_new_default ("refresh",
- pk_action,
- _("Refresh"),
- _("Refreshing is not normally required but will retrieve the latest application and update lists"));
- g_object_set (refresh_action, "auth-icon-name", NULL, NULL);
- polkit_action_unref (pk_action);
-
- g_signal_connect (refresh_action, "activate",
- G_CALLBACK (pk_update_viewer_refresh_cb), NULL);
-
- button = polkit_gnome_action_create_button (refresh_action);
- gtk_container_add (GTK_CONTAINER (widget), button);
- gtk_size_group_add_widget (size_group, button);
-
- widget = glade_xml_get_widget (glade_xml, "button_history");
- g_signal_connect (widget, "clicked",
- G_CALLBACK (pk_update_viewer_history_cb), NULL);
- gtk_size_group_add_widget (size_group, widget);
-
widget = glade_xml_get_widget (glade_xml, "button_help");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_button_help_cb), "update-viewer");
@@ -1965,6 +1920,17 @@
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_button_help_cb), "update-viewer-details");
+ widget = glade_xml_get_widget (glade_xml, "button_history");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (pk_update_viewer_history_cb), NULL);
+
+ /* make the refresh button the same size as the history one */
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
+ widget = glade_xml_get_widget (glade_xml, "button_refresh");
+ gtk_size_group_add_widget (size_group, widget);
+ widget = glade_xml_get_widget (glade_xml, "button_history");
+ gtk_size_group_add_widget (size_group, widget);
+
/* create list stores */
list_store_details = gtk_list_store_new (PACKAGES_COLUMN_LAST, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
@@ -2041,8 +2007,8 @@
/* coldplug */
pk_update_viewer_get_new_update_list ();
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ /* wait */
+ gtk_main ();
/* we might have visual stuff running, close it down */
ret = pk_client_cancel (client_query, &error);
@@ -2055,6 +2021,7 @@
g_object_unref (list_store_preview);
g_object_unref (list_store_description);
g_object_unref (list_store_details);
+ g_object_unref (gclient);
g_object_unref (control);
g_object_unref (client_query);
g_object_unref (client_action);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]