[gnome-color-manager] Show a progress bar on the calibration action page



commit d13de30964cc9cf8f8b9cf367d262ca68c18ad76
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 8 14:54:48 2011 +0000

    Show a progress bar on the calibration action page
    
    The update jumps are huge at the moment, but WILLFIX.

 src/gcm-calibrate-argyll.c |   30 ++++++++++++++++++++++++++++++
 src/gcm-calibrate-main.c   |   19 +++++++++++++++++++
 src/gcm-calibrate.c        |   19 +++++++++++++++++++
 src/gcm-calibrate.h        |    4 ++++
 4 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 51f7d55..64d120e 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -1217,16 +1217,25 @@ gcm_calibrate_argyll_display (GcmCalibrate *calibrate, CdDevice *device, CdSenso
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 30);
+
 	/* step 3 */
 	ret = gcm_calibrate_argyll_display_draw_and_measure (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 40);
+
 	/* step 4 */
 	ret = gcm_calibrate_argyll_display_generate_profile (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 80);
+
 	/* step 5 */
 	ret = gcm_calibrate_argyll_remove_temp_files (calibrate_argyll, error);
 	if (!ret)
@@ -1693,6 +1702,9 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, CdDevice *device, CdSenso
 
 	}
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 30);
+
 	/* we need to read the ti2 file to set the device used for calibration */
 	if (print_kind == GCM_CALIBRATE_PRINT_KIND_ANALYZE) {
 		filename = g_strdup_printf ("%s/%s.ti2", working_path, basename);
@@ -1709,11 +1721,17 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, CdDevice *device, CdSenso
 			goto out;
 	}
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 60);
+
 	/* step 3 */
 	ret = gcm_calibrate_argyll_display_read_chart (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 80);
+
 	/* step 4 */
 	ret = gcm_calibrate_argyll_device_generate_profile (calibrate_argyll, error);
 	if (!ret)
@@ -1865,21 +1883,33 @@ gcm_calibrate_argyll_device (GcmCalibrate *calibrate, CdDevice *device, CdSensor
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 10);
+
 	/* step 2 */
 	ret = gcm_calibrate_argyll_device_measure (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 70);
+
 	/* step 3 */
 	ret = gcm_calibrate_argyll_device_generate_profile (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 80);
+
 	/* step 4 */
 	ret = gcm_calibrate_argyll_remove_temp_files (calibrate_argyll, error);
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 90);
+
 	/* step 5 */
 	ret = gcm_calibrate_argyll_set_filename_result (calibrate_argyll, error);
 	if (!ret)
diff --git a/src/gcm-calibrate-main.c b/src/gcm-calibrate-main.c
index 2508f30..513fe04 100644
--- a/src/gcm-calibrate-main.c
+++ b/src/gcm-calibrate-main.c
@@ -73,6 +73,7 @@ typedef struct {
 	GtkWidget	*action_title;
 	GtkWidget	*action_message;
 	GtkWidget	*action_image;
+	GtkWidget	*action_progress;
 	gboolean	 has_pending_interaction;
 	gboolean	 started_calibration;
 	GcmCalibratePage current_page;
@@ -838,6 +839,10 @@ gcm_calib_setup_page_action (GcmCalibratePriv *calib)
 	gtk_image_set_from_icon_name (GTK_IMAGE (calib->action_image), "face-frown", GTK_ICON_SIZE_DIALOG);
 	gtk_box_pack_start (GTK_BOX (content), calib->action_image, FALSE, FALSE, 0);
 
+	/* add progress marker */
+	calib->action_progress = gtk_progress_bar_new ();
+	gtk_box_pack_start (GTK_BOX (content), calib->action_progress, FALSE, FALSE, 0);
+
 	/* add content widget */
 	gcm_calibrate_set_content_widget (calib->calibrate, vbox);
 
@@ -2066,6 +2071,15 @@ gcm_calib_message_changed_cb (GcmCalibrate *calibrate,
 }
 
 static void
+gcm_calib_progress_changed_cb (GcmCalibrate *calibrate,
+			       guint percentage,
+			       GcmCalibratePriv *calib)
+{
+	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (calib->action_progress),
+				       percentage / 100.0f);
+}
+
+static void
 gcm_calib_image_changed_cb (GcmCalibrate *calibrate,
 			    const gchar *filename,
 			    GcmCalibratePriv *calib)
@@ -2148,6 +2162,9 @@ main (int argc, char **argv)
 	calib->old_brightness = G_MAXUINT;
 	calib->brightness = gcm_brightness_new ();
 	calib->calibrate = gcm_calibrate_argyll_new ();
+	g_object_set (calib->calibrate,
+		      "precision", GCM_CALIBRATE_PRECISION_LONG,
+		      NULL);
 	calib->device_kind = CD_DEVICE_KIND_UNKNOWN;
 	g_signal_connect (calib->calibrate, "title-changed",
 			  G_CALLBACK (gcm_calib_title_changed_cb), calib);
@@ -2155,6 +2172,8 @@ main (int argc, char **argv)
 			  G_CALLBACK (gcm_calib_message_changed_cb), calib);
 	g_signal_connect (calib->calibrate, "image-changed",
 			  G_CALLBACK (gcm_calib_image_changed_cb), calib);
+	g_signal_connect (calib->calibrate, "progress-changed",
+			  G_CALLBACK (gcm_calib_progress_changed_cb), calib);
 	g_signal_connect (calib->calibrate, "interaction-required",
 			  G_CALLBACK (gcm_calib_interaction_required_cb), calib);
 
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index 35fa51b..cd5ccc7 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -93,6 +93,7 @@ enum {
 	SIGNAL_TITLE_CHANGED,
 	SIGNAL_MESSAGE_CHANGED,
 	SIGNAL_IMAGE_CHANGED,
+	SIGNAL_PROGRESS_CHANGED,
 	SIGNAL_INTERACTION_REQUIRED,
 	SIGNAL_LAST
 };
@@ -777,6 +778,9 @@ gcm_calibrate_device (GcmCalibrate *calibrate,
 	if (!ret)
 		goto out;
 
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 0);
+
 	switch (cd_device_get_kind (device)) {
 	case CD_DEVICE_KIND_DISPLAY:
 		ret = gcm_calibrate_display (calibrate,
@@ -797,6 +801,9 @@ gcm_calibrate_device (GcmCalibrate *calibrate,
 					    error);
 		break;
 	}
+
+	/* set progress */
+	gcm_calibrate_set_progress (calibrate, 100);
 out:
 	return ret;
 }
@@ -822,6 +829,12 @@ gcm_calibrate_set_image (GcmCalibrate *calibrate, const gchar *filename)
 }
 
 void
+gcm_calibrate_set_progress (GcmCalibrate *calibrate, guint percentage)
+{
+	g_signal_emit (calibrate, signals[SIGNAL_PROGRESS_CHANGED], 0, percentage);
+}
+
+void
 gcm_calibrate_interaction_required (GcmCalibrate *calibrate, const gchar *button_text)
 {
 	g_signal_emit (calibrate, signals[SIGNAL_INTERACTION_REQUIRED], 0, button_text);
@@ -1114,6 +1127,12 @@ gcm_calibrate_class_init (GcmCalibrateClass *klass)
 			      G_STRUCT_OFFSET (GcmCalibrateClass, image_changed),
 			      NULL, NULL, g_cclosure_marshal_VOID__STRING,
 			      G_TYPE_NONE, 1, G_TYPE_STRING);
+	signals[SIGNAL_PROGRESS_CHANGED] =
+		g_signal_new ("progress-changed",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GcmCalibrateClass, progress_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
 	signals[SIGNAL_INTERACTION_REQUIRED] =
 		g_signal_new ("interaction-required",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index caf7e1b..a7783c5 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -74,6 +74,8 @@ struct _GcmCalibrateClass
 							 const gchar	*message);
 	void		(* image_changed)		(GcmCalibrate	*calibrate,
 							 const gchar	*filename);
+	void		(* progress_changed)		(GcmCalibrate	*calibrate,
+							 guint		 percentage);
 	void		(* interaction_required)	(GcmCalibrate	*calibrate,
 							 const gchar	*button_text);
 };
@@ -145,6 +147,8 @@ void		 gcm_calibrate_set_message		(GcmCalibrate	*calibrate,
 							 const gchar	*message);
 void		 gcm_calibrate_set_image		(GcmCalibrate	*calibrate,
 							 const gchar	*filename);
+void		 gcm_calibrate_set_progress		(GcmCalibrate	*calibrate,
+							 guint		 percentage);
 void		 gcm_calibrate_pop			(GcmCalibrate	*calibrate);
 void		 gcm_calibrate_interaction_required	(GcmCalibrate	*calibrate,
 							 const gchar	*button_text);



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