[file-roller] fixed archive display name in the update dialog



commit 3ca9ad6a5b2b5151af3aaffde84d3698890655d3
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Aug 2 16:48:02 2010 +0200

    fixed archive display name in the update dialog

 src/dlg-update.c |  109 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 61 insertions(+), 48 deletions(-)
---
diff --git a/src/dlg-update.c b/src/dlg-update.c
index 411ceaa..a2c7e8a 100644
--- a/src/dlg-update.c
+++ b/src/dlg-update.c
@@ -31,20 +31,20 @@
 #include "fr-window.h"
 
 
-enum { 
-	IS_SELECTED_COLUMN, 
+enum {
+	IS_SELECTED_COLUMN,
 	NAME_COLUMN,
-	DATA_COLUMN, 
-	N_COLUMNS 
+	DATA_COLUMN,
+	N_COLUMNS
 };
 
 typedef struct {
 	FrWindow     *window;
 	GtkBuilder *builder;
 
-	GtkWidget    *update_file_dialog;	
+	GtkWidget    *update_file_dialog;
 	GtkWidget    *update_file_primary_text_label;
-	
+
 	GtkWidget    *update_files_dialog;
 	GtkWidget    *update_files_primary_text_label;
 	GtkWidget    *update_files_secondary_text_label;
@@ -74,22 +74,22 @@ get_selected_files (DialogData *data)
 {
 	GList       *selection = NULL;
 	GtkTreeIter  iter;
-		
+
 	if (! gtk_tree_model_get_iter_first (data->list_model, &iter))
 		return NULL;
-		
+
 	do {
 		gboolean  is_selected;
 		OpenFile *file;
-		
-                gtk_tree_model_get (data->list_model, &iter, 
+
+                gtk_tree_model_get (data->list_model, &iter,
                 		    IS_SELECTED_COLUMN, &is_selected,
-                		    DATA_COLUMN, &file, 
+                		    DATA_COLUMN, &file,
                 		    -1);
                 if (is_selected)
                 	selection = g_list_prepend (selection, file);
 	} while (gtk_tree_model_iter_next (data->list_model, &iter));
-	
+
 	return g_list_reverse (selection);
 }
 
@@ -100,15 +100,15 @@ update_cb (GtkWidget *widget,
 {
 	DialogData *data = callback_data;
 	GList      *selection;
-	
+
 	selection = get_selected_files (data);
 	if (fr_window_update_files (data->window, selection)) {
 		int n_files;
-		
+
 		n_files = g_list_length (data->file_list);
 		if (n_files == 1)
 			gtk_widget_destroy (data->update_file_dialog);
-		else 
+		else
 			gtk_widget_destroy (data->update_files_dialog);
 	}
 	if (selection != NULL)
@@ -122,11 +122,11 @@ update_file_list (DialogData *data)
 	gboolean     n_files;
 	GList       *scan;
 	GtkTreeIter  iter;
-	
+
 	n_files = g_list_length (data->file_list);
-	
+
 	/* update the file list */
-	
+
 	gtk_list_store_clear (GTK_LIST_STORE (data->list_model));
 	for (scan = data->file_list; scan; scan = scan->next) {
 		char     *utf8_name;
@@ -134,7 +134,7 @@ update_file_list (DialogData *data)
 
 		gtk_list_store_append (GTK_LIST_STORE (data->list_model),
 				       &iter);
-				       
+
 		utf8_name = g_filename_display_name (file_name_from_path (file->path));
 		gtk_list_store_set (GTK_LIST_STORE (data->list_model),
 				    &iter,
@@ -149,45 +149,58 @@ update_file_list (DialogData *data)
 
 	if (n_files == 1) {
 		OpenFile *file = data->file_list->data;
-		char     *file_name, *archive_name, *label, *markup;
-		
+		char     *file_name;
+		char     *unescaped;
+		char     *archive_name;
+		char     *label;
+		char     *markup;
+
 		/* primary text */
-		
+
 		file_name = g_filename_display_name (file_name_from_path (file->path));
-		archive_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (data->window)));
+		unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL);
+		archive_name = g_path_get_basename (unescaped);
 		label = g_markup_printf_escaped (_("Update the file \"%s\" in the archive \"%s\"?"), file_name, archive_name);
 		markup = g_strdup_printf ("<big><b>%s</b></big>", label);
 		gtk_label_set_markup (GTK_LABEL (data->update_file_primary_text_label), markup);
+
 		g_free (markup);
 		g_free (label);
 		g_free (archive_name);
+		g_free (unescaped);
 		g_free (file_name);
 	}
 	else if (n_files > 1) {
-		char *archive_name, *label, *markup;
-		
+		char *unescaped;
+		char *archive_name;
+		char *label;
+		char *markup;
+
 		/* primary text */
-		
-		archive_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (data->window)));
+
+		unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL);
+		archive_name = g_path_get_basename (unescaped);
 		label = g_markup_printf_escaped (_("Update the files in the archive \"%s\"?"), archive_name);
 		markup = g_strdup_printf ("<big><b>%s</b></big>", label);
 		gtk_label_set_markup (GTK_LABEL (data->update_files_primary_text_label), markup);
+
 		g_free (markup);
 		g_free (label);
 		g_free (archive_name);
-		
+		g_free (unescaped);
+
 		/* secondary text */
-		
+
 		label = g_strdup_printf (ngettext ("The file has been modified with an external application. If you don't update the file in the archive, all of your changes will be lost.",
 						   "%d files have been modified with an external application. If you don't update the files in the archive, all of your changes will be lost.",
-						   n_files), 
+						   n_files),
 					 n_files);
 		gtk_label_set_text (GTK_LABEL (data->update_files_secondary_text_label), label);
 		g_free (label);
 	}
-	
+
 	/* show the appropriate dialog */
-	
+
 	if (n_files == 1) {
 		/*gtk_window_set_modal (GTK_WINDOW (data->update_files_dialog), FALSE);*/
 		gtk_widget_hide (data->update_files_dialog);
@@ -214,17 +227,17 @@ n_selected (DialogData *data)
 {
 	int         n = 0;
 	GtkTreeIter iter;
-		
+
 	if (! gtk_tree_model_get_iter_first (data->list_model, &iter))
 		return 0;
-		
+
 	do {
 		gboolean is_selected;
                 gtk_tree_model_get (data->list_model, &iter, IS_SELECTED_COLUMN, &is_selected, -1);
                 if (is_selected)
                 	n++;
 	} while (gtk_tree_model_iter_next (data->list_model, &iter));
-	
+
 	return n;
 }
 
@@ -245,7 +258,7 @@ is_selected_toggled (GtkCellRendererToggle *cell,
 	gtk_list_store_set (GTK_LIST_STORE (model), &iter, IS_SELECTED_COLUMN, value, -1);
 
 	gtk_tree_path_free (path);
-	
+
 	gtk_widget_set_sensitive (data->update_files_ok_button, n_selected (data) > 0);
 }
 
@@ -258,7 +271,7 @@ dlg_update (FrWindow *window)
 	GtkWidget         *update_file_cancel_button;
 	GtkWidget         *update_files_cancel_button;
 	GtkCellRenderer   *renderer;
-	GtkTreeViewColumn *column;	
+	GtkTreeViewColumn *column;
 
 	data = g_new0 (DialogData, 1);
 
@@ -270,14 +283,14 @@ dlg_update (FrWindow *window)
 
 	data->file_list = NULL;
 	data->window = window;
-	
+
 	/* Get the widgets. */
 
 	data->update_file_dialog = _gtk_builder_get_widget (data->builder, "update_file_dialog");
 	data->update_file_primary_text_label = _gtk_builder_get_widget (data->builder, "update_file_primary_text_label");
 	update_file_ok_button = _gtk_builder_get_widget (data->builder, "update_file_ok_button");
 	update_file_cancel_button = _gtk_builder_get_widget (data->builder, "update_file_cancel_button");
-	
+
 	data->update_files_dialog = _gtk_builder_get_widget (data->builder, "update_files_dialog");
 	data->update_files_primary_text_label = _gtk_builder_get_widget (data->builder, "update_files_primary_text_label");
 	data->update_files_secondary_text_label = _gtk_builder_get_widget (data->builder, "update_files_secondary_text_label");
@@ -326,7 +339,7 @@ dlg_update (FrWindow *window)
 	g_object_unref (G_OBJECT (data->list_model));
 
 	column = gtk_tree_view_column_new ();
-	
+
 	renderer = gtk_cell_renderer_toggle_new ();
         g_signal_connect (G_OBJECT (renderer),
                           "toggled",
@@ -336,7 +349,7 @@ dlg_update (FrWindow *window)
         gtk_tree_view_column_set_attributes (column, renderer,
                                              "active", IS_SELECTED_COLUMN,
                                              NULL);
-                                             
+
 	renderer = gtk_cell_renderer_text_new ();
 	gtk_tree_view_column_pack_start (column, renderer, TRUE);
 	gtk_tree_view_column_set_attributes (column, renderer,
@@ -346,14 +359,14 @@ dlg_update (FrWindow *window)
 	gtk_tree_view_append_column (GTK_TREE_VIEW (data->update_files_treeview), column);
 
 	/* Run dialog. */
-	
+
 	gtk_window_set_transient_for (GTK_WINDOW (data->update_file_dialog),
 				      GTK_WINDOW (window));
 	gtk_window_set_transient_for (GTK_WINDOW (data->update_files_dialog),
 				      GTK_WINDOW (window));
-	
+
 	update_file_list (data);
-	
+
 	return data;
 }
 
@@ -366,15 +379,15 @@ dlg_update_add_file (gpointer  dialog,
 	GList      *scan;
 
 	/* avoid duplicates */
-	
+
 	for (scan = data->file_list; scan; scan = scan->next) {
 		OpenFile *test = scan->data;
-		if (uricmp (test->extracted_uri, file->extracted_uri) == 0) 
+		if (uricmp (test->extracted_uri, file->extracted_uri) == 0)
 			return;
 	}
-	
+
 	/**/
-	
+
 	data->file_list = g_list_append (data->file_list, file);
 	update_file_list (data);
 }



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