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



commit 401895e66a62102b67dd87c4f97c99b0071fc5fb
Author: Richard Hughes <richard hughsie com>
Date:   Sat Oct 3 16:22:29 2009 +0100

    moo

 src/gpk-application.c |  109 ++++++++++++++++---------------------------------
 1 files changed, 36 insertions(+), 73 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 474d585..6a6c86f 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -3191,54 +3191,17 @@ gpk_application_add_welcome (GpkApplication *application)
 /**
  * gpk_application_create_group_array_enum:
  **/
-static gboolean
+static void
 gpk_application_create_group_array_enum (GpkApplication *application)
 {
 	GtkWidget *widget;
 	guint i;
-	GtkTreeIter iter;
-	const gchar *icon_name;
 
 	/* set to no indent */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "treeview_groups"));
 	gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (widget), FALSE);
 	gtk_tree_view_set_level_indentation  (GTK_TREE_VIEW (widget), 0);
 
-	/* add an "all" entry if we can GetPackages */
-	if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_GET_PACKAGES)) {
-		gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
-		icon_name = gpk_role_enum_to_icon_name (PK_ROLE_ENUM_GET_PACKAGES);
-		gtk_tree_store_set (application->priv->groups_store, &iter,
-				    /* TRANSLATORS: title: all of the packages on the system and availble in sources */
-				    GROUPS_COLUMN_NAME, _("All packages"),
-				    /* TRANSLATORS: tooltip: all packages */
-				    GROUPS_COLUMN_SUMMARY, _("Show all packages"),
-				    GROUPS_COLUMN_ID, "all-packages",
-				    GROUPS_COLUMN_ACTIVE, TRUE,
-				    GROUPS_COLUMN_ICON, icon_name, -1);
-	}
-
-	/* no group information */
-	if (application->priv->groups == 0)
-		return FALSE;
-
-	/* add these at the top of the array */
-	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_COLLECTIONS))
-		gpk_application_group_add_data (application, PK_GROUP_ENUM_COLLECTIONS);
-	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_NEWEST))
-		gpk_application_group_add_data (application, PK_GROUP_ENUM_NEWEST);
-
-	/* add group item for selected items */
-	gpk_application_group_add_selected (application);
-
-	/* add a separator only if we can do both */
-	gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
-	gtk_tree_store_set (application->priv->groups_store, &iter,
-			    GROUPS_COLUMN_ID, "separator", -1);
-	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "treeview_groups"));
-	gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (widget),
-					      gpk_application_group_row_separator_func, NULL, NULL);
-
 	/* create group tree view if we can search by group */
 	if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_GROUP)) {
 		/* add all the groups supported (except collections, which we handled above */
@@ -3248,9 +3211,6 @@ gpk_application_create_group_array_enum (GpkApplication *application)
 				gpk_application_group_add_data (application, i);
 		}
 	}
-
-	/* we populated the menu  */
-	return TRUE;
 }
 
 /**
@@ -3267,7 +3227,6 @@ gpk_application_get_categories_cb (PkClient *client, GAsyncResult *res, GpkAppli
 	GtkTreeIter iter2;
 	guint i, j;
 	GtkTreeView *treeview;
-	const gchar *icon_name;
 	PkItemCategory *item;
 	PkItemCategory *item2;
 
@@ -3291,37 +3250,7 @@ gpk_application_get_categories_cb (PkClient *client, GAsyncResult *res, GpkAppli
 	gtk_tree_view_set_show_expanders (treeview, TRUE);
 	gtk_tree_view_set_level_indentation  (treeview, 3);
 
-	/* add an "all" entry if we can GetPackages */
-	if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_GET_PACKAGES)) {
-		gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
-		icon_name = gpk_role_enum_to_icon_name (PK_ROLE_ENUM_GET_PACKAGES);
-		gtk_tree_store_set (application->priv->groups_store, &iter,
-				    /* TRANSLATORS: title: all of the packages on the system and availble in sources */
-				    GROUPS_COLUMN_NAME, _("All packages"),
-				    /* TRANSLATORS: tooltip: all packages */
-				    GROUPS_COLUMN_SUMMARY, _("Show all packages"),
-				    GROUPS_COLUMN_ID, "all-packages",
-				    GROUPS_COLUMN_ACTIVE, TRUE,
-				    GROUPS_COLUMN_ICON, icon_name, -1);
-	}
-
-	/* add these at the top of the array */
-	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_COLLECTIONS))
-		gpk_application_group_add_data (application, PK_GROUP_ENUM_COLLECTIONS);
-	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_NEWEST))
-		gpk_application_group_add_data (application, PK_GROUP_ENUM_NEWEST);
-
-	/* add group item for selected items */
-	gpk_application_group_add_selected (application);
-
-	/* add a separator */
-	gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
-	gtk_tree_store_set (application->priv->groups_store, &iter,
-			    GROUPS_COLUMN_ID, "separator", -1);
-	gtk_tree_view_set_row_separator_func (treeview,
-					      gpk_application_group_row_separator_func, NULL, NULL);
-
-	/* add repos wih descriptions */
+	/* add repos with descriptions */
 	array = pk_results_get_category_array (results);
 	for (i=0; i<array->len; i++) {
 		item = g_ptr_array_index (array, i);
@@ -3425,6 +3354,8 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkAppl
 	gboolean ret;
 	PkBitfield filters;
 	gboolean enabled;
+	GtkTreeIter iter;
+	const gchar *icon_name;
 
 	/* get the result */
 	ret = pk_control_get_properties_finish (control, res, &error);
@@ -3543,6 +3474,38 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkAppl
 		gtk_widget_hide (widget);
 	}
 
+	/* add an "all" entry if we can GetPackages */
+	ret = gconf_client_get_bool (application->priv->gconf_client, GPK_CONF_APPLICATION_SHOW_ALL_PACKAGES, NULL);
+	if (ret && pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_GET_PACKAGES)) {
+		gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
+		icon_name = gpk_role_enum_to_icon_name (PK_ROLE_ENUM_GET_PACKAGES);
+		gtk_tree_store_set (application->priv->groups_store, &iter,
+				    /* TRANSLATORS: title: all of the packages on the system and availble in sources */
+				    GROUPS_COLUMN_NAME, _("All packages"),
+				    /* TRANSLATORS: tooltip: all packages */
+				    GROUPS_COLUMN_SUMMARY, _("Show all packages"),
+				    GROUPS_COLUMN_ID, "all-packages",
+				    GROUPS_COLUMN_ACTIVE, TRUE,
+				    GROUPS_COLUMN_ICON, icon_name, -1);
+	}
+
+	/* add these at the top of the array */
+	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_COLLECTIONS))
+		gpk_application_group_add_data (application, PK_GROUP_ENUM_COLLECTIONS);
+	if (pk_bitfield_contain (application->priv->groups, PK_GROUP_ENUM_NEWEST))
+		gpk_application_group_add_data (application, PK_GROUP_ENUM_NEWEST);
+
+	/* add group item for selected items */
+	gpk_application_group_add_selected (application);
+
+	/* add a separator */
+	gtk_tree_store_append (application->priv->groups_store, &iter, NULL);
+	gtk_tree_store_set (application->priv->groups_store, &iter,
+			    GROUPS_COLUMN_ID, "separator", -1);
+	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "treeview_groups"));
+	gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (widget),
+					      gpk_application_group_row_separator_func, NULL, NULL);
+
 	/* simple array or category tree? */
 	ret = gconf_client_get_bool (application->priv->gconf_client, GPK_CONF_APPLICATION_CATEGORY_GROUPS, NULL);
 	if (ret && pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_GET_CATEGORIES))



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