[gthumb] rename_series: use an embedded progress widget instead of a dialog



commit 0dfa5e3d57a65d8ef4cdd75ad9ff65d6382a14c7
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Apr 4 01:25:31 2011 +0200

    rename_series: use an embedded progress widget instead of a dialog

 extensions/rename_series/data/ui/rename-series.ui |   11 +++++++++++
 extensions/rename_series/dlg-rename-series.c      |   20 ++++++++++++++++----
 gthumb/gth-progress-dialog.c                      |   16 +++++++++-------
 gthumb/gth-progress-dialog.h                      |    2 ++
 4 files changed, 38 insertions(+), 11 deletions(-)
---
diff --git a/extensions/rename_series/data/ui/rename-series.ui b/extensions/rename_series/data/ui/rename-series.ui
index b54a8fa..11edf0a 100644
--- a/extensions/rename_series/data/ui/rename-series.ui
+++ b/extensions/rename_series/data/ui/rename-series.ui
@@ -517,6 +517,17 @@
                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkVBox" id="task_box">
+                <property name="visible">True</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="position">1</property>
diff --git a/extensions/rename_series/dlg-rename-series.c b/extensions/rename_series/dlg-rename-series.c
index 0c253d8..817efc3 100644
--- a/extensions/rename_series/dlg-rename-series.c
+++ b/extensions/rename_series/dlg-rename-series.c
@@ -105,12 +105,14 @@ destroy_cb (GtkWidget  *widget,
 		g_source_remove (data->update_id);
 		data->update_id = 0;
 	}
+
 	if (data->task_completed_id != 0)
 		g_signal_handler_disconnect (data->task, data->task_completed_id);
 	if (data->task != NULL) {
 		gth_task_cancel (data->task);
 		_g_object_unref (data->task);
 	}
+
 	g_free (data->required_attributes);
 	g_object_unref (data->builder);
 	_g_object_list_unref (data->file_data_list);
@@ -418,9 +420,11 @@ load_file_data_task_completed_cb (GthTask  *task,
 {
 	DialogData *data = user_data;
 
+	gtk_widget_hide (GET_WIDGET ("task_box"));
+
 	if (error != NULL) {
-		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Cannot read file information"), &error);
-		_g_object_unref (data->task);
+		/* FIXME _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Cannot read file information"), &error); */
+		g_object_unref (data->task);
 		data->task = NULL;
 		data->task_completed_id = 0;
 		gtk_widget_destroy (data->dialog);
@@ -465,14 +469,22 @@ dlg_rename_series_update_preview (DialogData *data)
 		data->required_attributes = required_attributes;
 
 		if (reload_required) {
-			gtk_widget_set_sensitive (data->dialog, FALSE);
+			GtkWidget *child;
+
+			/* FIXME gtk_widget_set_sensitive (data->dialog, FALSE); */
+
+			gtk_widget_show (GET_WIDGET ("task_box"));
 
 			data->task = gth_load_file_data_task_new (data->file_list, data->required_attributes);
 			data->task_completed_id = g_signal_connect (data->task,
 								    "completed",
 								    G_CALLBACK (load_file_data_task_completed_cb),
 								    data);
-			gth_browser_exec_task (data->browser, data->task, FALSE);
+
+			child = gth_task_progress_new (data->task);
+			gtk_widget_show (child);
+			gtk_box_pack_start (GTK_BOX (GET_WIDGET ("task_box")), child, TRUE, TRUE, 0);
+			gth_task_exec (data->task, NULL);
 
 			return;
 		}
diff --git a/gthumb/gth-progress-dialog.c b/gthumb/gth-progress-dialog.c
index 789872f..0de9976 100644
--- a/gthumb/gth-progress-dialog.c
+++ b/gthumb/gth-progress-dialog.c
@@ -114,6 +114,7 @@ gth_task_progress_init (GthTaskProgress *self)
 
 	self->description_label = gtk_label_new ("");
 	gtk_misc_set_alignment (GTK_MISC (self->description_label), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (self->description_label), PANGO_ELLIPSIZE_END);
 	gtk_widget_show (self->description_label);
 	gtk_box_pack_start (GTK_BOX (vbox), self->description_label, FALSE, FALSE, 0);
 
@@ -127,6 +128,7 @@ gth_task_progress_init (GthTaskProgress *self)
 	pango_attr_list_insert (attr_list, pango_attr_size_new (8500));
 	g_object_set (self->details_label, "attributes", attr_list, NULL);
 	gtk_misc_set_alignment (GTK_MISC (self->details_label), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (self->details_label), PANGO_ELLIPSIZE_END);
 	gtk_widget_show (self->details_label);
 	gtk_box_pack_start (GTK_BOX (vbox), self->details_label, FALSE, FALSE, 0);
 
@@ -216,7 +218,7 @@ task_progress_cb (GthTask    *task,
 }
 
 
-static void gth_progress_dialog_remove_child (GthProgressDialog *dialog, GtkWidget *child);
+static void gth_progress_dialog_child_removed (GthProgressDialog *dialog);
 
 
 static void
@@ -233,8 +235,11 @@ task_completed_cb (GthTask  *task,
 	}
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
-	if (gtk_widget_is_toplevel (toplevel))
-		gth_progress_dialog_remove_child (GTH_PROGRESS_DIALOG (toplevel), GTK_WIDGET (self));
+
+	gtk_widget_destroy (GTK_WIDGET (self));
+
+	if (gtk_widget_is_toplevel (toplevel) && GTH_IS_PROGRESS_DIALOG (toplevel))
+		gth_progress_dialog_child_removed (GTH_PROGRESS_DIALOG (toplevel));
 }
 
 
@@ -436,11 +441,8 @@ gth_progress_dialog_add_task (GthProgressDialog *self,
 
 
 static void
-gth_progress_dialog_remove_child (GthProgressDialog *self,
-				  GtkWidget         *child)
+gth_progress_dialog_child_removed (GthProgressDialog *self)
 {
-	gtk_widget_destroy (child);
-
 	if (_gtk_container_get_n_children (GTK_CONTAINER (self->priv->task_box)) == 0) {
 		if (self->priv->show_event != 0) {
 			g_source_remove (self->priv->show_event);
diff --git a/gthumb/gth-progress-dialog.h b/gthumb/gth-progress-dialog.h
index 1b3ffb4..a4f2de3 100644
--- a/gthumb/gth-progress-dialog.h
+++ b/gthumb/gth-progress-dialog.h
@@ -52,6 +52,8 @@ GtkWidget *    gth_progress_dialog_new         (GtkWindow         *parent);
 void           gth_progress_dialog_add_task    (GthProgressDialog *dialog,
 						GthTask           *task);
 
+GtkWidget *    gth_task_progress_new           (GthTask           *task);
+
 G_END_DECLS
 
 #endif /* GTH_PROGRESS_DIALOG_H */



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