gnome-packagekit r246 - trunk/src



Author: rhughes
Date: Tue Jul 15 09:24:14 2008
New Revision: 246
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=246&view=rev

Log:
from git

Modified:
   trunk/src/gpk-application.c
   trunk/src/gpk-client-requires.c
   trunk/src/gpk-client-requires.h
   trunk/src/gpk-client.c
   trunk/src/gpk-dialog.c
   trunk/src/gpk-dialog.h
   trunk/src/gpk-interface.h
   trunk/src/gpk-update-viewer.c

Modified: trunk/src/gpk-application.c
==============================================================================
--- trunk/src/gpk-application.c	(original)
+++ trunk/src/gpk-application.c	Tue Jul 15 09:24:14 2008
@@ -423,34 +423,12 @@
 }
 
 /**
- * gpk_application_modal_info:
+ * gpk_application_strcmp_indirect:
  **/
-static void
-gpk_application_modal_info (GpkApplication *application, const gchar *title, const gchar *text)
+gint
+gpk_application_strcmp_indirect (gchar **a, gchar **b)
 {
-	GtkWidget *dialog;
-	GtkWidget *widget;
-	GtkWidget *main_window;
-	GtkWidget *scrolled_window;
-
-	g_return_if_fail (PK_IS_APPLICATION (application));
-
-	widget = gtk_text_view_new ();
-	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-	gtk_widget_set_size_request (scrolled_window, 400, 200);
-	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), widget);
-
-	main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
-	dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (main_window),
-					      GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK,
-					      GTK_RESPONSE_NONE, NULL);
-
-	gpk_application_set_text_buffer (widget, text);
-	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), scrolled_window);
-
-	/* ensure that the dialog box is destroyed when the user responds. */
-	g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
-	gtk_widget_show_all (dialog);
+	return strcmp (*a, *b);
 }
 
 /**
@@ -459,9 +437,13 @@
 static void
 gpk_application_menu_files_cb (GtkAction *action, GpkApplication *application)
 {
+	GPtrArray *array;
 	GError *error = NULL;
 	gchar **files;
-	gchar *text;
+	gchar *title;
+	GtkWidget *widget;
+	GtkWidget *dialog;
+	PkPackageId *id;
 
 	g_return_if_fail (PK_IS_APPLICATION (application));
 
@@ -472,18 +454,28 @@
 		return;
 	}
 
-	/* split and show */
-	text = g_strjoinv ("\n", files);
+	/* convert to pointer array */
+	array = pk_argv_to_ptr_array (files);
+	g_ptr_array_sort (array, (GCompareFunc) gpk_application_strcmp_indirect);
 
-	if (pk_strzero (text)) {
-		g_free (text);
-		text = g_strdup (_("No files"));
-	}
+	/* title */
+	id = pk_package_id_new_from_string (application->priv->package);
+	title = g_strdup_printf (ngettext ("%i file installed by %s",
+					   "%i files installed by %s",
+					   array->len), array->len, id->name);
+
+	widget = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
+	dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_DESTROY_WITH_PARENT,
+					 GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", title);
+	gpk_dialog_embed_file_list_widget (GTK_DIALOG (dialog), array);
 
-	gpk_application_modal_info (application, _("File list"), text);
+	gtk_dialog_run (GTK_DIALOG (dialog));
+	gtk_widget_destroy (GTK_WIDGET (dialog));
 
-	g_free (text);
+	g_free (title);
+	g_ptr_array_free (array, TRUE);
 	g_strfreev (files);
+	pk_package_id_free (id);
 }
 
 /**

Modified: trunk/src/gpk-client-requires.c
==============================================================================
--- trunk/src/gpk-client-requires.c	(original)
+++ trunk/src/gpk-client-requires.c	Tue Jul 15 09:24:14 2008
@@ -37,18 +37,29 @@
 #include "gpk-error.h"
 #include "gpk-common.h"
 #include "gpk-dialog.h"
+#include "gpk-client-private.h"
 
 static PkClient *client = NULL;
 
 /**
+ * gpk_client_status_changed_cb:
+ **/
+static void
+gpk_client_status_changed_cb (PkClient *client, PkStatusEnum status, GpkClient *gclient)
+{
+	gpk_client_set_status (gclient, status);
+}
+
+/**
  * gpk_client_requires_show:
  *
  * Return value: if we agreed to remove the deps
  **/
 gboolean
-gpk_client_requires_show (GtkWindow *window, gchar **package_ids)
+gpk_client_requires_show (GpkClient *gclient, gchar **package_ids)
 {
 	GtkWidget *dialog;
+	GtkWindow *window;
 	GtkResponseType button;
 	PkPackageList *list;
 	gboolean ret;
@@ -64,10 +75,16 @@
 	client = pk_client_new ();
 	pk_client_set_use_buffer (client, TRUE, NULL);
 	pk_client_set_synchronous (client, TRUE, NULL);
+	g_signal_connect (client, "status-changed",
+			  G_CALLBACK (gpk_client_status_changed_cb), gclient);
+
+	/* get the packages we depend on */
+	gpk_client_set_title (gclient, _("Finding packages we require"));
 
 	/* reset */
 	ret = pk_client_reset (client, &error);
 	if (!ret) {
+		window = gpk_client_get_window (gclient);
 		gpk_error_dialog_modal (window, _("Failed to reset client"), NULL, error->message);
 		g_error_free (error);
 		ret = FALSE;
@@ -77,6 +94,7 @@
 	/* find out if this would force removal of other packages */
 	ret = pk_client_get_requires (client, PK_FILTER_ENUM_INSTALLED, package_ids, TRUE, &error);
 	if (!ret) {
+		window = gpk_client_get_window (gclient);
 		gpk_error_dialog_modal (window, _("Failed to get requires"),
 					_("Could not work out what packages would also be removed"),
 					error->message);
@@ -114,6 +132,7 @@
 	g_free (name);
 
 	/* show UI */
+	window = gpk_client_get_window (gclient);
 	dialog = gtk_message_dialog_new (window, GTK_DIALOG_DESTROY_WITH_PARENT,
 					 GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, "%s", title);
 	gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);

Modified: trunk/src/gpk-client-requires.h
==============================================================================
--- trunk/src/gpk-client-requires.h	(original)
+++ trunk/src/gpk-client-requires.h	Tue Jul 15 09:24:14 2008
@@ -27,7 +27,7 @@
 G_BEGIN_DECLS
 
 void		 gpk_client_requires_self_test		(gpointer	 data);
-gboolean	 gpk_client_requires_show		(GtkWindow	*window,
+gboolean	 gpk_client_requires_show		(GpkClient	*gclient,
 							 gchar		**package_ids);
 
 G_END_DECLS

Modified: trunk/src/gpk-client.c
==============================================================================
--- trunk/src/gpk-client.c	(original)
+++ trunk/src/gpk-client.c	Tue Jul 15 09:24:14 2008
@@ -1092,7 +1092,6 @@
 	gboolean ret;
 	GError *error_local = NULL;
 	gchar *text = NULL;
-	GtkWidget *widget;
 
 	g_return_val_if_fail (GPK_IS_CLIENT (gclient), FALSE);
 	g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -1106,14 +1105,17 @@
 	/* set title */
 	gpk_client_setup_window (gclient, _("Remove packages"));
 
+	/* setup the UI */
+	gpk_client_set_progress_files (gclient, FALSE);
+	gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
+
 	/* are we dumb and can't check for depends? */
 	if (!pk_enums_contain (gclient->priv->roles, PK_ROLE_ENUM_GET_REQUIRES)) {
 		pk_warning ("skipping depends check");
 		goto skip_checks;
 	}
 
-	widget = glade_xml_get_widget (gclient->priv->glade_xml, "window_updates");
-	ret = gpk_client_requires_show (GTK_WINDOW (widget), package_ids);
+	ret = gpk_client_requires_show (gclient, package_ids);
 	/* did we click no or exit the window? */
 	if (!ret) {
 		gpk_client_error_msg (gclient, _("Failed to remove package"), _("Additional packages were also not removed"), NULL);
@@ -1133,6 +1135,7 @@
 	}
 
 	/* try to remove the package_ids */
+	gpk_client_set_progress_files (gclient, TRUE);
 	ret = pk_client_remove_packages (gclient->priv->client_action, package_ids, TRUE, FALSE, &error_local);
 	if (!ret) {
 		/* check if we got a permission denied */
@@ -1204,7 +1207,7 @@
 	gpk_client_setup_window (gclient, _("Install packages"));
 
 	/* setup the UI */
-	gpk_client_set_progress_files (gclient, TRUE);
+	gpk_client_set_progress_files (gclient, FALSE);
 	gpk_client_set_page (gclient, GPK_CLIENT_PAGE_PROGRESS);
 
 	/* are we dumb and can't check for depends? */
@@ -1234,6 +1237,7 @@
 
 	/* try to install the package_id */
 	gpk_client_set_title (gclient, _("Installing packages"));
+	gpk_client_set_progress_files (gclient, TRUE);
 	ret = pk_client_install_packages (gclient->priv->client_action, package_ids, &error_local);
 	if (!ret) {
 		/* check if we got a permission denied */

Modified: trunk/src/gpk-dialog.c
==============================================================================
--- trunk/src/gpk-dialog.c	(original)
+++ trunk/src/gpk-dialog.c	Tue Jul 15 09:24:14 2008
@@ -212,6 +212,56 @@
 }
 
 /**
+ * gpk_dialog_embed_file_list_widget:
+ **/
+gboolean
+gpk_dialog_embed_file_list_widget (GtkDialog *dialog, GPtrArray *files)
+{
+	GtkWidget *scroll;
+	GtkWidget *widget;
+	GtkTextBuffer *buffer;
+	gchar **array;
+	gchar *text;
+
+	/* split and show */
+	array = pk_ptr_array_to_argv (files);
+	text = g_strjoinv ("\n", array);
+
+	if (pk_strzero (text)) {
+		g_free (text);
+		text = g_strdup (_("No files"));
+	}
+
+	/* create a text view to hold the store */
+	widget = gtk_text_view_new ();
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);
+	gtk_text_view_set_left_margin (GTK_TEXT_VIEW (widget), 5);
+	gtk_text_view_set_right_margin (GTK_TEXT_VIEW (widget), 5);
+
+	/* scroll the treeview */
+	scroll = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+					GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), widget);
+	gtk_widget_show (scroll);
+
+	/* set in buffer */
+	buffer = gtk_text_buffer_new (NULL);
+	gtk_text_buffer_set_text (buffer, text, -1);
+	gtk_text_view_set_buffer (GTK_TEXT_VIEW (widget), buffer);
+	gtk_widget_show (widget);
+
+	/* add some spacing to conform to the GNOME HIG */
+	gtk_container_set_border_width (GTK_CONTAINER (scroll), 6);
+	gtk_widget_set_size_request (GTK_WIDGET (scroll), -1, 300);
+
+	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), scroll);
+	g_free (text);
+
+	return TRUE;
+}
+
+/**
  * gpk_client_checkbutton_show_depends_cb:
  **/
 static void

Modified: trunk/src/gpk-dialog.h
==============================================================================
--- trunk/src/gpk-dialog.h	(original)
+++ trunk/src/gpk-dialog.h	Tue Jul 15 09:24:14 2008
@@ -30,6 +30,8 @@
 
 gboolean	 gpk_dialog_embed_package_list_widget	(GtkDialog	*dialog,
 							 PkPackageList	*list);
+gboolean	 gpk_dialog_embed_file_list_widget	(GtkDialog	*dialog,
+							 GPtrArray	*files);
 gboolean	 gpk_dialog_embed_do_not_show_widget	(GtkDialog	*dialog,
 							 const gchar	*key);
 gchar		*gpk_dialog_package_id_name_join_locale	(gchar		**package_ids);

Modified: trunk/src/gpk-interface.h
==============================================================================
--- trunk/src/gpk-interface.h	(original)
+++ trunk/src/gpk-interface.h	Tue Jul 15 09:24:14 2008
@@ -53,7 +53,7 @@
 #endif /* !G_ENABLE_DEBUG */
 
 
-/* NONE:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.54JLDU:1) */
+/* NONE:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.YRR1DU:1) */
 extern void dbus_glib_marshal_gpk_dbus_VOID__STRING_POINTER (GClosure     *closure,
                                                              GValue       *return_value,
                                                              guint         n_param_values,

Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c	(original)
+++ trunk/src/gpk-update-viewer.c	Tue Jul 15 09:24:14 2008
@@ -767,6 +767,50 @@
 	return pretty;
 }
 
+/**
+ * gpk_update_viewer_pretty_description:
+ **/
+static gchar *
+gpk_update_viewer_pretty_description (const gchar *description)
+{
+	gchar **lines;
+	GString *string;
+	gchar *line;
+	gchar *line2;
+	guint len;
+	guint i;
+
+	/* process each line */
+	lines = g_strsplit (description, "\n", 0);
+	string = g_string_new ("");
+	len = g_strv_length (lines);
+	for (i=0; i<len; i++) {
+		/* do not free this */
+		line = g_strstrip (lines[i]);
+
+		/* common prefixes */
+		if (g_str_has_prefix (line, "- ") ||
+		    g_str_has_prefix (line, "* ")) {
+			line2 = g_strdup_printf ("â %s", line+2);
+		} else {
+			line2 = g_strdup (line);
+		}
+
+		/* if not null then append back */
+		if (!pk_strzero (line2)) {
+			g_string_append_printf (string, "%s\n", line2);
+		}
+		g_free (line2);
+	}
+	/* remove trailing \n */
+	if (string->len > 0) {
+		g_string_set_size (string, string->len - 1);
+	}
+	line = g_string_free (string, FALSE);
+	g_strfreev (lines);
+
+	return line;
+}
 
 /**
  * gpk_update_viewer_update_detail_cb:
@@ -781,6 +825,7 @@
 	gchar *package_pretty;
 	const gchar *info_text;
 	PkInfoEnum info;
+	gchar *line;
 
 	/* clear existing list */
 	gpk_update_viewer_description_animation_stop ();
@@ -829,14 +874,11 @@
 	gpk_update_viewer_add_description_item (_("Repository"), obj->id->data, NULL);
 
 	if (!pk_strzero (obj->update_text)) {
-		gchar *first;
-		gchar *second;
-		first = pk_strreplace (obj->update_text, "\n- ", "\nâ ");
-		second = pk_strreplace (first, "\n* ", "\nâ ");
+		/* convert the bullets */
+		line = gpk_update_viewer_pretty_description (obj->update_text);
 		/* translators: this is the package description */
-		gpk_update_viewer_add_description_item (_("Description"), second, NULL);
-		g_free (first);
-		g_free (second);
+		gpk_update_viewer_add_description_item (_("Description"), line, NULL);
+		g_free (line);
 	}
 
 	/* add all the links */



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