gnome-packagekit r124 - in trunk: . data src



Author: rhughes
Date: Mon Mar 24 22:28:59 2008
New Revision: 124
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=124&view=rev

Log:
from git

Modified:
   trunk/configure.ac
   trunk/data/pk-application.glade
   trunk/data/pk-transactions.glade
   trunk/data/pk-update-viewer.glade
   trunk/src/pk-application.c
   trunk/src/pk-auto-refresh.c
   trunk/src/pk-cell-renderer-uri.c
   trunk/src/pk-common-gui.c
   trunk/src/pk-install-package.c
   trunk/src/pk-notify.c
   trunk/src/pk-prefs.c
   trunk/src/pk-progress.c
   trunk/src/pk-repo.c
   trunk/src/pk-smart-icon.c
   trunk/src/pk-transaction-viewer.c
   trunk/src/pk-update-icon.c
   trunk/src/pk-update-viewer.c
   trunk/src/pk-watch.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Mon Mar 24 22:28:59 2008
@@ -66,7 +66,7 @@
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(PACKAGEKIT, packagekit >= $PACKAGEKIT_REQUIRED)
+PKG_CHECK_MODULES(PACKAGEKIT, packagekit >= $PACKAGEKIT_REQUIRED polkit-gnome)
 AC_SUBST(PACKAGEKIT_CFLAGS)
 AC_SUBST(PACKAGEKIT_LIBS)
 

Modified: trunk/data/pk-application.glade
==============================================================================
--- trunk/data/pk-application.glade	(original)
+++ trunk/data/pk-application.glade	Mon Mar 24 22:28:59 2008
@@ -22,23 +22,10 @@
                 <property name="label" translatable="yes">_System</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <widget class="GtkMenu" id="menu1">
+                  <widget class="GtkMenu" id="menu_system">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
-                      <widget class="GtkImageMenuItem" id="imagemenuitem_refresh">
-                        <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">_Refresh application lists</property>
-                        <property name="use_underline">True</property>
-                        <child internal-child="image">
-                          <widget class="GtkImage" id="menu-item-image11">
-                            <property name="stock">gtk-redo</property>
-                          </widget>
-                        </child>
-                      </widget>
-                    </child>
-                    <child>
                       <widget class="GtkImageMenuItem" id="menuitem_sources">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -382,6 +369,53 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <widget class="GtkButton" id="button_cancel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="response_id">0</property>
+                            <child>
+                              <widget class="GtkAlignment" id="alignment2">
+                                <property name="visible">True</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox3">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">2</property>
+                                    <child>
+                                      <widget class="GtkImage" id="image2">
+                                        <property name="visible">True</property>
+                                        <property name="stock">gtk-dialog-error</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label_button_cancel">
+                                        <property name="visible">True</property>
+                                        <property name="label">_Cancel</property>
+                                        <property name="use_underline">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
@@ -638,101 +672,14 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkHBox" id="hbox27">
+                      <widget class="GtkHBox" id="hbox_package">
                         <property name="visible">True</property>
                         <property name="spacing">5</property>
                         <child>
-                          <widget class="GtkButton" id="button_install">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="response_id">0</property>
-                            <child>
-                              <widget class="GtkAlignment" id="alignment24">
-                                <property name="visible">True</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <widget class="GtkHBox" id="hbox28">
-                                    <property name="visible">True</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <widget class="GtkImage" id="image5">
-                                        <property name="visible">True</property>
-                                        <property name="stock">gtk-floppy</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkLabel" id="label35">
-                                        <property name="visible">True</property>
-                                        <property name="label" translatable="yes">_Install</property>
-                                        <property name="use_underline">True</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </widget>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                         <child>
-                          <widget class="GtkButton" id="button_remove">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="response_id">0</property>
-                            <child>
-                              <widget class="GtkAlignment" id="alignment25">
-                                <property name="visible">True</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <widget class="GtkHBox" id="hbox29">
-                                    <property name="visible">True</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <widget class="GtkImage" id="image6">
-                                        <property name="visible">True</property>
-                                        <property name="stock">gtk-dialog-error</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkLabel" id="label36">
-                                        <property name="visible">True</property>
-                                        <property name="label" translatable="yes">_Remove</property>
-                                        <property name="use_underline">True</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </widget>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                         <child>
                           <widget class="GtkButton" id="button_homepage">

Modified: trunk/data/pk-transactions.glade
==============================================================================
--- trunk/data/pk-transactions.glade	(original)
+++ trunk/data/pk-transactions.glade	Mon Mar 24 22:28:59 2008
@@ -4,7 +4,7 @@
 <glade-interface>
   <widget class="GtkWindow" id="window_transactions">
     <property name="visible">True</property>
-    <property name="title" translatable="yes">Transaction Viewer</property>
+    <property name="title" translatable="yes">Update History</property>
     <property name="modal">True</property>
     <property name="window_position">GTK_WIN_POS_CENTER</property>
     <property name="icon_name">gtk-info</property>
@@ -79,7 +79,7 @@
           </widget>
         </child>
         <child>
-          <widget class="GtkHButtonBox" id="hbuttonbox1">
+          <widget class="GtkHButtonBox" id="buttonbox">
             <property name="visible">True</property>
             <property name="spacing">5</property>
             <property name="layout_style">GTK_BUTTONBOX_END</property>
@@ -94,50 +94,7 @@
               </widget>
             </child>
             <child>
-              <widget class="GtkButton" id="button_rollback">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="response_id">0</property>
-                <child>
-                  <widget class="GtkAlignment" id="alignment5">
-                    <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <widget class="GtkHBox" id="hbox1">
-                        <property name="visible">True</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <widget class="GtkImage" id="image1">
-                            <property name="visible">True</property>
-                            <property name="stock">gtk-go-back</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="GtkLabel" id="label10">
-                            <property name="visible">True</property>
-                            <property name="label">_Rollback</property>
-                            <property name="use_underline">True</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </widget>
-                    </child>
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
               <widget class="GtkButton" id="button_close">

Modified: trunk/data/pk-update-viewer.glade
==============================================================================
--- trunk/data/pk-update-viewer.glade	(original)
+++ trunk/data/pk-update-viewer.glade	Mon Mar 24 22:28:59 2008
@@ -92,19 +92,13 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkAlignment" id="alignment3">
+                      <widget class="GtkAlignment" id="alignment_refresh">
                         <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_refresh">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="label" translatable="yes">Refresh</property>
-                            <property name="response_id">0</property>
-                          </widget>
+                          <placeholder/>
                         </child>
                       </widget>
                       <packing>
@@ -168,7 +162,7 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkHButtonBox" id="hbuttonbox1">
+                  <widget class="GtkHButtonBox" id="buttonbox_overview">
                     <property name="visible">True</property>
                     <property name="spacing">6</property>
                     <property name="layout_style">GTK_BUTTONBOX_END</property>
@@ -185,50 +179,7 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="button_apply2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="can_default">True</property>
-                        <property name="response_id">0</property>
-                        <child>
-                          <widget class="GtkAlignment" id="alignment8">
-                            <property name="visible">True</property>
-                            <property name="xscale">0</property>
-                            <property name="yscale">0</property>
-                            <child>
-                              <widget class="GtkHBox" id="hbox11">
-                                <property name="visible">True</property>
-                                <property name="spacing">2</property>
-                                <child>
-                                  <widget class="GtkImage" id="image10">
-                                    <property name="visible">True</property>
-                                    <property name="stock">gtk-apply</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label19">
-                                    <property name="visible">True</property>
-                                    <property name="label">_Update System</property>
-                                    <property name="use_underline">True</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="position">1</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                     <child>
                       <widget class="GtkButton" id="button_review">
@@ -383,7 +334,7 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkHButtonBox" id="hbuttonbox3">
+                  <widget class="GtkHButtonBox" id="buttonbox_review">
                     <property name="visible">True</property>
                     <property name="spacing">6</property>
                     <property name="layout_style">GTK_BUTTONBOX_END</property>
@@ -446,50 +397,7 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="button_apply">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="can_default">True</property>
-                        <property name="response_id">0</property>
-                        <child>
-                          <widget class="GtkAlignment" id="alignment4">
-                            <property name="visible">True</property>
-                            <property name="xscale">0</property>
-                            <property name="yscale">0</property>
-                            <child>
-                              <widget class="GtkHBox" id="hbox6">
-                                <property name="visible">True</property>
-                                <property name="spacing">2</property>
-                                <child>
-                                  <widget class="GtkImage" id="image5">
-                                    <property name="visible">True</property>
-                                    <property name="stock">gtk-apply</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label13">
-                                    <property name="visible">True</property>
-                                    <property name="label" translatable="yes">_Apply Updates</property>
-                                    <property name="use_underline">True</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="position">2</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                     <child>
                       <widget class="GtkButton" id="button_close2">
@@ -757,7 +665,7 @@
                   </widget>
                 </child>
                 <child>
-                  <widget class="GtkHButtonBox" id="hbuttonbox5">
+                  <widget class="GtkHButtonBox" id="buttonbox_confirm">
                     <property name="visible">True</property>
                     <property name="spacing">6</property>
                     <property name="layout_style">GTK_BUTTONBOX_END</property>
@@ -774,50 +682,7 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="button_restart">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="can_default">True</property>
-                        <property name="response_id">0</property>
-                        <child>
-                          <widget class="GtkAlignment" id="alignment11">
-                            <property name="visible">True</property>
-                            <property name="xscale">0</property>
-                            <property name="yscale">0</property>
-                            <child>
-                              <widget class="GtkHBox" id="hbox13">
-                                <property name="visible">True</property>
-                                <property name="spacing">2</property>
-                                <child>
-                                  <widget class="GtkImage" id="image12">
-                                    <property name="visible">True</property>
-                                    <property name="stock">gtk-refresh</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label14">
-                                    <property name="visible">True</property>
-                                    <property name="label" translatable="yes">_Restart computer now</property>
-                                    <property name="use_underline">True</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="position">1</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                     <child>
                       <widget class="GtkButton" id="button_close4">

Modified: trunk/src/pk-application.c
==============================================================================
--- trunk/src/pk-application.c	(original)
+++ trunk/src/pk-application.c	Mon Mar 24 22:28:59 2008
@@ -31,6 +31,8 @@
 #include <math.h>
 #include <string.h>
 
+#include <polkit-gnome/polkit-gnome.h>
+
 #include <pk-debug.h>
 #include <pk-client.h>
 #include <pk-common.h>
@@ -78,8 +80,11 @@
 	PkEnumList		*filter_list;
 	PkEnumList		*group_list;
 	PkEnumList		*current_filter;
-	gboolean		 search_in_progress;
+	gboolean		 has_package; /* if we got a package in the search */
 	PkSearchType		 search_type;
+	PolKitGnomeAction	*install_action;
+	PolKitGnomeAction	*remove_action;
+	PolKitGnomeAction	*refresh_action;
 };
 
 enum {
@@ -173,8 +178,8 @@
  * pk_application_install_cb:
  **/
 static void
-pk_application_install_cb (GtkWidget      *widget,
-		           PkApplication  *application)
+pk_application_install_cb (PolKitGnomeAction *action,
+		           PkApplication     *application)
 {
 	gboolean ret;
 
@@ -301,8 +306,8 @@
  * pk_application_remove_cb:
  **/
 static void
-pk_application_remove_cb (GtkWidget      *widget,
-		          PkApplication  *application)
+pk_application_remove_cb (PolKitGnomeAction *action,
+		          PkApplication     *application)
 {
 	PkClient *client;
 
@@ -451,6 +456,9 @@
 		return;
 	}
 
+	/* mark as got so we don't warn */
+	application->priv->has_package = TRUE;
+
 	/* get convenience object */
 	eobj = pk_extra_obj_new_from_package_id_summary (package_id, summary);
 
@@ -524,7 +532,7 @@
  * pk_application_finished_cb:
  **/
 static void
-pk_application_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, PkApplication *application)
+pk_application_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, PkApplication *application)
 {
 	GtkWidget *widget;
 	gboolean ret;
@@ -549,30 +557,39 @@
 		g_free (text);
 	}
 
-	/* hide widget */
-	pk_statusbar_hide (application->priv->statusbar);
-
-	/* Correct text on button */
-	if (application->priv->search_in_progress == TRUE) {
-		widget = glade_xml_get_widget (application->priv->glade_xml, "label_button_find");
-		gtk_label_set_label (GTK_LABEL (widget), _("Find"));
+	if (role == PK_ROLE_ENUM_SEARCH_NAME ||
+	    role == PK_ROLE_ENUM_SEARCH_DETAILS ||
+	    role == PK_ROLE_ENUM_SEARCH_GROUP) {
 
+		/* switch round buttons */
 		widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
-		gtk_widget_set_tooltip_text (widget, _("Find packages"));
+		gtk_widget_show (widget);
+		widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
+		gtk_widget_hide (widget);
 
-		application->priv->search_in_progress = FALSE;
-	} else {
-		/* do we need to update the search? */
-		if (role == PK_ROLE_ENUM_INSTALL_PACKAGE ||
-		    role == PK_ROLE_ENUM_REMOVE_PACKAGE) {
-			/* refresh the search as the items may have changed */
-			gtk_list_store_clear (application->priv->packages_store);
-			application->priv->search_in_progress = TRUE;
-			ret = pk_client_requeue (application->priv->client_search, NULL);
-			if (ret == FALSE) {
-				application->priv->search_in_progress = FALSE;
-				pk_warning ("failed to requeue the search");
-			}
+		/* were there no entries found? */
+		if (exit == PK_EXIT_ENUM_SUCCESS && !application->priv->has_package) {
+			GtkTreeIter iter;
+			gtk_list_store_append (application->priv->packages_store, &iter);
+			gtk_list_store_set (application->priv->packages_store, &iter,
+					    PACKAGES_COLUMN_INSTALLED, FALSE,
+					    PACKAGES_COLUMN_TEXT, _("No results were found"),
+					    PACKAGES_COLUMN_IMAGE, "search",
+					    -1);
+		}
+	}
+
+	/* hide widget */
+	pk_statusbar_hide (application->priv->statusbar);
+
+	/* do we need to update the search? */
+	if (role == PK_ROLE_ENUM_INSTALL_PACKAGE ||
+	    role == PK_ROLE_ENUM_REMOVE_PACKAGE) {
+		/* refresh the search as the items may have changed */
+		gtk_list_store_clear (application->priv->packages_store);
+		ret = pk_client_requeue (application->priv->client_search, NULL);
+		if (ret == FALSE) {
+			pk_warning ("failed to requeue the search");
 		}
 	}
 }
@@ -592,27 +609,44 @@
 }
 
 /**
+ * pk_application_cancel_cb:
+ **/
+static void
+pk_application_cancel_cb (GtkWidget *button_widget, PkApplication *application)
+{
+	GtkWidget *widget;
+	gboolean ret;
+
+	g_return_if_fail (application != NULL);
+	g_return_if_fail (PK_IS_APPLICATION (application));
+
+	ret = pk_client_cancel (application->priv->client_search, NULL);
+	pk_debug ("canceled? %i", ret);
+
+	/* switch buttons around */
+	if (ret) {
+		widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
+		gtk_widget_show (widget);
+		widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
+		gtk_widget_hide (widget);
+	}
+}
+
+/**
  * pk_application_find_cb:
  **/
 static void
-pk_application_find_cb (GtkWidget	*button_widget,
-		        PkApplication	*application)
+pk_application_find_cb (GtkWidget *button_widget, PkApplication *application)
 {
 	GtkWidget *widget;
 	const gchar *package;
 	gchar *filter_all;
+	GError *error = NULL;
 	gboolean ret;
 
 	g_return_if_fail (application != NULL);
 	g_return_if_fail (PK_IS_APPLICATION (application));
 
-	if (application->priv->search_in_progress == TRUE) {
-		pk_debug ("trying to cancel task...");
-		ret = pk_client_cancel (application->priv->client_search, NULL);
-		pk_warning ("canceled? %i", ret);
-		return;
-	}
-
 	widget = glade_xml_get_widget (application->priv->glade_xml, "entry_text");
 	package = gtk_entry_get_text (GTK_ENTRY (widget));
 	ret = pk_strvalidate (package);
@@ -632,15 +666,15 @@
 	if (application->priv->search_type == PK_SEARCH_NAME) {
 		pk_client_reset (application->priv->client_search, NULL);
 		pk_client_set_name_filter (application->priv->client_search, TRUE, NULL);
-		ret = pk_client_search_name (application->priv->client_search, filter_all, package, NULL);
+		ret = pk_client_search_name (application->priv->client_search, filter_all, package, &error);
 	} else if (application->priv->search_type == PK_SEARCH_DETAILS) {
 		pk_client_reset (application->priv->client_search, NULL);
 		pk_client_set_name_filter (application->priv->client_search, TRUE, NULL);
-		ret = pk_client_search_details (application->priv->client_search, filter_all, package, NULL);
+		ret = pk_client_search_details (application->priv->client_search, filter_all, package, &error);
 	} else if (application->priv->search_type == PK_SEARCH_FILE) {
 		pk_client_reset (application->priv->client_search, NULL);
 		pk_client_set_name_filter (application->priv->client_search, TRUE, NULL);
-		ret = pk_client_search_file (application->priv->client_search, filter_all, package, NULL);
+		ret = pk_client_search_file (application->priv->client_search, filter_all, package, &error);
 	} else {
 		pk_warning ("invalid search type");
 		return;
@@ -648,24 +682,26 @@
 
 	if (ret == FALSE) {
 		pk_application_error_message (application,
-					      _("The search could not be completed"), NULL);
+					      _("The search could not be completed"), error->message);
+		g_error_free (error);
 		return;
 	}
 
 	/* clear existing list */
 	gtk_list_store_clear (application->priv->packages_store);
-
-	application->priv->search_in_progress = TRUE;
+	application->priv->has_package = FALSE;
 
 	/* hide details */
 	widget = glade_xml_get_widget (application->priv->glade_xml, "vbox_description_pane");
 	gtk_widget_hide (widget);
 
-	widget = glade_xml_get_widget (application->priv->glade_xml, "label_button_find");
-	gtk_label_set_label (GTK_LABEL (widget), _("Cancel"));
-
+	/* switch around buttons */
 	widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
-	gtk_widget_set_tooltip_text (widget, _("Cancel search"));
+	gtk_widget_hide (widget);
+	if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_CANCEL)) {
+		widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
+		gtk_widget_show (widget);
+	}
 
 	g_free (filter_all);
 }
@@ -721,7 +757,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) == TRUE) {
+	if (pk_enum_list_contains (application->priv->role_list, 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);
@@ -731,7 +767,7 @@
 	valid = pk_strvalidate (package);
 
 	widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
-	if (valid == FALSE || pk_strzero (package) == TRUE) {
+	if (valid == FALSE || pk_strzero (package)) {
 		gtk_widget_set_sensitive (widget, FALSE);
 	} else {
 		gtk_widget_set_sensitive (widget, TRUE);
@@ -796,6 +832,7 @@
 	gboolean ret;
 	gchar *filter;
 	gchar *id;
+	GError *error = NULL;
 
 	g_return_if_fail (application != NULL);
 	g_return_if_fail (PK_IS_APPLICATION (application));
@@ -819,12 +856,21 @@
 		/* cancel this, we don't care about old results that are pending */
 		pk_client_cancel (application->priv->client_search, NULL);
 		pk_client_reset (application->priv->client_search, NULL);
-		ret = pk_client_search_group (application->priv->client_search, filter, id, NULL);
+		ret = pk_client_search_group (application->priv->client_search, filter, id, &error);
 		g_free (filter);
 		/* ick, we failed so pretend we didn't do the action */
-		if (ret == FALSE) {
+		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)) {
+				widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
+				gtk_widget_show (widget);
+			}
+		} else {
 			pk_application_error_message (application,
-						      _("The group could not be queried"), NULL);
+						      _("The group could not be queried"), error->message);
+			g_error_free (error);
 		}
 	}
 }
@@ -992,19 +1038,17 @@
 		g_free (package_id);
 		pk_debug ("selected row is: %i %s", installed, application->priv->package);
 
-		widget = glade_xml_get_widget (application->priv->glade_xml, "button_install");
 		if (installed == FALSE &&
-		    pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_INSTALL_PACKAGE) == TRUE) {
-			gtk_widget_show (widget);
+		    pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_INSTALL_PACKAGE)) {
+			polkit_gnome_action_set_visible (application->priv->install_action, TRUE);
 		} else {
-			gtk_widget_hide (widget);
+			polkit_gnome_action_set_visible (application->priv->install_action, FALSE);
 		}
-		widget = glade_xml_get_widget (application->priv->glade_xml, "button_remove");
-		if (installed == TRUE &&
-		    pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_REMOVE_PACKAGE) == TRUE) {
-			gtk_widget_show (widget);
+		if (installed &&
+		    pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_REMOVE_PACKAGE)) {
+			polkit_gnome_action_set_visible (application->priv->remove_action, TRUE);
 		} else {
-			gtk_widget_hide (widget);
+			polkit_gnome_action_set_visible (application->priv->remove_action, FALSE);
 		}
 
 		/* refresh */
@@ -1014,10 +1058,8 @@
 
 	} else {
 		pk_debug ("no row selected");
-		widget = glade_xml_get_widget (application->priv->glade_xml, "button_install");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (application->priv->glade_xml, "button_remove");
-		gtk_widget_hide (widget);
+		polkit_gnome_action_set_visible (application->priv->install_action, FALSE);
+		polkit_gnome_action_set_visible (application->priv->remove_action, FALSE);
 		widget = glade_xml_get_widget (application->priv->glade_xml, "button_homepage");
 		gtk_widget_hide (widget);
 		widget = glade_xml_get_widget (application->priv->glade_xml, "hbox_filesize");
@@ -1065,7 +1107,7 @@
 				     gchar *string1, gchar *string2,
 				     gint int1, gint int2, gpointer user_data)
 {
-	if (pk_strequal (name, "entry_text") == TRUE) {
+	if (pk_strequal (name, "entry_text")) {
 		pk_debug ("creating sexy icon=%s", name);
 		return sexy_icon_entry_new ();
 	}
@@ -1176,7 +1218,7 @@
 	}
 	pk_debug ("icon_pos=%i", icon_pos);
 
-	if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_NAME) == TRUE) {
+	if (pk_enum_list_contains (application->priv->role_list, 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);
@@ -1185,7 +1227,7 @@
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
-	if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_DETAILS) == TRUE) {
+	if (pk_enum_list_contains (application->priv->role_list, 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);
@@ -1194,7 +1236,7 @@
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
-	if (pk_enum_list_contains (application->priv->role_list, PK_ROLE_ENUM_SEARCH_FILE) == TRUE) {
+	if (pk_enum_list_contains (application->priv->role_list, 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);
@@ -1491,11 +1533,14 @@
 	guint page;
 	guint i;
 	gboolean ret;
+	PolKitAction *pk_action;
+	GtkWidget *button;
+	GtkWidget *item;
 
 	application->priv = PK_APPLICATION_GET_PRIVATE (application);
 	application->priv->package = NULL;
 	application->priv->url = NULL;
-	application->priv->search_in_progress = FALSE;
+	application->priv->has_package = FALSE;
 	application->priv->gconf_client = gconf_client_get_default ();
 
 	application->priv->search_type = PK_SEARCH_UNKNOWN;
@@ -1588,15 +1633,46 @@
 	g_signal_connect (main_window, "delete_event",
 			  G_CALLBACK (pk_application_delete_event_cb), application);
 
-	widget = glade_xml_get_widget (application->priv->glade_xml, "button_install");
-	g_signal_connect (widget, "clicked",
+	widget = glade_xml_get_widget (application->priv->glade_xml, "hbox_package");
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.install");
+	application->priv->install_action = polkit_gnome_action_new_default ("install",
+									     pk_action,
+									     _("_Install"),
+									     _("Install selected package"));
+	g_object_set (application->priv->install_action,
+		      "no-icon-name", GTK_STOCK_FLOPPY,
+		      "auth-icon-name", GTK_STOCK_FLOPPY,
+		      "yes-icon-name", GTK_STOCK_FLOPPY,
+		      "self-blocked-icon-name", GTK_STOCK_FLOPPY,
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (application->priv->install_action, "activate",
 			  G_CALLBACK (pk_application_install_cb), application);
-	gtk_widget_set_tooltip_text (widget, _("Install selected package"));
+        button = polkit_gnome_action_create_button (application->priv->install_action);
 
-	widget = glade_xml_get_widget (application->priv->glade_xml, "button_remove");
-	g_signal_connect (widget, "clicked",
+	gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (widget), button, 0);
+
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.remove");
+	application->priv->remove_action = polkit_gnome_action_new_default ("remove",
+									    pk_action,
+									    _("_Remove"),
+									    _("Remove selected package"));
+	g_object_set (application->priv->remove_action,
+		      "no-icon-name", GTK_STOCK_DIALOG_ERROR,
+		      "auth-icon-name", GTK_STOCK_DIALOG_ERROR,
+		      "yes-icon-name", GTK_STOCK_DIALOG_ERROR,
+		      "self-blocked-icon-name", GTK_STOCK_DIALOG_ERROR,
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (application->priv->remove_action, "activate",
 			  G_CALLBACK (pk_application_remove_cb), application);
-	gtk_widget_set_tooltip_text (widget, _("Remove selected package"));
+        button = polkit_gnome_action_create_button (application->priv->remove_action);
+
+	gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (widget), button, 1);
 
 	widget = glade_xml_get_widget (application->priv->glade_xml, "button_homepage");
 	g_signal_connect (widget, "clicked",
@@ -1607,9 +1683,25 @@
 	g_signal_connect (widget, "activate",
 			  G_CALLBACK (pk_application_menu_about_cb), application);
 
-	widget = glade_xml_get_widget (application->priv->glade_xml, "imagemenuitem_refresh");
-	g_signal_connect (widget, "activate",
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
+	application->priv->refresh_action = polkit_gnome_action_new_default ("refresh",
+									     pk_action,
+									     _("_Refresh application lists"),
+									     NULL);
+	g_object_set (application->priv->refresh_action,
+		      "no-icon-name", "gtk-redo-ltr",
+		      "auth-icon-name", "gtk-redo-ltr",
+		      "yes-icon-name", "gtk-redo-ltr",
+		      "self-blocked-icon-name", "gtk-redo-ltr",
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (application->priv->refresh_action, "activate",
 			  G_CALLBACK (pk_application_menu_refresh_cb), application);
+	item = gtk_action_create_menu_item (GTK_ACTION (application->priv->refresh_action));
+
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menu_system");
+	gtk_menu_shell_prepend (GTK_MENU_SHELL (widget), item);
 
 	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_sources");
 	g_signal_connect (widget, "activate",
@@ -1631,35 +1723,35 @@
 			  G_CALLBACK (pk_application_menu_filter_installed_cb), application);
 
 	/* devel filter */
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_yes");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_devel_yes");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_devel_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_no");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_devel_no");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_devel_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_both");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_devel_both");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_devel_cb), application);
 
 	/* gui filter */
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_yes");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_gui_yes");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_gui_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_no");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_gui_no");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_gui_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_both");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_gui_both");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_gui_cb), application);
 
 	/* free filter */
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_yes");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_free_yes");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_free_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_no");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_free_no");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_free_cb), application);
-	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_installed_both");
+	widget = glade_xml_get_widget (application->priv->glade_xml, "menuitem_free_both");
 	g_signal_connect (widget, "toggled",
 			  G_CALLBACK (pk_application_menu_filter_free_cb), application);
 
@@ -1728,12 +1820,19 @@
 			  G_CALLBACK (pk_application_find_cb), application);
 	gtk_widget_set_tooltip_text (widget, _("Find packages"));
 
+	/* cancel button */
+	widget = glade_xml_get_widget (application->priv->glade_xml, "button_cancel");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (pk_application_cancel_cb), application);
+	gtk_widget_set_tooltip_text (widget, _("Cancel search"));
+	gtk_widget_hide (widget);
+
 	/* the fancy text entry widget */
 	widget = glade_xml_get_widget (application->priv->glade_xml, "entry_text");
 
 	/* autocompletion can be turned off as it's slow */
 	autocomplete = gconf_client_get_bool (application->priv->gconf_client, PK_CONF_AUTOCOMPLETE, NULL);
-	if (autocomplete == TRUE) {
+	if (autocomplete) {
 		/* create the completion object */
 		completion = gtk_entry_completion_new ();
 
@@ -1841,7 +1940,7 @@
 	pk_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) == TRUE) {
+	if (pk_enum_list_contains (application->priv->role_list, 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));
@@ -1892,6 +1991,9 @@
 	g_object_unref (application->priv->statusbar);
 	g_object_unref (application->priv->extra);
 	g_object_unref (application->priv->gconf_client);
+	g_object_unref (application->priv->install_action);
+	g_object_unref (application->priv->remove_action);
+	g_object_unref (application->priv->refresh_action);
 
 	g_free (application->priv->url);
 	g_free (application->priv->package);

Modified: trunk/src/pk-auto-refresh.c
==============================================================================
--- trunk/src/pk-auto-refresh.c	(original)
+++ trunk/src/pk-auto-refresh.c	Mon Mar 24 22:28:59 2008
@@ -200,7 +200,7 @@
 	g_return_val_if_fail (PK_IS_AUTO_REFRESH (arefresh), FALSE);
 
 	/* not on battery */
-	if (arefresh->priv->on_battery == TRUE) {
+	if (arefresh->priv->on_battery) {
 		pk_debug ("not when on battery");
 		return FALSE;
 	}
@@ -442,7 +442,7 @@
 		printf ("DEBUG: ERROR: %s\n", error->message);
 		g_error_free (error);
 	}
-	if (ret == TRUE) {
+	if (ret) {
 		arefresh->priv->on_battery = on_battery;
 		pk_debug ("setting on battery %i", on_battery);
 	}
@@ -538,7 +538,7 @@
 	arefresh->priv->network = pk_network_new ();
 	g_signal_connect (arefresh->priv->network, "online",
 			  G_CALLBACK (pk_auto_refresh_network_changed_cb), arefresh);
-	if (pk_network_is_online (arefresh->priv->network) == TRUE) {
+	if (pk_network_is_online (arefresh->priv->network)) {
 		arefresh->priv->network_active = TRUE;
 	}
 

Modified: trunk/src/pk-cell-renderer-uri.c
==============================================================================
--- trunk/src/pk-cell-renderer-uri.c	(original)
+++ trunk/src/pk-cell-renderer-uri.c	Mon Mar 24 22:28:59 2008
@@ -133,7 +133,7 @@
 	if (cru->uri == NULL) {
 		g_object_set (G_OBJECT (cell), "foreground", "#000000", NULL);
 		g_object_set (G_OBJECT (cru), "underline", PANGO_UNDERLINE_NONE, NULL);
-	} else if (cru->clicked == TRUE) {
+	} else if (cru->clicked) {
 		g_object_set (G_OBJECT (cell), "foreground", "#840084", NULL);
 		g_object_set (G_OBJECT (cru), "underline", PANGO_UNDERLINE_SINGLE, NULL);
 	} else {

Modified: trunk/src/pk-common-gui.c
==============================================================================
--- trunk/src/pk-common-gui.c	(original)
+++ trunk/src/pk-common-gui.c	Mon Mar 24 22:28:59 2008
@@ -25,9 +25,12 @@
 #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>
@@ -154,39 +157,124 @@
 	{0, NULL}
 };
 
-/**
- * pk_restart_system:
- **/
+static gboolean
+try_system_restart (DBusGProxy  *proxy,
+		    GError     **error)
+{
+	return dbus_g_proxy_call_with_timeout (proxy,
+					      "Restart",
+					      INT_MAX,
+					      error,
+					      /* parameters: */
+					      G_TYPE_INVALID,
+					      /* return values: */
+					      G_TYPE_INVALID);
+}
+
+static PolKitAction *
+get_action_from_error (GError *error)
+{
+	PolKitAction *action;
+	const char   *paction;
+
+	action = polkit_action_new ();
+
+	paction = NULL;
+	if (g_str_has_prefix (error->message, "Not privileged for action: ")) {
+		paction = error->message + strlen ("Not privileged for action: ");
+	}
+	polkit_action_set_action_id (action, paction);
+
+	return action;
+}
+
+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);
+}
+
 gboolean
 pk_restart_system (void)
 {
 	DBusGProxy *proxy;
-	DBusGConnection	*connection;
+	DBusGConnection *connection;
 	GError *error = NULL;
 	gboolean ret;
+	PolKitAction *action;
 
 	/* check dbus connections, exit if not valid */
-	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (error != NULL) {
-		pk_warning ("cannot acccess the session bus: %s", error->message);
+		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, GPM_DBUS_SERVICE, GPM_DBUS_PATH, GPM_DBUS_INTERFACE);
+	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 gnome-power-manager");
+		pk_warning ("Cannot connect to ConsoleKit");
 		return FALSE;
 	}
 
 	/* do the method */
-	ret = dbus_g_proxy_call (proxy, "Reboot", &error, G_TYPE_INVALID, G_TYPE_INVALID);
+	ret = try_system_restart (proxy, &error);
 	if (!ret) {
-		pk_warning ("cannot reboot: %s", error->message);
-		g_error_free (error);
+		if (dbus_g_error_has_name (error, "org.freedesktop.ConsoleKit.Manager.NotPrivileged")) {
+			action = get_action_from_error (error);
+			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;
 }
 
@@ -255,7 +343,7 @@
 	gchar *text;
 	GString *string;
 
-	if (pk_strzero (package_id) == TRUE) {
+	if (pk_strzero (package_id)) {
 		return g_strdup (_("Package identifier not valid"));
 	}
 
@@ -291,13 +379,13 @@
 	PkPackageId *ident;
 	gchar *text;
 
-	if (pk_strzero (package_id) == TRUE) {
+	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 (pk_strzero (summary) == TRUE) {
+	if (pk_strzero (summary)) {
 		/* just have name */
 		text = g_strdup (ident->name);
 	} else {
@@ -318,7 +406,7 @@
 	gchar *text;
 	GString *string;
 
-	if (pk_strzero (package_id) == TRUE) {
+	if (pk_strzero (package_id)) {
 		return g_strdup (_("Package identifier not valid"));
 	}
 
@@ -344,7 +432,7 @@
 	PkPackageId *ident;
 
 	/* not set! */
-	if (pk_strzero (package_id) == TRUE) {
+	if (pk_strzero (package_id)) {
 		pk_warning ("package_id blank, returning 'unknown'");
 		return g_strdup ("Package identifier not valid");
 	}
@@ -372,7 +460,7 @@
 	gboolean ret = TRUE;
 
 	/* trivial case */
-	if (pk_strzero (icon) == TRUE) {
+	if (pk_strzero (icon)) {
 		return FALSE;
 	}
 

Modified: trunk/src/pk-install-package.c
==============================================================================
--- trunk/src/pk-install-package.c	(original)
+++ trunk/src/pk-install-package.c	Mon Mar 24 22:28:59 2008
@@ -75,7 +75,7 @@
 	g_object_unref (client);
 
 	/* did we resolve? */
-	if (pk_strzero (package) == TRUE) {
+	if (pk_strzero (package)) {
 		pk_error_modal_dialog (_("Failed to resolve"),
 				       _("The package could not be found on the system"));
 		g_main_loop_quit (loop);
@@ -158,7 +158,7 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version == TRUE) {
+	if (program_version) {
 		g_print (VERSION "\n");
 		return 0;
 	}

Modified: trunk/src/pk-notify.c
==============================================================================
--- trunk/src/pk-notify.c	(original)
+++ trunk/src/pk-notify.c	Mon Mar 24 22:28:59 2008
@@ -145,7 +145,7 @@
 	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
 	g_free (cmdline);
 
-	if (ret == TRUE)
+	if (ret)
 		goto out;
 
 	g_error_free (error);
@@ -390,18 +390,23 @@
 pk_notify_update_system (PkNotify *notify)
 {
 	gboolean ret;
+	GError *error = NULL;
+	gchar *message;
 
 	g_return_val_if_fail (notify != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_NOTIFY (notify), FALSE);
 
 	pk_debug ("install updates");
-	ret = pk_client_update_system (notify->priv->client_update_system, NULL);
-	if (ret == TRUE) {
+	ret = pk_client_update_system (notify->priv->client_update_system, &error);
+	if (ret) {
 		pk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
 	} else {
-		pk_warning ("failed to update system");
-		pk_smart_icon_notify_new (notify->priv->sicon, _("Failed to update system"), _("Client action was refused"),
+		pk_warning ("failed to update system: %s", error->message);
+		message = g_strdup_printf (_("Client action was refused: %s"), error->message);
+		g_error_free (error);
+		pk_smart_icon_notify_new (notify->priv->sicon, _("Failed to update system"), message,
 				      "process-stop", PK_NOTIFY_URGENCY_LOW, PK_NOTIFY_TIMEOUT_SHORT);
+		g_free (message);
 		pk_smart_icon_notify_button (notify->priv->sicon, PK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, PK_CONF_NOTIFY_ERROR);
 		pk_smart_icon_notify_show (notify->priv->sicon);
 	}
@@ -762,7 +767,7 @@
 	if (update == PK_UPDATE_ENUM_ALL) {
 		pk_debug ("we should do the update automatically!");
 		ret = pk_notify_update_system (notify);
-		if (ret == TRUE) {
+		if (ret) {
 			pk_notify_auto_update_message (notify);
 		} else {
 			pk_warning ("update failed");
@@ -817,7 +822,7 @@
 	g_return_val_if_fail (notify != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_NOTIFY (notify), FALSE);
 
-	if (pk_task_list_contains_role (notify->priv->tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) == TRUE) {
+	if (pk_task_list_contains_role (notify->priv->tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
 		pk_debug ("Not checking for updates as already in progress");
 		return FALSE;
 	}
@@ -871,12 +876,12 @@
 	g_return_val_if_fail (PK_IS_NOTIFY (notify), FALSE);
 
 	/* got a cache, no need to poll */
-	if (notify->priv->cache_okay == TRUE) {
+	if (notify->priv->cache_okay) {
 		return FALSE;
 	}
 
 	/* already in progress, but not yet certified okay */
-	if (notify->priv->cache_update_in_progress == TRUE) {
+	if (notify->priv->cache_update_in_progress) {
 		return TRUE;
 	}
 
@@ -919,7 +924,7 @@
 	g_return_if_fail (notify != NULL);
 	g_return_if_fail (PK_IS_NOTIFY (notify));
 	/* hide icon if we are updating */
-	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) == TRUE) {
+	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
 		pk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
 	}
 }

Modified: trunk/src/pk-prefs.c
==============================================================================
--- trunk/src/pk-prefs.c	(original)
+++ trunk/src/pk-prefs.c	Mon Mar 24 22:28:59 2008
@@ -318,7 +318,7 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version == TRUE) {
+	if (program_version) {
 		g_print (VERSION "\n");
 		return 0;
 	}

Modified: trunk/src/pk-progress.c
==============================================================================
--- trunk/src/pk-progress.c	(original)
+++ trunk/src/pk-progress.c	Mon Mar 24 22:28:59 2008
@@ -239,7 +239,7 @@
 	widget = glade_xml_get_widget (progress->priv->glade_xml, "hbox_percentage");
 	gtk_widget_show (widget);
 
-	if (progress->priv->task_ended == TRUE) {
+	if (progress->priv->task_ended) {
 		/* hide the box */
 		widget = glade_xml_get_widget (progress->priv->glade_xml, "hbox_percentage");
 		gtk_widget_hide (widget);
@@ -264,7 +264,7 @@
 	widget = glade_xml_get_widget (progress->priv->glade_xml, "hbox_subpercentage");
 	gtk_widget_show (widget);
 
-	if (progress->priv->task_ended == TRUE) {
+	if (progress->priv->task_ended) {
 		/* hide the box */
 		widget = glade_xml_get_widget (progress->priv->glade_xml, "hbox_subpercentage");
 		gtk_widget_hide (widget);
@@ -451,7 +451,7 @@
 	role_text = pk_role_enum_to_localised_present (role);
 
 	/* check to see if we have a package_id or just a search term */
-	if (pk_strzero (package_id) == TRUE) {
+	if (pk_strzero (package_id)) {
 		text = g_strdup (role_text);
 	} else if (pk_package_id_check (package_id) == FALSE) {
 		text = g_strdup_printf ("%s: %s", role_text, package_id);
@@ -504,7 +504,7 @@
 
 	/* coldplug */
 	ret = pk_client_get_progress (progress->priv->client, &percentage, &subpercentage, &elapsed, &remaining, NULL);
-	if (ret == TRUE) {
+	if (ret) {
 		pk_progress_progress_changed_cb (progress->priv->client, percentage,
 						 subpercentage, elapsed, remaining, progress);
 	} else {
@@ -516,7 +516,7 @@
 
 	/* do the best we can */
 	ret = pk_client_get_package (progress->priv->client, &text, NULL);
-	if (ret == TRUE) {
+	if (ret) {
 		pk_progress_package_cb (progress->priv->client, 0, text, NULL, progress);
 	}
 

Modified: trunk/src/pk-repo.c
==============================================================================
--- trunk/src/pk-repo.c	(original)
+++ trunk/src/pk-repo.c	Mon Mar 24 22:28:59 2008
@@ -243,7 +243,7 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version == TRUE) {
+	if (program_version) {
 		g_print (VERSION "\n");
 		return 0;
 	}
@@ -299,7 +299,7 @@
 	pk_treeview_add_columns (GTK_TREE_VIEW (widget));
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
 
-	if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REPO_LIST) == TRUE) {
+	if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REPO_LIST)) {
 		/* get the update list */
 		pk_client_get_repo_list (client, NULL);
 	} else {

Modified: trunk/src/pk-smart-icon.c
==============================================================================
--- trunk/src/pk-smart-icon.c	(original)
+++ trunk/src/pk-smart-icon.c	Mon Mar 24 22:28:59 2008
@@ -219,7 +219,7 @@
 		timeout_val = 15000;
 	}
 
-	if (gtk_status_icon_get_visible (sicon->priv->status_icon) == TRUE) {
+	if (gtk_status_icon_get_visible (sicon->priv->status_icon)) {
 		sicon->priv->dialog = notify_notification_new_with_status_icon (title, message, icon, sicon->priv->status_icon);
 	} else {
 		sicon->priv->dialog = notify_notification_new (title, message, icon, NULL);

Modified: trunk/src/pk-transaction-viewer.c
==============================================================================
--- trunk/src/pk-transaction-viewer.c	(original)
+++ trunk/src/pk-transaction-viewer.c	Mon Mar 24 22:28:59 2008
@@ -31,6 +31,8 @@
 #include <dbus/dbus-glib.h>
 #include <locale.h>
 
+#include <polkit-gnome/polkit-gnome.h>
+
 #include <pk-debug.h>
 #include <pk-client.h>
 #include <pk-connection.h>
@@ -46,6 +48,7 @@
 static PkClient *client = NULL;
 static gchar *transaction_id = NULL;
 static GHashTable *hash = NULL;
+static PolKitGnomeAction *rollback_action = NULL;
 
 enum
 {
@@ -77,7 +80,7 @@
  * pk_button_rollback_cb:
  **/
 static void
-pk_button_rollback_cb (GtkWidget *widget, gpointer data)
+pk_button_rollback_cb (PolKitGnomeAction *action, gpointer data)
 {
 	GMainLoop *loop = (GMainLoop *) data;
 	pk_client_rollback (client, transaction_id, NULL);
@@ -342,6 +345,8 @@
 	GtkTreeSelection *selection;
 	PkConnection *pconnection;
 	PkEnumList *role_list;
+	PolKitAction *pk_action;
+	GtkWidget *button;
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
@@ -418,9 +423,34 @@
 	widget = glade_xml_get_widget (glade_xml, "button_help");
 	g_signal_connect (widget, "clicked",
 			  G_CALLBACK (pk_button_help_cb), NULL);
-	widget = glade_xml_get_widget (glade_xml, "button_rollback");
-	g_signal_connect (widget, "clicked",
+	/* no help yet */
+	gtk_widget_hide (widget);
+
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.rollback");
+	rollback_action = polkit_gnome_action_new_default ("rollback",
+							   pk_action,
+							   _("_Rollback"),
+							   NULL);
+	g_object_set (rollback_action,
+		      "no-icon-name", "gtk-go-back-ltr",
+		      "auth-icon-name", "gtk-go-back-ltr",
+		      "yes-icon-name", "gtk-go-back-ltr",
+		      "self-blocked-icon-name", "gtk-go-back-ltr",
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (rollback_action, "activate",
 			  G_CALLBACK (pk_button_rollback_cb), loop);
+	button = polkit_gnome_action_create_button (rollback_action);
+	widget = glade_xml_get_widget (glade_xml, "buttonbox");
+        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) == TRUE) {
+		polkit_gnome_action_set_visible (rollback_action, TRUE);
+	} else {
+		polkit_gnome_action_set_visible (rollback_action, FALSE);
+	}
 
 	gtk_widget_set_size_request (main_window, 500, 300);
 
@@ -449,14 +479,6 @@
 	pk_treeview_add_details_columns (GTK_TREE_VIEW (widget));
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
 
-	/* hide the rollback button if we can't do the action */
-	widget = glade_xml_get_widget (glade_xml, "button_rollback");
-	if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_ROLLBACK) == TRUE) {
-		gtk_widget_show (widget);
-	} else {
-		gtk_widget_hide (widget);
-	}
-
 	/* get the update list */
 	pk_client_get_old_transactions (client, 0, NULL);
 	gtk_widget_show (main_window);

Modified: trunk/src/pk-update-icon.c
==============================================================================
--- trunk/src/pk-update-icon.c	(original)
+++ trunk/src/pk-update-icon.c	Mon Mar 24 22:28:59 2008
@@ -76,7 +76,7 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version == TRUE) {
+	if (program_version) {
 		g_print (VERSION "\n");
 		return 0;
 	}

Modified: trunk/src/pk-update-viewer.c
==============================================================================
--- trunk/src/pk-update-viewer.c	(original)
+++ trunk/src/pk-update-viewer.c	Mon Mar 24 22:28:59 2008
@@ -32,6 +32,8 @@
 #include <dbus/dbus-glib.h>
 #include <locale.h>
 
+#include <polkit-gnome/polkit-gnome.h>
+
 #include <pk-debug.h>
 #include <pk-client.h>
 #include <pk-common.h>
@@ -52,6 +54,11 @@
 static PkTaskList *tlist = NULL;
 static gchar *cached_package_id = NULL;
 
+static PolKitGnomeAction *refresh_action = NULL;
+static PolKitGnomeAction *update_system_action = NULL;
+static PolKitGnomeAction *update_package_action = NULL;
+static PolKitGnomeAction *restart_action = NULL;
+
 /* for the preview throbber */
 static void pk_updates_add_preview_item (PkClient *client, const gchar *icon, const gchar *message, gboolean clear);
 static void pk_updates_description_animation_stop (void);
@@ -429,30 +436,34 @@
  * pk_updates_refresh_cb:
  **/
 static void
-pk_updates_refresh_cb (GtkWidget *widget, gpointer data)
+pk_updates_refresh_cb (PolKitGnomeAction *action, gpointer data)
 {
 	gboolean ret;
+	GError *error;
+	GtkWidget *widget;
+
+	/* we can't click this if we havn't finished */
+	pk_client_reset (client, NULL);
+	error = NULL;
+	ret = pk_client_refresh_cache (client, TRUE, &error);
+	if (ret == FALSE) {
+		pk_error_modal_dialog (_("Failed to refresh"), error->message);
+		g_error_free (error);
+		return;
+	}
 
 	/* clear existing list */
 	pk_updates_preview_animation_start ();
 
 	/* make the refresh button non-clickable */
-	gtk_widget_set_sensitive (widget, FALSE);
+	polkit_gnome_action_set_sensitive (refresh_action, FALSE);
+	polkit_gnome_action_set_sensitive (update_system_action, FALSE);
 
 	/* make the buttons non-clickable until we get completion */
-	widget = glade_xml_get_widget (glade_xml, "button_apply2");
-	gtk_widget_set_sensitive (widget, FALSE);
 	widget = glade_xml_get_widget (glade_xml, "button_review");
 	gtk_widget_set_sensitive (widget, FALSE);
 	widget = glade_xml_get_widget (glade_xml, "button_history");
 	gtk_widget_set_sensitive (widget, FALSE);
-
-	/* we can't click this if we havn't finished */
-	pk_client_reset (client, NULL);
-	ret = pk_client_refresh_cache (client, TRUE, NULL);
-	if (ret == FALSE) {
-		pk_warning ("failed to refresh cache");
-	}
 }
 
 static void
@@ -601,6 +612,7 @@
 	tree_view = glade_xml_get_widget (glade_xml, "treeview_description");
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
 	gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
+	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (tree_view));
 }
 
 /**
@@ -950,7 +962,7 @@
 	gchar *markup;
 
 	/* clear existing list */
-	if (clear == TRUE) {
+	if (clear) {
 		gtk_list_store_clear (list_store_preview);
 	}
 
@@ -1065,14 +1077,12 @@
 	pk_updates_preview_animation_stop ();
 
 	/* make the buttons clickable again now we have completed */
-	widget = glade_xml_get_widget (glade_xml, "button_apply2");
-	gtk_widget_set_sensitive (widget, TRUE);
 	widget = glade_xml_get_widget (glade_xml, "button_review");
 	gtk_widget_set_sensitive (widget, TRUE);
-	widget = glade_xml_get_widget (glade_xml, "button_refresh");
-	gtk_widget_set_sensitive (widget, TRUE);
 	widget = glade_xml_get_widget (glade_xml, "button_history");
 	gtk_widget_set_sensitive (widget, TRUE);
+	polkit_gnome_action_set_sensitive (refresh_action, TRUE);
+	polkit_gnome_action_set_sensitive (update_system_action, TRUE);
 
 	/* hide the cancel */
 	if (role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
@@ -1089,10 +1099,7 @@
 				pk_debug ("showing reboot widgets");
 				widget = glade_xml_get_widget (glade_xml, "hbox_restart");
 				gtk_widget_show (widget);
-				widget = glade_xml_get_widget (glade_xml, "button_restart");
-				gtk_widget_show (widget);
-				g_signal_connect (widget, "clicked",
-						  G_CALLBACK (pk_updates_restart_cb), NULL);
+				polkit_gnome_action_set_visible (restart_action, TRUE);
 			}
 
 			/* set correct view */
@@ -1123,8 +1130,7 @@
 		/* if no updates then hide apply */
 		widget = glade_xml_get_widget (glade_xml, "button_review");
 		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "button_apply2");
-		gtk_widget_hide (widget);
+		polkit_gnome_action_set_visible (update_system_action, FALSE);
 	} else {
 
 		PkPackageItem *item;
@@ -1199,8 +1205,7 @@
 		/* set visible and sensitive */
 		widget = glade_xml_get_widget (glade_xml, "button_review");
 		gtk_widget_show (widget);
-		widget = glade_xml_get_widget (glade_xml, "button_apply2");
-		gtk_widget_show (widget);
+		polkit_gnome_action_set_visible (update_system_action, TRUE);
 	}
 }
 
@@ -1236,10 +1241,8 @@
 static void
 pk_updates_task_list_changed_cb (PkTaskList *tlist, gpointer data)
 {
-	GtkWidget *widget;
-
 	/* hide buttons if we are updating */
-	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) == TRUE) {
+	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
 		/* clear existing list */
 		gtk_list_store_clear (list_store_preview);
 
@@ -1247,10 +1250,8 @@
 		pk_updates_add_preview_item (client, "dialog-information", _("There is an update already in progress!"), TRUE);
 
 		/* if doing it then hide apply and refresh */
-		widget = glade_xml_get_widget (glade_xml, "button_apply");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "button_refresh");
-		gtk_widget_hide (widget);
+		polkit_gnome_action_set_visible (update_system_action, FALSE);
+		polkit_gnome_action_set_visible (refresh_action, FALSE);
 	}
 }
 
@@ -1323,6 +1324,8 @@
 	PkRoleEnum role;
 	gboolean ret;
 	GtkSizeGroup *size_group;
+	GtkWidget *button;
+	PolKitAction *pk_action;
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
@@ -1350,7 +1353,7 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version == TRUE) {
+	if (program_version) {
 		g_print (VERSION "\n");
 		return 0;
 	}
@@ -1409,8 +1412,28 @@
 	/* hide from finished page until we have updates */
 	widget = glade_xml_get_widget (glade_xml, "hbox_restart");
 	gtk_widget_hide (widget);
-	widget = glade_xml_get_widget (glade_xml, "button_restart");
-	gtk_widget_hide (widget);
+
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.consolekit.system.restart");
+	restart_action = polkit_gnome_action_new_default ("restart-system",
+							  pk_action,
+							  _("_Restart computer now"),
+							  NULL);
+	g_object_set (restart_action,
+		      "no-icon-name", GTK_STOCK_REFRESH,
+		      "auth-icon-name", GTK_STOCK_REFRESH,
+		      "yes-icon-name", GTK_STOCK_REFRESH,
+		      "self-blocked-icon-name", GTK_STOCK_REFRESH,
+		      "no-visible", FALSE,
+		      "master-visible", FALSE,
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (restart_action, "activate",
+			  G_CALLBACK (pk_updates_restart_cb), loop);
+	button = polkit_gnome_action_create_button (restart_action);
+	widget = glade_xml_get_widget (glade_xml, "buttonbox_confirm");
+	gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (widget), button, 1);
 
 	/* Get the main window quit */
 	g_signal_connect (main_window, "delete_event",
@@ -1452,23 +1475,64 @@
 			  G_CALLBACK (pk_button_overview_cb), loop);
 	gtk_widget_set_tooltip_text(widget, _("Back to overview"));
 
-	widget = glade_xml_get_widget (glade_xml, "button_apply");
-	g_signal_connect (widget, "clicked",
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-package");
+	update_package_action = polkit_gnome_action_new_default ("update-package",
+								pk_action,
+								_("_Apply Updates"),
+								_("Apply the selected updates"));
+	g_object_set (update_package_action,
+		      "no-icon-name", GTK_STOCK_APPLY,
+		      "auth-icon-name", GTK_STOCK_APPLY,
+		      "yes-icon-name", GTK_STOCK_APPLY,
+		      "self-blocked-icon-name", GTK_STOCK_APPLY,
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (update_package_action, "activate",
 			  G_CALLBACK (pk_updates_apply_cb), loop);
-	gtk_widget_set_tooltip_text(widget, _("Apply all updates"));
-
-	widget = glade_xml_get_widget (glade_xml, "button_apply2");
-	g_signal_connect (widget, "clicked",
+	button = polkit_gnome_action_create_button (update_package_action);
+	widget = glade_xml_get_widget (glade_xml, "buttonbox_review");
+	gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (widget), button, 2);
+
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.update-system");
+	update_system_action = polkit_gnome_action_new_default ("update-system",
+								pk_action,
+								_("_Update System"),
+								_("Apply all updates"));
+	g_object_set (update_system_action,
+		      "no-icon-name", GTK_STOCK_APPLY,
+		      "auth-icon-name", GTK_STOCK_APPLY,
+		      "yes-icon-name", GTK_STOCK_APPLY,
+		      "self-blocked-icon-name", GTK_STOCK_APPLY,
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (update_system_action, "activate",
 			  G_CALLBACK (pk_updates_apply_cb), loop);
-	gtk_widget_set_tooltip_text(widget, _("Apply all updates"));
+	button = polkit_gnome_action_create_button (update_system_action);
+	widget = glade_xml_get_widget (glade_xml, "buttonbox_overview");
+	gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (widget), button, 1);
 
 	size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
 
-	widget = glade_xml_get_widget (glade_xml, "button_refresh");
-	g_signal_connect (widget, "clicked",
+	widget = glade_xml_get_widget (glade_xml, "alignment_refresh");
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.refresh-cache");
+	refresh_action = polkit_gnome_action_new_default ("refresh",
+						          pk_action,
+							  _("Refresh"),
+							  _("Refreshing is not normally required but will retrieve the latest application and update lists"));
+	g_object_set (refresh_action, "auth-icon-name", NULL, NULL);
+	polkit_action_unref (pk_action);
+
+	g_signal_connect (refresh_action, "activate",
 			  G_CALLBACK (pk_updates_refresh_cb), NULL);
-	gtk_widget_set_tooltip_text(widget, _("Refreshing is not normally required but will retrieve the latest application and update lists"));
-	gtk_size_group_add_widget (size_group, widget);
+
+	button = polkit_gnome_action_create_button (refresh_action);
+	gtk_container_add (GTK_CONTAINER (widget), button);
+	gtk_size_group_add_widget (size_group, button);
 
 	widget = glade_xml_get_widget (glade_xml, "button_history");
 	g_signal_connect (widget, "clicked",
@@ -1524,10 +1588,8 @@
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
 
 	/* make the buttons non-clickable until we get completion */
-	widget = glade_xml_get_widget (glade_xml, "button_refresh");
-	gtk_widget_set_sensitive (widget, FALSE);
-	widget = glade_xml_get_widget (glade_xml, "button_apply2");
-	gtk_widget_set_sensitive (widget, FALSE);
+	polkit_gnome_action_set_sensitive (refresh_action, FALSE);
+	polkit_gnome_action_set_sensitive (update_system_action, FALSE);
 	widget = glade_xml_get_widget (glade_xml, "button_review");
 	gtk_widget_set_sensitive (widget, FALSE);
 	widget = glade_xml_get_widget (glade_xml, "button_history");
@@ -1537,6 +1599,12 @@
 	pk_update_update_last_refreshed_time (client);
 	pk_update_update_last_updated_time (client);
 
+	/* set the labels blank until we get a package */
+	widget = glade_xml_get_widget (glade_xml, "progress_part_label");
+	gtk_label_set_label (GTK_LABEL (widget), "");
+	widget = glade_xml_get_widget (glade_xml, "progress_package_label");
+	gtk_label_set_label (GTK_LABEL (widget), "");
+
 	/* get the update list */
 	ret = pk_client_get_updates (client, "basename", NULL);
 	if (ret) {

Modified: trunk/src/pk-watch.c
==============================================================================
--- trunk/src/pk-watch.c	(original)
+++ trunk/src/pk-watch.c	Mon Mar 24 22:28:59 2008
@@ -37,6 +37,8 @@
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 
+#include <polkit-gnome/polkit-gnome.h>
+
 #include <pk-debug.h>
 #include <pk-job-list.h>
 #include <pk-client.h>
@@ -67,6 +69,7 @@
 	PkTaskList		*tlist;
 	GConfClient		*gconf_client;
 	gboolean		 show_refresh_in_menu;
+	PolKitGnomeAction	*restart_action;
 };
 
 G_DEFINE_TYPE (PkWatch, pk_watch, G_TYPE_OBJECT)
@@ -115,7 +118,7 @@
 		localised_status = pk_status_enum_to_localised_text (item->status);
 
 		/* we have text? */
-		if (pk_strzero (item->package_id) == TRUE) {
+		if (pk_strzero (item->package_id)) {
 			g_string_append_printf (status, "%s\n", localised_status);
 		} else {
 			/* display the package name, not the package_id */
@@ -233,8 +236,8 @@
 	g_return_if_fail (watch != NULL);
 	g_return_if_fail (PK_IS_WATCH (watch));
 
-	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_REFRESH_CACHE) == TRUE ||
-	    pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) == TRUE) {
+	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_REFRESH_CACHE) ||
+	    pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
 		watch->priv->show_refresh_in_menu = FALSE;
 	} else {
 		watch->priv->show_refresh_in_menu = TRUE;
@@ -345,7 +348,7 @@
 	pk_client_is_caller_active (client, &is_active, NULL);
 
 	/* do we ignore this error? */
-	if (is_active == TRUE) {
+	if (is_active) {
 		pk_debug ("client active so leaving error %s\n%s", title, details);
 		return;
 	}
@@ -420,7 +423,7 @@
 	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
 	g_free (cmdline);
 
-	if (ret == TRUE)
+	if (ret)
 		goto out;
 
 	g_error_free (error);
@@ -558,19 +561,9 @@
  * pk_watch_restart_cb:
  **/
 static void
-pk_watch_restart_cb (GtkMenuItem *item, gpointer data)
+pk_watch_restart_cb (PolKitGnomeAction *action, gpointer data)
 {
-	gboolean ret;
-	PkWatch *watch = PK_WATCH (data);
-
-	g_return_if_fail (watch != NULL);
-	g_return_if_fail (PK_IS_WATCH (watch));
-
-	/* restart using gnome-power-manager */
-	ret = pk_restart_system ();
-	if (!ret) {
-		pk_warning ("failed to reboot");
-	}
+	pk_restart_system ();
 }
 
 /**
@@ -582,6 +575,8 @@
 	gboolean ret;
 	PkWatch *watch = PK_WATCH (data);
 	PkClient *client;
+	GError *error = NULL;
+	gchar *message;
 
 	g_return_if_fail (watch != NULL);
 	g_return_if_fail (PK_IS_WATCH (watch));
@@ -594,9 +589,12 @@
 	ret = pk_client_refresh_cache (client, TRUE, NULL);
 	if (ret == FALSE) {
 		g_object_unref (client);
-		pk_warning ("failed to refresh cache");
-		pk_smart_icon_notify_new (watch->priv->sicon, _("Failed to refresh cache"), _("Client action was refused"),
+		pk_warning ("failed to refresh cache: %s", error->message);
+		message = g_strdup_printf (_("Client action was refused: %s"), error->message);
+		g_error_free (error);
+		pk_smart_icon_notify_new (watch->priv->sicon, _("Failed to refresh cache"), message,
 				      "process-stop", PK_NOTIFY_URGENCY_LOW, PK_NOTIFY_TIMEOUT_SHORT);
+		g_free (message);
 		pk_smart_icon_notify_show (watch->priv->sicon);
 	}
 }
@@ -717,7 +715,7 @@
 	pk_watch_populate_menu_with_jobs (watch, menu);
 
 	/* force a refresh if we are not updating or refreshing */
-	if (watch->priv->show_refresh_in_menu == TRUE) {
+	if (watch->priv->show_refresh_in_menu) {
 
 		/* Separator for HIG? */
 		widget = gtk_separator_menu_item_new ();
@@ -773,11 +771,7 @@
 	pk_debug ("icon left clicked");
 
 	/* restart computer */
-	widget = gtk_image_menu_item_new_with_mnemonic (_("_Restart computer"));
-	image = gtk_image_new_from_icon_name ("system-shutdown", GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (widget), image);
-	g_signal_connect (G_OBJECT (widget), "activate",
-			  G_CALLBACK (pk_watch_restart_cb), watch);
+	widget = gtk_action_create_menu_item (GTK_ACTION (watch->priv->restart_action));
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), widget);
 
 	/* hide this option */
@@ -804,7 +798,7 @@
 	g_return_if_fail (watch != NULL);
 	g_return_if_fail (PK_IS_WATCH (watch));
 	pk_debug ("connected=%i", connected);
-	if (connected == TRUE) {
+	if (connected) {
 		pk_watch_refresh_icon (watch);
 		pk_watch_refresh_tooltip (watch);
 	} else {
@@ -822,7 +816,7 @@
 	g_return_if_fail (PK_IS_WATCH (watch));
 
 	pk_debug ("setting locked %i, doing g-p-m (un)inhibit", is_locked);
-	if (is_locked == TRUE) {
+	if (is_locked) {
 		pk_inhibit_create (watch->priv->inhibit);
 	} else {
 		pk_inhibit_remove (watch->priv->inhibit);
@@ -837,6 +831,9 @@
 pk_watch_init (PkWatch *watch)
 {
 	GtkStatusIcon *status_icon;
+	PolKitAction *pk_action;
+	PolKitGnomeAction *restart_action;
+
 	watch->priv = PK_WATCH_GET_PRIVATE (watch);
 
 	watch->priv->show_refresh_in_menu = TRUE;
@@ -881,6 +878,24 @@
 	if (pk_connection_valid (watch->priv->pconnection)) {
 		pk_connection_changed_cb (watch->priv->pconnection, TRUE, watch);
 	}
+
+	pk_action = polkit_action_new ();
+	polkit_action_set_action_id (pk_action, "org.freedesktop.consolekit.system.restart");
+
+	restart_action = polkit_gnome_action_new_default ("restart-system",
+							  pk_action,
+							  _("_Restart computer"),
+							  NULL);
+	g_object_set (restart_action,
+		      "no-icon-name", "gnome-shutdown",
+		      "auth-icon-name", "gnome-shutdown",
+		      "yes-icon-name","gnome-shutdown",
+		      "self-blocked-icon-name", "gnome-shutdown",
+		      NULL);
+	polkit_action_unref (pk_action);
+	g_signal_connect (restart_action, "activate",
+			  G_CALLBACK (pk_watch_restart_cb), NULL);
+	watch->priv->restart_action = restart_action;
 }
 
 /**
@@ -904,6 +919,7 @@
 	g_object_unref (watch->priv->client);
 	g_object_unref (watch->priv->pconnection);
 	g_object_unref (watch->priv->gconf_client);
+	g_object_unref (watch->priv->restart_action);
 
 	G_OBJECT_CLASS (pk_watch_parent_class)->finalize (object);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]