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



commit 4f8f1b1e9c37daa0123d6eb8c4cd00121b56ca54
Author: Richard Hughes <richard hughsie com>
Date:   Sat Oct 3 16:01:42 2009 +0100

    moo

 data/gpk-application.ui |    5 +++++
 src/gpk-application.c   |   35 +++++++++++++++++++++++++----------
 src/gpk-common.c        |   28 +++++++++++++++-------------
 src/gpk-prefs.c         |    4 +++-
 4 files changed, 48 insertions(+), 24 deletions(-)
---
diff --git a/data/gpk-application.ui b/data/gpk-application.ui
index f6358c6..740fd22 100644
--- a/data/gpk-application.ui
+++ b/data/gpk-application.ui
@@ -9,6 +9,7 @@
     <child>
       <object class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <child>
           <object class="GtkMenuBar" id="menubar1">
             <property name="visible">True</property>
@@ -430,9 +431,11 @@
             <child>
               <object class="GtkVBox" id="vbox2">
                 <property name="visible">True</property>
+                <property name="orientation">vertical</property>
                 <child>
                   <object class="GtkVBox" id="vbox3">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <child>
                       <object class="GtkHBox" id="hbox7">
                         <property name="visible">True</property>
@@ -440,6 +443,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox_groups">
                             <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkHBox" id="hbox26">
@@ -534,6 +538,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox4">
                             <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkScrolledWindow" id="scrolledwindow_packages">
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 293ea74..474d585 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -481,9 +481,9 @@ gpk_application_install (GpkApplication *application)
 
 	/* add to array */
 	package = pk_package_new ();
+	pk_package_set_id (package, package_id_selected, NULL);
 	g_object_set (package,
 		      "info", PK_INFO_ENUM_AVAILABLE,
-		      "id", package_id_selected,
 		      "summary", summary_selected,
 		      NULL);
 	pk_package_sack_add_package (application->priv->package_sack, package);
@@ -689,6 +689,8 @@ gpk_application_progress_cb (PkProgress *progress, PkProgressType type, GpkAppli
 
 			widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "hbox_status"));
 			gtk_widget_hide (widget);
+			widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "progressbar_progress"));
+			gtk_widget_hide (widget);
 			gpk_animated_icon_enable_animation (GPK_ANIMATED_ICON (application->priv->image_status), FALSE);
 			goto out;
 		}
@@ -704,7 +706,14 @@ gpk_application_progress_cb (PkProgress *progress, PkProgressType type, GpkAppli
 		application->priv->status_last = status;
 
 	} else if (type == PK_PROGRESS_TYPE_PERCENTAGE) {
-		egg_debug ("now %i", percentage);
+		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "progressbar_progress"));
+		if (percentage > 0) {
+			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), (gfloat) percentage / 100.0f);
+			gtk_widget_show (widget);
+		} else {
+			gtk_widget_hide (widget);
+		}
+
 	} else if (type == PK_PROGRESS_TYPE_ALLOW_CANCEL) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "button_cancel"));
 		gtk_widget_set_sensitive (widget, allow_cancel);
@@ -780,7 +789,7 @@ gpk_application_remove (GpkApplication *application)
 	}
 
 	/* already added */
-	ret = (pk_package_sack_find_by_id (application->priv->package_sack, package_id_selected) != NULL);
+	ret = (pk_package_sack_find_by_id (application->priv->package_sack, package_id_selected) == NULL);
 	if (!ret) {
 		egg_warning ("already added");
 		goto out;
@@ -788,9 +797,9 @@ gpk_application_remove (GpkApplication *application)
 
 	application->priv->action = PK_ACTION_REMOVE;
 	package = pk_package_new ();
+	pk_package_set_id (package, package_id_selected, NULL);
 	g_object_set (package,
 		      "info", PK_INFO_ENUM_AVAILABLE,
-		      "id", package_id_selected,
 		      "summary", summary_selected,
 		      NULL);
 	pk_package_sack_add_package (application->priv->package_sack, package);
@@ -1666,7 +1675,7 @@ gpk_application_populate_selected (GpkApplication *application)
 
 	/* get size */
 	len = pk_package_sack_get_size (application->priv->package_sack);
-	
+
 	/* nothing in queue */
 	if (len == 0) {
 		gpk_application_suggest_better_search (application);
@@ -2385,14 +2394,20 @@ out:
 }
 
 /**
- * gpk_application_connection_changed_cb:
+ * gpk_application_notify_network_state_cb:
  **/
 static void
-gpk_application_connection_changed_cb (PkControl *control, gboolean connected, GpkApplication *application)
+gpk_application_notify_network_state_cb (PkControl *control, GParamSpec *pspec, GpkApplication *application)
 {
+	PkNetworkEnum state;
+
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
-	egg_debug ("connected=%i", connected);
+	/* show icon? */
+	g_object_get (control,
+		      "network-state", &state,
+		      NULL);
+	egg_debug ("state=%i", state);
 }
 
 /**
@@ -3665,8 +3680,8 @@ gpk_application_init (GpkApplication *application)
 
 	/* get properties */
 	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);
+	g_signal_connect (application->priv->control, "notify::network-state",
+			  G_CALLBACK (gpk_application_notify_network_state_cb), application);
 
 	/* get localised data from sqlite database */
 	application->priv->desktop = pk_desktop_new ();
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 265498c..472e232 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -297,20 +297,20 @@ gpk_package_id_format_twoline (const gchar *package_id, const gchar *summary)
 
 	/* optional */
 	split = pk_package_id_split (package_id);
-	if (summary == NULL || summary[0] == '\0') {
-		string = g_string_new (split[0]);
+	if (summary == NULL || summary[PK_PACKAGE_ID_NAME] == '\0') {
+		string = g_string_new (split[PK_PACKAGE_ID_NAME]);
 	} else {
 		string = g_string_new ("");
 		summary_safe = g_markup_escape_text (summary, -1);
-		g_string_append_printf (string, "<b>%s</b>\n%s", summary_safe, split[0]);
+		g_string_append_printf (string, "<b>%s</b>\n%s", summary_safe, split[PK_PACKAGE_ID_NAME]);
 		g_free (summary_safe);
 	}
 
 	/* some backends don't provide this */
-	if (split[1][0] != '\0')
-		g_string_append_printf (string, "-%s", split[2]);
-	if (split[2][0] != '\0')
-		g_string_append_printf (string, " (%s)", split[3]);
+	if (split[PK_PACKAGE_ID_VERSION][0] != '\0')
+		g_string_append_printf (string, "-%s", split[PK_PACKAGE_ID_VERSION]);
+	if (split[PK_PACKAGE_ID_ARCH][0] != '\0')
+		g_string_append_printf (string, " (%s)", split[PK_PACKAGE_ID_ARCH]);
 
 	text = g_string_free (string, FALSE);
 	g_strfreev (split);
@@ -334,10 +334,10 @@ gpk_package_id_format_oneline (const gchar *package_id, const gchar *summary)
 	split = pk_package_id_split (package_id);
 	if (summary == NULL || summary[0] == '\0') {
 		/* just have name */
-		text = g_strdup (split[0]);
+		text = g_strdup (split[PK_PACKAGE_ID_NAME]);
 	} else {
 		summary_safe = g_markup_escape_text (summary, -1);
-		text = g_strdup_printf ("<b>%s</b> (%s)", summary_safe, split[0]);
+		text = g_strdup_printf ("<b>%s</b> (%s)", summary_safe, split[PK_PACKAGE_ID_NAME]);
 		g_free (summary_safe);
 	}
 	g_strfreev (split);
@@ -623,7 +623,9 @@ gpk_package_entry_completion_get_names_from_file (const gchar *filename)
 		split = g_strsplit (lines[i], "\t", 3);
 		if (g_strv_length (split) != 3)
 			continue;
-		item = pk_item_package_new (pk_info_enum_from_text (split[0]), split[1], split[2]);
+		item = pk_item_package_new (pk_info_enum_from_text (split[PK_PACKAGE_ID_NAME]),
+					    split[PK_PACKAGE_ID_VERSION],
+					    split[PK_PACKAGE_ID_ARCH]);
 		g_ptr_array_add (array, item);
 		g_strfreev (split);
 	}
@@ -667,12 +669,12 @@ gpk_package_entry_completion_model_new (void)
 		}
 
 		split = pk_package_id_split (item->package_id);
-		data = g_hash_table_lookup (hash, (gpointer) split[0]);
+		data = g_hash_table_lookup (hash, (gpointer) split[PK_PACKAGE_ID_NAME]);
 		if (data == NULL) {
 			/* append just the name */
-			g_hash_table_insert (hash, g_strdup (split[0]), GINT_TO_POINTER (1));
+			g_hash_table_insert (hash, g_strdup (split[PK_PACKAGE_ID_NAME]), GINT_TO_POINTER (1));
 			gtk_list_store_append (store, &iter);
-			gtk_list_store_set (store, &iter, 0, split[0], -1);
+			gtk_list_store_set (store, &iter, 0, split[PK_PACKAGE_ID_NAME], -1);
 		}
 		g_strfreev (split);
 	}
diff --git a/src/gpk-prefs.c b/src/gpk-prefs.c
index d872850..fe9c4de 100644
--- a/src/gpk-prefs.c
+++ b/src/gpk-prefs.c
@@ -370,7 +370,9 @@ gpk_prefs_notify_network_state_cb (PkControl *control, GParamSpec *pspec, gpoint
 	PkNetworkEnum state;
 
 	/* only show label on mobile broadband */
-	g_object_get (control, "network-state", &state, NULL);
+	g_object_get (control,
+		      "network-state", &state,
+		      NULL);
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_mobile_broadband"));
 	if (state == PK_NETWORK_ENUM_MOBILE)
 		gtk_widget_show (widget);



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