gnome-packagekit r332 - in trunk: data help help/C src



Author: rhughes
Date: Fri Oct 10 13:39:05 2008
New Revision: 332
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=332&view=rev

Log:
from git

Modified:
   trunk/data/gpk-log.glade
   trunk/data/gpk-service-pack.glade
   trunk/help/C/gnome-packagekit.xml
   trunk/help/Makefile.am
   trunk/src/gpk-enum.c
   trunk/src/gpk-log.c
   trunk/src/gpk-service-pack.c

Modified: trunk/data/gpk-log.glade
==============================================================================
--- trunk/data/gpk-log.glade	(original)
+++ trunk/data/gpk-log.glade	Fri Oct 10 13:39:05 2008
@@ -3,15 +3,42 @@
 <!--*- mode: xml -*-->
 <glade-interface>
   <widget class="GtkWindow" id="window_simple">
-    <property name="title" translatable="yes">Update History</property>
+    <property name="title" translatable="yes">Software Log Viewer</property>
     <property name="window_position">GTK_WIN_POS_CENTER</property>
     <property name="icon_name">gtk-info</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
     <child>
       <widget class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
         <property name="border_width">10</property>
-        <property name="spacing">12</property>
+        <property name="spacing">6</property>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
+            <child>
+              <widget class="GtkEntry" id="entry_package">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button_filter">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">Filter</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+          </packing>
+        </child>
         <child>
           <widget class="GtkScrolledWindow" id="scrolledwindow_simple">
             <property name="visible">True</property>
@@ -23,11 +50,15 @@
               <widget class="GtkTreeView" id="treeview_simple">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="headers_visible">False</property>
+                <property name="headers_clickable">True</property>
                 <property name="rules_hint">True</property>
+                <property name="show_expanders">False</property>
               </widget>
             </child>
           </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
         </child>
         <child>
           <widget class="GtkHButtonBox" id="buttonbox">
@@ -56,23 +87,37 @@
               </packing>
             </child>
             <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">gtk-refresh</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_close">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="is_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="label">gtk-close</property>
                 <property name="use_stock">True</property>
                 <property name="response_id">0</property>
               </widget>
               <packing>
-                <property name="position">2</property>
+                <property name="position">3</property>
               </packing>
             </child>
           </widget>
           <packing>
             <property name="expand">False</property>
             <property name="fill">False</property>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </widget>

Modified: trunk/data/gpk-service-pack.glade
==============================================================================
--- trunk/data/gpk-service-pack.glade	(original)
+++ trunk/data/gpk-service-pack.glade	Fri Oct 10 13:39:05 2008
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.4 on Thu Oct  9 16:21:25 2008 -->
+<!--Generated with glade3 3.4.4 on Fri Oct 10 12:14:12 2008 -->
 <glade-interface>
   <widget class="GtkWindow" id="window_pack">
-    <property name="title" translatable="yes">Service Pack Generator</property>
+    <property name="title" translatable="yes">Service Pack Creator</property>
     <property name="resizable">False</property>
     <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
     <child>
@@ -27,6 +27,16 @@
                     <property name="visible">True</property>
                     <property name="spacing">3</property>
                     <child>
+                      <widget class="GtkRadioButton" id="radiobutton_copy">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">Create a copy of this computers package list</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">radiobutton_updates</property>
+                      </widget>
+                    </child>
+                    <child>
                       <widget class="GtkRadioButton" id="radiobutton_updates">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -35,6 +45,9 @@
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                       </widget>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                     <child>
                       <widget class="GtkRadioButton" id="radiobutton_package">
@@ -46,7 +59,7 @@
                         <property name="group">radiobutton_updates</property>
                       </widget>
                       <packing>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                     <child>
@@ -62,7 +75,7 @@
                         </child>
                       </widget>
                       <packing>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                   </widget>
@@ -72,7 +85,7 @@
             <child>
               <widget class="GtkLabel" id="label8">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">&lt;b&gt;Contents of service pack&lt;/b&gt;</property>
+                <property name="label" translatable="yes">&lt;b&gt;Action&lt;/b&gt;</property>
                 <property name="use_markup">True</property>
               </widget>
               <packing>
@@ -104,11 +117,11 @@
                     <child>
                       <widget class="GtkFileChooserButton" id="filechooserbutton_directory">
                         <property name="visible">True</property>
-                        <property name="preview_widget_active">False</property>
+                        <property name="local_only">False</property>
                         <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
                         <property name="use_preview_label">False</property>
                         <property name="do_overwrite_confirmation">True</property>
-                        <property name="local_only">False</property>
+                        <property name="preview_widget_active">False</property>
                         <property name="title" translatable="yes">Save New Service Pack</property>
                       </widget>
                       <packing>
@@ -121,9 +134,9 @@
                     <child>
                       <widget class="GtkFileChooserButton" id="filechooserbutton_exclude">
                         <property name="visible">True</property>
-                        <property name="preview_widget_active">False</property>
-                        <property name="do_overwrite_confirmation">True</property>
                         <property name="local_only">False</property>
+                        <property name="do_overwrite_confirmation">True</property>
+                        <property name="preview_widget_active">False</property>
                         <property name="title" translatable="yes">Select A Package List File</property>
                       </widget>
                       <packing>
@@ -132,24 +145,30 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkLabel" id="label9">
+                      <widget class="GtkHBox" id="hbox3">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">Service pack destination:</property>
-                        <property name="use_markup">True</property>
+                        <child>
+                          <widget class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Destination package list:</property>
+                            <property name="use_markup">True</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options"></property>
+                        <property name="x_options">GTK_FILL</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkHBox" id="hbox3">
+                      <widget class="GtkHBox" id="hbox1">
                         <property name="visible">True</property>
                         <child>
-                          <widget class="GtkLabel" id="label2">
+                          <widget class="GtkLabel" id="label9">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">Destination file list:</property>
+                            <property name="label" translatable="yes">Output directory:</property>
                             <property name="use_markup">True</property>
                           </widget>
                           <packing>
@@ -158,6 +177,8 @@
                         </child>
                       </widget>
                       <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
                       </packing>
                     </child>

Modified: trunk/help/C/gnome-packagekit.xml
==============================================================================
--- trunk/help/C/gnome-packagekit.xml	(original)
+++ trunk/help/C/gnome-packagekit.xml	Fri Oct 10 13:39:05 2008
@@ -504,6 +504,34 @@
  </para>
 </section>
 
+<section id="software-log">
+  <title>Software Log Viewer</title>
+  <figure>
+    <title>Log viewer</title>
+    <screenshot>
+      <mediaobject>
+        <imageobject>
+          <imagedata fileref="figures/gpk-log.png" format="PNG"/>
+        </imageobject>
+      </mediaobject>
+    </screenshot>
+  </figure>
+  <para>
+    This tool can be opened using <menuchoice><guimenu>Applications</guimenu>
+    <guisubmenu>System Tools</guisubmenu>
+    <guimenuitem>Software Log Viewer</guimenuitem></menuchoice>.
+  </para>
+  <para>
+    The log viewer can be used to find out what updates were downloaded and
+    installed.
+    The filter will match on the package name, version or architecture.
+  </para>
+  <para>
+    It can also can be used to roll back to a specific point for package
+    backends that support <literal>RollBack</literal>.
+ </para>
+</section>
+
 <section id="service-pack">
   <title>Service Pack Creator</title>
   <figure>
@@ -565,7 +593,64 @@
     service pack on a <filename>ubuntu-intrepid-ppc</filename> machine.
   </para>
   <para>
-    <command>pkgenpack</command> is a command line tool for creating service pack files.
+    We need a destination file list because we not know what packages are
+    installed on the destination computer.
+    For example:
+  </para>
+  <figure>
+    <title>Two example computers</title>
+    <screenshot>
+      <mediaobject>
+        <imageobject>
+          <imagedata fileref="figures/gpk-service-pack-example.png" format="PNG"/>
+        </imageobject>
+      </mediaobject>
+    </screenshot>
+  </figure>
+  <para>
+    Computer A has the following packages installed, and has internet access.
+  </para>
+  <itemizedlist>
+    <listitem><literal>glib</literal></listitem>
+    <listitem><literal>dbus</literal></listitem>
+    <listitem><literal>dbus-glib</literal></listitem>
+    <listitem><literal>libgnome</literal></listitem>
+  </itemizedlist>
+  <para>
+    Computer B has the following packages installed, and does not have internet access.
+  </para>
+  <itemizedlist>
+    <listitem><literal>glib</literal></listitem>
+    <listitem><literal>dbus</literal></listitem>
+    <listitem><literal>kdebase</literal></listitem>
+    <listitem><literal>kdeapps</literal></listitem>
+  </itemizedlist>
+  <para>
+    Computer B wants to have a service pack containing a new version of
+    <literal>k3b</literal> so that it can burn DVD-RWs.
+  </para>
+  <para>
+    The <literal>k3b</literal> program has dependancies of <literal>dbus</literal>,
+    <literal>dbus-glib</literal> and <literal>kdebase</literal>.
+    Now, if we asked computer A to download <literal>k3b</literal>, it would download
+    <literal>k3b</literal> <emphasis>and</emphasis> <literal>kdebase</literal> but
+    <emphasis>not</emphasis> <literal>dbus-glib</literal>.
+    We need to provide computer A with the information about what packages computer B
+    has got installed before we can create the service pack.
+  </para>
+  <para>
+    If we generate a package list on computer B, and the transfer it to
+    computer A on a USB pendrive or CDRW we can download the correct packages.
+    In this case we would download <literal>k3b</literal> and
+    <literal>dbus-glib</literal> and pack it into the new service pack.
+  </para>
+  <para>
+    The service pack can now be transferred from computer A to computer B on
+    the USB pendrive.
+  </para>
+  <para>
+    The <command>pkgenpack</command> command line tool can also be used for
+    creating service pack files.
   </para>
 </section>
 
@@ -576,7 +661,7 @@
     PackageKit-cron package.
     This package contains a cron job that as well as a configuration file.
     The settings are controlled via the configuration file at
-    <command>/etc/sysconfig/packagekit-background</command>.
+    <filename>/etc/sysconfig/packagekit-background</filename>.
     You can set it to just check for updates or perform the updates
     automatically and notify any email address.
   </para>

Modified: trunk/help/Makefile.am
==============================================================================
--- trunk/help/Makefile.am	(original)
+++ trunk/help/Makefile.am	Fri Oct 10 13:39:05 2008
@@ -10,6 +10,7 @@
 	figures/gpk-eula.png \
 	figures/gpk-prefs.png \
 	figures/gpk-repo-auth.png \
+	figures/gpk-log.png \
 	figures/gpk-repo.png \
 	figures/gpk-signature.png \
 	figures/gpk-updates-overview.png \
@@ -18,6 +19,7 @@
 	figures/gpk-remove-confirm.png \
 	figures/gpk-updates.png \
 	figures/gpk-service-pack.png \
+	figures/gpk-service-pack-example.png \
 	figures/gpk-updates-warning.png
 
 DOC_LINGUAS = el es oc pl sv

Modified: trunk/src/gpk-enum.c
==============================================================================
--- trunk/src/gpk-enum.c	(original)
+++ trunk/src/gpk-enum.c	Fri Oct 10 13:39:05 2008
@@ -1127,19 +1127,19 @@
 		text = _("Searched for package name");
 		break;
 	case PK_ROLE_ENUM_REMOVE_PACKAGES:
-		text = _("Removed package");
+		text = _("Removed packages");
 		break;
 	case PK_ROLE_ENUM_INSTALL_PACKAGES:
-		text = _("Installed package");
+		text = _("Installed packages");
 		break;
 	case PK_ROLE_ENUM_INSTALL_FILES:
-		text = _("Installed local file");
+		text = _("Installed local files");
 		break;
 	case PK_ROLE_ENUM_REFRESH_CACHE:
 		text = _("Refreshed package cache");
 		break;
 	case PK_ROLE_ENUM_UPDATE_PACKAGES:
-		text = _("Updated package");
+		text = _("Updated packages");
 		break;
 	case PK_ROLE_ENUM_UPDATE_SYSTEM:
 		text = _("Updated system");

Modified: trunk/src/gpk-log.c
==============================================================================
--- trunk/src/gpk-log.c	(original)
+++ trunk/src/gpk-log.c	Fri Oct 10 13:39:05 2008
@@ -32,6 +32,7 @@
 #include <locale.h>
 
 #include <polkit-gnome/polkit-gnome.h>
+#include <gconf/gconf-client.h>
 
 #include <pk-client.h>
 #include <pk-control.h>
@@ -50,12 +51,17 @@
 static GtkListStore *list_store = NULL;
 static PkClient *client = NULL;
 static gchar *transaction_id = NULL;
+static gchar *filter = NULL;
 static PolKitGnomeAction *button_action = NULL;
 
 enum
 {
 	GPK_LOG_COLUMN_ICON,
-	GPK_LOG_COLUMN_TEXT,
+	GPK_LOG_COLUMN_DAY,
+	GPK_LOG_COLUMN_DATE,
+	GPK_LOG_COLUMN_ROLE,
+	GPK_LOG_COLUMN_DURATION,
+	GPK_LOG_COLUMN_DETAILS,
 	GPK_LOG_COLUMN_ID,
 	GPK_LOG_COLUMN_LAST
 };
@@ -64,9 +70,9 @@
  * gpk_log_button_help_cb:
  **/
 static void
-gpk_log_button_help_cb (GtkWidget *widget, gboolean data)
+gpk_log_button_help_cb (GtkWidget *widget, gpointer data)
 {
-	gpk_gnome_help ("update-log");
+	gpk_gnome_help ("software-log");
 }
 
 /**
@@ -150,56 +156,96 @@
 
 	/* add a nice header, and make text italic */
 	text = g_string_free (string, FALSE);
-	whole = g_strdup_printf ("<b>%s</b>: %s\n", gpk_info_enum_to_localised_past (info), text);
+	whole = g_strdup_printf ("%s: %s\n", gpk_info_enum_to_localised_past (info), text);
 	g_free (text);
 	return whole;
 }
 
 /**
- * gpk_log_get_transaction_item:
+ * gpk_log_get_details_localised:
  **/
 static gchar *
-gpk_log_get_transaction_item (const gchar *timespec, const gchar *data)
+gpk_log_get_details_localised (const gchar *timespec, const gchar *data)
 {
-	gchar *pretty;
 	GString *string;
 	gchar *text;
 	gchar **array;
 
-	pretty = gpk_log_get_localised_date (timespec);
 	string = g_string_new ("");
-	g_string_append_printf (string, "<big><b>%s</b></big>\n", pretty);
-	g_free (pretty);
-
 	array = g_strsplit (data, "\n", 0);
 
 	/* get each type */
 	text = gpk_log_get_type_line (array, PK_INFO_ENUM_INSTALLING);
-	if (text != NULL) {
+	if (text != NULL)
 		g_string_append (string, text);
-	}
 	g_free (text);
 	text = gpk_log_get_type_line (array, PK_INFO_ENUM_REMOVING);
-	if (text != NULL) {
+	if (text != NULL)
 		g_string_append (string, text);
-	}
 	g_free (text);
 	text = gpk_log_get_type_line (array, PK_INFO_ENUM_UPDATING);
-	if (text != NULL) {
+	if (text != NULL)
 		g_string_append (string, text);
-	}
 	g_free (text);
 	g_strfreev (array);
 
 	/* remove last \n */
-	if (string->len > 0) {
+	if (string->len > 0)
 		g_string_set_size (string, string->len - 1);
-	}
 
 	return g_string_free (string, FALSE);
 }
 
 /**
+ * gpk_log_filter:
+ **/
+static gboolean
+gpk_log_filter (const gchar *data)
+{
+	gboolean ret = FALSE;
+	guint i;
+	guint length;
+	gchar **sections;
+	gchar **packages;
+	PkPackageId *id;
+
+	if (filter == NULL)
+		return TRUE;
+
+	/* look in all the data for the filter string */
+	packages = g_strsplit (data, "\n", 0);
+	length = g_strv_length (packages);
+	for (i=0; i<length; i++) {
+		sections = g_strsplit (packages[i], "\t", 0);
+
+		/* check if type matches filter */
+		if (g_strrstr (sections[0], filter) != NULL)
+			ret = TRUE;
+
+		/* check to see if package name, version or arch matches */
+		id = pk_package_id_new_from_string (sections[1]);
+		if (g_strrstr (id->name, filter) != NULL)
+			ret = TRUE;
+		if (id->version != NULL && g_strrstr (id->version, filter) != NULL)
+			ret = TRUE;
+		if (id->arch != NULL && g_strrstr (id->arch, filter) != NULL)
+			ret = TRUE;
+
+		pk_package_id_free (id);
+		g_strfreev (sections);
+
+		/* shortcut for speed */
+		if (ret)
+			break;
+	}
+
+	g_strfreev (packages);
+
+	return ret;
+}
+
+
+/**
  * gpk_log_transaction_cb:
  **/
 static void
@@ -207,8 +253,13 @@
 			gboolean succeeded, PkRoleEnum role, guint duration, const gchar *data, gpointer user_data)
 {
 	GtkTreeIter iter;
-	gchar *text;
+	gchar *details;
+	gchar *date;
+	gchar **date_part;
+	gchar *time;
+	gboolean ret;
 	const gchar *icon_name;
+	const gchar *role_text;
 
 	/* only show transactions that succeeded */
 	if (!succeeded) {
@@ -216,16 +267,43 @@
 		return;
 	}
 
+	/* filter */
+	ret = gpk_log_filter (data);
+	if (!ret) {
+		egg_debug ("tid %s did not match, so not adding", tid);
+		return;
+	}
+
 	/* put formatted text into treeview */
-	text = gpk_log_get_transaction_item (timespec, data);
+	details = gpk_log_get_details_localised (timespec, data);
+	date = gpk_log_get_localised_date (timespec);
+	date_part = g_strsplit (date, ", ", 2);
+
+	if (duration > 0)
+		time = gpk_time_to_localised_string (duration / 1000);
+	else
+		time = g_strdup (_("No data"));
+	icon_name = gpk_role_enum_to_icon_name (role);
+	role_text = gpk_role_enum_to_localised_past (role);
+
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter,
-			    GPK_LOG_COLUMN_TEXT, text,
+			    GPK_LOG_COLUMN_ICON, icon_name,
+			    GPK_LOG_COLUMN_DAY, date_part[0],
+			    GPK_LOG_COLUMN_DATE, date_part[1],
+			    GPK_LOG_COLUMN_ROLE, role_text,
+			    GPK_LOG_COLUMN_DURATION, time,
+			    GPK_LOG_COLUMN_DETAILS, details,
 			    GPK_LOG_COLUMN_ID, tid, -1);
-	g_free (text);
 
-	icon_name = gpk_role_enum_to_icon_name (role);
-	gtk_list_store_set (list_store, &iter, GPK_LOG_COLUMN_ICON, icon_name, -1);
+	/* spin the gui */
+	while (gtk_events_pending ())
+		gtk_main_iteration ();
+
+	g_strfreev (date_part);
+	g_free (details);
+	g_free (date);
+	g_free (time);
 }
 
 /**
@@ -237,18 +315,38 @@
 	GtkCellRenderer *renderer;
 	GtkTreeViewColumn *column;
 
+	/* column for date */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Date"), renderer,
+							   "markup", GPK_LOG_COLUMN_DATE, NULL);
+	gtk_tree_view_append_column (treeview, column);
+	gtk_tree_view_column_set_expand (column, TRUE);
+
 	/* image */
 	renderer = gtk_cell_renderer_pixbuf_new ();
-        g_object_set (renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
-	column = gtk_tree_view_column_new_with_attributes (_("Role"), renderer,
+        g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
+	column = gtk_tree_view_column_new_with_attributes ("", renderer,
 							   "icon-name", GPK_LOG_COLUMN_ICON, NULL);
 	gtk_tree_view_append_column (treeview, column);
 
-	/* column for text */
+	/* column for role */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Role"), renderer,
+							   "markup", GPK_LOG_COLUMN_ROLE, NULL);
+	gtk_tree_view_append_column (treeview, column);
+	gtk_tree_view_column_set_expand (column, TRUE);
+
+	/* column for duration */
 	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Transaction"), renderer,
-							   "markup", GPK_LOG_COLUMN_TEXT, NULL);
-	gtk_tree_view_column_set_sort_column_id (column, GPK_LOG_COLUMN_TEXT);
+	column = gtk_tree_view_column_new_with_attributes (_("Duration"), renderer,
+							   "markup", GPK_LOG_COLUMN_DURATION, NULL);
+	gtk_tree_view_append_column (treeview, column);
+	gtk_tree_view_column_set_expand (column, TRUE);
+
+	/* column for details */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Details"), renderer,
+							   "markup", GPK_LOG_COLUMN_DETAILS, NULL);
 	gtk_tree_view_append_column (treeview, column);
 	gtk_tree_view_column_set_expand (column, TRUE);
 }
@@ -257,7 +355,7 @@
  * gpk_log_treeview_clicked_cb:
  **/
 static void
-gpk_log_treeview_clicked_cb (GtkTreeSelection *selection, gboolean data)
+gpk_log_treeview_clicked_cb (GtkTreeSelection *selection, gpointer data)
 {
 	GtkTreeModel *model;
 	GtkTreeIter iter;
@@ -284,9 +382,8 @@
 				        gchar *string1, gchar *string2,
 				        gint int1, gint int2, gpointer user_data)
 {
-	if (egg_strequal (name, "button_action")) {
+	if (egg_strequal (name, "button_action"))
 		return polkit_gnome_action_create_button (button_action);
-	}
 	egg_warning ("name unknown=%s", name);
 	return NULL;
 }
@@ -324,6 +421,63 @@
 }
 
 /**
+ * gpk_log_refresh
+ **/
+static gboolean
+gpk_log_refresh (void)
+{
+	gboolean ret;
+	GError *error = NULL;
+	gtk_list_store_clear (list_store);
+	ret = pk_client_reset (client, &error);
+	if (!ret) {
+		egg_warning ("failed to reset client: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	ret = pk_client_get_old_transactions (client, 0, &error);
+	if (!ret) {
+		egg_warning ("failed to get list: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gpk_log_button_refresh_cb:
+ **/
+static void
+gpk_log_button_refresh_cb (GtkWidget *widget, gpointer data)
+{
+	/* refresh */
+	gpk_log_refresh ();
+}
+
+/**
+ * gpk_log_button_filter_cb:
+ **/
+static void
+gpk_log_button_filter_cb (GtkWidget *widget2, gpointer data)
+{
+	GtkWidget *widget;
+	const gchar *package;
+
+	/* set the new filter */
+	g_free (filter);
+	widget = glade_xml_get_widget (glade_xml, "entry_package");
+	package = gtk_entry_get_text (GTK_ENTRY(widget));
+	if (!egg_strzero (package))
+		filter = g_strdup (package);
+	else
+		filter = NULL;
+
+	/* refresh */
+	gpk_log_refresh ();
+}
+
+/**
  * main:
  **/
 int
@@ -332,8 +486,10 @@
 	gboolean verbose = FALSE;
 	gboolean program_version = FALSE;
 	GOptionContext *context;
+	GConfClient *gconf_client;
 	GtkWidget *widget;
 	GtkTreeSelection *selection;
+	GtkEntryCompletion *completion;
 	PkBitfield roles;
 	PkControl *control;
 	EggUnique *egg_unique;
@@ -353,9 +509,8 @@
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	if (! g_thread_supported ()) {
+	if (! g_thread_supported ())
 		g_thread_init (NULL);
-	}
 	dbus_g_thread_init ();
 	g_type_init ();
 
@@ -375,16 +530,15 @@
 
 	/* are we running privileged */
 	ret = gpk_check_privileged_user (_("Log viewer"));
-	if (!ret) {
+	if (!ret)
 		return 1;
-	}
 
 	/* are we already activated? */
 	egg_unique = egg_unique_new ();
 	ret = egg_unique_assign (egg_unique, "org.freedesktop.PackageKit.LogViewer");
-	if (!ret) {
+	if (!ret)
 		goto unique_out;
-	}
+
 	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpk_log_activated_cb), NULL);
 
@@ -399,8 +553,7 @@
 	glade_set_custom_handler (gpk_update_viewer_create_custom_widget, NULL);
 
 	client = pk_client_new ();
-	g_signal_connect (client, "transaction",
-			  G_CALLBACK (gpk_log_transaction_cb), NULL);
+	g_signal_connect (client, "transaction", G_CALLBACK (gpk_log_transaction_cb), NULL);
 
 	/* get actions */
 	control = pk_control_new ();
@@ -410,7 +563,7 @@
 	glade_xml = glade_xml_new (GPK_DATA "/gpk-log.glade", NULL, NULL);
 	widget = glade_xml_get_widget (glade_xml, "window_simple");
 	gtk_window_set_icon_name (GTK_WINDOW (widget), GPK_ICON_SOFTWARE_LOG);
-	gtk_widget_set_size_request (widget, 500, 400);
+	gtk_widget_set_size_request (widget, 750, 300);
 
 	/* Get the main window quit */
 	g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
@@ -420,22 +573,40 @@
 	gtk_widget_grab_default (widget);
 
 	widget = glade_xml_get_widget (glade_xml, "button_help");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (gpk_log_button_help_cb), NULL);
+	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_help_cb), NULL);
+	widget = glade_xml_get_widget (glade_xml, "button_refresh");
+	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_refresh_cb), NULL);
+	widget = glade_xml_get_widget (glade_xml, "button_filter");
+	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_filter_cb), NULL);
+
+	/* hit enter in the search box for filter */
+	widget = glade_xml_get_widget (glade_xml, "entry_package");
+	g_signal_connect (widget, "activate", G_CALLBACK (gpk_log_button_filter_cb), NULL);
+
+	/* autocompletion can be turned off as it's slow */
+	gconf_client = gconf_client_get_default ();
+	ret = gconf_client_get_bool (gconf_client, GPK_CONF_AUTOCOMPLETE, NULL);
+	if (ret) {
+		/* create the completion object */
+		completion = gpk_package_entry_completion_new ();
+		widget = glade_xml_get_widget (glade_xml, "entry_package");
+		gtk_entry_set_completion (GTK_ENTRY (widget), completion);
+		g_object_unref (completion);
+	}
+	g_object_unref (gconf_client);
 
 	/* connect up PolicyKit actions */
 	g_signal_connect (button_action, "activate", G_CALLBACK (gpk_log_button_rollback_cb), NULL);
 
 	/* hide the rollback button if we can't do the action */
-	if (pk_bitfield_contain (roles, PK_ROLE_ENUM_ROLLBACK)) {
+	if (pk_bitfield_contain (roles, PK_ROLE_ENUM_ROLLBACK))
 		polkit_gnome_action_set_visible (button_action, TRUE);
-	} else {
+	else
 		polkit_gnome_action_set_visible (button_action, FALSE);
-	}
 
 	/* create list stores */
-	list_store = gtk_list_store_new (GPK_LOG_COLUMN_LAST, G_TYPE_STRING,
-						 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+	list_store = gtk_list_store_new (GPK_LOG_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+					 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 
 	/* create transaction_id tree view */
 	widget = glade_xml_get_widget (glade_xml, "treeview_simple");
@@ -451,7 +622,7 @@
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
 
 	/* get the update list */
-	pk_client_get_old_transactions (client, 0, NULL);
+	gpk_log_refresh ();
 
 	/* show */
 	widget = glade_xml_get_widget (glade_xml, "window_simple");
@@ -462,6 +633,7 @@
 	g_object_unref (list_store);
 	g_object_unref (client);
 	g_free (transaction_id);
+	g_free (filter);
 unique_out:
 	g_object_unref (egg_unique);
 	return 0;

Modified: trunk/src/gpk-service-pack.c
==============================================================================
--- trunk/src/gpk-service-pack.c	(original)
+++ trunk/src/gpk-service-pack.c	Fri Oct 10 13:39:05 2008
@@ -597,6 +597,7 @@
 		gtk_entry_set_completion (GTK_ENTRY (widget), completion);
 		g_object_unref (completion);
 	}
+	g_object_unref (client);
 
 	gtk_widget_show (main_window);
 



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