[gnome-packagekit/glib2: 54/79] moo



commit 06c65600d0bcc5cefeea1ead4a353c786d88e27e
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 2 15:40:14 2009 +0100

    moo

 src/Makefile.am         |    4 +-
 src/gpk-application.c   |  217 ++++++++++++++++++++++-------------------------
 src/gpk-service-pack.c  |   34 ++-----
 src/gpk-update-viewer.c |    2 +-
 4 files changed, 112 insertions(+), 145 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4bbd08e..17aff7c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,11 +34,11 @@ INCLUDES =						\
 	$(NULL)
 
 if FALSE
-	gpk-application					
 	gpk-update-viewer				
 endif
 
 bin_PROGRAMS =						\
+	gpk-application					\
 	gpk-repo					\
 	gpk-prefs					\
 	gpk-install-catalog				\
@@ -183,7 +183,6 @@ gpk_update_icon_LDADD =					\
 	$(shared_LIBS)					\
 	$(NULL)
 
-if FALSE
 gpk_application_SOURCES =				\
 	gpk-application-main.c				\
 	gpk-application.c				\
@@ -196,7 +195,6 @@ gpk_application_LDADD =					\
 	libgpkshared.a					\
 	$(shared_LIBS)					\
 	$(NULL)
-endif
 
 gpk_service_pack_SOURCES =				\
 	gpk-service-pack.c				\
diff --git a/src/gpk-application.c b/src/gpk-application.c
index a9f7b9b..6e444da 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -82,7 +82,6 @@ struct GpkApplicationPrivate
 	EggMarkdown		*markdown;
 	PkControl		*control;
 	PkClient		*client;
-	PkControl		*pconnection;
 	PkDesktop		*desktop;
 	gchar			*group;
 	gchar			*url;
@@ -100,9 +99,6 @@ struct GpkApplicationPrivate
 	GPtrArray		*package_array;
 	GtkWidget		*image_status;
 	GpkHelperRun		*helper_run;
-#if !PK_CHECK_VERSION(0,5,2)
-	gboolean		 dep_check_info_only; /* bodge to tell apart the differing uses of GetDepends */
-#endif
 	guint			 status_id;
 	PkStatusEnum		 status_last;
 };
@@ -312,7 +308,7 @@ gpk_application_packages_checkbox_invert (GpkApplication *application)
 	checkbox = gpk_application_state_get_checkbox (state);
 
 	/* set new value */
-	gtk_array_store_set (GTK_LIST_STORE (model), &iter,
+	gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 			    PACKAGES_COLUMN_STATE, state,
 			    PACKAGES_COLUMN_CHECKBOX, checkbox,
 			    PACKAGES_COLUMN_IMAGE, icon,
@@ -392,7 +388,7 @@ gpk_application_set_buttons_apply_clear (GpkApplication *application)
 		g_free (package_id);
 
 		/* set visible */
-		gtk_array_store_set (GTK_LIST_STORE (model), &iter, PACKAGES_COLUMN_CHECKBOX_VISIBLE, enabled, -1);
+		gtk_list_store_set (GTK_LIST_STORE (model), &iter, PACKAGES_COLUMN_CHECKBOX_VISIBLE, enabled, -1);
 		valid = gtk_tree_model_iter_next (model, &iter);
 	}
 }
@@ -685,9 +681,6 @@ gpk_application_menu_requires_cb (GtkAction *action, GpkApplication *application
 
 	/* get the requires */
 	package_ids = pk_package_ids_from_id (package_id_selected);
-#if !PK_CHECK_VERSION(0,5,2)
-	application->priv->dep_check_info_only = TRUE;
-#endif
 	ret = pk_client_get_requires (application->priv->client, PK_FILTER_ENUM_NONE,
 				      package_ids, TRUE, &error);
 	if (!ret) {
@@ -720,9 +713,6 @@ gpk_application_menu_depends_cb (GtkAction *action, GpkApplication *application)
 
 	/* get the depends */
 	package_ids = pk_package_ids_from_id (package_id_selected);
-#if !PK_CHECK_VERSION(0,5,2)
-	application->priv->dep_check_info_only = TRUE;
-#endif
 	ret = pk_client_get_depends (application->priv->client, PK_FILTER_ENUM_NONE,
 				     package_ids, TRUE, &error);
 	if (!ret) {
@@ -780,8 +770,8 @@ gpk_application_add_detail_item (GpkApplication *application, const gchar *title
 	markup = g_strdup_printf ("<b>%s:</b>", title);
 
 	egg_debug ("%s %s %s", markup, text, uri);
-	gtk_array_store_append (application->priv->details_store, &iter);
-	gtk_array_store_set (application->priv->details_store, &iter,
+	gtk_list_store_append (application->priv->details_store, &iter);
+	gtk_list_store_set (application->priv->details_store, &iter,
 			    DETAIL_COLUMN_TITLE, markup,
 			    DETAIL_COLUMN_TEXT, text,
 			    DETAIL_COLUMN_URI, uri,
@@ -804,7 +794,7 @@ gpk_application_clear_details_really (GpkApplication *application)
 	GtkWidget *widget;
 
 	/* hide details */
-	gtk_array_store_clear (application->priv->details_store);
+	gtk_list_store_clear (application->priv->details_store);
 
 	/* clear the old text */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "textview_description"));
@@ -837,7 +827,7 @@ static void
 gpk_application_clear_packages (GpkApplication *application)
 {
 	/* clear existing array */
-	gtk_array_store_clear (application->priv->packages_store);
+	gtk_list_store_clear (application->priv->packages_store);
 	application->priv->has_package = FALSE;
 }
 
@@ -857,7 +847,7 @@ gpk_application_text_format_display (GpkApplication *application, const gchar *a
  * gpk_application_details_cb:
  **/
 static void
-gpk_application_details_cb (PkClient *client, PkDetailsObj *details, GpkApplication *application)
+gpk_application_details_cb (PkClient *client, PkItemDetails *item, GpkApplication *application)
 {
 	GtkWidget *widget;
 	gchar *text;
@@ -865,58 +855,60 @@ gpk_application_details_cb (PkClient *client, PkDetailsObj *details, GpkApplicat
 	const gchar *repo_name;
 	const gchar *group;
 	gboolean installed;
+	gchar **split = NULL;
 
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
-	installed = g_strcmp0 (details->id->data, "installed") == 0;
+	split = pk_package_id_split (item->package_id);
+	installed = g_strcmp0 (split[PK_PACKAGE_ID_DATA], "installed") == 0;
 
 	/* hide to start */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "scrolledwindow_detail"));
 	gtk_widget_show (widget);
 
-	gtk_array_store_clear (application->priv->details_store);
+	gtk_list_store_clear (application->priv->details_store);
 
 	/* if a collection, mark as such */
-	if (g_strcmp0 (details->id->data, "meta") == 0)
+	if (g_strcmp0 (split[PK_PACKAGE_ID_DATA], "meta") == 0)
 		/* TRANSLATORS: the type of package is a collection (metagroup) */
 		gpk_application_add_detail_item (application, _("Type"), _("Collection"), NULL);
 
 	/* homepage */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_homepage"));
-	if (egg_strzero (details->url) == FALSE) {
+	if (egg_strzero (item->url) == FALSE) {
 		gtk_widget_set_sensitive (widget, TRUE);
 
 		/* TRANSLATORS: tooltip: go to the web address */
-		text = g_strdup_printf (_("Visit %s"), details->url);
+		text = g_strdup_printf (_("Visit %s"), item->url);
 		gtk_widget_set_tooltip_text (widget, text);
 		g_free (text);
 
 		/* TRANSLATORS: add an entry to go to the project home page */
-		gpk_application_add_detail_item (application, _("Project"), _("Homepage"), details->url);
+		gpk_application_add_detail_item (application, _("Project"), _("Homepage"), item->url);
 
 		/* save the url for the button */
 		g_free (application->priv->url);
-		application->priv->url = g_strdup (details->url);
+		application->priv->url = g_strdup (item->url);
 
 	} else {
 		gtk_widget_set_sensitive (widget, FALSE);
 	}
 
 	/* group */
-	if (details->group != PK_GROUP_ENUM_UNKNOWN) {
-		group = gpk_group_enum_to_localised_text (details->group);
+	if (item->group != PK_GROUP_ENUM_UNKNOWN) {
+		group = gpk_group_enum_to_localised_text (item->group);
 		/* TRANSLATORS: the group the package belongs in */
 		gpk_application_add_detail_item (application, _("Group"), group, NULL);
 	}
 
 	/* group */
-	if (!egg_strzero (details->license)) {
+	if (!egg_strzero (item->license)) {
 		/* TRANSLATORS: the licence string for the package */
-		gpk_application_add_detail_item (application, _("License"), details->license, NULL);
+		gpk_application_add_detail_item (application, _("License"), item->license, NULL);
 	}
 
 	/* menu path */
-	value = gpk_desktop_guess_best_file (application->priv->desktop, details->id->name);
+	value = gpk_desktop_guess_best_file (application->priv->desktop, split[PK_PACKAGE_ID_NAME]);
 	if (value != NULL) {
 		text = gpk_desktop_get_menu_path (value);
 		if (text != NULL) {
@@ -928,16 +920,16 @@ gpk_application_details_cb (PkClient *client, PkDetailsObj *details, GpkApplicat
 	g_free (value);
 
 	/* set the description */
-	text = gpk_application_text_format_display (application, details->description);
+	text = gpk_application_text_format_display (application, item->description);
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "textview_description"));
 	gpk_application_set_text_buffer (widget, text);
 	g_free (text);
 
 	/* if non-zero, set the size */
-	if (details->size > 0) {
+	if (item->size > 0) {
 		/* set the size */
-		value = g_format_size_for_display (details->size);
-		if (g_strcmp0 (details->id->data, "meta") == 0)
+		value = g_format_size_for_display (item->size);
+		if (g_strcmp0 (split[PK_PACKAGE_ID_DATA], "meta") == 0)
 			/* TRANSLATORS: the size of the meta package */
 			gpk_application_add_detail_item (application, _("Size"), value, NULL);
 		else if (installed)
@@ -950,12 +942,13 @@ gpk_application_details_cb (PkClient *client, PkDetailsObj *details, GpkApplicat
 	}
 
 	/* set the repo text, or hide if installed */
-	if (!installed && g_strcmp0 (details->id->data, "meta") != 0) {
+	if (!installed && g_strcmp0 (split[PK_PACKAGE_ID_DATA], "meta") != 0) {
 		/* get the full name of the repo from the repo_id */
-		repo_name = gpk_application_get_full_repo_name (application, details->id->data);
+		repo_name = gpk_application_get_full_repo_name (application, split[PK_PACKAGE_ID_DATA]);
 		/* TRANSLATORS: where the package came from, the software source name */
 		gpk_application_add_detail_item (application, _("Source"), repo_name, NULL);
 	}
+	g_strfreev (split);
 }
 
 /**
@@ -1011,8 +1004,8 @@ gpk_application_add_item_to_results (GpkApplication *application, const PkItemPa
 	/* can we modify this? */
 	enabled = gpk_application_get_checkbox_enable (application, state);
 
-	gtk_array_store_append (application->priv->packages_store, &iter);
-	gtk_array_store_set (application->priv->packages_store, &iter,
+	gtk_list_store_append (application->priv->packages_store, &iter);
+	gtk_list_store_set (application->priv->packages_store, &iter,
 			    PACKAGES_COLUMN_STATE, state,
 			    PACKAGES_COLUMN_CHECKBOX, installed ^ in_queue,
 			    PACKAGES_COLUMN_CHECKBOX_VISIBLE, enabled,
@@ -1108,8 +1101,8 @@ gpk_application_suggest_better_search (GpkApplication *application)
 	}
 
 	text = g_strdup_printf ("%s\n%s", title, message);
-	gtk_array_store_append (application->priv->packages_store, &iter);
-	gtk_array_store_set (application->priv->packages_store, &iter,
+	gtk_list_store_append (application->priv->packages_store, &iter);
+	gtk_list_store_set (application->priv->packages_store, &iter,
 			    PACKAGES_COLUMN_STATE, state,
 			    PACKAGES_COLUMN_CHECKBOX, FALSE,
 			    PACKAGES_COLUMN_CHECKBOX_VISIBLE, FALSE,
@@ -1266,7 +1259,7 @@ gpk_application_select_exact_match (GpkApplication *application, const gchar *te
 	GtkTreeModel *model;
 	GtkTreeSelection *selection = NULL;
 	gchar *package_id;
-	gchar *id;
+	gchar *split;
 
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
@@ -1281,15 +1274,15 @@ gpk_application_select_exact_match (GpkApplication *application, const gchar *te
 		if (package_id != NULL) {
 
 			/* exact match, so select and scroll */
-			id = xxxnotneededanymore (package_id);
-			if (g_strcmp0 (id->name, text) == 0) {
+			split = pk_package_id_split (package_id);
+			if (g_strcmp0 (split[PK_PACKAGE_ID_NAME], text) == 0) {
 				selection = gtk_tree_view_get_selection (treeview);
 				gtk_tree_selection_select_iter (selection, &iter);
 				path = gtk_tree_model_get_path (model, &iter);
 				gtk_tree_view_scroll_to_cell (treeview, path, NULL, FALSE, 0.5f, 0.5f);
 				gtk_tree_path_free (path);
 			}
-			g_free (id);
+			g_strfreev (split);
 
 			/* no point continuing for a second match */
 			if (selection != NULL)
@@ -1827,7 +1820,7 @@ gpk_application_button_clear_cb (GtkWidget *widget_button, GpkApplication *appli
 			checkbox = gpk_application_state_get_checkbox (state);
 
 			/* set new value */
-			gtk_array_store_set (GTK_LIST_STORE (model), &iter,
+			gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 					    PACKAGES_COLUMN_STATE, state,
 					    PACKAGES_COLUMN_CHECKBOX, checkbox,
 					    PACKAGES_COLUMN_IMAGE, icon,
@@ -2091,7 +2084,7 @@ out:
  * gpk_application_connection_changed_cb:
  **/
 static void
-gpk_application_connection_changed_cb (PkControl *pconnection, gboolean connected, GpkApplication *application)
+gpk_application_connection_changed_cb (PkControl *control, gboolean connected, GpkApplication *application)
 {
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
@@ -2883,23 +2876,6 @@ gpk_application_group_row_separator_func (GtkTreeModel *model, GtkTreeIter *iter
 }
 
 /**
- * pk_application_repo_detail_cb:
- **/
-static void
-pk_application_repo_detail_cb (PkClient *client, const gchar *repo_id,
-			       const gchar *description, gboolean enabled,
-			       GpkApplication *application)
-{
-	g_return_if_fail (GPK_IS_APPLICATION (application));
-
-	egg_debug ("repo = %s:%s", repo_id, description);
-	/* no problem, just no point adding as we will fallback to the repo_id */
-	if (description == NULL)
-		return;
-	g_hash_table_insert (application->priv->repos, g_strdup (repo_id), g_strdup (description));
-}
-
-/**
  * gpk_application_treeview_renderer_clicked:
  **/
 static void
@@ -2950,7 +2926,7 @@ gpk_application_add_welcome (GpkApplication *application)
 	PkBitfield state = 0;
 
 	gpk_application_clear_packages (application);
-	gtk_array_store_append (application->priv->packages_store, &iter);
+	gtk_list_store_append (application->priv->packages_store, &iter);
 
 	/* enter something nice */
 	if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_GROUP)) {
@@ -2960,7 +2936,7 @@ gpk_application_add_welcome (GpkApplication *application)
 		/* TRANSLATORS: welcome text if we have to search by name */
 		welcome = _("Enter a package name and then click find to get started.");
 	}
-	gtk_array_store_set (application->priv->packages_store, &iter,
+	gtk_list_store_set (application->priv->packages_store, &iter,
 			    PACKAGES_COLUMN_STATE, state,
 			    PACKAGES_COLUMN_CHECKBOX, FALSE,
 			    PACKAGES_COLUMN_CHECKBOX_VISIBLE, FALSE,
@@ -3205,9 +3181,9 @@ gpk_application_files_cb (PkClient *client, const gchar *package_id,
 	gchar *title;
 	GtkWindow *window;
 	GtkWidget *dialog;
-	gchar *id;
 	gchar *package_id_selected = NULL;
 	gboolean ret;
+	gchar **split;
 
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
@@ -3225,16 +3201,16 @@ gpk_application_files_cb (PkClient *client, const gchar *package_id,
 	g_ptr_array_sort (array, (GCompareFunc) gpk_application_strcmp_indirect);
 
 	/* title */
-	id = xxxnotneededanymore (package_id_selected);
+	split = pk_package_id_split (package_id_selected);
 	/* TRANSLATORS: title: how many files are installed by the application */
 	title = g_strdup_printf (ngettext ("%i file installed by %s",
 					   "%i files installed by %s",
-					   array->len), array->len, id->name);
+					   array->len), array->len, split[PK_PACKAGE_ID_NAME]);
 
 	window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
 	dialog = gtk_message_dialog_new (window, GTK_DIALOG_DESTROY_WITH_PARENT,
 					 GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", title);
-	gpk_dialog_embed_file_array_widget (GTK_DIALOG (dialog), array);
+	gpk_dialog_embed_file_list_widget (GTK_DIALOG (dialog), array);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
 	gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 250);
 
@@ -3244,7 +3220,7 @@ gpk_application_files_cb (PkClient *client, const gchar *package_id,
 	g_free (title);
 	g_ptr_array_unref (array);
 	g_strfreev (files);
-	g_free (id);
+	g_strfreev (split);
 out:
 	g_free (package_id_selected);
 }
@@ -3253,14 +3229,14 @@ out:
  * pk_backend_status_get_properties_cb:
  **/
 static void
-pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLoop *loop)
+pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkApplication *application)
 {
 	GtkWidget *widget;
 	GError *error = NULL;
 	PkControl *control = PK_CONTROL(object);
 	gboolean ret;
 	PkBitfield filters;
-	PkBitfield roles;
+	gboolean enabled;
 
 	/* get the result */
 	ret = pk_control_get_properties_finish (control, res, &error);
@@ -3268,14 +3244,13 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLo
 		/* TRANSLATORS: daemon is broken */
 		g_print ("%s: %s\n", _("Exiting as properties could not be retrieved"), error->message);
 		g_error_free (error);
-		g_main_loop_quit (loop);
 		goto out;
 	}
 
 	/* get values */
 	g_object_get (control,
 		      "roles", &application->priv->roles,
-		      "filters", &application->priv->filters,
+		      "filters", &filters,
 		      "groups", &application->priv->groups,
 		      NULL);
 
@@ -3317,34 +3292,34 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLo
 
 
 	/* hide the filters we can't support */
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_INSTALLED) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_installed"));
 		gtk_widget_hide (widget);
 	}
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_DEVELOPMENT) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_DEVELOPMENT) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_devel"));
 		gtk_widget_hide (widget);
 	}
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_GUI) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_GUI) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_gui"));
 		gtk_widget_hide (widget);
 	}
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_FREE) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_FREE) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_free"));
 		gtk_widget_hide (widget);
 	}
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_ARCH) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_ARCH) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_arch"));
 		gtk_widget_hide (widget);
 	}
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_SOURCE) == FALSE) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_SOURCE) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_source"));
 		gtk_widget_hide (widget);
 	}
 
 	/* BASENAME, use by default, or hide */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_basename"));
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_BASENAME)) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_BASENAME)) {
 		enabled = gconf_client_get_bool (application->priv->gconf_client,
 						 GPK_CONF_APPLICATION_FILTER_BASENAME, NULL);
 		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), enabled);
@@ -3356,7 +3331,7 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLo
 
 	/* NEWEST, use by default, or hide */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_newest"));
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_NEWEST)) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NEWEST)) {
 		/* set from remembered state */
 		enabled = gconf_client_get_bool (application->priv->gconf_client,
 						 GPK_CONF_APPLICATION_FILTER_NEWEST, NULL);
@@ -3369,7 +3344,7 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLo
 
 	/* ARCH, use by default, or hide */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_arch"));
-	if (pk_bitfield_contain (application->priv->filters, PK_FILTER_ENUM_ARCH)) {
+	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_ARCH)) {
 		/* set from remembered state */
 		enabled = gconf_client_get_bool (application->priv->gconf_client,
 						 GPK_CONF_APPLICATION_FILTER_ARCH, NULL);
@@ -3391,6 +3366,43 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GMainLo
 out:
 	return;
 }
+
+/**
+ * gpk_application_get_repo_list_cb:
+ **/
+static void
+gpk_application_get_repo_list_cb (PkClient *client, GAsyncResult *res, GpkApplication *application)
+{
+	PkResults *results;
+	GError *error = NULL;
+	GPtrArray *array = NULL;
+	PkItemRepoDetail *item;
+	guint i;
+
+	/* get the results */
+	results = pk_client_generic_finish (client, res, &error);
+	if (results == NULL) {
+		egg_warning ("failed to get list of repos: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* add repos wih descriptions */
+	array = pk_results_get_repo_detail_array (results);
+	for (i=0; i<array->len; i++) {
+		item = g_ptr_array_index (array, i);
+		egg_debug ("repo = %s:%s", item->repo_id, item->description);
+		/* no problem, just no point adding as we will fallback to the repo_id */
+		if (item->description == NULL)
+			continue;
+		g_hash_table_insert (application->priv->repos, g_strdup (item->repo_id), g_strdup (item->description));
+	}
+
+out:
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	if (results != NULL)
+		g_object_unref (results);
 }
 
 /**
@@ -3404,7 +3416,6 @@ gpk_application_init (GpkApplication *application)
 	GtkWidget *image;
 	GtkEntryCompletion *completion;
 	GtkTreeSelection *selection;
-	gboolean enabled;
 	gboolean ret;
 	gchar *mode;
 	GError *error = NULL;
@@ -3417,9 +3428,6 @@ gpk_application_init (GpkApplication *application)
 	application->priv->url = NULL;
 	application->priv->search_text = NULL;
 	application->priv->has_package = FALSE;
-#if !PK_CHECK_VERSION(0,5,2)
-	application->priv->dep_check_info_only = FALSE;
-#endif
 	application->priv->details_event_id = 0;
 	application->priv->status_id = 0;
 	application->priv->status_last = PK_STATUS_ENUM_UNKNOWN;
@@ -3443,7 +3451,7 @@ gpk_application_init (GpkApplication *application)
 				 application, NULL, NULL);
 
 	/* create array stores */
-	application->priv->packages_store = gtk_array_store_new (PACKAGES_COLUMN_LAST,
+	application->priv->packages_store = gtk_list_store_new (PACKAGES_COLUMN_LAST,
 							        G_TYPE_STRING,
 								G_TYPE_UINT64,
 							        G_TYPE_BOOLEAN,
@@ -3457,7 +3465,7 @@ gpk_application_init (GpkApplication *application)
 							      G_TYPE_STRING,
 							      G_TYPE_STRING,
 							      G_TYPE_BOOLEAN);
-	application->priv->details_store = gtk_array_store_new (DETAIL_COLUMN_LAST,
+	application->priv->details_store = gtk_list_store_new (DETAIL_COLUMN_LAST,
 							       G_TYPE_STRING,
 							       G_TYPE_STRING,
 							       G_TYPE_STRING);
@@ -3472,31 +3480,9 @@ gpk_application_init (GpkApplication *application)
 
 	/* this is what we use mainly */
 	application->priv->client = pk_client_new ();
-	g_signal_connect (application->priv->client, "files",
-			  G_CALLBACK (gpk_application_files_cb), application);
-	g_signal_connect (application->priv->client, "package",
-			  G_CALLBACK (gpk_application_package_cb), application);
-	g_signal_connect (application->priv->client, "details",
-			  G_CALLBACK (gpk_application_details_cb), application);
-	g_signal_connect (application->priv->client, "error-code",
-			  G_CALLBACK (gpk_application_error_code_cb), application);
-	g_signal_connect (application->priv->client, "finished",
-			  G_CALLBACK (gpk_application_finished_cb), application);
-	g_signal_connect (application->priv->client, "status-changed",
-			  G_CALLBACK (gpk_application_status_changed_cb), application);
-	g_signal_connect (application->priv->client, "allow-cancel",
-			  G_CALLBACK (gpk_application_allow_cancel_cb), application);
-	g_signal_connect (application->priv->client, "repo-detail",
-			  G_CALLBACK (pk_application_repo_detail_cb), application);
-	g_signal_connect (application->priv->client, "repo-signature-required",
-			  G_CALLBACK (gpk_application_repo_signature_required_cb), application);
-	g_signal_connect (application->priv->client, "eula-required",
-			  G_CALLBACK (gpk_application_eula_required_cb), application);
-	g_signal_connect (application->priv->client, "media-change-required",
-			  G_CALLBACK (gpk_application_media_change_required_cb), application);
 
 	/* get properties */
-	pk_control_get_properties_async (application->priv->control, NULL, (GAsyncReadyCallback) pk_backend_status_get_properties_cb, loop);
+	pk_control_get_properties_async (application->priv->control, NULL, (GAsyncReadyCallback) pk_backend_status_get_properties_cb, application);
 	g_signal_connect (application->priv->control, "connection-changed",
 			  G_CALLBACK (gpk_application_connection_changed_cb), application);
 
@@ -3801,11 +3787,9 @@ gpk_application_init (GpkApplication *application)
 			  G_CALLBACK (gpk_application_groups_treeview_changed_cb), application);
 
 	/* get repos, so we can show the full name in the software source box */
-	ret = pk_client_get_repo_array (application->priv->client, PK_FILTER_ENUM_NONE, &error);
-	if (!ret) {
-		egg_warning ("failed to get repo array: %s", error->message);
-		g_error_free (error);
-	}
+	pk_client_get_repo_list_async (application->priv->client, PK_FILTER_ENUM_NONE, NULL,
+				       NULL, NULL,
+				       (GAsyncReadyCallback) gpk_application_get_repo_list_cb, application);
 
 	/* set current action */
 	application->priv->action = PK_ACTION_NONE;
@@ -3877,7 +3861,6 @@ gpk_application_finalize (GObject *object)
 	g_object_unref (application->priv->details_store);
 	g_object_unref (application->priv->control);
 	g_object_unref (application->priv->client);
-	g_object_unref (application->priv->pconnection);
 	g_object_unref (application->priv->desktop);
 	g_object_unref (application->priv->gconf_client);
 	g_object_unref (application->priv->markdown);
diff --git a/src/gpk-service-pack.c b/src/gpk-service-pack.c
index 718db8c..45a40aa 100644
--- a/src/gpk-service-pack.c
+++ b/src/gpk-service-pack.c
@@ -190,27 +190,6 @@ gpk_pack_set_percentage (guint percentage)
 	gtk_progress_bar_set_fraction (progress_bar, percentage / 100.0f);
 }
 
-#if 0
-/**
- * gpk_pack_percentage_cb:
- **/
-static void
-gpk_pack_percentage_cb (PkServicePack *pack, guint percentage, gpointer data)
-{
-	gpk_pack_set_percentage (percentage);
-}
-
-/**
- * gpk_pack_progress_changed_cb:
- **/
-static void
-gpk_pack_progress_changed_cb (PkClient *_client, guint percentage, guint subpercentage,
-			      guint elapsed, guint remaining, gpointer data)
-{
-	gpk_pack_set_percentage (percentage);
-}
-#endif
-
 /**
  * gpk_pack_resolve_package_id:
  **/
@@ -413,12 +392,19 @@ static void
 gpk_pack_progress_cb (PkProgress *progress, PkProgressType type, gpointer userdata)
 {
 	PkStatusEnum status;
+	gint percentage;
+
+	g_object_get (progress,
+		      "status", &status,
+		      "percentage", &percentage,
+		      NULL);
+
 	if (type == PK_PROGRESS_TYPE_STATUS) {
-		g_object_get (progress,
-			      "status", &status,
-			      NULL);
 		egg_debug ("now %s", pk_status_enum_to_text (status));
+	} else (type == PK_PROGRESS_TYPE_PERCENTAGE) {
+		gpk_pack_set_percentage (percentage);
 	}
+
 }
 
 /**
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 5030dd4..5d3d8e1 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -499,7 +499,7 @@ gpk_update_viewer_model_get_path (GtkTreeModel *model, const gchar *id)
  * gpk_update_viewer_details_cb:
  **/
 static void
-gpk_update_viewer_details_cb (PkClient *client, const PkDetailsObj *item, gpointer data)
+gpk_update_viewer_details_cb (PkClient *client, const PkItemDetails *item, gpointer data)
 {
 	GtkTreeView *treeview;
 	GtkTreeModel *model;



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