file-roller r2439 - in trunk: . src



Author: paobac
Date: Wed Aug 20 09:57:10 2008
New Revision: 2439
URL: http://svn.gnome.org/viewvc/file-roller?rev=2439&view=rev

Log:
2008-08-20  Paolo Bacchilega  <paobac svn gnome org>

	* README: updated.
	
	* src/main.h: 
	* src/main.c: added sort_mime_types_by_extension() and 
	sort_mime_types_by_description()
	
	* src/dlg-new.c: sort the type list by description.
	* src/dlg-batch-add.c: sort the type list by extension.

	Fixes bug: Sort the archive type list to make it easier to find the
	desired type.


Modified:
   trunk/ChangeLog
   trunk/README
   trunk/src/dlg-batch-add.c
   trunk/src/dlg-new.c
   trunk/src/main.c
   trunk/src/main.h

Modified: trunk/README
==============================================================================
--- trunk/README	(original)
+++ trunk/README	Wed Aug 20 09:57:10 2008
@@ -7,8 +7,9 @@
 * What is it ?
 
   File Roller is an archive manager for the GNOME environment.  This means
-  that you can : create and modify archives; view the content of an archive; 
-  view a file contained in the archive; extract files from the archive.
+  that you can create and modify archives; view the content of an archive; 
+  view and modify a file contained in the archive; extract files from the 
+  archive.
 
   File Roller is only a front-end (a graphical interface) to archiving programs
   like tar and zip. The supported file types are :
@@ -50,20 +51,22 @@
 * Licensing
 
   This program is released under the terms of the GNU General Public
-  License (GNU GPL).  
-
+  License (GNU GPL) version 2 or greater.  
   You can find a copy of the license in the file COPYING.
 
 * Dependencies
 
-  In order to use this program you need a working GNOME environment
-  version 2.x, with the development tools installed properly.
-
-  Also you need : 
-          * gnome-vfs
-          * libglade
-          * bonobo-activation
-          * bonobo
+  In order to build this program from the source code you need a working 
+  GNOME environment version 2.x, with the development tools installed
+  properly. 
+
+  Also you need the following libraries: 
+  	* glib >= 2.16.0
+  	* gtk+ >= 2.12.0
+  	* libgnome >= 2.6.0
+  	* libgnomeui >= 2.6.0
+        * libglade >= 2.4.0
+        * libnautilus-extension >= 2.22.2 (optional)
 
 * Install
 

Modified: trunk/src/dlg-batch-add.c
==============================================================================
--- trunk/src/dlg-batch-add.c	(original)
+++ trunk/src/dlg-batch-add.c	Wed Aug 20 09:57:10 2008
@@ -49,7 +49,8 @@
 typedef struct {
 	FrWindow   *window;
 	GladeXML   *gui;
-
+	int        *supported_types;
+	
 	GtkWidget  *dialog;
 	GtkWidget  *a_add_to_entry;
 	GtkWidget  *a_location_filechooserbutton;
@@ -88,33 +89,21 @@
 static const char *
 get_ext (DialogData *data)
 {
-	int *save_type_list;
-	int  idx;
-
-	if (data->single_file)
-		save_type_list = single_file_save_type;
-	else
-		save_type_list =  save_type;
+	int idx;
 
 	idx = gtk_combo_box_get_active (GTK_COMBO_BOX (data->a_archive_type_combo_box));
 
-	return mime_type_desc[save_type_list[idx]].default_ext;
+	return mime_type_desc[data->supported_types[idx]].default_ext;
 }
 
 
 static void
 set_archive_options (DialogData *data)
 {
-	int *save_type_list;
-	int  idx;
-
-	if (data->single_file)
-		save_type_list = single_file_save_type;
-	else
-		save_type_list = save_type;
+	int idx;
 
 	idx = gtk_combo_box_get_active (GTK_COMBO_BOX (data->a_archive_type_combo_box));
-	if (mime_type_desc[save_type_list[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT) {
+	if (mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT) {
 		char *pwd;
 
 		pwd = (char*) gtk_entry_get_text (GTK_ENTRY (data->a_password_entry));
@@ -122,13 +111,13 @@
 			pwd = g_strstrip (pwd);
 			if (strcmp (pwd, "") != 0) {
 				fr_window_set_password (data->window, pwd);
-				if (mime_type_desc[save_type_list[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER)
+				if (mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER)
 					fr_window_set_encrypt_header (data->window, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton)));
 			}
 		}
 	}
 
-	if ((mime_type_desc[save_type_list[idx]].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES)
+	if ((mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES)
 	    && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->a_volume_checkbutton)))
 	{
 		double value;
@@ -415,15 +404,10 @@
 archive_type_combo_box_changed_cb (GtkComboBox *combo_box,
 				   DialogData  *data)
 {
-	int        *save_type_list;
 	const char *mime_type;
 	int         idx = gtk_combo_box_get_active (combo_box);
 
-	if (data->single_file)
-		save_type_list = single_file_save_type;
-	else
-		save_type_list =  save_type;
-	mime_type = mime_type_desc[save_type_list[idx]].mime_type;
+	mime_type = mime_type_desc[data->supported_types[idx]].mime_type;
 
 	gtk_image_set_from_pixbuf (GTK_IMAGE (data->add_image), get_mime_type_pixbuf (mime_type, ARCHIVE_ICON_SIZE, NULL));
 	update_sensitivity_for_mime_type (data, mime_type);
@@ -434,22 +418,16 @@
 update_archive_type_combo_box_from_ext (DialogData  *data,
 					const char  *ext)
 {
-	int *save_type_list;
-	int  idx = 0;
-	int  i;
+	int idx = 0;
+	int i;
 
 	if (ext == NULL) {
 		gtk_combo_box_set_active (GTK_COMBO_BOX (data->a_archive_type_combo_box), 0);
 		return;
 	}
 
-	if (data->single_file)
-		save_type_list = single_file_save_type;
-	else
-		save_type_list =  save_type;
-
-	for (i = 0; save_type_list[i] != -1; i++)
-		if (strcmp (ext, mime_type_desc[save_type_list[i]].default_ext) == 0) {
+	for (i = 0; data->supported_types[i] != -1; i++)
+		if (strcmp (ext, mime_type_desc[data->supported_types[i]].default_ext) == 0) {
 			idx = i;
 			break;
 		}
@@ -503,7 +481,6 @@
 	const char   *first_filename;
 	char         *parent;
 	int           i;
-	int          *save_type_list;
 
 	if (file_list == NULL)
 		return;
@@ -581,13 +558,14 @@
 
 	data->a_archive_type_combo_box = gtk_combo_box_new_text ();
 	if (data->single_file)
-		save_type_list = single_file_save_type;
+		data->supported_types = single_file_save_type;
 	else
-		save_type_list = save_type;
-
-	for (i = 0; save_type_list[i] != -1; i++)
+		data->supported_types = save_type;
+	sort_mime_types_by_extension (data->supported_types);
+	
+	for (i = 0; data->supported_types[i] != -1; i++)
 		gtk_combo_box_append_text (GTK_COMBO_BOX (data->a_archive_type_combo_box),
-					   mime_type_desc[save_type_list[i]].default_ext);
+					   mime_type_desc[data->supported_types[i]].default_ext);
 
 	gtk_box_pack_start (GTK_BOX (a_archive_type_box), data->a_archive_type_combo_box, TRUE, TRUE, 0);
 	gtk_widget_show_all (a_archive_type_box);

Modified: trunk/src/dlg-new.c
==============================================================================
--- trunk/src/dlg-new.c	(original)
+++ trunk/src/dlg-new.c	Wed Aug 20 09:57:10 2008
@@ -205,7 +205,8 @@
 
 	data->window = window;
 	data->supported_types = supported_types;
-
+	sort_mime_types_by_description (data->supported_types);
+	
 	/* Get the widgets. */
 
 	data->dialog = glade_xml_get_widget (data->gui, "filechooserdialog");

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Wed Aug 20 09:57:10 2008
@@ -628,6 +628,54 @@
 }
 
 
+static int
+cmp_mime_type_by_extension (const void *p1, 
+			    const void *p2)
+{
+	int i1 = * (int*) p1;
+	int i2 = * (int*) p2;
+	
+	return strcmp (mime_type_desc[i1].default_ext, mime_type_desc[i2].default_ext);
+}
+
+
+static int
+cmp_mime_type_by_description (const void *p1, 
+			      const void *p2)
+{
+	int i1 = * (int*) p1;
+	int i2 = * (int*) p2;
+	
+	return g_utf8_collate (_(mime_type_desc[i1].name), _(mime_type_desc[i2].name));
+}
+
+
+static void
+sort_mime_types (int *a,
+                 int(*compar)(const void *, const void *))
+{
+	int n = 0;
+
+	while (a[n] != -1) 
+		n++;		
+	qsort (a, n, sizeof (int), compar);
+}
+
+
+void
+sort_mime_types_by_extension (int *a)
+{
+	sort_mime_types (a, cmp_mime_type_by_extension);
+}
+
+
+void
+sort_mime_types_by_description (int *a)
+{
+	sort_mime_types (a, cmp_mime_type_by_description);
+}
+
+
 static void
 compute_supported_archive_types (void)
 {

Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h	(original)
+++ trunk/src/main.h	Wed Aug 20 09:57:10 2008
@@ -75,5 +75,7 @@
 const char * get_mime_type_from_extension    (const char    *ext);
 const char * get_archive_filename_extension  (const char    *uri);
 int          get_mime_type_index             (const char    *mime_type);
-
+void         sort_mime_types_by_extension    (int           *a);
+void         sort_mime_types_by_description  (int           *a);
+		                              
 #endif /* MAIN_H */



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