gnome-packagekit r159 - in trunk: . data libpackagekit-gnome po src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r159 - in trunk: . data libpackagekit-gnome po src
- Date: Fri, 11 Apr 2008 23:31:29 +0100 (BST)
Author: rhughes
Date: Fri Apr 11 23:31:29 2008
New Revision: 159
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=159&view=rev
Log:
from git
Added:
trunk/libpackagekit-gnome/
trunk/libpackagekit-gnome/Makefile.am
trunk/libpackagekit-gnome/gpk-client.c
trunk/libpackagekit-gnome/gpk-client.h
trunk/libpackagekit-gnome/gpk-common.c
trunk/libpackagekit-gnome/gpk-common.h
trunk/libpackagekit-gnome/gpk-self-test.c
Removed:
trunk/src/gpk-common.c
trunk/src/gpk-common.h
trunk/src/gpk-self-test.c
Modified:
trunk/.gitignore
trunk/Makefile.am
trunk/configure.ac
trunk/data/gpk-install-file.desktop.in
trunk/data/gpk-repo.glade
trunk/data/gpk-update-viewer.glade
trunk/po/POTFILES.in
trunk/src/.gitignore
trunk/src/Makefile.am
trunk/src/gpk-application.c
trunk/src/gpk-auto-refresh.c
trunk/src/gpk-backend-status.c
trunk/src/gpk-log.c
trunk/src/gpk-notify.c
trunk/src/gpk-prefs.c
trunk/src/gpk-progress.c
trunk/src/gpk-repo.c
trunk/src/gpk-update-viewer.c
trunk/src/gpk-watch.c
Modified: trunk/.gitignore
==============================================================================
--- trunk/.gitignore (original)
+++ trunk/.gitignore Fri Apr 11 23:31:29 2008
@@ -30,4 +30,5 @@
xmldocs.make
.svn
NEWS.new
+packagekit-gnome.pc
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Fri Apr 11 23:31:29 2008
@@ -1,16 +1,21 @@
SUBDIRS = \
libselftest \
libgbus \
+ libpackagekit-gnome \
src \
po \
data \
help
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = packagekit-gnome.pc
+
EXTRA_DIST = \
MAINTAINERS \
intltool-extract.in \
intltool-merge.in \
intltool-update.in \
+ packagekit-gnome.pc.in \
omf.make \
xmldocs.make \
gnome-doc-utils.make
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Apr 11 23:31:29 2008
@@ -5,6 +5,22 @@
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
+# libtool versioning - this applies to libpackagekit
+#
+# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
+#
+# increment;
+# CURRENT If the API or ABI interface has changed (reset REVISION to 0)
+# REVISION If the API and ABI remains the same, but bugs are fixed.
+# AGE If libpackagekit can be linked into executables which can be
+# built with previous versions of this library. Don't use.
+LT_CURRENT=1
+LT_REVISION=0
+LT_AGE=0
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+
AC_PROG_CC
AC_PROG_INSTALL
AM_PROG_LIBTOOL
@@ -177,7 +193,9 @@
dnl ---------------------------------------------------------------------------
AC_OUTPUT([
Makefile
+packagekit-gnome.pc
libselftest/Makefile
+libpackagekit-gnome/Makefile
libgbus/Makefile
src/Makefile
help/Makefile
Modified: trunk/data/gpk-install-file.desktop.in
==============================================================================
--- trunk/data/gpk-install-file.desktop.in (original)
+++ trunk/data/gpk-install-file.desktop.in Fri Apr 11 23:31:29 2008
@@ -4,7 +4,7 @@
_GenericName=Package Installer
_Comment=Install selected software on the system
Categories=System;X-Red-Hat-Base;X-Fedora;
-Exec=/usr/bin/gpk-install-file %F
+Exec=/usr/bin/gpk-install-local-file %F
Terminal=false
Type=Application
Icon=system-software-installer
Modified: trunk/data/gpk-repo.glade
==============================================================================
--- trunk/data/gpk-repo.glade (original)
+++ trunk/data/gpk-repo.glade Fri Apr 11 23:31:29 2008
@@ -22,6 +22,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="treeview_repo">
@@ -36,7 +37,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Shows more repositories that may be interesting</property>
- <property name="label" translatable="yes" comments="shows extra -source and -debuginfo repos">_Show detailed information</property>
+ <property name="label" translatable="yes" comments="shows extra -source, -debuginfo, and -devel repos">_Show source, debug, and development repositories</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
Modified: trunk/data/gpk-update-viewer.glade
==============================================================================
--- trunk/data/gpk-update-viewer.glade (original)
+++ trunk/data/gpk-update-viewer.glade Fri Apr 11 23:31:29 2008
@@ -69,50 +69,40 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkAlignment" id="alignment1">
+ <widget class="GtkLabel" id="label_last_update">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkButton" id="button_history">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">View History</property>
- <property name="response_id">0</property>
- </widget>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Unknown....</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment_refresh">
+ <widget class="GtkLabel" id="label_last_refresh">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <placeholder/>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Unknown....</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Last refresh:</property>
+ <property name="label" translatable="yes">Last update:</property>
</widget>
<packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@@ -120,38 +110,48 @@
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Last update:</property>
+ <property name="label" translatable="yes">Last refresh:</property>
</widget>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label_last_refresh">
+ <widget class="GtkAlignment" id="alignment_refresh">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Unknown....</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label_last_update">
+ <widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Unknown....</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkButton" id="button_history">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">View History</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
@@ -180,9 +180,6 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkButton" id="button_review">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -225,10 +222,13 @@
</child>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_close3">
<property name="visible">True</property>
<property name="can_focus">True</property>
Added: trunk/libpackagekit-gnome/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/Makefile.am Fri Apr 11 23:31:29 2008
@@ -0,0 +1,94 @@
+
+NULL =
+
+INCLUDES = \
+ $(GTK_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(POLKIT_GNOME_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(GCONF_CFLAGS) \
+ $(LIBGLADE_CFLAGS) \
+ $(PACKAGEKIT_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ -DDATADIR=\"$(datadir)\" \
+ -DPK_DATA=\"$(pkgdatadir)\" \
+ -I$(top_srcdir)/libselftest \
+ $(NULL)
+
+SELFTEST_LIBS = \
+ $(top_builddir)/libselftest/libselftest.la \
+ $(NULL)
+
+lib_LTLIBRARIES = \
+ libpackagekit-gnome.la \
+ $(NULL)
+
+libpackagekit_gnome_includedir = $(includedir)/packagekit-gnome
+
+libpackagekit_gnome_include_HEADERS = \
+ gpk-client.h \
+ gpk-common.h \
+ $(NULL)
+
+libpackagekit_gnome_la_SOURCES = \
+ gpk-common.c \
+ gpk-common.h \
+ gpk-client.c \
+ gpk-client.h \
+ $(NULL)
+
+libpackagekit_gnome_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS) \
+ $(GTK_LIBS) \
+ $(PACKAGEKIT_LIBS) \
+ $(POLKIT_GNOME_LIBS) \
+ $(LIBGLADE_LIBS) \
+ $(NULL)
+
+libpackagekit_gnome_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ $(NULL)
+
+check_PROGRAMS = \
+ gpk-self-test
+
+noinst_PROGRAMS = \
+ gpk-self-test
+
+gpk_self_test_SOURCES = \
+ gpk-common.h \
+ gpk-common.c \
+ gpk-self-test.c \
+ $(NULL)
+
+gpk_self_test_LDADD = \
+ $(GLIB_LIBS) \
+ $(GTK_LIBS) \
+ $(DBUS_LIBS) \
+ $(SELFTEST_LIBS) \
+ $(PK_LIBS) \
+ $(PACKAGEKIT_LIBS) \
+ $(POLKIT_GNOME_LIBS) \
+ $(NULL)
+
+TESTS = gpk-self-test
+
+if PK_BUILD_GPROF
+clean-gprof:
+ rm -f *.out
+gprof: clean-gprof all check
+ gprof ./gpk-self-test > gprof.txt
+endif
+
+gpk_self_test_CPPFLAGS= \
+ -DPK_BUILD_TESTS
+
+clean-local:
+ rm -f *~
+ rm -f *.out
+ rm -f *.gcda
+ rm -f *.gcno
+ rm -f gcov.txt
+ rm -f gprof.txt
+
Added: trunk/libpackagekit-gnome/gpk-client.c
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/gpk-client.c Fri Apr 11 23:31:29 2008
@@ -0,0 +1,747 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <pk-debug.h>
+#include <pk-client.h>
+#include <pk-package-id.h>
+#include <pk-control.h>
+
+#include "gpk-client.h"
+#include "gpk-common.h"
+
+static void gpk_client_class_init (GpkClientClass *klass);
+static void gpk_client_init (GpkClient *gclient);
+static void gpk_client_finalize (GObject *object);
+
+#define GPK_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_CLIENT, GpkClientPrivate))
+
+struct GpkClientPrivate
+{
+ PkClient *client_action;
+ PkClient *client_resolve;
+ GladeXML *glade_xml;
+ gint pulse_timeout;
+ PkControl *control;
+ PkRoleEnum roles;
+};
+
+typedef enum {
+ GPK_CLIENT_PAGE_PROGRESS,
+ GPK_CLIENT_PAGE_CONFIRM,
+ GPK_CLIENT_PAGE_ERROR,
+ GPK_CLIENT_PAGE_LAST
+} GpkClientPageEnum;
+
+G_DEFINE_TYPE (GpkClient, gpk_client, G_TYPE_OBJECT)
+
+/**
+ * gpk_client_set_page:
+ **/
+static void
+gpk_client_set_page (GpkClient *gclient, GpkClientPageEnum page)
+{
+ GList *list, *l;
+ GtkWidget *widget;
+ guint i;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "hbox_hidden");
+ list = gtk_container_get_children (GTK_CONTAINER (widget));
+ for (l=list, i=0; l; l=l->next, i++) {
+ if (i == page) {
+ gtk_widget_show (l->data);
+ } else {
+ gtk_widget_hide (l->data);
+ }
+ }
+}
+
+/**
+ * gpk_install_finished_timeout:
+ **/
+static gboolean
+gpk_install_finished_timeout (gpointer data)
+{
+ gtk_main_quit ();
+ return FALSE;
+}
+
+/**
+ * gpk_client_finished_cb:
+ **/
+static void
+gpk_client_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, GpkClient *gclient)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ if (exit == PK_EXIT_ENUM_SUCCESS) {
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_CONFIRM);
+ g_timeout_add_seconds (30, gpk_install_finished_timeout, gclient);
+ }
+ /* make insensitive */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
+ gtk_widget_set_sensitive (widget, FALSE);
+
+ /* set to 100% */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), 1.0f);
+}
+
+/**
+ * gpk_client_progress_changed_cb:
+ **/
+static void
+gpk_client_progress_changed_cb (PkClient *client, guint percentage, guint subpercentage,
+ guint elapsed, guint remaining, GpkClient *gclient)
+{
+ GtkWidget *widget;
+
+ 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 (percentage != PK_CLIENT_PERCENTAGE_INVALID) {
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), (gfloat) percentage / 100.0);
+ }
+}
+
+/**
+ * gpk_client_pulse_progress:
+ **/
+static gboolean
+gpk_client_pulse_progress (GpkClient *gclient)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "progressbar_percent");
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
+ return TRUE;
+}
+
+/**
+ * gpk_client_status_changed_cb:
+ **/
+static void
+gpk_client_status_changed_cb (PkClient *client, PkStatusEnum status, GpkClient *gclient)
+{
+ GtkWidget *widget;
+ gchar *text;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "progress_part_label");
+ text = g_strdup_printf ("<b>%s</b>", gpk_status_enum_to_localised_text (status));
+ gtk_label_set_markup (GTK_LABEL (widget), text);
+ g_free (text);
+
+ if (status == PK_STATUS_ENUM_WAIT) {
+ if (gclient->priv->pulse_timeout == 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);
+ }
+ }
+}
+
+/**
+ * gpk_client_error_code_cb:
+ **/
+static void
+gpk_client_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkClient *gclient)
+{
+ GtkWidget *widget;
+ const gchar *title;
+ gchar *title_bold;
+ gchar *details_safe;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ gpk_client_set_page (gclient, GPK_CLIENT_PAGE_ERROR);
+
+ /* set bold title */
+ widget = glade_xml_get_widget (gclient->priv->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 (gclient->priv->glade_xml, "label_error_message");
+ gtk_label_set_label (GTK_LABEL (widget), gpk_error_enum_to_localised_message (code));
+
+ widget = glade_xml_get_widget (gclient->priv->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);
+}
+
+/**
+ * pk_client_package_cb:
+ **/
+static void
+pk_client_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id,
+ const gchar *summary, GpkClient *gclient)
+{
+ gchar *text;
+ GtkWidget *widget;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ text = gpk_package_id_pretty (package_id, summary);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "label_package");
+ gtk_label_set_markup (GTK_LABEL (widget), text);
+ g_free (text);
+}
+
+/**
+ * pk_client_allow_cancel_cb:
+ **/
+static void
+pk_client_allow_cancel_cb (PkClient *client, gboolean allow_cancel, GpkClient *gclient)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
+ gtk_widget_set_sensitive (widget, allow_cancel);
+}
+
+/**
+ * gpk_client_window_delete_event_cb:
+ **/
+static gboolean
+gpk_client_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpkClient *gclient)
+{
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ gtk_main_quit ();
+ return FALSE;
+}
+
+/**
+ * gpk_client_button_close_cb:
+ **/
+static void
+gpk_client_button_close_cb (GtkWidget *widget, GpkClient *gclient)
+{
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+ gtk_main_quit ();
+}
+
+/**
+ * gpk_client_button_help_cb:
+ **/
+static void
+gpk_client_button_help_cb (GtkWidget *widget, GpkClient *gclient)
+{
+ g_return_if_fail (GPK_IS_CLIENT (gclient));
+ gpk_show_help (NULL);
+}
+
+/**
+ * pk_client_button_cancel_cb:
+ **/
+static void
+pk_client_button_cancel_cb (GtkWidget *widget, GpkClient *gclient)
+{
+ gboolean ret;
+ GError *error = NULL;
+
+ /* we might have a transaction running */
+ ret = pk_client_cancel (gclient->priv->client_action, &error);
+ if (!ret) {
+ pk_warning ("failed to cancel client: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+/**
+ * gpk_client_error_message:
+ **/
+static void
+gpk_client_error_msg (GpkClient *gclient, const gchar *title, const gchar *message)
+{
+ GtkWidget *widget;
+ GtkWidget *dialog;
+
+ /* hide the main window */
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+ gtk_widget_hide (widget);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "%s", title);
+ gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
+
+/**
+ * gpk_client_install_local_file:
+ * @gclient: a valid #GpkClient instance
+ * @file: a file such as "./hal-devel-0.10.0.rpm"
+ *
+ * Install a file locally, and get the deps from the repositories.
+ * This is useful for double clicking on a .rpm or .deb file.
+ *
+ * Return value: %TRUE if the method is running
+ **/
+gboolean
+gpk_client_install_local_file (GpkClient *gclient, const gchar *file_rel)
+{
+ gboolean ret;
+ GError *error = NULL;
+ gchar *text;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ g_return_val_if_fail (file_rel != NULL, FALSE);
+
+ ret = pk_client_install_file (gclient->priv->client_action, file_rel, &error);
+ if (!ret) {
+ /* check if we got a permission denied */
+ if (g_str_has_prefix (error->message, "org.freedesktop.packagekit.")) {
+ gpk_client_error_msg (gclient, _("Failed to install file"),
+ _("You don't have the necessary privileges to install local files"));
+ } else {
+ text = g_markup_escape_text (error->message, -1);
+ gpk_client_error_msg (gclient, _("Failed to install file"), text);
+ g_free (text);
+ }
+ g_error_free (error);
+ goto out;
+ }
+
+ /* wait for completion */
+ gtk_main ();
+
+ /* we're done */
+ if (gclient->priv->pulse_timeout != 0) {
+ g_source_remove (gclient->priv->pulse_timeout);
+ gclient->priv->pulse_timeout = 0;
+ }
+out:
+ return ret;
+}
+
+/**
+ * gpk_client_install_package_id:
+ * @gclient: a valid #GpkClient instance
+ * @package_id: a package_id such as hal-info;0.20;i386;fedora
+ *
+ * Return value: %TRUE if the method is running
+ **/
+gboolean
+gpk_client_install_package_id (GpkClient *gclient, const gchar *package_id)
+{
+ GtkWidget *widget;
+ GtkWidget *dialog;
+ GtkResponseType button;
+ gboolean ret;
+ GError *error = NULL;
+ gchar *text;
+ 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);
+
+ /* 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);
+ if (!ret) {
+ gpk_client_error_msg (gclient, _("Failed to reset client"), _("Failed to reset resolve"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* find out if this would drag in other packages */
+ ret = pk_client_get_depends (gclient->priv->client_resolve, PK_FILTER_ENUM_NOT_INSTALLED, package_id, TRUE, &error);
+ if (!ret) {
+ text = g_strdup_printf ("%s: %s", _("Could not work out what packages would be also installed"), error->message);
+ gpk_client_error_msg (gclient, _("Failed to get depends"), text);
+ g_free (text);
+ ret = FALSE;
+ goto out;
+ }
+
+ /* process package list */
+ len = pk_client_package_buffer_get_size (gclient->priv->client_resolve);
+ string = g_string_new (_("The following packages also have to be downloaded:"));
+ 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_pretty_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");
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
+ "%s", _("Download additional packages?"));
+ 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 install package"), _("Additional packages were not downloaded"));
+ ret = FALSE;
+ goto out;
+ }
+
+skip_checks:
+ /* try to install the package_id */
+ ret = pk_client_install_package (gclient->priv->client_action, package_id, &error);
+ if (!ret) {
+ /* check if we got a permission denied */
+ if (g_str_has_prefix (error->message, "org.freedesktop.packagekit.")) {
+ gpk_client_error_msg (gclient, _("Failed to install package"),
+ _("You don't have the necessary privileges to install packages"));
+ } else {
+ text = g_markup_escape_text (error->message, -1);
+ gpk_client_error_msg (gclient, _("Failed to install package"), text);
+ g_free (text);
+ }
+ g_error_free (error);
+ goto out;
+ }
+
+ /* wait for completion */
+ gtk_main ();
+
+ /* we're done */
+ if (gclient->priv->pulse_timeout != 0) {
+ g_source_remove (gclient->priv->pulse_timeout);
+ gclient->priv->pulse_timeout = 0;
+ }
+out:
+ return ret;
+}
+
+/**
+ * gpk_client_install_package_name:
+ * @gclient: a valid #GpkClient instance
+ * @package: a pakage name such as hal-info
+ *
+ * Install a package of the newest and most correct version.
+ *
+ * Return value: %TRUE if the method is running
+ **/
+gboolean
+gpk_client_install_package_name (GpkClient *gclient, const gchar *package)
+{
+ gboolean ret;
+ GError *error = NULL;
+ guint len;
+ guint i;
+ gboolean already_installed = FALSE;
+ gchar *package_id = NULL;
+ PkPackageItem *item;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ g_return_val_if_fail (package != NULL, FALSE);
+
+ ret = pk_client_resolve (gclient->priv->client_resolve, PK_FILTER_ENUM_NONE, package, &error);
+ if (!ret) {
+ gpk_client_error_msg (gclient, _("Failed to resolve package"), _("Incorrect response from search"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* found nothing? */
+ len = pk_client_package_buffer_get_size (gclient->priv->client_resolve);
+ if (len == 0) {
+ gpk_client_error_msg (gclient, _("Failed to find package"), _("The package could not be found online"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* see what we've got already */
+ for (i=0; i<len; i++) {
+ item = pk_client_package_buffer_get_item (gclient->priv->client_resolve, i);
+ if (item->info == PK_INFO_ENUM_INSTALLED) {
+ already_installed = TRUE;
+ break;
+ } else if (item->info == PK_INFO_ENUM_AVAILABLE) {
+ pk_debug ("package '%s' resolved", item->package_id);
+ package_id = g_strdup (item->package_id);
+ break;
+ }
+ }
+
+ /* already installed? */
+ if (already_installed) {
+ gpk_client_error_msg (gclient, _("Failed to install package"), _("The package is already installed"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* got junk? */
+ if (package_id == NULL) {
+ gpk_client_error_msg (gclient, _("Failed to find package"), _("Incorrect response from search"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* install this specific package */
+ ret = gpk_client_install_package_id (gclient, package_id);
+out:
+ g_free (package_id);
+ return ret;
+}
+
+/**
+ * gpk_client_install_provide_file:
+ * @gclient: a valid #GpkClient instance
+ * @full_path: a file path name such as /usr/sbin/packagekitd
+ *
+ * Install a package which provides a file on the system.
+ *
+ * Return value: %TRUE if the method is running
+ **/
+gboolean
+gpk_client_install_provide_file (GpkClient *gclient, const gchar *full_path)
+{
+ gboolean ret;
+ GError *error = NULL;
+ guint len;
+ guint i;
+ gboolean already_installed = FALSE;
+ gchar *package_id = NULL;
+ PkPackageItem *item;
+ PkPackageId *ident;
+ gchar *text;
+
+ g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
+ g_return_val_if_fail (full_path != NULL, FALSE);
+
+
+ ret = pk_client_search_file (gclient->priv->client_resolve, PK_FILTER_ENUM_NONE, full_path, &error);
+ if (!ret) {
+ text = g_strdup_printf ("%s: %s", _("Incorrect response from search"), error->message);
+ gpk_client_error_msg (gclient, _("Failed to search for file"), text);
+ g_free (text);
+ ret = FALSE;
+ goto out;
+ }
+
+ /* found nothing? */
+ len = pk_client_package_buffer_get_size (gclient->priv->client_resolve);
+ if (len == 0) {
+ gpk_client_error_msg (gclient, _("Failed to find package"), _("The file could not be found in any packages"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* see what we've got already */
+ for (i=0; i<len; i++) {
+ item = pk_client_package_buffer_get_item (gclient->priv->client_resolve, i);
+ if (item->info == PK_INFO_ENUM_INSTALLED) {
+ already_installed = TRUE;
+ g_free (package_id);
+ package_id = g_strdup (item->package_id);
+ break;
+ } else if (item->info == PK_INFO_ENUM_AVAILABLE) {
+ pk_debug ("package '%s' resolved to:", item->package_id);
+ package_id = g_strdup (item->package_id);
+ }
+ }
+
+ /* already installed? */
+ if (already_installed) {
+ ident = pk_package_id_new_from_string (package_id);
+ text = g_strdup_printf (_("The %s package already provides the file %s"), ident->name, full_path);
+ gpk_client_error_msg (gclient, _("Failed to install file"), text);
+ g_free (text);
+ pk_package_id_free (ident);
+ ret = FALSE;
+ goto out;
+ }
+
+ /* got junk? */
+ if (package_id == NULL) {
+ gpk_client_error_msg (gclient, _("Failed to install file"), _("Incorrect response from file search"));
+ ret = FALSE;
+ goto out;
+ }
+
+ /* install this specific package */
+ ret = gpk_client_install_package_id (gclient, package_id);
+out:
+ g_free (package_id);
+ return ret;
+}
+
+/**
+ * gpk_client_class_init:
+ * @klass: The GpkClientClass
+ **/
+static void
+gpk_client_class_init (GpkClientClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gpk_client_finalize;
+ g_type_class_add_private (klass, sizeof (GpkClientPrivate));
+}
+
+/**
+ * gpk_client_init:
+ * @client: This class instance
+ **/
+static void
+gpk_client_init (GpkClient *gclient)
+{
+ GtkWidget *widget;
+
+ gclient->priv = GPK_CLIENT_GET_PRIVATE (gclient);
+
+ gclient->priv->glade_xml = NULL;
+ gclient->priv->pulse_timeout = 0;
+
+ /* add application specific icons to search path */
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+ PK_DATA G_DIR_SEPARATOR_S "icons");
+
+ /* get actions */
+ gclient->priv->control = pk_control_new ();
+ gclient->priv->roles = pk_control_get_actions (gclient->priv->control);
+
+ gclient->priv->client_action = pk_client_new ();
+ g_signal_connect (gclient->priv->client_action, "finished",
+ G_CALLBACK (gpk_client_finished_cb), gclient);
+ g_signal_connect (gclient->priv->client_action, "progress-changed",
+ G_CALLBACK (gpk_client_progress_changed_cb), gclient);
+ g_signal_connect (gclient->priv->client_action, "status-changed",
+ G_CALLBACK (gpk_client_status_changed_cb), gclient);
+ g_signal_connect (gclient->priv->client_action, "error-code",
+ G_CALLBACK (gpk_client_error_code_cb), gclient);
+ g_signal_connect (gclient->priv->client_action, "package",
+ G_CALLBACK (pk_client_package_cb), gclient);
+ g_signal_connect (gclient->priv->client_action, "allow-cancel",
+ G_CALLBACK (pk_client_allow_cancel_cb), 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);
+ pk_client_set_use_buffer (gclient->priv->client_resolve, TRUE, NULL);
+ pk_client_set_synchronous (gclient->priv->client_resolve, TRUE, NULL);
+
+ gclient->priv->glade_xml = glade_xml_new (PK_DATA "/gpk-install-file.glade", NULL, NULL);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
+
+ /* Get the main window quit */
+ g_signal_connect (widget, "delete_event",
+ G_CALLBACK (gpk_client_window_delete_event_cb), gclient);
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_close_cb), gclient);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close2");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_close_cb), gclient);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_close3");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_close_cb), gclient);
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_cancel");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (pk_client_button_cancel_cb), gclient);
+ gtk_widget_set_sensitive (widget, FALSE);
+
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help3");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_help_cb), gclient);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help4");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_help_cb), gclient);
+ widget = glade_xml_get_widget (gclient->priv->glade_xml, "button_help5");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (gpk_client_button_help_cb), gclient);
+
+ /* 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);
+}
+
+/**
+ * gpk_client_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gpk_client_finalize (GObject *object)
+{
+ GpkClient *gclient;
+
+ g_return_if_fail (GPK_IS_CLIENT (object));
+
+ gclient = GPK_CLIENT (object);
+ g_return_if_fail (gclient->priv != NULL);
+ g_object_unref (gclient->priv->client_action);
+ g_object_unref (gclient->priv->client_resolve);
+ g_object_unref (gclient->priv->control);
+
+ G_OBJECT_CLASS (gpk_client_parent_class)->finalize (object);
+}
+
+/**
+ * gpk_client_new:
+ *
+ * Return value: a new GpkClient object.
+ **/
+GpkClient *
+gpk_client_new (void)
+{
+ GpkClient *gclient;
+ gclient = g_object_new (GPK_TYPE_CLIENT, NULL);
+ return GPK_CLIENT (gclient);
+}
+
Added: trunk/libpackagekit-gnome/gpk-client.h
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/gpk-client.h Fri Apr 11 23:31:29 2008
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GPK_CLIENT_H
+#define __GPK_CLIENT_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GPK_TYPE_CLIENT (gpk_client_get_type ())
+#define GPK_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPK_TYPE_CLIENT, GpkClient))
+#define GPK_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPK_TYPE_CLIENT, GpkClientClass))
+#define GPK_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPK_TYPE_CLIENT))
+#define GPK_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPK_TYPE_CLIENT))
+#define GPK_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPK_TYPE_CLIENT, GpkClientClass))
+#define GPK_CLIENT_ERROR (gpk_client_error_quark ())
+#define GPK_CLIENT_TYPE_ERROR (gpk_client_error_get_type ())
+
+typedef struct GpkClientPrivate GpkClientPrivate;
+
+typedef struct
+{
+ GObject parent;
+ GpkClientPrivate *priv;
+} GpkClient;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} GpkClientClass;
+
+GType gpk_client_get_type (void) G_GNUC_CONST;
+GpkClient *gpk_client_new (void);
+
+gboolean gpk_client_install_local_file (GpkClient *gclient,
+ const gchar *file_rel)
+ G_GNUC_WARN_UNUSED_RESULT;
+gboolean gpk_client_install_provide_file (GpkClient *gclient,
+ const gchar *full_path)
+ G_GNUC_WARN_UNUSED_RESULT;
+gboolean gpk_client_install_package_name (GpkClient *gclient,
+ const gchar *package)
+ G_GNUC_WARN_UNUSED_RESULT;
+gboolean gpk_client_install_package_id (GpkClient *gclient,
+ const gchar *package_id)
+ G_GNUC_WARN_UNUSED_RESULT;
+
+G_END_DECLS
+
+#endif /* __GPK_CLIENT_H */
Added: trunk/libpackagekit-gnome/gpk-common.c
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/gpk-common.c Fri Apr 11 23:31:29 2008
@@ -0,0 +1,1826 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <math.h>
+#include <string.h>
+#include <unistd.h>
+#include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
+
+#include <polkit-gnome/polkit-gnome.h>
+
+#include <pk-debug.h>
+#include <pk-package-id.h>
+#include <pk-enum.h>
+#include <pk-common.h>
+#include "gpk-common.h"
+
+/* icon names */
+static PkEnumMatch enum_info_icon_name[] = {
+ {PK_INFO_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_INFO_ENUM_INSTALLED, "pk-package-installed"},
+ {PK_INFO_ENUM_AVAILABLE, "pk-package-available"},
+ {PK_INFO_ENUM_LOW, "pk-update-low"},
+ {PK_INFO_ENUM_NORMAL, "pk-update-normal"},
+ {PK_INFO_ENUM_IMPORTANT, "pk-update-high"},
+ {PK_INFO_ENUM_SECURITY, "pk-update-security"},
+ {PK_INFO_ENUM_BUGFIX, "pk-update-bugfix"},
+ {PK_INFO_ENUM_ENHANCEMENT, "pk-update-enhancement"},
+ {PK_INFO_ENUM_BLOCKED, "pk-setup"},
+ {PK_INFO_ENUM_DOWNLOADING, "pk-package-download"},
+ {PK_INFO_ENUM_UPDATING, "pk-package-update"},
+ {PK_INFO_ENUM_INSTALLING, "pk-package-add"},
+ {PK_INFO_ENUM_REMOVING, "pk-package-delete"},
+ {PK_INFO_ENUM_OBSOLETING, "pk-package-cleanup"},
+ {PK_INFO_ENUM_CLEANUP, "pk-package-cleanup"},
+ {0, NULL}
+};
+
+static PkEnumMatch enum_status_icon_name[] = {
+ {PK_STATUS_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_STATUS_ENUM_WAIT, "pk-wait"},
+ {PK_STATUS_ENUM_SETUP, "pk-setup"},
+ {PK_STATUS_ENUM_RUNNING, "pk-setup"},
+ {PK_STATUS_ENUM_QUERY, "pk-package-search"},
+ {PK_STATUS_ENUM_INFO, "pk-package-info"},
+ {PK_STATUS_ENUM_REFRESH_CACHE, "pk-refresh-cache"},
+ {PK_STATUS_ENUM_REMOVE, "pk-package-delete"},
+ {PK_STATUS_ENUM_DOWNLOAD, "pk-package-download"},
+ {PK_STATUS_ENUM_INSTALL, "pk-package-add"},
+ {PK_STATUS_ENUM_UPDATE, "pk-package-update"},
+ {PK_STATUS_ENUM_CLEANUP, "pk-package-cleanup"},
+ {PK_STATUS_ENUM_OBSOLETE, "pk-package-cleanup"},
+ {PK_STATUS_ENUM_DEP_RESOLVE, "pk-package-info"}, /* TODO: need better icon */
+ {PK_STATUS_ENUM_ROLLBACK, "pk-package-info"}, /* TODO: need better icon */
+ {PK_STATUS_ENUM_COMMIT, "pk-setup"}, /* TODO: need better icon */
+ {PK_STATUS_ENUM_REQUEST, "pk-package-search"},
+ {PK_STATUS_ENUM_FINISHED, "pk-package-cleanup"}, /* TODO: need better icon */
+ {PK_STATUS_ENUM_CANCEL, "pk-package-cleanup"}, /* TODO: need better icon */
+ {0, NULL}
+};
+
+static PkEnumMatch enum_role_icon_name[] = {
+ {PK_ROLE_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_ROLE_ENUM_CANCEL, "process-stop.svg"},
+ {PK_ROLE_ENUM_RESOLVE, "pk-package-search"},
+ {PK_ROLE_ENUM_ROLLBACK, "pk-rollback"},
+ {PK_ROLE_ENUM_GET_DEPENDS, "pk-package-info"},
+ {PK_ROLE_ENUM_GET_UPDATE_DETAIL, "pk-package-info"},
+ {PK_ROLE_ENUM_GET_DESCRIPTION, "pk-package-info"},
+ {PK_ROLE_ENUM_GET_REQUIRES, "pk-package-info"},
+ {PK_ROLE_ENUM_GET_UPDATES, "pk-package-info"},
+ {PK_ROLE_ENUM_SEARCH_DETAILS, "pk-package-search"},
+ {PK_ROLE_ENUM_SEARCH_FILE, "pk-package-search"},
+ {PK_ROLE_ENUM_SEARCH_GROUP, "pk-package-search"},
+ {PK_ROLE_ENUM_SEARCH_NAME, "pk-package-search"},
+ {PK_ROLE_ENUM_REFRESH_CACHE, "pk-refresh-cache"},
+ {PK_ROLE_ENUM_REMOVE_PACKAGE, "pk-package-delete"},
+ {PK_ROLE_ENUM_INSTALL_PACKAGE, "pk-package-add"},
+ {PK_ROLE_ENUM_INSTALL_FILE, "pk-package-add"},
+ {PK_ROLE_ENUM_UPDATE_PACKAGES, "pk-package-update"},
+ {PK_ROLE_ENUM_SERVICE_PACK, "pk-package-update"},
+ {PK_ROLE_ENUM_UPDATE_SYSTEM, "system-software-update"},
+ {PK_ROLE_ENUM_GET_REPO_LIST, "emblem-system"},
+ {PK_ROLE_ENUM_REPO_ENABLE, "emblem-system"},
+ {PK_ROLE_ENUM_REPO_SET_DATA, "emblem-system"},
+ {PK_ROLE_ENUM_INSTALL_SIGNATURE, "emblem-system"},
+ {PK_ROLE_ENUM_GET_PACKAGES, "pk-package-search"},
+ {0, NULL}
+};
+
+static PkEnumMatch enum_group_icon_name[] = {
+ {PK_GROUP_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_GROUP_ENUM_ACCESSIBILITY, "preferences-desktop-accessibility"},
+ {PK_GROUP_ENUM_ACCESSORIES, "applications-accessories"},
+ {PK_GROUP_ENUM_EDUCATION, "utilities-system-monitor"},
+ {PK_GROUP_ENUM_GAMES, "applications-games"},
+ {PK_GROUP_ENUM_GRAPHICS, "applications-graphics"},
+ {PK_GROUP_ENUM_INTERNET, "applications-internet"},
+ {PK_GROUP_ENUM_OFFICE, "applications-office"},
+ {PK_GROUP_ENUM_OTHER, "applications-other"},
+ {PK_GROUP_ENUM_PROGRAMMING, "applications-development"},
+ {PK_GROUP_ENUM_MULTIMEDIA, "applications-multimedia"},
+ {PK_GROUP_ENUM_SYSTEM, "applications-system"},
+ {PK_GROUP_ENUM_DESKTOP_GNOME, "pk-desktop-gnome"},
+ {PK_GROUP_ENUM_DESKTOP_KDE, "pk-desktop-kde"},
+ {PK_GROUP_ENUM_DESKTOP_XFCE, "pk-desktop-xfce"},
+ {PK_GROUP_ENUM_DESKTOP_OTHER, "user-desktop"},
+ {PK_GROUP_ENUM_PUBLISHING, "accessories-dictionary"},
+ {PK_GROUP_ENUM_SERVERS, "network-server"},
+ {PK_GROUP_ENUM_FONTS, "preferences-desktop-font"},
+ {PK_GROUP_ENUM_ADMIN_TOOLS, "system-lock-screen"},
+ {PK_GROUP_ENUM_LEGACY, "media-floppy"},
+ {PK_GROUP_ENUM_LOCALIZATION, "preferences-desktop-locale"},
+ {PK_GROUP_ENUM_VIRTUALIZATION, "computer"},
+ {PK_GROUP_ENUM_SECURITY, "network-wireless-encrypted"},
+ {PK_GROUP_ENUM_POWER_MANAGEMENT, "battery"},
+ {PK_GROUP_ENUM_COMMUNICATION, "folder-remote"},
+ {PK_GROUP_ENUM_NETWORK, "network-wired"},
+ {PK_GROUP_ENUM_MAPS, "applications-multimedia"},
+ {PK_GROUP_ENUM_REPOS, "system-file-manager"},
+ {0, NULL}
+};
+
+static PkEnumMatch enum_restart_icon_name[] = {
+ {PK_RESTART_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_RESTART_ENUM_NONE, "dialog-information"},
+ {PK_RESTART_ENUM_SYSTEM, "dialog-error"},
+ {PK_RESTART_ENUM_SESSION, "dialog-warning"},
+ {PK_RESTART_ENUM_APPLICATION, "dialog-warning"},
+ {0, NULL}
+};
+
+static PkEnumMatch enum_message_icon_name[] = {
+ {PK_MESSAGE_ENUM_UNKNOWN, "help-browser"}, /* fall though value */
+ {PK_MESSAGE_ENUM_NOTICE, "dialog-information"},
+ {PK_MESSAGE_ENUM_WARNING, "dialog-warning"},
+ {PK_MESSAGE_ENUM_DAEMON, "dialog-error"},
+ {0, NULL}
+};
+
+static gboolean
+try_system_restart (DBusGProxy *proxy, GError **error)
+{
+ return dbus_g_proxy_call_with_timeout (proxy, "Restart", INT_MAX,
+ error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+static PolKitAction *
+get_action_from_error (GError *error)
+{
+ PolKitAction *action;
+ gchar *paction, *p;
+
+ action = polkit_action_new ();
+
+ paction = NULL;
+ if (g_str_has_prefix (error->message, "Not privileged for action: ")) {
+ paction = g_strdup (error->message + strlen ("Not privileged for action: "));
+ p = strchr (paction, ' ');
+ if (p)
+ *p = '\0';
+ }
+ polkit_action_set_action_id (action, paction);
+
+ g_free (paction);
+
+ return action;
+}
+
+static PolKitResult
+get_result_from_error (GError *error)
+{
+ PolKitResult result = POLKIT_RESULT_UNKNOWN;
+ const char *p;
+
+ p = strrchr (error->message, ' ');
+ if (p) {
+ p++;
+ polkit_result_from_string_representation (p, &result);
+ }
+
+ return result;
+}
+
+static void
+system_restart_auth_cb (PolKitAction *action, gboolean gained_privilege,
+ GError *error, DBusGProxy *proxy)
+{
+ GError *local_error;
+ gboolean res;
+
+ if (!gained_privilege) {
+ if (error != NULL) {
+ pk_warning ("Not privileged to restart system: %s", error->message);
+ }
+ return;
+ }
+
+ local_error = NULL;
+ res = try_system_restart (proxy, &local_error);
+ if (!res) {
+ pk_warning ("Unable to restart system: %s", local_error->message);
+ g_error_free (local_error);
+ }
+}
+
+static gboolean
+request_restart_priv (DBusGProxy *proxy, PolKitAction *action, GError **error)
+{
+ guint xid;
+ pid_t pid;
+
+ xid = 0;
+ pid = getpid ();
+
+ return polkit_gnome_auth_obtain (action, xid, pid,
+ (PolKitGnomeAuthCB) system_restart_auth_cb,
+ proxy, error);
+}
+
+/**
+ * gpk_restart_system:
+ **/
+gboolean
+gpk_restart_system (void)
+{
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
+ GError *error = NULL;
+ gboolean ret;
+ PolKitAction *action;
+ PolKitAction *action2;
+ PolKitResult result;
+
+ /* check dbus connections, exit if not valid */
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ pk_warning ("cannot acccess the system bus: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* get a connection */
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager");
+ if (proxy == NULL) {
+ pk_warning ("Cannot connect to ConsoleKit");
+ return FALSE;
+ }
+
+ /* do the method */
+ ret = try_system_restart (proxy, &error);
+ if (!ret) {
+ if (dbus_g_error_has_name (error, "org.freedesktop.ConsoleKit.Manager.NotPrivileged")) {
+ action = get_action_from_error (error);
+ result = get_result_from_error (error);
+
+ if (result == POLKIT_RESULT_NO) {
+ action2 = polkit_action_new ();
+ polkit_action_set_action_id (action2,
+ "org.freedesktop.consolekit.system.restart-multiple-users");
+ if (polkit_action_equal (action, action2)) {
+ gpk_error_modal_dialog (_("Failed to restart"),
+ _("You are not allowed to restart the computer "
+ "because multiple users are logged in"));
+ }
+
+ g_error_free (error);
+
+ polkit_action_unref (action);
+ polkit_action_unref (action2);
+
+ return FALSE;
+ }
+ g_clear_error (&error);
+ ret = request_restart_priv (proxy, action, &error);
+ polkit_action_unref (action);
+ }
+ if (!ret) {
+ pk_warning ("Unable to restart system: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ g_object_unref (G_OBJECT (proxy));
+
+ return ret;
+}
+
+/**
+ * gpk_execute_url:
+ **/
+gboolean
+gpk_execute_url (const gchar *url)
+{
+ gchar *data;
+ gboolean ret;
+
+ g_return_val_if_fail (url != NULL, FALSE);
+
+ data = g_strconcat ("gnome-open ", url, NULL);
+ ret = g_spawn_command_line_async (data, NULL);
+ if (ret == FALSE) {
+ pk_warning ("spawn of '%s' failed", data);
+ }
+ g_free (data);
+ return ret;
+}
+
+/**
+ * gpk_show_help:
+ * @link_id: Subsection of gnome-packagekit help file, or NULL.
+ **/
+gboolean
+gpk_show_help (const gchar *link_id)
+{
+ GError *error = NULL;
+ gchar *command;
+ const gchar *lang;
+ gchar *uri = NULL;
+ GdkScreen *gscreen;
+ gint i;
+ gboolean ret = TRUE;
+ const gchar *const *langs = g_get_language_names ();
+
+ for (i = 0; langs[i]; i++) {
+ lang = langs[i];
+ if (strchr (lang, '.')) {
+ continue;
+ }
+ uri = g_build_filename(DATADIR,
+ "/gnome/help/gnome-packagekit/",
+ lang,
+ "/gnome-packagekit.xml",
+ NULL);
+ if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
+ break;
+ }
+ }
+ if (link_id) {
+ command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
+ } else {
+ command = g_strconcat ("gnome-open ghelp://", uri, NULL);
+ }
+ pk_debug ("using command %s", command);
+
+ gscreen = gdk_screen_get_default();
+ gdk_spawn_command_line_on_screen (gscreen, command, &error);
+ if (error != NULL) {
+ GtkWidget *d;
+ d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG(d));
+ gtk_widget_destroy (d);
+ g_error_free (error);
+ ret = FALSE;
+ }
+
+ g_free (command);
+ g_free (uri);
+ return ret;
+}
+
+/**
+ * gpk_size_to_si_size_text:
+ **/
+gchar *
+gpk_size_to_si_size_text (guint64 size)
+{
+ gdouble frac;
+
+ /* double cast, not sure why, but it works */
+ frac = (gdouble) (long int) size;
+
+ /* first chunk */
+ if (frac < 1024) {
+ return g_strdup_printf ("%li bytes", (long int) size);
+ }
+ /* next chunk */
+ frac /= 1024.0;
+ if (frac < 1024) {
+ return g_strdup_printf ("%.1lf kB", frac);
+ }
+ /* next chunk */
+ frac /= 1024.0;
+ if (frac < 1024) {
+ return g_strdup_printf ("%.1lf MB", frac);
+ }
+ /* next chunk */
+ frac /= 1024.0;
+ if (frac < 1024) {
+ return g_strdup_printf ("%.1lf GB", frac);
+ }
+ /* no way.... */
+ pk_warning ("cannot have a file this large!");
+ return NULL;
+}
+
+/**
+ * gpk_package_id_pretty:
+ **/
+gchar *
+gpk_package_id_pretty (const gchar *package_id, const gchar *summary)
+{
+ PkPackageId *ident;
+ gchar *text;
+ GString *string;
+
+ /* split by delimeter */
+ ident = pk_package_id_new_from_string (package_id);
+ if (ident == NULL) {
+ pk_warning ("invalid package_id %s", package_id);
+ return NULL;
+ }
+
+ string = g_string_new (ident->name);
+ if (ident->version != NULL) {
+ g_string_append_printf (string, "-%s", ident->version);
+ }
+ if (ident->arch != NULL) {
+ g_string_append_printf (string, " (%s)", ident->arch);
+ }
+ g_string_prepend (string, "<b>");
+ g_string_append (string, "</b>");
+
+ /* ITS4: ignore, we generated this */
+ if (pk_strzero (summary) == FALSE) {
+ g_string_append_printf (string, "\n%s", summary);
+ }
+ text = g_string_free (string, FALSE);
+
+ pk_package_id_free (ident);
+ return text;
+}
+
+/**
+ * gpk_package_id_pretty_oneline:
+ **/
+gchar *
+gpk_package_id_pretty_oneline (const gchar *package_id, const gchar *summary)
+{
+ PkPackageId *ident;
+ gchar *text;
+
+ /* split by delimeter */
+ ident = pk_package_id_new_from_string (package_id);
+ if (ident == NULL) {
+ pk_warning ("invalid package_id %s", package_id);
+ return NULL;
+ }
+
+ if (pk_strzero (summary)) {
+ /* just have name */
+ text = g_strdup (ident->name);
+ } else {
+ text = g_strdup_printf ("<b>%s</b> (%s)", summary, ident->name);
+ }
+
+ pk_package_id_free (ident);
+ return text;
+}
+
+/**
+ * gpk_package_id_name_version:
+ **/
+gchar *
+gpk_package_id_name_version (const gchar *package_id)
+{
+ PkPackageId *ident;
+ gchar *text;
+ GString *string;
+
+ if (pk_strzero (package_id)) {
+ return g_strdup (_("Package identifier not valid"));
+ }
+
+ /* split by delimeter */
+ ident = pk_package_id_new_from_string (package_id);
+ if (ident == NULL) {
+ pk_warning ("invalid package_id %s", package_id);
+ return NULL;
+ }
+
+ string = g_string_new (ident->name);
+ if (ident->version != NULL) {
+ g_string_append_printf (string, "-%s", ident->version);
+ }
+ text = g_string_free (string, FALSE);
+
+ pk_package_id_free (ident);
+ return text;
+}
+
+/**
+ * pk_package_id_get_name:
+ **/
+gchar *
+gpk_package_get_name (const gchar *package_id)
+{
+ gchar *package = NULL;
+ PkPackageId *ident;
+
+ ident = pk_package_id_new_from_string (package_id);
+ if (ident == NULL) {
+ package = g_strdup (package_id);
+ } else {
+ package = g_strdup (ident->name);
+ }
+ pk_package_id_free (ident);
+ return package;
+}
+
+/**
+ * gpk_icon_valid:
+ *
+ * Check icon actually exists and is valid in this theme
+ **/
+gboolean
+gpk_icon_valid (const gchar *icon)
+{
+ GtkIconInfo *icon_info;
+ static GtkIconTheme *icon_theme = NULL;
+ gboolean ret = TRUE;
+
+ /* trivial case */
+ if (pk_strzero (icon)) {
+ return FALSE;
+ }
+
+ /* no unref required */
+ if (icon_theme == NULL) {
+ icon_theme = gtk_icon_theme_get_default ();
+ }
+
+ /* default to 32x32 */
+ icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 32, GTK_ICON_LOOKUP_USE_BUILTIN);
+ if (icon_info == NULL) {
+ pk_debug ("ignoring broken icon %s", icon);
+ ret = FALSE;
+ } else {
+ /* we only used this to see if it was valid */
+ gtk_icon_info_free (icon_info);
+ }
+ return ret;
+}
+
+/**
+ * gpk_error_modal_dialog:
+ *
+ * Shows a modal error, and blocks until the user clicks close
+ **/
+gboolean
+gpk_error_modal_dialog (const gchar *title, const gchar *message)
+{
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "%s", title);
+ gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return TRUE;
+}
+
+/**
+ * gpk_error_enum_to_localised_text:
+ **/
+const gchar *
+gpk_error_enum_to_localised_text (PkErrorCodeEnum code)
+{
+ const gchar *text = NULL;
+ switch (code) {
+ case PK_ERROR_ENUM_NO_NETWORK:
+ text = _("No network connection available");
+ break;
+ case PK_ERROR_ENUM_NO_CACHE:
+ text = _("No package cache is available.");
+ break;
+ case PK_ERROR_ENUM_OOM:
+ text = _("Out of memory");
+ break;
+ case PK_ERROR_ENUM_CREATE_THREAD_FAILED:
+ text = _("Failed to create a thread");
+ break;
+ case PK_ERROR_ENUM_NOT_SUPPORTED:
+ text = _("Not supported by this backend");
+ break;
+ case PK_ERROR_ENUM_INTERNAL_ERROR:
+ text = _("An internal system error has occurred");
+ break;
+ case PK_ERROR_ENUM_GPG_FAILURE:
+ text = _("A security trust relationship is not present");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED:
+ text = _("The package is not installed");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_NOT_FOUND:
+ text = _("The package was not found");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED:
+ text = _("The package is already installed");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED:
+ text = _("The package download failed");
+ break;
+ case PK_ERROR_ENUM_GROUP_NOT_FOUND:
+ text = _("The group was not found");
+ break;
+ case PK_ERROR_ENUM_DEP_RESOLUTION_FAILED:
+ text = _("Dependency resolution failed");
+ break;
+ case PK_ERROR_ENUM_FILTER_INVALID:
+ text = _("Search filter was invalid");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_ID_INVALID:
+ text = _("The package identifier was not well formed");
+ break;
+ case PK_ERROR_ENUM_TRANSACTION_ERROR:
+ text = _("Transaction error");
+ break;
+ case PK_ERROR_ENUM_REPO_NOT_FOUND:
+ text = _("Repository name was not found");
+ break;
+ case PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE:
+ text = _("Could not remove a protected system package");
+ break;
+ case PK_ERROR_ENUM_TRANSACTION_CANCELLED:
+ text = _("The task was canceled");
+ break;
+ case PK_ERROR_ENUM_PROCESS_KILL:
+ text = _("The task was forcibly canceled");
+ break;
+ case PK_ERROR_ENUM_FAILED_CONFIG_PARSING:
+ text = _("Reading the config file failed");
+ break;
+ case PK_ERROR_ENUM_CANNOT_CANCEL:
+ text = _("The task cannot be cancelled");
+ break;
+ case PK_ERROR_ENUM_CANNOT_INSTALL_SOURCE_PACKAGE:
+ text = _("Source packages cannot be installed");
+ break;
+ default:
+ text = _("Unknown error");
+ }
+ return text;
+}
+
+/**
+ * gpk_error_enum_to_localised_message:
+ **/
+const gchar *
+gpk_error_enum_to_localised_message (PkErrorCodeEnum code)
+{
+ const gchar *text = NULL;
+ switch (code) {
+ case PK_ERROR_ENUM_NO_NETWORK:
+ text = _("There is no network connection available.\n"
+ "Please check your connection settings and try again");
+ break;
+ case PK_ERROR_ENUM_NO_CACHE:
+ text = _("The package list needs to be rebuilt.\n"
+ "This should have been done by the backend automatically.");
+ break;
+ case PK_ERROR_ENUM_OOM:
+ text = _("The service that is responsible for handling user requests is out of memory.\n"
+ "Please restart your computer.");
+ break;
+ case PK_ERROR_ENUM_CREATE_THREAD_FAILED:
+ text = _("A thread could not be created to service the user request.");
+ break;
+ case PK_ERROR_ENUM_NOT_SUPPORTED:
+ text = _("The action is not supported by this backend.\n"
+ "Please report a bug as this shouldn't have happened.");
+ break;
+ case PK_ERROR_ENUM_INTERNAL_ERROR:
+ text = _("A problem that we were not expecting has occurred.\n"
+ "Please report this bug with the error description.");
+ break;
+ case PK_ERROR_ENUM_GPG_FAILURE:
+ text = _("A security trust relationship could not be made with software source.\n"
+ "Please check your security settings.");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED:
+ text = _("The package that is trying to be removed or updated is not already installed.");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_NOT_FOUND:
+ text = _("The package that is being modified was not found on your system or in any software source.");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED:
+ text = _("The package that is trying to be installed is already installed.");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED:
+ text = _("The package download failed.\n"
+ "Please check your network connectivity.");
+ break;
+ case PK_ERROR_ENUM_GROUP_NOT_FOUND:
+ text = _("The group type was not found.\n"
+ "Please check your group list and try again.");
+ break;
+ case PK_ERROR_ENUM_DEP_RESOLUTION_FAILED:
+ text = _("A package could not be found that allows the task to complete.\n"
+ "More information is available in the detailed report.");
+ break;
+ case PK_ERROR_ENUM_FILTER_INVALID:
+ text = _("The search filter was not correctly formed.");
+ break;
+ case PK_ERROR_ENUM_PACKAGE_ID_INVALID:
+ text = _("The package identifier was not well formed when sent to the server.\n"
+ "This normally indicates an internal error and should be reported.");
+ break;
+ case PK_ERROR_ENUM_TRANSACTION_ERROR:
+ text = _("An unspecified task error has occurred.\n"
+ "More information is available in the detailed report.");
+ break;
+ case PK_ERROR_ENUM_REPO_NOT_FOUND:
+ text = _("The remote software source name was not found.\n"
+ "You may need to enable an item in Software Sources");
+ break;
+ case PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE:
+ text = _("Removing a protected system package is not alloed.");
+ break;
+ case PK_ERROR_ENUM_TRANSACTION_CANCELLED:
+ text = _("The task was canceled successfully and no packages were changed.");
+ break;
+ case PK_ERROR_ENUM_PROCESS_KILL:
+ text = _("The task was canceled successfully and no packages were changed.\n"
+ "The backend did not exit cleanly.");
+ break;
+ case PK_ERROR_ENUM_FAILED_CONFIG_PARSING:
+ text = _("The native package configuration file could not be opened.\n"
+ "Please make sure configuration is valid.");
+ break;
+ case PK_ERROR_ENUM_CANNOT_CANCEL:
+ text = _("The task is not safe to be cancelled at this time.");
+ break;
+ case PK_ERROR_ENUM_CANNOT_INSTALL_SOURCE_PACKAGE:
+ text = _("Source packages are not normally installed this way.\n"
+ "Check the extension of the file you are trying to install.");
+ break;
+ default:
+ text = _("Unknown error, please report a bug.\n"
+ "More information is available in the detailed report.");
+ }
+ return text;
+}
+
+/**
+ * gpk_restart_enum_to_localised_text_future:
+ **/
+const gchar *
+gpk_restart_enum_to_localised_text_future (PkRestartEnum restart)
+{
+ const gchar *text = NULL;
+ switch (restart) {
+ case PK_RESTART_ENUM_NONE:
+ text = _("No restart is necessary for this update");
+ break;
+ case PK_RESTART_ENUM_APPLICATION:
+ text = _("An application restart is required after this update");
+ break;
+ case PK_RESTART_ENUM_SESSION:
+ text = _("You will be required to log off and back on after this update");
+ break;
+ case PK_RESTART_ENUM_SYSTEM:
+ text = _("A system restart is required after this update");
+ break;
+ default:
+ pk_warning ("restart unrecognised: %i", restart);
+ }
+ return text;
+}
+
+/**
+ * gpk_restart_enum_to_localised_text:
+ **/
+const gchar *
+gpk_restart_enum_to_localised_text (PkRestartEnum restart)
+{
+ const gchar *text = NULL;
+ switch (restart) {
+ case PK_RESTART_ENUM_NONE:
+ text = _("No restart is required");
+ break;
+ case PK_RESTART_ENUM_SYSTEM:
+ text = _("A system restart is required");
+ break;
+ case PK_RESTART_ENUM_SESSION:
+ text = _("You will need to log off and log back on");
+ break;
+ case PK_RESTART_ENUM_APPLICATION:
+ text = _("You need to restart the application");
+ break;
+ default:
+ pk_warning ("restart unrecognised: %i", restart);
+ }
+ return text;
+}
+
+/**
+ * gpk_message_enum_to_localised_text:
+ **/
+const gchar *
+gpk_message_enum_to_localised_text (PkMessageEnum message)
+{
+ const gchar *text = NULL;
+ switch (message) {
+ case PK_MESSAGE_ENUM_NOTICE:
+ text = _("PackageKit notice");
+ break;
+ case PK_MESSAGE_ENUM_WARNING:
+ text = _("PackageKit warning");
+ break;
+ case PK_MESSAGE_ENUM_DAEMON:
+ text = _("PackageKit daemon");
+ break;
+ default:
+ pk_warning ("message unrecognised: %i", message);
+ }
+ return text;
+}
+
+/**
+ * gpk_status_enum_to_localised_text:
+ **/
+const gchar *
+gpk_status_enum_to_localised_text (PkStatusEnum status)
+{
+ const gchar *text = NULL;
+ switch (status) {
+ case PK_STATUS_ENUM_UNKNOWN:
+ text = _("Unknown state");
+ break;
+ case PK_STATUS_ENUM_SETUP:
+ text = _("Waiting for PackageKit service");
+ break;
+ case PK_STATUS_ENUM_WAIT:
+ text = _("Waiting for other tasks to complete");
+ break;
+ case PK_STATUS_ENUM_RUNNING:
+ text = _("Running task");
+ break;
+ case PK_STATUS_ENUM_QUERY:
+ text = _("Querying");
+ break;
+ case PK_STATUS_ENUM_INFO:
+ text = _("Getting information");
+ break;
+ case PK_STATUS_ENUM_REMOVE:
+ text = _("Removing");
+ break;
+ case PK_STATUS_ENUM_DOWNLOAD:
+ text = _("Downloading");
+ break;
+ case PK_STATUS_ENUM_INSTALL:
+ text = _("Installing");
+ break;
+ case PK_STATUS_ENUM_REFRESH_CACHE:
+ text = _("Refreshing software list");
+ break;
+ case PK_STATUS_ENUM_UPDATE:
+ text = _("Updating");
+ break;
+ case PK_STATUS_ENUM_CLEANUP:
+ text = _("Cleaning up");
+ break;
+ case PK_STATUS_ENUM_OBSOLETE:
+ text = _("Obsoleting");
+ break;
+ case PK_STATUS_ENUM_DEP_RESOLVE:
+ text = _("Resolving dependencies");
+ break;
+ case PK_STATUS_ENUM_SIG_CHECK:
+ text = _("Checking signatures");
+ break;
+ case PK_STATUS_ENUM_ROLLBACK:
+ text = _("Rolling back");
+ break;
+ case PK_STATUS_ENUM_TEST_COMMIT:
+ text = _("Testing changes");
+ break;
+ case PK_STATUS_ENUM_COMMIT:
+ text = _("Committing changes");
+ break;
+ case PK_STATUS_ENUM_REQUEST:
+ text = _("Requesting data");
+ break;
+ case PK_STATUS_ENUM_FINISHED:
+ text = _("Finished");
+ break;
+ case PK_STATUS_ENUM_CANCEL:
+ text = _("Cancelling");
+ break;
+ default:
+ pk_warning ("status unrecognised: %s", pk_status_enum_to_text (status));
+ }
+ return text;
+}
+
+/**
+ * gpk_update_enum_to_localised_text:
+ **/
+gchar *
+gpk_update_enum_to_localised_text (PkInfoEnum info, guint number)
+{
+ gchar *text = NULL;
+ switch (info) {
+ case PK_INFO_ENUM_LOW:
+ text = g_strdup_printf (ngettext ("%i trivial update", "%i trivial updates", number), number);
+ break;
+ case PK_INFO_ENUM_NORMAL:
+ text = g_strdup_printf (ngettext ("%i update", "%i updates", number), number);
+ break;
+ case PK_INFO_ENUM_IMPORTANT:
+ text = g_strdup_printf (ngettext ("%i important update", "%i important updates", number), number);
+ break;
+ case PK_INFO_ENUM_SECURITY:
+ text = g_strdup_printf (ngettext ("%i security update", "%i security updates", number), number);
+ break;
+ case PK_INFO_ENUM_BUGFIX:
+ text = g_strdup_printf (ngettext ("%i bug fix update", "%i bug fix updates", number), number);
+ break;
+ case PK_INFO_ENUM_ENHANCEMENT:
+ text = g_strdup_printf (ngettext ("%i enhancement update", "%i enhancement updates", number), number);
+ break;
+ default:
+ pk_warning ("update info unrecognised: %s", pk_info_enum_to_text (info));
+ }
+ return text;
+}
+
+/**
+ * gpk_info_enum_to_localised_text:
+ **/
+const gchar *
+gpk_info_enum_to_localised_text (PkInfoEnum info)
+{
+ const gchar *text = NULL;
+ switch (info) {
+ case PK_INFO_ENUM_LOW:
+ text = _("Trivial update");
+ break;
+ case PK_INFO_ENUM_NORMAL:
+ text = _("Update");
+ break;
+ case PK_INFO_ENUM_IMPORTANT:
+ text = _("Important update");
+ break;
+ case PK_INFO_ENUM_SECURITY:
+ text = _("Security update");
+ break;
+ case PK_INFO_ENUM_BUGFIX:
+ text = _("Bug fix update");
+ break;
+ case PK_INFO_ENUM_ENHANCEMENT:
+ text = _("Enhancement update");
+ break;
+ case PK_INFO_ENUM_BLOCKED:
+ text = _("Blocked update");
+ break;
+ case PK_INFO_ENUM_DOWNLOADING:
+ text = _("Downloading");
+ break;
+ case PK_INFO_ENUM_UPDATING:
+ text = _("Updating");
+ break;
+ case PK_INFO_ENUM_INSTALLING:
+ text = _("Installing");
+ break;
+ case PK_INFO_ENUM_REMOVING:
+ text = _("Removing");
+ break;
+ case PK_INFO_ENUM_INSTALLED:
+ text = _("Installed");
+ break;
+ case PK_INFO_ENUM_AVAILABLE:
+ text = _("Available");
+ break;
+ case PK_INFO_ENUM_CLEANUP:
+ text = _("Cleaned up");
+ break;
+ case PK_INFO_ENUM_OBSOLETING:
+ text = _("Obsoleting");
+ break;
+ default:
+ pk_warning ("info unrecognised: %s", pk_info_enum_to_text (info));
+ }
+ return text;
+}
+
+/**
+ * gpk_role_enum_to_localised_present:
+ **/
+const gchar *
+gpk_role_enum_to_localised_present (PkRoleEnum role)
+{
+ const gchar *text = NULL;
+ switch (role) {
+ case PK_ROLE_ENUM_UNKNOWN:
+ text = _("Unknown role type");
+ break;
+ case PK_ROLE_ENUM_GET_DEPENDS:
+ text = _("Getting dependencies");
+ break;
+ case PK_ROLE_ENUM_GET_UPDATE_DETAIL:
+ text = _("Getting update detail");
+ break;
+ case PK_ROLE_ENUM_GET_DESCRIPTION:
+ text = _("Getting description");
+ break;
+ case PK_ROLE_ENUM_GET_REQUIRES:
+ text = _("Getting requires");
+ break;
+ case PK_ROLE_ENUM_GET_UPDATES:
+ text = _("Getting updates");
+ break;
+ case PK_ROLE_ENUM_SEARCH_DETAILS:
+ text = _("Searching details");
+ break;
+ case PK_ROLE_ENUM_SEARCH_FILE:
+ text = _("Searching for file");
+ break;
+ case PK_ROLE_ENUM_SEARCH_GROUP:
+ text = _("Searching groups");
+ break;
+ case PK_ROLE_ENUM_SEARCH_NAME:
+ text = _("Searching for package name");
+ break;
+ case PK_ROLE_ENUM_REMOVE_PACKAGE:
+ text = _("Removing");
+ break;
+ case PK_ROLE_ENUM_INSTALL_PACKAGE:
+ text = _("Installing");
+ break;
+ case PK_ROLE_ENUM_INSTALL_FILE:
+ text = _("Installing file");
+ break;
+ case PK_ROLE_ENUM_REFRESH_CACHE:
+ text = _("Refreshing package cache");
+ break;
+ case PK_ROLE_ENUM_UPDATE_PACKAGES:
+ text = _("Updating packages");
+ break;
+ case PK_ROLE_ENUM_UPDATE_SYSTEM:
+ text = _("Updating system");
+ break;
+ case PK_ROLE_ENUM_CANCEL:
+ text = _("Canceling");
+ break;
+ case PK_ROLE_ENUM_ROLLBACK:
+ text = _("Rolling back");
+ break;
+ case PK_ROLE_ENUM_GET_REPO_LIST:
+ text = _("Getting list of repositories");
+ break;
+ case PK_ROLE_ENUM_REPO_ENABLE:
+ text = _("Enabling repository");
+ break;
+ case PK_ROLE_ENUM_REPO_SET_DATA:
+ text = _("Setting repository data");
+ break;
+ case PK_ROLE_ENUM_RESOLVE:
+ text = _("Resolved");
+ break;
+ case PK_ROLE_ENUM_GET_FILES:
+ text = _("Getting file list");
+ break;
+ case PK_ROLE_ENUM_WHAT_PROVIDES:
+ text = _("Getting what provides");
+ break;
+ case PK_ROLE_ENUM_SERVICE_PACK:
+ text = _("Service pack");
+ break;
+ case PK_ROLE_ENUM_INSTALL_SIGNATURE:
+ text = _("Installing signature");
+ break;
+ case PK_ROLE_ENUM_GET_PACKAGES:
+ text = _("Getting package lists");
+ break;
+ default:
+ pk_warning ("role unrecognised: %s", pk_role_enum_to_text (role));
+ }
+ return text;
+}
+
+/**
+ * gpk_role_enum_to_localised_past:
+ *
+ * These are past tense versions of the action
+ **/
+const gchar *
+gpk_role_enum_to_localised_past (PkRoleEnum role)
+{
+ const gchar *text = NULL;
+ switch (role) {
+ case PK_ROLE_ENUM_UNKNOWN:
+ text = _("Unknown role type");
+ break;
+ case PK_ROLE_ENUM_GET_DEPENDS:
+ text = _("Got dependencies");
+ break;
+ case PK_ROLE_ENUM_GET_UPDATE_DETAIL:
+ text = _("Got update detail");
+ break;
+ case PK_ROLE_ENUM_GET_DESCRIPTION:
+ text = _("Got description");
+ break;
+ case PK_ROLE_ENUM_GET_REQUIRES:
+ text = _("Got requires");
+ break;
+ case PK_ROLE_ENUM_GET_UPDATES:
+ text = _("Got updates");
+ break;
+ case PK_ROLE_ENUM_SEARCH_DETAILS:
+ text = _("Got details");
+ break;
+ case PK_ROLE_ENUM_SEARCH_FILE:
+ text = _("Searched for file");
+ break;
+ case PK_ROLE_ENUM_SEARCH_GROUP:
+ text = _("Searched groups");
+ break;
+ case PK_ROLE_ENUM_SEARCH_NAME:
+ text = _("Searched for package name");
+ break;
+ case PK_ROLE_ENUM_REMOVE_PACKAGE:
+ text = _("Removed package");
+ break;
+ case PK_ROLE_ENUM_INSTALL_PACKAGE:
+ text = _("Installed package");
+ break;
+ case PK_ROLE_ENUM_INSTALL_FILE:
+ text = _("Installed local file");
+ break;
+ case PK_ROLE_ENUM_SERVICE_PACK:
+ text = _("Updating from service pack");
+ break;
+ case PK_ROLE_ENUM_REFRESH_CACHE:
+ text = _("Refreshed package cache");
+ break;
+ case PK_ROLE_ENUM_UPDATE_PACKAGES:
+ text = _("Updated package");
+ break;
+ case PK_ROLE_ENUM_UPDATE_SYSTEM:
+ text = _("Updated system");
+ break;
+ case PK_ROLE_ENUM_CANCEL:
+ text = _("Canceled");
+ break;
+ case PK_ROLE_ENUM_ROLLBACK:
+ text = _("Rolled back");
+ break;
+ case PK_ROLE_ENUM_GET_REPO_LIST:
+ text = _("Got list of repositories");
+ break;
+ case PK_ROLE_ENUM_REPO_ENABLE:
+ text = _("Enabled repository");
+ break;
+ case PK_ROLE_ENUM_REPO_SET_DATA:
+ text = _("Set repository data");
+ break;
+ case PK_ROLE_ENUM_RESOLVE:
+ text = _("Resolved");
+ break;
+ case PK_ROLE_ENUM_GET_FILES:
+ text = _("Got file list");
+ break;
+ case PK_ROLE_ENUM_WHAT_PROVIDES:
+ text = _("Got what provides");
+ break;
+ case PK_ROLE_ENUM_INSTALL_SIGNATURE:
+ text = _("Installed signature");
+ break;
+ case PK_ROLE_ENUM_GET_PACKAGES:
+ text = _("Got package lists");
+ break;
+ default:
+ pk_warning ("role unrecognised: %s", pk_role_enum_to_text (role));
+ }
+ return text;
+}
+
+/**
+ * gpk_group_enum_to_localised_text:
+ **/
+const gchar *
+gpk_group_enum_to_localised_text (PkGroupEnum group)
+{
+ const gchar *text = NULL;
+ switch (group) {
+ case PK_GROUP_ENUM_ACCESSIBILITY:
+ text = _("Accessibility");
+ break;
+ case PK_GROUP_ENUM_ACCESSORIES:
+ text = _("Accessories");
+ break;
+ case PK_GROUP_ENUM_EDUCATION:
+ text = _("Education");
+ break;
+ case PK_GROUP_ENUM_GAMES:
+ text = _("Games");
+ break;
+ case PK_GROUP_ENUM_GRAPHICS:
+ text = _("Graphics");
+ break;
+ case PK_GROUP_ENUM_INTERNET:
+ text = _("Internet");
+ break;
+ case PK_GROUP_ENUM_OFFICE:
+ text = _("Office");
+ break;
+ case PK_GROUP_ENUM_OTHER:
+ text = _("Other");
+ break;
+ case PK_GROUP_ENUM_PROGRAMMING:
+ text = _("Programming");
+ break;
+ case PK_GROUP_ENUM_MULTIMEDIA:
+ text = _("Multimedia");
+ break;
+ case PK_GROUP_ENUM_SYSTEM:
+ text = _("System");
+ break;
+ case PK_GROUP_ENUM_DESKTOP_GNOME:
+ text = _("GNOME desktop");
+ break;
+ case PK_GROUP_ENUM_DESKTOP_KDE:
+ text = _("KDE desktop");
+ break;
+ case PK_GROUP_ENUM_DESKTOP_XFCE:
+ text = _("XFCE desktop");
+ break;
+ case PK_GROUP_ENUM_DESKTOP_OTHER:
+ text = _("Other desktops");
+ break;
+ case PK_GROUP_ENUM_PUBLISHING:
+ text = _("Publishing");
+ break;
+ case PK_GROUP_ENUM_SERVERS:
+ text = _("Servers");
+ break;
+ case PK_GROUP_ENUM_FONTS:
+ text = _("Fonts");
+ break;
+ case PK_GROUP_ENUM_ADMIN_TOOLS:
+ text = _("Admin tools");
+ break;
+ case PK_GROUP_ENUM_LEGACY:
+ text = _("Legacy");
+ break;
+ case PK_GROUP_ENUM_LOCALIZATION:
+ text = _("Localization");
+ break;
+ case PK_GROUP_ENUM_VIRTUALIZATION:
+ text = _("Virtualization");
+ break;
+ case PK_GROUP_ENUM_SECURITY:
+ text = _("Security");
+ break;
+ case PK_GROUP_ENUM_POWER_MANAGEMENT:
+ text = _("Power management");
+ break;
+ case PK_GROUP_ENUM_COMMUNICATION:
+ text = _("Communication");
+ break;
+ case PK_GROUP_ENUM_NETWORK:
+ text = _("Network");
+ break;
+ case PK_GROUP_ENUM_MAPS:
+ text = _("Maps");
+ break;
+ case PK_GROUP_ENUM_REPOS:
+ text = _("Software sources");
+ break;
+ case PK_GROUP_ENUM_UNKNOWN:
+ text = _("Unknown group");
+ break;
+ default:
+ pk_warning ("group unrecognised: %i", group);
+ }
+ return text;
+}
+
+/**
+ * gpk_info_enum_to_icon_name:
+ **/
+const gchar *
+gpk_info_enum_to_icon_name (PkInfoEnum info)
+{
+ return pk_enum_find_string (enum_info_icon_name, info);
+}
+
+/**
+ * gpk_status_enum_to_icon_name:
+ **/
+const gchar *
+gpk_status_enum_to_icon_name (PkStatusEnum status)
+{
+ return pk_enum_find_string (enum_status_icon_name, status);
+}
+
+/**
+ * gpk_role_enum_to_icon_name:
+ **/
+const gchar *
+gpk_role_enum_to_icon_name (PkRoleEnum role)
+{
+ return pk_enum_find_string (enum_role_icon_name, role);
+}
+
+/**
+ * gpk_group_enum_to_icon_name:
+ **/
+const gchar *
+gpk_group_enum_to_icon_name (PkGroupEnum group)
+{
+ return pk_enum_find_string (enum_group_icon_name, group);
+}
+
+/**
+ * gpk_restart_enum_to_icon_name:
+ **/
+const gchar *
+gpk_restart_enum_to_icon_name (PkRestartEnum restart)
+{
+ return pk_enum_find_string (enum_restart_icon_name, restart);
+}
+
+/**
+ * gpk_message_enum_to_icon_name:
+ **/
+const gchar *
+gpk_message_enum_to_icon_name (PkMessageEnum message)
+{
+ return pk_enum_find_string (enum_message_icon_name, message);
+}
+
+/**
+ * gpk_time_to_localised_string:
+ * @time_secs: The time value to convert in seconds
+ * @cookie: The cookie we are looking for
+ *
+ * Returns a localised timestring
+ *
+ * Return value: The time string, e.g. "2 hours 3 minutes"
+ **/
+gchar *
+gpk_time_to_localised_string (guint time_secs)
+{
+ gchar* timestring = NULL;
+ guint hours;
+ guint minutes;
+ guint seconds;
+
+ /* is valid? */
+ if (time_secs == 0) {
+ timestring = g_strdup_printf (_("Now"));
+ return timestring;
+ }
+
+ /* make local copy */
+ seconds = time_secs;
+
+ /* less than a minute */
+ if (seconds < 60) {
+ timestring = g_strdup_printf (ngettext ("%i second",
+ "%i seconds",
+ seconds), seconds);
+ return timestring;
+ }
+
+ /* Add 0.5 to do rounding */
+ minutes = (guint) ((time_secs / 60.0 ) + 0.5);
+ seconds = seconds % 60;
+
+ /* less than an hour */
+ if (minutes < 60) {
+ if (seconds == 0) {
+ timestring = g_strdup_printf (ngettext ("%i minute",
+ "%i minutes",
+ minutes), minutes);
+ } else {
+ /* TRANSLATOR: "%i %s %i %s" are "%i minutes %i seconds"
+ * Swap order with "%2$s %2$i %1$s %1$i if needed */
+ timestring = g_strdup_printf (_("%i %s %i %s"),
+ minutes, ngettext ("minute", "minutes", minutes),
+ seconds, ngettext ("second", "seconds", seconds));
+ }
+ return timestring;
+ }
+
+ /* more than an hour */
+ hours = minutes / 60;
+ minutes = minutes % 60;
+ if (minutes == 0) {
+ timestring = g_strdup_printf (ngettext (
+ "%i hour",
+ "%i hours",
+ hours), hours);
+ } else {
+ /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+ * Swap order with "%2$s %2$i %1$s %1$i if needed */
+ timestring = g_strdup_printf (_("%i %s %i %s"),
+ hours, ngettext ("hour", "hours", hours),
+ minutes, ngettext ("minute", "minutes", minutes));
+ }
+ return timestring;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_common_gui (LibSelfTest *test)
+{
+ gchar *text;
+ guint i;
+ const gchar *string;
+
+ if (libst_start (test, "GpkCommon", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ /************************************************************
+ **************** time text **************
+ ************************************************************/
+ libst_title (test, "time zero");
+ text = gpk_time_to_localised_string (0);
+ if (text != NULL && strcmp (text, _("Now")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 1s");
+ text = gpk_time_to_localised_string (1);
+ if (text != NULL && strcmp (text, _("1 second")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 1m");
+ text = gpk_time_to_localised_string (1*60);
+ if (text != NULL && strcmp (text, _("1 minute")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 1h");
+ text = gpk_time_to_localised_string (1*60*60);
+ if (text != NULL && strcmp (text, _("1 hour")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 30s");
+ text = gpk_time_to_localised_string (30);
+ if (text != NULL && strcmp (text, _("30 seconds")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 30m");
+ text = gpk_time_to_localised_string (30*60);
+ if (text != NULL && strcmp (text, _("30 minutes")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 30m1s");
+ text = gpk_time_to_localised_string (30*60+1);
+ if (text != NULL && strcmp (text, _("30 minutes 1 second")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "time 30m10s");
+ text = gpk_time_to_localised_string (30*60+10);
+ if (text != NULL && strcmp (text, _("30 minutes 10 seconds")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************
+ **************** size text **************
+ ************************************************************/
+ libst_title (test, "size zero");
+ text = gpk_size_to_si_size_text (0);
+ if (text != NULL && strcmp (text, _("0 bytes")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "size 512 bytes");
+ text = gpk_size_to_si_size_text (512);
+ if (text != NULL && strcmp (text, _("512 bytes")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "size 256.2 MB");
+ text = gpk_size_to_si_size_text (256*1025*1024);
+ if (text != NULL && strcmp (text, _("256.2 MB")) == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************
+ **************** package name text **************
+ ************************************************************/
+ libst_title (test, "get name null");
+ text = gpk_package_get_name (NULL);
+ if (text == NULL) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+
+ /************************************************************/
+ libst_title (test, "get name not id");
+ text = gpk_package_get_name ("ania");
+ if (text != NULL && strcmp (text, "ania") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "get name just id");
+ text = gpk_package_get_name ("simon;1.0.0;i386;moo");
+ if (text != NULL && strcmp (text, "simon") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************
+ **************** package name text **************
+ ************************************************************/
+ libst_title (test, "package id pretty null");
+ text = gpk_package_id_pretty (NULL, NULL);
+ if (text == NULL) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+
+ /************************************************************/
+ libst_title (test, "package id pretty valid package id, no summary");
+ text = gpk_package_id_pretty ("simon;0.0.1;i386;data", NULL);
+ if (text != NULL && strcmp (text, "<b>simon-0.0.1 (i386)</b>") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "package id pretty valid package id, no summary 2");
+ text = gpk_package_id_pretty ("simon;0.0.1;;data", NULL);
+ if (text != NULL && strcmp (text, "<b>simon-0.0.1</b>") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "package id pretty valid package id, no summary 3");
+ text = gpk_package_id_pretty ("simon;;;data", NULL);
+ if (text != NULL && strcmp (text, "<b>simon</b>") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "package id pretty valid package id, no summary 4");
+ text = gpk_package_id_pretty ("simon;0.0.1;;data", "dude");
+ if (text != NULL && strcmp (text, "<b>simon-0.0.1</b>\ndude") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed, got %s", text);
+ }
+ g_free (text);
+
+ /************************************************************
+ **************** localised enums **************
+ ************************************************************/
+ libst_title (test, "check we convert all the localised past role enums");
+ for (i=1; i<PK_ROLE_ENUM_UNKNOWN; i*=2) {
+ string = gpk_role_enum_to_localised_past (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised present role enums");
+ for (i=1; i<PK_ROLE_ENUM_UNKNOWN; i*=2) {
+ string = gpk_role_enum_to_localised_present (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the role icon name enums");
+ for (i=1; i<PK_ROLE_ENUM_UNKNOWN; i*=2) {
+ string = gpk_role_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised info enums");
+ for (i=1; i<PK_INFO_ENUM_UNKNOWN; i*=2) {
+ string = gpk_info_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the info icon names enums");
+ for (i=1; i<PK_INFO_ENUM_UNKNOWN; i*=2) {
+ string = gpk_info_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised status enums");
+ for (i=1; i<PK_STATUS_ENUM_UNKNOWN; i*=2) {
+ string = gpk_status_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the status icon names enums");
+ for (i=1; i<PK_STATUS_ENUM_UNKNOWN; i*=2) {
+ string = gpk_status_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the restart icon names enums");
+ for (i=0; i<PK_RESTART_ENUM_UNKNOWN; i++) {
+ string = gpk_restart_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised error enums");
+ for (i=0; i<PK_ERROR_ENUM_UNKNOWN; i++) {
+ string = gpk_error_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised error enums");
+ for (i=0; i<PK_ERROR_ENUM_UNKNOWN; i++) {
+ string = gpk_error_enum_to_localised_message (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised restart enums");
+ for (i=0; i<PK_RESTART_ENUM_UNKNOWN; i++) {
+ string = gpk_restart_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the message icon name enums");
+ for (i=0; i<PK_MESSAGE_ENUM_UNKNOWN; i++) {
+ string = gpk_message_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised message enums");
+ for (i=0; i<PK_MESSAGE_ENUM_UNKNOWN; i++) {
+ string = gpk_message_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised restart future enums");
+ for (i=0; i<PK_RESTART_ENUM_UNKNOWN; i++) {
+ string = gpk_restart_enum_to_localised_text_future (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the localised group enums");
+ for (i=1; i<PK_GROUP_ENUM_UNKNOWN; i*=2) {
+ string = gpk_group_enum_to_localised_text (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "check we convert all the group icon name enums");
+ for (i=1; i<PK_GROUP_ENUM_UNKNOWN; i*=2) {
+ string = gpk_group_enum_to_icon_name (i);
+ if (string == NULL) {
+ libst_failed (test, "failed to get %i", i);
+ break;
+ }
+ }
+ libst_success (test, NULL);
+
+ libst_end (test);
+}
+#endif
+
Added: trunk/libpackagekit-gnome/gpk-common.h
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/gpk-common.h Fri Apr 11 23:31:29 2008
@@ -0,0 +1,107 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_COMMON_GUI_H
+#define __PK_COMMON_GUI_H
+
+#include <glib-object.h>
+#include <pk-enum.h>
+
+G_BEGIN_DECLS
+
+#define GPK_PROGRESS_BAR_PULSE_DELAY 50
+#define GPK_PROGRESS_BAR_PULSE_STEP 0.05
+
+#define GPK_CONF_NOTIFY_COMPLETED "/apps/gnome-packagekit/notify_complete"
+#define GPK_CONF_NOTIFY_AVAILABLE "/apps/gnome-packagekit/notify_available"
+#define GPK_CONF_NOTIFY_CRITICAL "/apps/gnome-packagekit/notify_critical"
+#define GPK_CONF_NOTIFY_ERROR "/apps/gnome-packagekit/notify_errors"
+#define GPK_CONF_NOTIFY_MESSAGE "/apps/gnome-packagekit/notify_message"
+#define GPK_CONF_NOTIFY_STARTED "/apps/gnome-packagekit/notify_started"
+#define GPK_CONF_NOTIFY_BATTERY_UPDATE "/apps/gnome-packagekit/notify_battery_update"
+#define GPK_CONF_NOTIFY_RESTART "/apps/gnome-packagekit/notify_restart"
+#define GPK_CONF_AUTOCOMPLETE "/apps/gnome-packagekit/autocomplete"
+#define GPK_CONF_SESSION_STARTUP_TIMEOUT "/apps/gnome-packagekit/session_startup_timeout"
+#define GPK_CONF_FREQUENCY_GET_UPDATES "/apps/gnome-packagekit/frequency_get_updates"
+#define GPK_CONF_FREQUENCY_REFRESH_CACHE "/apps/gnome-packagekit/frequency_refresh_cache"
+#define GPK_CONF_AUTO_UPDATE "/apps/gnome-packagekit/auto_update"
+#define GPK_CONF_UPDATE_BATTERY "/apps/gnome-packagekit/update_battery"
+#define GPK_CONF_REPO_SHOW_DETAILS "/apps/gnome-packagekit/repo/show_details"
+
+#define GPK_CONF_APPLICATION_FILTER_BASENAME "/apps/gnome-packagekit/application/filter_basename"
+#define GPK_CONF_APPLICATION_FILTER_NEWEST "/apps/gnome-packagekit/application/filter_newest"
+
+#define GS_DBUS_SERVICE "org.gnome.ScreenSaver"
+#define GS_DBUS_PATH "/org/gnome/ScreenSaver"
+#define GS_DBUS_INTERFACE "org.gnome.ScreenSaver"
+
+#define GPM_DBUS_SERVICE "org.freedesktop.PowerManagement"
+#define GPM_DBUS_PATH "/org/freedesktop/PowerManagement"
+#define GPM_DBUS_PATH_INHIBIT "/org/freedesktop/PowerManagement/Inhibit"
+#define GPM_DBUS_INTERFACE "org.freedesktop.PowerManagement"
+#define GPM_DBUS_INTERFACE_INHIBIT "org.freedesktop.PowerManagement.Inhibit"
+
+gchar *gpk_package_get_name (const gchar *package_id);
+gchar *gpk_package_id_pretty (const gchar *package_id,
+ const gchar *summary);
+gchar *gpk_package_id_pretty_oneline (const gchar *package_id,
+ const gchar *summary);
+gchar *gpk_package_id_name_version (const gchar *package_id);
+gboolean gpk_icon_valid (const gchar *icon);
+gboolean gpk_error_modal_dialog (const gchar *title,
+ const gchar *message);
+gboolean gpk_execute_url (const gchar *url);
+gboolean gpk_show_help (const gchar *link_id);
+gboolean gpk_restart_system (void);
+const gchar *gpk_role_enum_to_localised_past (PkRoleEnum role)
+ G_GNUC_CONST;
+const gchar *gpk_role_enum_to_localised_present (PkRoleEnum role)
+ G_GNUC_CONST;
+const gchar *gpk_role_enum_to_icon_name (PkRoleEnum role);
+const gchar *gpk_info_enum_to_localised_text (PkInfoEnum info)
+ G_GNUC_CONST;
+const gchar *gpk_info_enum_to_icon_name (PkInfoEnum info);
+const gchar *gpk_status_enum_to_localised_text (PkStatusEnum status)
+ G_GNUC_CONST;
+const gchar *gpk_status_enum_to_icon_name (PkStatusEnum status);
+const gchar *gpk_restart_enum_to_icon_name (PkRestartEnum restart);
+const gchar *gpk_error_enum_to_localised_text (PkErrorCodeEnum code)
+ G_GNUC_CONST;
+const gchar *gpk_error_enum_to_localised_message (PkErrorCodeEnum code);
+const gchar *gpk_restart_enum_to_localised_text (PkRestartEnum restart)
+ G_GNUC_CONST;
+const gchar *gpk_message_enum_to_icon_name (PkMessageEnum message);
+const gchar *gpk_message_enum_to_localised_text (PkMessageEnum message)
+ G_GNUC_CONST;
+const gchar *gpk_restart_enum_to_localised_text_future(PkRestartEnum restart)
+ G_GNUC_CONST;
+const gchar *gpk_group_enum_to_localised_text (PkGroupEnum group)
+ G_GNUC_CONST;
+const gchar *gpk_group_enum_to_icon_name (PkGroupEnum group);
+gchar *gpk_size_to_si_size_text (guint64 size);
+gchar *gpk_update_enum_to_localised_text (PkInfoEnum info,
+ guint number)
+ G_GNUC_CONST;
+gchar *gpk_time_to_localised_string (guint time_secs);
+
+G_END_DECLS
+
+#endif /* __PK_COMMON_GUI_H */
Added: trunk/libpackagekit-gnome/gpk-self-test.c
==============================================================================
--- (empty file)
+++ trunk/libpackagekit-gnome/gpk-self-test.c Fri Apr 11 23:31:29 2008
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libselftest.h>
+#include <pk-debug.h>
+
+/* prototypes */
+void libst_common_gui (LibSelfTest *test);
+
+int
+main (int argc, char **argv)
+{
+ LibSelfTest test;
+
+ if (! g_thread_supported ()) {
+ g_thread_init (NULL);
+ }
+ g_type_init ();
+ libst_init (&test);
+ pk_debug_init (TRUE);
+
+ /* tests go here */
+ libst_common_gui (&test);
+
+ return (libst_finish (&test));
+}
+
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Fri Apr 11 23:31:29 2008
@@ -18,14 +18,15 @@
data/gpk-update-icon.desktop.in
data/gpk-update-viewer.desktop.in
data/gpk-update-viewer.glade
+libpackagekit-gnome/gpk-common.c
+libpackagekit-gnome/gpk-client.c
src/gpk-application.c
src/gpk-application-main.c
src/gpk-backend-status.c
-src/gpk-common.c
-src/gpk-client.c
src/gpk-inhibit.c
-src/gpk-install-file.c
-src/gpk-install-package.c
+src/gpk-install-local-file.c
+src/gpk-install-package-name.c
+src/gpk-install-provide-file.c
src/gpk-log.c
src/gpk-notify.c
src/gpk-prefs.c
Modified: trunk/src/.gitignore
==============================================================================
--- trunk/src/.gitignore (original)
+++ trunk/src/.gitignore Fri Apr 11 23:31:29 2008
@@ -2,15 +2,16 @@
Makefile.in
*.o
.deps
+.libs
gpk-marshal.c
gpk-marshal.h
gpk-interface.h
-gpk-self-test
gpk-repo
gpk-application
gpk-update-icon
-gpk-install-file
-gpk-install-package
+gpk-install-local-file
+gpk-install-package-name
+gpk-install-provide-file
gpk-prefs
gpk-update-viewer
gpk-backend-status
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Apr 11 23:31:29 2008
@@ -21,67 +21,74 @@
-DLOCALEDIR=\""$(localedir)"\" \
-DVERSION="\"$(VERSION)\"" \
-DPK_DATA=\"$(pkgdatadir)\" \
+ -I$(top_srcdir)/libpackagekit-gnome \
-I$(top_srcdir)/libgbus \
- -I$(top_srcdir)/libselftest \
$(NULL)
-GBUS_LIBS = \
- $(top_builddir)/libgbus/libgbus.la \
+GPK_LIBS = \
+ $(top_builddir)/libpackagekit-gnome/libpackagekit-gnome.la \
$(NULL)
-SELFTEST_LIBS = \
- $(top_builddir)/libselftest/libselftest.la \
+GBUS_LIBS = \
+ $(top_builddir)/libgbus/libgbus.la \
$(NULL)
bin_PROGRAMS = \
gpk-application \
gpk-repo \
gpk-prefs \
- gpk-install-file \
- gpk-install-package \
+ gpk-install-local-file \
+ gpk-install-provide-file \
+ gpk-install-package-name \
gpk-update-icon \
gpk-update-viewer \
gpk-log \
gpk-backend-status \
$(NULL)
-gpk_install_file_SOURCES = \
- gpk-install-file.c \
- gpk-client.c \
- gpk-client.h \
- gpk-common.c \
- gpk-common.h \
+gpk_install_provide_file_SOURCES = \
+ gpk-install-provide-file.c \
$(NULL)
-gpk_install_file_LDADD = \
+gpk_install_provide_file_LDADD = \
$(GLIB_LIBS) \
- $(GBUS_LIBS) \
$(DBUS_LIBS) \
- $(LIBNOTIFY_LIBS) \
+ $(GCONF_LIBS) \
+ $(LIBGLADE_LIBS) \
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
- $(LIBGLADE_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
-gpk_install_package_SOURCES = \
- gpk-install-package.c \
- gpk-progress.c \
- gpk-progress.h \
- gpk-client.c \
- gpk-client.h \
- gpk-common.c \
- gpk-common.h \
+gpk_install_local_file_SOURCES = \
+ gpk-install-local-file.c \
$(NULL)
-gpk_install_package_LDADD = \
+gpk_install_local_file_LDADD = \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
- $(LIBNOTIFY_LIBS) \
+ $(GCONF_LIBS) \
+ $(LIBGLADE_LIBS) \
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
+ $(NULL)
+
+gpk_install_package_name_SOURCES = \
+ gpk-install-package-name.c \
+ $(NULL)
+
+gpk_install_package_name_LDADD = \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS) \
+ $(GCONF_LIBS) \
$(LIBGLADE_LIBS) \
+ $(GTK_LIBS) \
+ $(PACKAGEKIT_LIBS) \
+ $(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_update_icon_SOURCES = \
@@ -100,8 +107,6 @@
gpk-marshal.h \
gpk-progress.c \
gpk-progress.h \
- gpk-common.c \
- gpk-common.h \
$(NULL)
gpk_update_icon_LDADD = \
@@ -113,6 +118,7 @@
$(LIBGLADE_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_application_SOURCES = \
@@ -121,10 +127,6 @@
gpk-application.h \
gpk-statusbar.c \
gpk-statusbar.h \
- gpk-client.c \
- gpk-client.h \
- gpk-common.c \
- gpk-common.h \
$(NULL)
gpk_application_LDADD = \
@@ -136,12 +138,11 @@
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_prefs_SOURCES = \
gpk-prefs.c \
- gpk-common.c \
- gpk-common.h \
$(NULL)
gpk_prefs_LDADD = \
@@ -152,14 +153,13 @@
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_update_viewer_SOURCES = \
gpk-update-viewer.c \
gpk-statusbar.c \
gpk-statusbar.h \
- gpk-common.c \
- gpk-common.h \
gpk-cell-renderer-uri.c \
gpk-cell-renderer-uri.h \
$(NULL)
@@ -171,14 +171,13 @@
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_repo_SOURCES = \
gpk-repo.c \
gpk-statusbar.c \
gpk-statusbar.h \
- gpk-common.c \
- gpk-common.h \
$(NULL)
gpk_repo_LDADD = \
@@ -189,12 +188,11 @@
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_log_SOURCES = \
gpk-log.c \
- gpk-common.c \
- gpk-common.h \
$(NULL)
gpk_log_LDADD = \
@@ -204,6 +202,7 @@
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(POLKIT_GNOME_LIBS) \
+ $(GPK_LIBS) \
$(NULL)
gpk_backend_status_SOURCES = \
@@ -218,31 +217,6 @@
$(PACKAGEKIT_LIBS) \
$(NULL)
-check_PROGRAMS = \
- gpk-self-test
-
-noinst_PROGRAMS = \
- gpk-self-test
-
-gpk_self_test_SOURCES = \
- gpk-common.h \
- gpk-common.c \
- gpk-self-test.c \
- $(NULL)
-
-gpk_self_test_LDADD = \
- $(GLIB_LIBS) \
- $(GTK_LIBS) \
- $(DBUS_LIBS) \
- $(SELFTEST_LIBS) \
- $(PK_LIBS) \
- $(PACKAGEKIT_LIBS) \
- $(POLKIT_GNOME_LIBS) \
- $(NULL)
-
-gpk_self_test_CPPFLAGS= \
- -DPK_BUILD_TESTS
-
BUILT_SOURCES = \
gpk-marshal.c \
gpk-marshal.h \
@@ -263,20 +237,6 @@
--output=gpk-interface.h \
$(srcdir)/gpk-interface.xml
-if PK_BUILD_GCOV
-clean-gcov:
- rm -f *.gcov *.gcda
-gcov: clean-gcov all check
- $(top_srcdir)/tools/create-coverage-report.sh packagekit $(filter %.c,$(packagekitd_SOURCES)) > gcov.txt
-endif
-
-if PK_BUILD_GPROF
-clean-gprof:
- rm -f *.out
-gprof: clean-gprof all check
- gprof ./gpk-self-test > gprof.txt
-endif
-
EXTRA_DIST = \
gpk-marshal.list \
gpk-interface.xml \
@@ -284,11 +244,6 @@
clean-local:
rm -f *~
- rm -f *.out
- rm -f *.gcda
- rm -f *.gcno
- rm -f gcov.txt
- rm -f gprof.txt
rm -f gpk-marshal.c gpk-marshal.h
CLEANFILES = *~ $(BUILT_SOURCES)
@@ -298,5 +253,3 @@
Makefile.in \
$(NULL)
-TESTS = gpk-self-test
-
Modified: trunk/src/gpk-application.c
==============================================================================
--- trunk/src/gpk-application.c (original)
+++ trunk/src/gpk-application.c Fri Apr 11 23:31:29 2008
@@ -34,12 +34,12 @@
#include <polkit-gnome/polkit-gnome.h>
#include <pk-debug.h>
+#include <pk-enum.h>
#include <pk-client.h>
#include <pk-control.h>
#include <pk-common.h>
#include <pk-connection.h>
#include <pk-package-id.h>
-#include <pk-enum-list.h>
#include <pk-extra.h>
#include <pk-extra-obj.h>
#include <locale.h>
@@ -86,10 +86,10 @@
gchar *package;
gchar *group;
gchar *url;
- PkEnumList *role_list;
- PkEnumList *filter_list;
- PkEnumList *group_list;
+ PkRoleEnum roles;
PkFilterEnum filters;
+ PkGroupEnum groups;
+ PkFilterEnum filters_current;
gboolean has_package; /* if we got a package in the search */
PkSearchType search_type;
PkSearchMode search_mode;
@@ -375,7 +375,7 @@
g_return_if_fail (PK_IS_APPLICATION (application));
/* are we dumb and can't check for requires? */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_REQUIRES) == FALSE) {
+ 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;
@@ -766,11 +766,11 @@
/* do the search */
if (application->priv->search_type == PK_SEARCH_NAME) {
- ret = pk_client_search_name (application->priv->client_search, application->priv->filters, package, &error);
+ ret = pk_client_search_name (application->priv->client_search, application->priv->filters_current, package, &error);
} else if (application->priv->search_type == PK_SEARCH_DETAILS) {
- ret = pk_client_search_details (application->priv->client_search, application->priv->filters, package, &error);
+ ret = pk_client_search_details (application->priv->client_search, application->priv->filters_current, package, &error);
} else if (application->priv->search_type == PK_SEARCH_FILE) {
- ret = pk_client_search_file (application->priv->client_search, application->priv->filters, package, &error);
+ ret = pk_client_search_file (application->priv->client_search, application->priv->filters_current, package, &error);
} else {
pk_warning ("invalid search type");
return FALSE;
@@ -794,7 +794,7 @@
/* switch around buttons */
widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
gtk_widget_hide (widget);
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_CANCEL)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_CANCEL)) {
widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
gtk_widget_show (widget);
}
@@ -826,13 +826,13 @@
/* refresh the search as the items may have changed */
gtk_list_store_clear (application->priv->packages_store);
- ret = pk_client_search_group (application->priv->client_search, application->priv->filters, application->priv->group, &error);
+ ret = pk_client_search_group (application->priv->client_search, application->priv->filters_current, application->priv->group, &error);
/* ick, we failed so pretend we didn't do the action */
if (ret) {
/* switch around buttons */
widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
gtk_widget_hide (widget);
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_CANCEL)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_CANCEL)) {
widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
gtk_widget_show (widget);
}
@@ -939,7 +939,7 @@
package = gtk_entry_get_text (GTK_ENTRY (widget));
/* clear group selection if we have the tab */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_GROUP)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_GROUP)) {
widget = glade_xml_get_widget (application->priv->glade_xml, "treeview_groups");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
gtk_tree_selection_unselect_all (selection);
@@ -1215,13 +1215,13 @@
pk_debug ("selected row is: %i %s", installed, application->priv->package);
if (installed == FALSE &&
- pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_INSTALL_PACKAGE)) {
+ pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_INSTALL_PACKAGE)) {
polkit_gnome_action_set_visible (application->priv->install_action, TRUE);
} else {
polkit_gnome_action_set_visible (application->priv->install_action, FALSE);
}
if (installed &&
- pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_REMOVE_PACKAGE)) {
+ pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_REMOVE_PACKAGE)) {
polkit_gnome_action_set_visible (application->priv->remove_action, TRUE);
} else {
polkit_gnome_action_set_visible (application->priv->remove_action, FALSE);
@@ -1396,7 +1396,7 @@
}
pk_debug ("icon_pos=%i", icon_pos);
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_NAME)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_NAME)) {
item = gtk_image_menu_item_new_with_mnemonic (_("Search by name"));
image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1405,7 +1405,7 @@
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_DETAILS)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_DETAILS)) {
item = gtk_image_menu_item_new_with_mnemonic (_("Search by description"));
image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1414,7 +1414,7 @@
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_FILE)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_FILE)) {
item = gtk_image_menu_item_new_with_mnemonic (_("Search by file"));
image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1664,14 +1664,14 @@
/* set new filter */
if (g_str_has_suffix (name, "_yes")) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_INSTALLED);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_INSTALLED);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_INSTALLED);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_INSTALLED);
} else if (g_str_has_suffix (name, "_no")) {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_INSTALLED);
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_NOT_INSTALLED);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_INSTALLED);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_NOT_INSTALLED);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_INSTALLED);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_INSTALLED);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_INSTALLED);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_INSTALLED);
}
/* refresh the search results */
@@ -1698,14 +1698,14 @@
/* set new filter */
if (g_str_has_suffix (name, "_yes")) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_DEVELOPMENT);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_DEVELOPMENT);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_DEVELOPMENT);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_DEVELOPMENT);
} else if (g_str_has_suffix (name, "_no")) {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_DEVELOPMENT);
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_NOT_DEVELOPMENT);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_DEVELOPMENT);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_NOT_DEVELOPMENT);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_DEVELOPMENT);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_DEVELOPMENT);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_DEVELOPMENT);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_DEVELOPMENT);
}
/* refresh the search results */
@@ -1732,14 +1732,14 @@
/* set new filter */
if (g_str_has_suffix (name, "_yes")) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_GUI);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_GUI);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_GUI);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_GUI);
} else if (g_str_has_suffix (name, "_no")) {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_GUI);
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_NOT_GUI);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_GUI);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_NOT_GUI);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_GUI);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_GUI);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_GUI);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_GUI);
}
/* refresh the search results */
@@ -1766,14 +1766,14 @@
/* set new filter */
if (g_str_has_suffix (name, "_yes")) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_FREE);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_FREE);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_FREE);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_FREE);
} else if (g_str_has_suffix (name, "_no")) {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_FREE);
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_NOT_FREE);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_FREE);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_NOT_FREE);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_FREE);
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NOT_FREE);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_FREE);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NOT_FREE);
}
/* refresh the search results */
@@ -1798,9 +1798,9 @@
/* change the filter */
if (enabled) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_BASENAME);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_BASENAME);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_BASENAME);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_BASENAME);
}
/* refresh the search results */
@@ -1825,9 +1825,9 @@
/* change the filter */
if (enabled) {
- pk_enums_add (application->priv->filters, PK_FILTER_ENUM_NEWEST);
+ pk_enums_add (application->priv->filters_current, PK_FILTER_ENUM_NEWEST);
} else {
- pk_enums_remove (application->priv->filters, PK_FILTER_ENUM_NEWEST);
+ pk_enums_remove (application->priv->filters_current, PK_FILTER_ENUM_NEWEST);
}
/* refresh the search results */
@@ -1908,9 +1908,7 @@
GtkTreeSelection *selection;
gboolean autocomplete;
gboolean enabled;
- PkGroupEnum group;
gchar *locale; /* does not need to be freed */
- guint length;
guint page;
guint i;
gboolean ret;
@@ -1927,7 +1925,7 @@
application->priv->search_type = PK_SEARCH_UNKNOWN;
application->priv->search_mode = PK_MODE_UNKNOWN;
- application->priv->filters = PK_FILTER_ENUM_NONE;
+ application->priv->filters_current = PK_FILTER_ENUM_NONE;
/* add application specific icons to search path */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -1995,17 +1993,10 @@
g_signal_connect (application->priv->client_files, "allow-cancel",
G_CALLBACK (gpk_application_allow_cancel_cb), application);
- /* get actions */
- application->priv->role_list = pk_control_get_actions (application->priv->control);
- pk_debug ("actions=%s", pk_enum_list_to_string (application->priv->role_list));
-
- /* get filters supported */
- application->priv->filter_list = pk_control_get_filters (application->priv->control);
- pk_debug ("filter=%s", pk_enum_list_to_string (application->priv->filter_list));
-
- /* get groups supported */
- application->priv->group_list = pk_control_get_groups (application->priv->control);
- pk_debug ("groups=%s", pk_enum_list_to_string (application->priv->group_list));
+ /* get enums */
+ application->priv->roles = pk_control_get_actions (application->priv->control);
+ application->priv->filters = pk_control_get_filters (application->priv->control);
+ application->priv->groups = pk_control_get_groups (application->priv->control);
application->priv->pconnection = pk_connection_new ();
g_signal_connect (application->priv->pconnection, "connection-changed",
@@ -2179,41 +2170,41 @@
widget = glade_xml_get_widget (application->priv->glade_xml, "notebook_description");
g_signal_connect (widget, "switch-page",
G_CALLBACK (gpk_application_notebook_changed_cb), application);
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_DESCRIPTION) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_DESCRIPTION) == FALSE) {
vbox = glade_xml_get_widget (application->priv->glade_xml, "vbox_description");
page = gtk_notebook_page_num (GTK_NOTEBOOK (widget), vbox);
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), page);
}
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_FILES) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_FILES) == FALSE) {
vbox = glade_xml_get_widget (application->priv->glade_xml, "vbox_files");
page = gtk_notebook_page_num (GTK_NOTEBOOK (widget), vbox);
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), page);
}
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_DEPENDS) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_DEPENDS) == FALSE) {
vbox = glade_xml_get_widget (application->priv->glade_xml, "vbox_depends");
page = gtk_notebook_page_num (GTK_NOTEBOOK (widget), vbox);
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), page);
}
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_REQUIRES) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_REQUIRES) == FALSE) {
vbox = glade_xml_get_widget (application->priv->glade_xml, "vbox_requires");
page = gtk_notebook_page_num (GTK_NOTEBOOK (widget), vbox);
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), page);
}
/* hide the group selector if we don't support search-groups */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_GROUP) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_GROUP) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "scrolledwindow_groups");
gtk_widget_hide (widget);
}
/* hide the refresh cache button if we can't do it */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_REFRESH_CACHE) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_REFRESH_CACHE) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "imagemenuitem_refresh");
gtk_widget_hide (widget);
}
/* hide the software-sources button if we can't do it */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_GET_REPO_LIST) == FALSE) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_GET_REPO_LIST) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "imagemenuitem_sources");
gtk_widget_hide (widget);
}
@@ -2274,26 +2265,26 @@
gpk_application_menu_search_by_name (NULL, application);
/* hide the filters we can't support */
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_INSTALLED) == FALSE) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_INSTALLED) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed");
gtk_widget_hide (widget);
}
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_DEVELOPMENT) == FALSE) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_DEVELOPMENT) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_devel");
gtk_widget_hide (widget);
}
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_GUI) == FALSE) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_GUI) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_gui");
gtk_widget_hide (widget);
}
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_FREE) == FALSE) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_FREE) == FALSE) {
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_free");
gtk_widget_hide (widget);
}
/* BASENAME, use by default, or hide */
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_basename");
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_BASENAME)) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_BASENAME)) {
enabled = gconf_client_get_bool (application->priv->gconf_client,
GPK_CONF_APPLICATION_FILTER_BASENAME, NULL);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), enabled);
@@ -2305,7 +2296,7 @@
/* NEWEST, use by default, or hide */
widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_newest");
- if (pk_enum_list_contains (application->priv->filter_list, PK_FILTER_ENUM_NEWEST)) {
+ if (pk_enums_contain (application->priv->filters, PK_FILTER_ENUM_NEWEST)) {
/* set from remembered state */
enabled = gconf_client_get_bool (application->priv->gconf_client,
GPK_CONF_APPLICATION_FILTER_NEWEST, NULL);
@@ -2366,7 +2357,7 @@
gpk_application_packages_add_columns (GTK_TREE_VIEW (widget));
/* create group tree view if we can search by group */
- if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_GROUP)) {
+ if (pk_enums_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_GROUP)) {
widget = glade_xml_get_widget (application->priv->glade_xml, "treeview_groups");
gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
GTK_TREE_MODEL (application->priv->groups_store));
@@ -2379,11 +2370,9 @@
gpk_application_groups_add_columns (GTK_TREE_VIEW (widget));
/* add all the groups supported */
- length = pk_enum_list_size (application->priv->group_list);
- for (i=0; i<length; i++) {
- group = pk_enum_list_get_item (application->priv->group_list, i);
- if (group != PK_GROUP_ENUM_UNKNOWN) {
- gpk_application_group_add_data (application, group);
+ for (i=1; i<PK_GROUP_ENUM_UNKNOWN; i*=2) {
+ if (pk_enums_contain (application->priv->groups, i)) {
+ gpk_application_group_add_data (application, i);
}
}
}
@@ -2410,9 +2399,6 @@
g_object_unref (application->priv->client_description);
g_object_unref (application->priv->client_files);
g_object_unref (application->priv->pconnection);
- g_object_unref (application->priv->filter_list);
- g_object_unref (application->priv->group_list);
- g_object_unref (application->priv->role_list);
g_object_unref (application->priv->statusbar);
g_object_unref (application->priv->extra);
g_object_unref (application->priv->gconf_client);
Modified: trunk/src/gpk-auto-refresh.c
==============================================================================
--- trunk/src/gpk-auto-refresh.c (original)
+++ trunk/src/gpk-auto-refresh.c Fri Apr 11 23:31:29 2008
@@ -145,7 +145,7 @@
return 0;
}
if (freq == PK_FREQ_ENUM_NEVER) {
- return 0;
+ return G_MAXUINT;
}
if (freq == PK_FREQ_ENUM_HOURLY) {
return 60*60;
@@ -220,7 +220,7 @@
/* have we passed the timout? */
if (time < thresh) {
- pk_debug ("not before timeout, thresh=%i, now=%i", thresh, time);
+ pk_debug ("not before timeout, thresh=%u, now=%u", thresh, time);
return FALSE;
}
@@ -253,7 +253,7 @@
/* have we passed the timout? */
if (time < thresh) {
- pk_debug ("not before timeout, thresh=%i, now=%i", thresh, time);
+ pk_debug ("not before timeout, thresh=%u, now=%u", thresh, time);
return FALSE;
}
@@ -267,6 +267,8 @@
static gboolean
gpk_auto_refresh_change_state (GpkAutoRefresh *arefresh)
{
+ guint thresh;
+
g_return_val_if_fail (PK_IS_AUTO_REFRESH (arefresh), FALSE);
/* we shouldn't do this early in the session startup */
@@ -281,6 +283,13 @@
return FALSE;
}
+ /* have we been told to never check for updates? */
+ thresh = gpk_auto_refresh_convert_frequency_text (arefresh, GPK_CONF_FREQUENCY_GET_UPDATES);
+ if (thresh == 0) {
+ pk_debug ("not when policy is to never refresh");
+ return FALSE;
+ }
+
/* we do this to get an icon at startup */
if (arefresh->priv->sent_get_updates == FALSE) {
gpk_auto_refresh_signal_get_updates (arefresh);
Modified: trunk/src/gpk-backend-status.c
==============================================================================
--- trunk/src/gpk-backend-status.c (original)
+++ trunk/src/gpk-backend-status.c Fri Apr 11 23:31:29 2008
@@ -30,7 +30,6 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
-#include <pk-enum-list.h>
#include <pk-control.h>
#include <locale.h>
@@ -72,8 +71,8 @@
GladeXML *glade_xml;
gchar *name;
gchar *author;
- PkEnumList *role_list;
- PkEnumList *filter_list;
+ PkRoleEnum roles;
+ PkFilterEnum filters;
PkControl *control;
gboolean retval;
@@ -114,8 +113,8 @@
loop = g_main_loop_new (NULL, FALSE);
control = pk_control_new ();
- role_list = pk_control_get_actions (control);
- filter_list = pk_control_get_filters (control);
+ roles = pk_control_get_actions (control);
+ filters = pk_control_get_filters (control);
/* general stuff */
retval = pk_control_get_backend_detail (control, &name, &author, NULL);
@@ -143,135 +142,133 @@
g_free (author);
/* actions */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_CANCEL)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_CANCEL)) {
widget = glade_xml_get_widget (glade_xml, "image_cancel");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_DEPENDS)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_DEPENDS)) {
widget = glade_xml_get_widget (glade_xml, "image_get_depends");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_UPDATE_DETAIL)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_UPDATE_DETAIL)) {
widget = glade_xml_get_widget (glade_xml, "image_get_update_detail");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_DESCRIPTION)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_DESCRIPTION)) {
widget = glade_xml_get_widget (glade_xml, "image_get_description");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_FILES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_FILES)) {
widget = glade_xml_get_widget (glade_xml, "image_get_files");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REQUIRES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_REQUIRES)) {
widget = glade_xml_get_widget (glade_xml, "image_get_requires");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_UPDATES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_UPDATES)) {
widget = glade_xml_get_widget (glade_xml, "image_get_updates");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_SEARCH_DETAILS)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_SEARCH_DETAILS)) {
widget = glade_xml_get_widget (glade_xml, "image_search_details");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_SEARCH_FILE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_SEARCH_FILE)) {
widget = glade_xml_get_widget (glade_xml, "image_search_file");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_SEARCH_GROUP)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_SEARCH_GROUP)) {
widget = glade_xml_get_widget (glade_xml, "image_search_group");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_SEARCH_NAME)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_SEARCH_NAME)) {
widget = glade_xml_get_widget (glade_xml, "image_search_name");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_REFRESH_CACHE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_REFRESH_CACHE)) {
widget = glade_xml_get_widget (glade_xml, "image_refresh_cache");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_REMOVE_PACKAGE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_REMOVE_PACKAGE)) {
widget = glade_xml_get_widget (glade_xml, "image_package_remove");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_INSTALL_PACKAGE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_INSTALL_PACKAGE)) {
widget = glade_xml_get_widget (glade_xml, "image_package_install");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_INSTALL_FILE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_INSTALL_FILE)) {
widget = glade_xml_get_widget (glade_xml, "image_file_install");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_UPDATE_PACKAGES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_UPDATE_PACKAGES)) {
widget = glade_xml_get_widget (glade_xml, "image_package_update");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
widget = glade_xml_get_widget (glade_xml, "image_system_update");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_RESOLVE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_RESOLVE)) {
widget = glade_xml_get_widget (glade_xml, "image_resolve");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_WHAT_PROVIDES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_WHAT_PROVIDES)) {
widget = glade_xml_get_widget (glade_xml, "image_what_provides");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_PACKAGES)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_PACKAGES)) {
widget = glade_xml_get_widget (glade_xml, "image_get_packages");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
/* repos */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REPO_LIST)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_REPO_LIST)) {
widget = glade_xml_get_widget (glade_xml, "image_get_repo_list");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_REPO_ENABLE)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_REPO_ENABLE)) {
widget = glade_xml_get_widget (glade_xml, "image_repo_enable");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_REPO_SET_DATA)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_REPO_SET_DATA)) {
widget = glade_xml_get_widget (glade_xml, "image_repo_set_data");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
/* filters */
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_INSTALLED)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
widget = glade_xml_get_widget (glade_xml, "image_installed");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_DEVELOPMENT)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_DEVELOPMENT)) {
widget = glade_xml_get_widget (glade_xml, "image_devel");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_GUI)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_GUI)) {
widget = glade_xml_get_widget (glade_xml, "image_gui");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_FREE)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_FREE)) {
widget = glade_xml_get_widget (glade_xml, "image_free");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_VISIBLE)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_VISIBLE)) {
widget = glade_xml_get_widget (glade_xml, "image_visible");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_SUPPORTED)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_SUPPORTED)) {
widget = glade_xml_get_widget (glade_xml, "image_supported");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
- if (pk_enum_list_contains (filter_list, PK_FILTER_ENUM_NEWEST)) {
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_NEWEST)) {
widget = glade_xml_get_widget (glade_xml, "image_newest");
gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gtk-apply", GTK_ICON_SIZE_MENU);
}
g_object_unref (glade_xml);
g_object_unref (control);
- g_object_unref (role_list);
- g_object_unref (filter_list);
g_main_loop_run (loop);
g_main_loop_unref (loop);
Modified: trunk/src/gpk-log.c
==============================================================================
--- trunk/src/gpk-log.c (original)
+++ trunk/src/gpk-log.c Fri Apr 11 23:31:29 2008
@@ -38,7 +38,6 @@
#include <pk-control.h>
#include <pk-connection.h>
#include <pk-package-id.h>
-#include <pk-enum-list.h>
#include <pk-common.h>
#include "gpk-common.h"
@@ -364,7 +363,7 @@
GtkWidget *widget;
GtkTreeSelection *selection;
PkConnection *pconnection;
- PkEnumList *role_list;
+ PkRoleEnum roles;
PolKitAction *pk_action;
GtkWidget *button;
PkControl *control;
@@ -415,7 +414,7 @@
/* get actions */
control = pk_control_new ();
- role_list = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control);
g_object_unref (control);
/* save the description in a hash */
@@ -467,7 +466,7 @@
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (widget), button, 1);
/* hide the rollback button if we can't do the action */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_ROLLBACK)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_ROLLBACK)) {
polkit_gnome_action_set_visible (rollback_action, TRUE);
} else {
polkit_gnome_action_set_visible (rollback_action, FALSE);
@@ -512,7 +511,6 @@
g_object_unref (list_store_details);
g_object_unref (client);
g_object_unref (pconnection);
- g_object_unref (role_list);
g_free (transaction_id);
g_hash_table_unref (hash);
Modified: trunk/src/gpk-notify.c
==============================================================================
--- trunk/src/gpk-notify.c (original)
+++ trunk/src/gpk-notify.c Fri Apr 11 23:31:29 2008
@@ -554,27 +554,24 @@
}
/**
- * gpk_notify_client_packages_to_enum_list:
+ * gpk_notify_client_info_to_enums:
**/
-static PkEnumList *
-gpk_notify_client_packages_to_enum_list (GpkNotify *notify, PkClient *client)
+static PkInfoEnum
+gpk_notify_client_info_to_enums (GpkNotify *notify, PkClient *client)
{
guint i;
guint length;
- PkEnumList *elist;
+ PkInfoEnum infos = 0;
PkPackageItem *item;
- g_return_val_if_fail (GPK_IS_NOTIFY (notify), NULL);
+ g_return_val_if_fail (GPK_IS_NOTIFY (notify), PK_INFO_ENUM_UNKNOWN);
/* shortcut */
length = pk_client_package_buffer_get_size (client);
if (length == 0) {
- return NULL;
+ return PK_INFO_ENUM_UNKNOWN;
}
- /* we can use an enumerated list */
- elist = pk_enum_list_new ();
-
/* add each status to a list */
for (i=0; i<length; i++) {
item = pk_client_package_buffer_get_item (client, i);
@@ -583,9 +580,9 @@
break;
}
pk_debug ("%s %s", item->package_id, pk_info_enum_to_text (item->info));
- pk_enum_list_append (elist, item->info);
+ pk_enums_add (infos, item->info);
}
- return elist;
+ return infos;
}
/**
@@ -595,22 +592,22 @@
gpk_notify_get_best_update_icon (GpkNotify *notify, PkClient *client)
{
gint value;
- PkEnumList *elist;
+ PkInfoEnum infos;
const gchar *icon;
g_return_val_if_fail (GPK_IS_NOTIFY (notify), NULL);
/* get an enumerated list with all the update types */
- elist = gpk_notify_client_packages_to_enum_list (notify, client);
+ infos = gpk_notify_client_info_to_enums (notify, client);
/* get the most important icon */
- value = pk_enum_list_contains_priority (elist,
- PK_INFO_ENUM_SECURITY,
- PK_INFO_ENUM_IMPORTANT,
- PK_INFO_ENUM_BUGFIX,
- PK_INFO_ENUM_NORMAL,
- PK_INFO_ENUM_ENHANCEMENT,
- PK_INFO_ENUM_LOW, -1);
+ value = pk_enums_contain_priority (infos,
+ PK_INFO_ENUM_SECURITY,
+ PK_INFO_ENUM_IMPORTANT,
+ PK_INFO_ENUM_BUGFIX,
+ PK_INFO_ENUM_NORMAL,
+ PK_INFO_ENUM_ENHANCEMENT,
+ PK_INFO_ENUM_LOW, -1);
if (value == -1) {
pk_warning ("should not be possible!");
value = PK_INFO_ENUM_LOW;
@@ -618,8 +615,6 @@
/* get the icon */
icon = gpk_info_enum_to_icon_name (value);
-
- g_object_unref (elist);
return icon;
}
Modified: trunk/src/gpk-prefs.c
==============================================================================
--- trunk/src/gpk-prefs.c (original)
+++ trunk/src/gpk-prefs.c Fri Apr 11 23:31:29 2008
@@ -35,7 +35,6 @@
#include <pk-debug.h>
#include <pk-control.h>
#include <pk-client.h>
-#include <pk-enum-list.h>
#include "gpk-common.h"
#define PK_FREQ_HOURLY_TEXT N_("Hourly")
@@ -289,7 +288,7 @@
GOptionContext *context;
GtkWidget *main_window;
GtkWidget *widget;
- PkEnumList *role_list;
+ PkRoleEnum roles;
PkClient *client;
PkControl *control;
@@ -333,7 +332,7 @@
/* get actions */
control = pk_control_new ();
- role_list = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control);
g_object_unref (control);
glade_xml = glade_xml_new (PK_DATA "/gpk-prefs.glade", NULL, NULL);
@@ -374,7 +373,6 @@
g_object_unref (glade_xml);
g_object_unref (client);
- g_object_unref (role_list);
return 0;
}
Modified: trunk/src/gpk-progress.c
==============================================================================
--- trunk/src/gpk-progress.c (original)
+++ trunk/src/gpk-progress.c Fri Apr 11 23:31:29 2008
@@ -35,7 +35,6 @@
#include <pk-connection.h>
#include <pk-package-id.h>
#include <pk-common.h>
-#include <pk-enum-list.h>
#include "gpk-common.h"
#include "gpk-progress.h"
@@ -576,7 +575,7 @@
{
GtkWidget *main_window;
GtkWidget *widget;
- PkEnumList *role_list;
+ PkRoleEnum roles;
PkControl *control;
progress->priv = GPK_PROGRESS_GET_PRIVATE (progress);
@@ -633,16 +632,14 @@
/* get actions */
control = pk_control_new ();
- role_list = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control);
g_object_unref (control);
/* can we ever do the action? */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_CANCEL) == FALSE) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_CANCEL) == FALSE) {
gtk_widget_hide (widget);
}
- g_object_unref (role_list);
-
widget = glade_xml_get_widget (progress->priv->glade_xml, "button_hide");
g_signal_connect (widget, "clicked",
G_CALLBACK (gpk_progress_hide_cb), progress);
Modified: trunk/src/gpk-repo.c
==============================================================================
--- trunk/src/gpk-repo.c (original)
+++ trunk/src/gpk-repo.c Fri Apr 11 23:31:29 2008
@@ -36,14 +36,13 @@
#include <pk-client.h>
#include <pk-control.h>
#include <pk-connection.h>
-#include <pk-enum-list.h>
#include "gpk-common.h"
#include "gpk-statusbar.h"
static GladeXML *glade_xml = NULL;
static GtkListStore *list_store = NULL;
static PkClient *client = NULL;
-static PkEnumList *role_list;
+static PkRoleEnum roles;
static GpkStatusbar *statusbar;
static GConfClient *gconf_client;
static gboolean show_details;
@@ -90,7 +89,7 @@
GError *error = NULL;
/* do we have the capability? */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_REPO_ENABLE) == FALSE) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_REPO_ENABLE) == FALSE) {
pk_debug ("can't change state");
return;
}
@@ -349,7 +348,7 @@
control = pk_control_new ();
g_signal_connect (control, "repo-list-changed",
G_CALLBACK (pk_repo_repo_list_changed_cb), NULL);
- role_list = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control);
glade_xml = glade_xml_new (PK_DATA "/gpk-repo.glade", NULL, NULL);
main_window = glade_xml_get_widget (glade_xml, "window_repo");
@@ -396,7 +395,7 @@
widget = glade_xml_get_widget (glade_xml, "statusbar_status");
gpk_statusbar_set_widget (statusbar, widget);
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REPO_LIST)) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_GET_REPO_LIST)) {
/* get the update list */
pk_repo_repo_list_refresh ();
} else {
@@ -416,7 +415,6 @@
g_object_unref (gconf_client);
g_object_unref (client);
g_object_unref (control);
- g_object_unref (role_list);
g_object_unref (statusbar);
return 0;
Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c (original)
+++ trunk/src/gpk-update-viewer.c Fri Apr 11 23:31:29 2008
@@ -42,7 +42,6 @@
#include <pk-connection.h>
#include <pk-package-id.h>
#include <pk-package-ids.h>
-#include <pk-enum-list.h>
#include "gpk-common.h"
#include "gpk-statusbar.h"
#include "gpk-cell-renderer-uri.h"
@@ -1712,7 +1711,7 @@
GtkWidget *widget;
GtkTreeSelection *selection;
PkConnection *pconnection;
- PkEnumList *role_list;
+ PkRoleEnum roles;
gboolean ret;
GtkSizeGroup *size_group;
GtkWidget *button;
@@ -1797,7 +1796,7 @@
G_CALLBACK (pk_updates_allow_cancel_cb), NULL);
/* get actions */
- role_list = pk_control_get_actions (control);
+ roles = pk_control_get_actions (control);
pconnection = pk_connection_new ();
g_signal_connect (pconnection, "connection-changed",
@@ -1867,7 +1866,7 @@
gtk_widget_set_sensitive (widget, FALSE);
/* can we ever do the action? */
- if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_CANCEL) == FALSE) {
+ if (pk_enums_contain (roles, PK_ROLE_ENUM_CANCEL) == FALSE) {
gtk_widget_hide (widget);
}
@@ -2052,7 +2051,6 @@
g_object_unref (client_query);
g_object_unref (client_action);
g_object_unref (pconnection);
- g_object_unref (role_list);
g_free (cached_package_id);
return 0;
Modified: trunk/src/gpk-watch.c
==============================================================================
--- trunk/src/gpk-watch.c (original)
+++ trunk/src/gpk-watch.c Fri Apr 11 23:31:29 2008
@@ -47,7 +47,6 @@
#include <pk-task-list.h>
#include <pk-connection.h>
#include <pk-package-id.h>
-#include <pk-enum-list.h>
#include "gpk-common.h"
#include "gpk-watch.h"
@@ -148,28 +147,24 @@
}
/**
- * gpk_watch_task_list_to_state_enum_list:
+ * gpk_watch_task_list_to_status_enums:
**/
-static PkEnumList *
-gpk_watch_task_list_to_state_enum_list (GpkWatch *watch)
+static PkStatusEnum
+gpk_watch_task_list_to_status_enums (GpkWatch *watch)
{
guint i;
guint length;
- PkEnumList *elist;
+ PkStatusEnum status = 0;
PkTaskListItem *item;
- g_return_val_if_fail (GPK_IS_WATCH (watch), NULL);
+ g_return_val_if_fail (GPK_IS_WATCH (watch), PK_STATUS_ENUM_UNKNOWN);
/* shortcut */
length = pk_task_list_get_size (watch->priv->tlist);
if (length == 0) {
- return NULL;
+ goto out;
}
- /* we can use an enumerated list */
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_STATUS);
-
/* add each status to a list */
for (i=0; i<length; i++) {
item = pk_task_list_get_item (watch->priv->tlist, i);
@@ -178,9 +173,10 @@
break;
}
pk_debug ("%s %s", item->tid, pk_status_enum_to_text (item->status));
- pk_enum_list_append (elist, item->status);
+ pk_enums_add (status, item->status);
}
- return elist;
+out:
+ return status;
}
/**
@@ -190,40 +186,40 @@
gpk_watch_refresh_icon (GpkWatch *watch)
{
const gchar *icon;
- PkEnumList *elist;
+ PkStatusEnum status;
gint value;
g_return_val_if_fail (GPK_IS_WATCH (watch), FALSE);
pk_debug ("rescan");
- elist = gpk_watch_task_list_to_state_enum_list (watch);
+ status = gpk_watch_task_list_to_status_enums (watch);
/* nothing in the list */
- if (elist == NULL) {
+ if (status == 0) {
pk_debug ("no activity");
gpk_smart_icon_set_icon_name (watch->priv->sicon, NULL);
return TRUE;
}
/* get the most important icon */
- value = pk_enum_list_contains_priority (elist,
- PK_STATUS_ENUM_REFRESH_CACHE,
- PK_STATUS_ENUM_CANCEL,
- PK_STATUS_ENUM_INSTALL,
- PK_STATUS_ENUM_REMOVE,
- PK_STATUS_ENUM_CLEANUP,
- PK_STATUS_ENUM_OBSOLETE,
- PK_STATUS_ENUM_SETUP,
- PK_STATUS_ENUM_UPDATE,
- PK_STATUS_ENUM_DOWNLOAD,
- PK_STATUS_ENUM_QUERY,
- PK_STATUS_ENUM_INFO,
- PK_STATUS_ENUM_WAIT,
- PK_STATUS_ENUM_DEP_RESOLVE,
- PK_STATUS_ENUM_ROLLBACK,
- PK_STATUS_ENUM_COMMIT,
- PK_STATUS_ENUM_REQUEST,
- PK_STATUS_ENUM_FINISHED, -1);
+ value = pk_enums_contain_priority (status,
+ PK_STATUS_ENUM_REFRESH_CACHE,
+ PK_STATUS_ENUM_CANCEL,
+ PK_STATUS_ENUM_INSTALL,
+ PK_STATUS_ENUM_REMOVE,
+ PK_STATUS_ENUM_CLEANUP,
+ PK_STATUS_ENUM_OBSOLETE,
+ PK_STATUS_ENUM_SETUP,
+ PK_STATUS_ENUM_UPDATE,
+ PK_STATUS_ENUM_DOWNLOAD,
+ PK_STATUS_ENUM_QUERY,
+ PK_STATUS_ENUM_INFO,
+ PK_STATUS_ENUM_WAIT,
+ PK_STATUS_ENUM_DEP_RESOLVE,
+ PK_STATUS_ENUM_ROLLBACK,
+ PK_STATUS_ENUM_COMMIT,
+ PK_STATUS_ENUM_REQUEST,
+ PK_STATUS_ENUM_FINISHED, -1);
/* only set if in the list and not unknown */
if (value != PK_STATUS_ENUM_UNKNOWN && value != -1) {
@@ -231,7 +227,6 @@
gpk_smart_icon_set_icon_name (watch->priv->sicon, icon);
}
- g_object_unref (elist);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]