Progress dialogs patch



Hi nautilus developers,

I'd like to propose a new lay-out for the progress dialogs in Nautilus.
I've written a patch which lets the dialogs follow the HIG guidelines.
I'd like to know your opinion on the placement of the widgets and the
changes I made with this patch.

I have opened a bugreport about it here[1]. But I'll attach the patch
with this e-mail too.

Cheers,
 Michiel

[1] http://bugzilla.gnome.org/show_bug.cgi?id=171694
? 171694-nautilus_dialog_hig.patch
? depcomp
? higify.patch
? nautilus-folder-handler.desktop
? stamp-h1
Index: libnautilus-private/nautilus-file-operations-progress.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations-progress.c,v
retrieving revision 1.45
diff -u -p -r1.45 nautilus-file-operations-progress.c
--- libnautilus-private/nautilus-file-operations-progress.c	27 Feb 2005 14:50:03 -0000	1.45
+++ libnautilus-private/nautilus-file-operations-progress.c	26 Mar 2005 15:48:51 -0000
@@ -50,9 +50,9 @@
  */
 #define PROGRESS_DIALOG_WIDTH 400
 
-#define OUTER_BORDER       5
-#define VERTICAL_SPACING   8
-#define HORIZONTAL_SPACING 3
+#define OUTER_BORDER       6
+#define VERTICAL_SPACING   6
+#define HORIZONTAL_SPACING 6
 
 #define MINIMUM_TIME_UP    1000
 
@@ -69,6 +69,7 @@ EEL_CLASS_BOILERPLATE (NautilusFileOpera
 		       GTK_TYPE_DIALOG)
 
 struct NautilusFileOperationsProgressDetails {
+	GtkWidget *primary_text_label;
 	GtkWidget *progress_title_label;
 	GtkWidget *progress_count_label;
 	GtkWidget *operation_name_label;
@@ -80,10 +81,13 @@ struct NautilusFileOperationsProgressDet
 
 	GtkWidget *progress_bar;
 
+	gchar *progress_title;
+
 	const char *from_prefix;
 	const char *to_prefix;
 
 	gulong files_total;
+	gulong file_index;
 	
 	GnomeVFSFileSize bytes_copied;
 	GnomeVFSFileSize bytes_total;
@@ -93,6 +97,9 @@ struct NautilusFileOperationsProgressDet
 
 	/* system time (microseconds) when dialog was mapped */
 	gint64 show_time;
+
+	/* string for remanint time */
+	gchar *remaining_time_string;
 	
 	/* time remaining in show timeout if it's paused and resumed */
 	guint remaining_time;
@@ -140,6 +147,8 @@ static void
 nautilus_file_operations_progress_update (NautilusFileOperationsProgress *progress)
 {
 	double fraction;
+	gchar *progress_count;
+	gchar *remaining_time_string = NULL;
 
 	if (progress->details->bytes_total == 0) {
 		/* We haven't set up the file count yet, do not update
@@ -150,7 +159,22 @@ nautilus_file_operations_progress_update
 
 	fraction = (double)progress->details->bytes_copied /
 		progress->details->bytes_total;
-	
+
+	if (progress->details->remaining_time_string == NULL) {
+		remaining_time_string = "";
+	} else {
+		remaining_time_string = progress->details->remaining_time_string;
+	}
+
+	progress_count = g_strdup_printf (_("%s %ld of %ld %s"),
+					  progress->details->progress_title,
+					  progress->details->file_index, 
+					  progress->details->files_total,
+					  remaining_time_string);
+	gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress->details->progress_bar), progress_count);
+
+	g_free (progress_count);
+
 	gtk_progress_bar_set_fraction
 		(GTK_PROGRESS_BAR (progress->details->progress_bar),
 		 fraction);
@@ -273,56 +297,80 @@ delete_event_callback (GtkWidget *widget
 static void
 nautilus_file_operations_progress_init (NautilusFileOperationsProgress *progress)
 {
-	GtkWidget *hbox, *vbox;
+	GtkWidget *hbox, *vbox, *progress_vbox, *file_hbox;
 	GtkTable *titled_label_table;
 
 	progress->details = g_new0 (NautilusFileOperationsProgressDetails, 1);
 
 	vbox = gtk_vbox_new (FALSE, VERTICAL_SPACING);
 	gtk_container_set_border_width (GTK_CONTAINER (vbox), OUTER_BORDER);
-	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (progress)->vbox), vbox, TRUE, TRUE, VERTICAL_SPACING);
+	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (progress)->vbox), vbox, TRUE, TRUE, 0);
+
+	progress->details->primary_text_label = gtk_label_new("");
+	gtk_misc_set_alignment (GTK_MISC (progress->details->primary_text_label), 0.0, 0.0);
+	gtk_box_pack_start (GTK_BOX (vbox), progress->details->primary_text_label, FALSE, FALSE, 0);
 
 	hbox = gtk_hbox_new (FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, HORIZONTAL_SPACING);
+	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
 
 	/* label- */
 	/* Files remaining to be copied: */
-	progress->details->progress_title_label = gtk_label_new ("");
+	/* progress->details->progress_title_label = gtk_label_new ("");
 	gtk_label_set_justify (GTK_LABEL (progress->details->progress_title_label), GTK_JUSTIFY_LEFT);
 	gtk_box_pack_start (GTK_BOX (hbox), progress->details->progress_title_label, FALSE, FALSE, 0);
-	eel_gtk_label_make_bold (GTK_LABEL (progress->details->progress_title_label));
+	eel_gtk_label_make_bold (GTK_LABEL (progress->details->progress_title_label)); */
 
 
 	/* label -- */
 	/* 24 of 30 */
-	progress->details->progress_count_label = gtk_label_new ("");
+	/* progress->details->progress_count_label = gtk_label_new ("");
 	gtk_label_set_justify (GTK_LABEL (progress->details->progress_count_label), GTK_JUSTIFY_RIGHT);
 	gtk_box_pack_end (GTK_BOX (hbox), progress->details->progress_count_label, FALSE, FALSE, 0);
-	eel_gtk_label_make_bold (GTK_LABEL (progress->details->progress_count_label));
+	eel_gtk_label_make_bold (GTK_LABEL (progress->details->progress_count_label)); */
 
-	/* progress bar */
-	progress->details->progress_bar = gtk_progress_bar_new ();
-	gtk_window_set_default_size (GTK_WINDOW (progress), PROGRESS_DIALOG_WIDTH, -1);
-	gtk_box_pack_start (GTK_BOX (vbox), progress->details->progress_bar, FALSE, TRUE, 0);
-	/* prevent a resizing of the bar when a real text is inserted later */
-	gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress->details->progress_bar), " ");
-
-	titled_label_table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
+	titled_label_table = GTK_TABLE (gtk_table_new (2, 2, FALSE));
 	gtk_table_set_row_spacings (titled_label_table, 4);
 	gtk_table_set_col_spacings (titled_label_table, 4);
 
-	create_titled_label (titled_label_table, 0,
+	/* create_titled_label (titled_label_table, 0,
 			     &progress->details->operation_name_label, 
-			     &progress->details->item_name);
-	create_titled_label (titled_label_table, 1,
+			     &progress->details->item_name); */
+	create_titled_label (titled_label_table, 0,
 			     &progress->details->from_label, 
 			     &progress->details->from_path_label);
-	create_titled_label (titled_label_table, 2,
+	create_titled_label (titled_label_table, 1,
 			     &progress->details->to_label, 
 			     &progress->details->to_path_label);
 
 	gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (titled_label_table), FALSE, FALSE, 0);
 
+	/* progress vbox */
+	progress_vbox = gtk_vbox_new (TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (vbox), progress_vbox, FALSE, FALSE, 0);
+
+	/* progress bar */
+	progress->details->progress_bar = gtk_progress_bar_new ();
+	gtk_window_set_default_size (GTK_WINDOW (progress), PROGRESS_DIALOG_WIDTH, -1);
+	gtk_box_pack_start (GTK_BOX (progress_vbox), progress->details->progress_bar, FALSE, TRUE, 0);
+	/* prevent a resizing of the bar when a real text is inserted later */
+	gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress->details->progress_bar), " ");
+
+	/* file hbox */
+	file_hbox = gtk_hbox_new (FALSE, HORIZONTAL_SPACING);
+	gtk_box_pack_start (GTK_BOX (progress_vbox), file_hbox, TRUE, TRUE, 2);
+
+	/* progress verb */
+	progress->details->operation_name_label = gtk_label_new ("");
+	gtk_misc_set_alignment (GTK_MISC (progress->details->operation_name_label), 0.0, 0.0);
+	gtk_box_pack_start (GTK_BOX (file_hbox), progress->details->operation_name_label, FALSE, FALSE, 0);
+
+	/* file label */
+	progress->details->item_name = gtk_label_new ("");
+	gtk_misc_set_alignment (GTK_MISC (progress->details->item_name), 0.0, 0.0);
+	gtk_label_set_ellipsize (GTK_LABEL (progress->details->item_name), PANGO_ELLIPSIZE_END);
+	gtk_box_pack_start (GTK_BOX (file_hbox), progress->details->item_name, TRUE, TRUE, 0);
+
+
 	/* Set window icon */
 	gtk_window_set_icon (GTK_WINDOW (progress), empty_jar_pixbuf);
 
@@ -413,8 +461,10 @@ time_remaining_callback (gpointer callba
 		str = g_strdup_printf (_("(%d:%02d Remaining)"), 
 				       time_remaining / 60, time_remaining % 60);
 	}
-	gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress->details->progress_bar), str);
-	
+	progress->details->remaining_time_string = g_strdup (str);
+
+	nautilus_file_operations_progress_update (progress);
+
 	g_free (str);
 
 	progress->details->time_remaining_timeout_id =
@@ -447,6 +497,7 @@ nautilus_file_operations_progress_new (c
 				       gboolean use_timeout)
 {
 	GtkWidget *widget;
+	gchar *primary_text;
 	NautilusFileOperationsProgress *progress;
 
 	widget = gtk_widget_new (nautilus_file_operations_progress_get_type (), NULL);
@@ -458,8 +509,17 @@ nautilus_file_operations_progress_new (c
 	gtk_window_set_title (GTK_WINDOW (widget), title);
 	gtk_window_set_wmclass (GTK_WINDOW (widget), "file_progress", "Nautilus");
 
+	primary_text = g_strconcat ("<big><b>", title, "</b></big>", NULL);
+	gtk_label_set_markup(GTK_LABEL (progress->details->primary_text_label),
+			primary_text);
+
 	gtk_dialog_add_button (GTK_DIALOG (widget), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 
+	gtk_container_set_border_width (GTK_CONTAINER (widget), OUTER_BORDER);
+
+	/* Disable separator */
+	gtk_dialog_set_has_separator (GTK_DIALOG (widget), FALSE);
+
 	progress->details->from_prefix = from_prefix;
 	progress->details->to_prefix = to_prefix;
 
@@ -491,8 +551,7 @@ nautilus_file_operations_progress_set_op
 {
 	g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
 
-	gtk_label_set_text (GTK_LABEL (progress->details->progress_title_label),
-			    operation_string);
+	progress->details->progress_title = g_strdup (operation_string);
 }
 
 void
@@ -506,7 +565,8 @@ nautilus_file_operations_progress_new_fi
 					    gulong file_index,
 					    GnomeVFSFileSize size)
 {
-	char *progress_count;
+	gchar *operation_markup;
+	gchar *item_markup;
 
 	g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
 
@@ -517,17 +577,18 @@ nautilus_file_operations_progress_new_fi
 		/* we haven't set up the file count yet, do not update the progress
 		 * count until we do
 		 */
-		gtk_label_set_text (GTK_LABEL (progress->details->operation_name_label),
-				    progress_verb);
-		set_text_unescaped_trimmed 
+		operation_markup = g_strconcat ("<i>", progress_verb, "</i>", NULL);
+		gtk_label_set_markup (GTK_LABEL (progress->details->operation_name_label),
+				    operation_markup);
+
+		item_markup = g_strconcat ("<i>\"", item_name, "\"</i>", NULL);
+		/* set_text_unescaped_trimmed 
 			(EEL_ELLIPSIZING_LABEL (progress->details->item_name),
-			 item_name);
+			 item_markup); */
+
+		gtk_label_set_markup (GTK_LABEL (progress->details->item_name), item_markup);
 
-		progress_count = g_strdup_printf (_("%ld of %ld"),
-						  file_index, 
-						  progress->details->files_total);
-		gtk_label_set_text (GTK_LABEL (progress->details->progress_count_label), progress_count);
-		g_free (progress_count);
+		progress->details->file_index = file_index;
 
 		gtk_label_set_text (GTK_LABEL (progress->details->from_label), from_prefix);
 		set_text_unescaped_trimmed 
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.186
diff -u -p -r1.186 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	22 Feb 2005 10:41:46 -0000	1.186
+++ libnautilus-private/nautilus-file-operations.c	26 Mar 2005 15:48:52 -0000
@@ -353,7 +353,7 @@ progress_dialog_set_to_from_item_text (N
 		
 		gnome_vfs_uri_unref (uri);
 		g_assert (progress_verb);
-		progress_label_text = g_strdup_printf ("%s:", progress_verb);
+		progress_label_text = g_strdup_printf ("%s", progress_verb);
 		/* "From" dialog label, source path gets placed next to it in the dialog */
 		from_prefix = _("From:");
 	}
@@ -427,7 +427,7 @@ handle_transfer_ok (const GnomeVFSXferPr
 		if (transfer_info->progress_dialog != NULL) {
 			nautilus_file_operations_progress_set_operation_string
 				(transfer_info->progress_dialog,
-				 transfer_info->action_label);
+				 transfer_info->action_label); 
 			nautilus_file_operations_progress_set_total
 				(transfer_info->progress_dialog,
 				 progress_info->files_total,
@@ -486,7 +486,7 @@ handle_transfer_ok (const GnomeVFSXferPr
 				(transfer_info->progress_dialog);
 			nautilus_file_operations_progress_set_operation_string
 				(transfer_info->progress_dialog,
-				 transfer_info->cleanup_name);
+				 transfer_info->cleanup_name); 
 		}
 		return 1;
 


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