file-roller r2250 - in trunk: . data src



Author: paobac
Date: Tue Apr 15 16:34:43 2008
New Revision: 2250
URL: http://svn.gnome.org/viewvc/file-roller?rev=2250&view=rev

Log:
2008-04-15  Paolo Bacchilega  <paobac svn gnome org>

	* src/dlg-prop.c: 
	
	use 'Location' instead of 'Path'.

	* src/preferences.h: 
	* src/gio-utils.h: 
	* src/gio-utils.c: 
	* src/fr-window.h: 
	* src/fr-window.c: 
	* src/fr-archive.h: 
	* src/fr-archive.c: 
	* src/file-utils.c: 
	* data/file-roller.schemas: 
	* src/dlg-add-folder.c:
	
	added an exclude folder filter to specify sub-folders to ignore when 
	adding a folder recursively.
	
	* src/dlg-add-folder.c (add_folder_cb): 
	* src/dlg-add-files.c (add_files_cb): 
	
	changed mnemonic keys to avoid collisions.

Modified:
   trunk/ChangeLog
   trunk/data/file-roller.schemas
   trunk/src/dlg-add-files.c
   trunk/src/dlg-add-folder.c
   trunk/src/dlg-prop.c
   trunk/src/file-utils.c
   trunk/src/fr-archive.c
   trunk/src/fr-archive.h
   trunk/src/fr-window.c
   trunk/src/fr-window.h
   trunk/src/gio-utils.c
   trunk/src/gio-utils.h
   trunk/src/preferences.h

Modified: trunk/data/file-roller.schemas
==============================================================================
--- trunk/data/file-roller.schemas	(original)
+++ trunk/data/file-roller.schemas	Tue Apr 15 16:34:43 2008
@@ -338,6 +338,18 @@
           <long></long>
         </locale>
       </schema>
+      
+      <schema>
+        <key>/schemas/apps/file-roller/dialogs/add/exclude_folders</key>
+	<applyto>/apps/file-roller/dialogs/add/exclude_folders</applyto>
+        <owner>file-roller</owner>
+        <type>string</type>
+        <default></default>
+        <locale name="C">
+          <short></short>
+          <long></long>
+        </locale>
+      </schema>
 
       <schema>
         <key>/schemas/apps/file-roller/dialogs/extract/update</key>

Modified: trunk/src/dlg-add-files.c
==============================================================================
--- trunk/src/dlg-add-files.c	(original)
+++ trunk/src/dlg-add-files.c	Tue Apr 15 16:34:43 2008
@@ -189,7 +189,7 @@
 	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE);
 	gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK);
 
-	data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("_Add only if newer"));
+	data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("Add only if _newer"));
 
 	main_box = gtk_hbox_new (FALSE, 20);
 	gtk_container_set_border_width (GTK_CONTAINER (main_box), 0);

Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c	(original)
+++ trunk/src/dlg-add-folder.c	Tue Apr 15 16:34:43 2008
@@ -49,6 +49,8 @@
 	GtkWidget   *include_files_label;
 	GtkWidget   *exclude_files_entry;
 	GtkWidget   *exclude_files_label;
+	GtkWidget   *exclude_folders_entry;
+	GtkWidget   *exclude_folders_label;
 	GtkWidget   *load_button;
 	GtkWidget   *save_button;
 	GtkWidget   *clear_button;
@@ -150,15 +152,22 @@
 
 	if (item_list != NULL) {
 		const char *folder = (char*) item_list->data;
-		const char *include_files = gtk_entry_get_text (GTK_ENTRY (data->include_files_entry));
-		const char *exclude_files = gtk_entry_get_text (GTK_ENTRY (data->exclude_files_entry));
+		const char *include_files;
+		const char *exclude_files;
+		const char *exclude_folders;
 		char       *dest_uri;
 		char       *dest_dir;
 
+		include_files = gtk_entry_get_text (GTK_ENTRY (data->include_files_entry));
+		exclude_files = gtk_entry_get_text (GTK_ENTRY (data->exclude_files_entry));
+		exclude_folders = gtk_entry_get_text (GTK_ENTRY (data->exclude_folders_entry));
+
 		if (utf8_only_spaces (include_files))
 			include_files = "*";
 		if (utf8_only_spaces (exclude_files))
 			exclude_files = NULL;
+		if (utf8_only_spaces (exclude_folders))
+			exclude_folders = NULL;
 
 		dest_uri = g_build_path (G_DIR_SEPARATOR_S,
 					 fr_window_get_current_location (window),
@@ -169,6 +178,7 @@
 		fr_window_archive_add_with_wildcard (window,
 						     include_files,
 						     exclude_files,
+						     exclude_folders,
 						     folder,
 						     dest_dir,
 						     update,
@@ -271,20 +281,28 @@
 	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE);
 	gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK);
 
-	data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("_Add only if newer"));
+	data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("Add only if _newer"));
 	data->include_subfold_checkbutton = gtk_check_button_new_with_mnemonic (_("_Include subfolders"));
 	data->exclude_symlinks = gtk_check_button_new_with_mnemonic (_("Exclude folders that are symbolic lin_ks"));
 
 	data->include_files_entry = gtk_entry_new ();
 	gtk_widget_set_tooltip_text (data->include_files_entry, _("example: *.o; *.bak"));
-	data->include_files_label = gtk_label_new_with_mnemonic (_("_Include files:"));
+	data->include_files_label = gtk_label_new_with_mnemonic (_("Include _files:"));
 	gtk_misc_set_alignment (GTK_MISC (data->include_files_label), 0.0, 0.5);
-
+	gtk_label_set_mnemonic_widget (GTK_LABEL (data->include_files_label), data->include_files_entry);
+	
 	data->exclude_files_entry = gtk_entry_new ();
 	gtk_widget_set_tooltip_text (data->exclude_files_entry, _("example: *.o; *.bak"));
 	data->exclude_files_label = gtk_label_new_with_mnemonic (_("E_xclude files:"));
 	gtk_misc_set_alignment (GTK_MISC (data->exclude_files_label), 0.0, 0.5);
-
+	gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_files_label), data->exclude_files_entry);
+	
+	data->exclude_folders_entry = gtk_entry_new ();
+	gtk_widget_set_tooltip_text (data->exclude_folders_entry, _("example: *.o; *.bak"));
+	data->exclude_folders_label = gtk_label_new_with_mnemonic (_("_Exclude folders:"));
+	gtk_misc_set_alignment (GTK_MISC (data->exclude_folders_label), 0.0, 0.5);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_folders_label), data->exclude_folders_entry);
+	
 	data->load_button = gtk_button_new_with_mnemonic (_("_Load Options"));
 	data->save_button = gtk_button_new_with_mnemonic (_("Sa_ve Options"));
 	data->clear_button = gtk_button_new_with_mnemonic (_("_Reset Options"));
@@ -308,7 +326,7 @@
 	gtk_box_pack_start (GTK_BOX (vbox), data->add_if_newer_checkbutton,
 			    TRUE, TRUE, 0);
 
-	table = gtk_table_new (2, 2, FALSE);
+	table = gtk_table_new (2, 4, FALSE);
 	gtk_table_set_row_spacings (GTK_TABLE (table), 6);
 	gtk_table_set_col_spacings (GTK_TABLE (table), 6);
 	gtk_box_pack_start (GTK_BOX (vbox), table,
@@ -322,7 +340,7 @@
 			  0, 0);
 	gtk_table_attach (GTK_TABLE (table),
 			  data->include_files_entry, 
-			  1, 2,
+			  1, 4,
 			  0, 1,
 			  GTK_FILL|GTK_EXPAND, 0,
 			  0, 0);
@@ -338,6 +356,18 @@
 			  1, 2,
 			  GTK_FILL|GTK_EXPAND, 0,
 			  0, 0);
+	gtk_table_attach (GTK_TABLE (table),
+			  data->exclude_folders_label,
+			  2, 3,
+			  1, 2,
+			  GTK_FILL, 0,
+			  0, 0);
+	gtk_table_attach (GTK_TABLE (table),
+			  data->exclude_folders_entry, 
+			  3, 4,
+			  1, 2,
+			  GTK_FILL|GTK_EXPAND, 0,
+			  0, 0);
 
 	/**/
 
@@ -412,6 +442,7 @@
 			   const char *filename,
 			   const char *include_files,
 			   const char *exclude_files,
+			   const char *exclude_folders,
 			   gboolean    update,
 			   gboolean    recursive,
 			   gboolean    no_symlinks)
@@ -428,6 +459,8 @@
 		gtk_entry_set_text (GTK_ENTRY (data->include_files_entry), include_files);
 	if (exclude_files != NULL)
 		gtk_entry_set_text (GTK_ENTRY (data->exclude_files_entry), exclude_files);
+	if (exclude_folders != NULL)
+		gtk_entry_set_text (GTK_ENTRY (data->exclude_folders_entry), exclude_folders);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->add_if_newer_checkbutton), update);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->include_subfold_checkbutton), recursive);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->exclude_symlinks), no_symlinks);
@@ -443,6 +476,7 @@
 				   gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (data->dialog)),
 				   "",
 				   "",
+				   "",
 				   FALSE,
 				   TRUE,
 				   FALSE);
@@ -462,6 +496,7 @@
 	char      *filename = NULL;
 	char      *include_files = NULL;
 	char      *exclude_files = NULL;
+	char      *exclude_folders = NULL;
 	gboolean   update;
 	gboolean   recursive;
 	gboolean   no_symlinks;
@@ -484,6 +519,7 @@
 	filename = g_key_file_get_string (key_file, "Options", "filename", NULL);
 	include_files = g_key_file_get_string (key_file, "Options", "include_files", NULL);
 	exclude_files = g_key_file_get_string (key_file, "Options", "exclude_files", NULL);
+	exclude_folders = g_key_file_get_string (key_file, "Options", "exclude_folders", NULL);
 	update = g_key_file_get_boolean (key_file, "Options", "update", NULL);
 	recursive = g_key_file_get_boolean (key_file, "Options", "recursive", NULL);
 	no_symlinks = g_key_file_get_boolean (key_file, "Options", "no_symlinks", NULL);
@@ -493,6 +529,7 @@
 			   	   filename,
 			   	   include_files,
 			   	   exclude_files,
+			   	   exclude_folders,
 			   	   update,
 			   	   recursive,
 			   	   no_symlinks);
@@ -503,6 +540,7 @@
 	g_free (filename);
 	g_free (include_files);
 	g_free (exclude_files);
+	g_free (exclude_folders);
 	g_key_file_free (key_file);
 	g_free (file_path);
 	g_object_unref (options_file);
@@ -519,6 +557,7 @@
 	char     *filename = NULL;
 	char     *include_files = NULL;
 	char     *exclude_files = NULL;
+	char     *exclude_folders = NULL;
 	gboolean  update;
 	gboolean  recursive;
 	gboolean  no_symlinks;
@@ -527,6 +566,7 @@
 	filename = eel_gconf_get_string (PREF_ADD_FILENAME, "");
 	include_files = eel_gconf_get_string (PREF_ADD_INCLUDE_FILES, "");
 	exclude_files = eel_gconf_get_string (PREF_ADD_EXCLUDE_FILES, "");
+	exclude_folders = eel_gconf_get_string (PREF_ADD_EXCLUDE_FOLDERS, "");
 	update = eel_gconf_get_boolean (PREF_ADD_UPDATE, FALSE);
 	recursive = eel_gconf_get_boolean (PREF_ADD_RECURSIVE, TRUE);
 	no_symlinks = eel_gconf_get_boolean (PREF_ADD_NO_SYMLINKS, FALSE);
@@ -536,6 +576,7 @@
 			   	   filename,
 			   	   include_files,
 			   	   exclude_files,
+			   	   exclude_folders,
 			   	   update,
 			   	   recursive,
 			   	   no_symlinks);
@@ -544,6 +585,7 @@
 	g_free (filename);
 	g_free (include_files);
 	g_free (exclude_files);
+	g_free (exclude_folders);
 }
 
 
@@ -553,6 +595,7 @@
 			  char       **filename,
 			  const char **include_files,
 			  const char **exclude_files,
+			  const char **exclude_folders,
 			  gboolean    *update,
 			  gboolean    *recursive,
 			  gboolean    *no_symlinks)
@@ -570,6 +613,10 @@
 	*exclude_files = gtk_entry_get_text (GTK_ENTRY (data->exclude_files_entry));
 	if (utf8_only_spaces (*exclude_files))
 		*exclude_files = "";
+		
+	*exclude_folders = gtk_entry_get_text (GTK_ENTRY (data->exclude_folders_entry));
+	if (utf8_only_spaces (*exclude_folders))
+		*exclude_folders = "";
 }
 
 
@@ -581,6 +628,7 @@
 	char       *filename;
 	const char *include_files;
 	const char *exclude_files;
+	const char *exclude_folders;
 	gboolean    update;
 	gboolean    recursive;
 	gboolean    no_symlinks;
@@ -591,6 +639,7 @@
 				  &filename,
 				  &include_files,
 				  &exclude_files,
+				  &exclude_folders,
 				  &update,
 				  &recursive,
 				  &no_symlinks);
@@ -602,6 +651,7 @@
 	g_key_file_set_string (key_file, "Options", "filename", filename);
 	g_key_file_set_string (key_file, "Options", "include_files", include_files);
 	g_key_file_set_string (key_file, "Options", "exclude_files", exclude_files);
+	g_key_file_set_string (key_file, "Options", "exclude_folders", exclude_folders);
 	g_key_file_set_boolean (key_file, "Options", "update", update);
 	g_key_file_set_boolean (key_file, "Options", "recursive", recursive);
 	g_key_file_set_boolean (key_file, "Options", "no_symlinks", no_symlinks);
@@ -621,6 +671,7 @@
 	char       *filename;
 	const char *include_files;
 	const char *exclude_files;
+	const char *exclude_folders;
 	gboolean    update;
 	gboolean    recursive;
 	gboolean    no_symlinks;
@@ -630,6 +681,7 @@
 				  &filename,
 				  &include_files,
 				  &exclude_files,
+				  &exclude_folders,
 				  &update,
 				  &recursive,
 				  &no_symlinks);
@@ -638,6 +690,7 @@
 	eel_gconf_set_string (PREF_ADD_FILENAME, filename);
 	eel_gconf_set_string (PREF_ADD_INCLUDE_FILES, include_files);
 	eel_gconf_set_string (PREF_ADD_EXCLUDE_FILES, exclude_files);
+	eel_gconf_set_string (PREF_ADD_EXCLUDE_FOLDERS, exclude_folders);
 	eel_gconf_set_boolean (PREF_ADD_UPDATE, update);
 	eel_gconf_set_boolean (PREF_ADD_RECURSIVE, recursive);
 	eel_gconf_set_boolean (PREF_ADD_NO_SYMLINKS, no_symlinks);

Modified: trunk/src/dlg-prop.c
==============================================================================
--- trunk/src/dlg-prop.c	(original)
+++ trunk/src/dlg-prop.c	Tue Apr 15 16:34:43 2008
@@ -107,7 +107,7 @@
 	/* Set widgets data. */
 
 	label_label = glade_xml_get_widget (data->gui, "p_path_label_label");
-	set_label (label_label, _("Path:"));
+	set_label (label_label, _("Location:"));
 
 	label = glade_xml_get_widget (data->gui, "p_path_label");
 	s = remove_level_from_path (fr_window_get_archive_uri (window));
@@ -122,7 +122,7 @@
 	set_label (label_label, _("Name:"));
 
 	label = glade_xml_get_widget (data->gui, "p_name_label");
-	utf8_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (window)));
+	utf8_name = g_filename_display_basename (fr_window_get_archive_uri (window));
 	gtk_label_set_text (GTK_LABEL (label), utf8_name);
 
 	title_txt = g_strdup_printf (_("%s Properties"), utf8_name);

Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c	(original)
+++ trunk/src/file-utils.c	Tue Apr 15 16:34:43 2008
@@ -384,7 +384,7 @@
 }
 
 
-/* like g_basename but does not warns about NULL and does not
+/* like g_basename but does not warn about NULL and does not
  * alloc a new string. */
 G_CONST_RETURN gchar *
 file_name_from_path (const gchar *file_name)

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Tue Apr 15 16:34:43 2008
@@ -2003,6 +2003,7 @@
 fr_archive_add_with_wildcard (FrArchive     *archive,
 			      const char    *include_files,
 			      const char    *exclude_files,
+			      const char    *exclude_folders,
 			      const char    *source_dir,
 			      const char    *dest_dir,
 			      gboolean       update,
@@ -2036,6 +2037,7 @@
 				NO_DOT_FILES,
 				include_files,
 				exclude_files,
+				exclude_folders,
 				IGNORE_CASE,
 				archive->priv->cancellable,
 				add_with_wildcard__step2,

Modified: trunk/src/fr-archive.h
==============================================================================
--- trunk/src/fr-archive.h	(original)
+++ trunk/src/fr-archive.h	Tue Apr 15 16:34:43 2008
@@ -157,6 +157,7 @@
 void        fr_archive_add_with_wildcard         (FrArchive     *archive,
 						  const char    *include_files,
 						  const char    *exclude_files,
+						  const char    *exclude_folders,
 						  const char    *base_dir,
 						  const char    *dest_dir,
 						  gboolean       update,

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Tue Apr 15 16:34:43 2008
@@ -2898,6 +2898,7 @@
 				  window->priv->convert_data.new_archive,
 				  "*",
 				  NULL,
+				  NULL,
 				  source_dir,
 				  NULL,
 				  FALSE,
@@ -5682,6 +5683,7 @@
 fr_window_archive_add_with_wildcard (FrWindow      *window,
 				     const char    *include_files,
 				     const char    *exclude_files,
+				     const char    *exclude_folders,
 				     const char    *base_dir,
 				     const char    *dest_dir,
 				     gboolean       update,
@@ -5691,6 +5693,7 @@
 	fr_archive_add_with_wildcard (window->archive,
 				      include_files,
 				      exclude_files,
+				      exclude_folders,
 				      base_dir,
 				      (dest_dir == NULL)? fr_window_get_current_location (window): dest_dir,
 				      update,

Modified: trunk/src/fr-window.h
==============================================================================
--- trunk/src/fr-window.h	(original)
+++ trunk/src/fr-window.h	Tue Apr 15 16:34:43 2008
@@ -125,6 +125,7 @@
 void        fr_window_archive_add_with_wildcard (FrWindow      *window,
 						 const char    *include_files,
 						 const char    *exclude_files,
+						 const char    *exclude_folders,
 						 const char    *base_dir,
 						 const char    *dest_dir,
 						 gboolean       update,

Modified: trunk/src/gio-utils.c
==============================================================================
--- trunk/src/gio-utils.c	(original)
+++ trunk/src/gio-utils.c	Tue Apr 15 16:34:43 2008
@@ -208,16 +208,6 @@
 }
 
 
-static void
-for_each_child_set_current (ForEachChildData *fec,
-			    const char       *directory)
-{
-	if (fec->current != NULL)
-		g_object_unref (fec->current);
-	fec->current = g_file_new_for_uri (directory);
-}
-
-
 static gboolean
 for_each_child_done_cb (gpointer user_data)
 {
@@ -236,7 +226,14 @@
 }
 
 
-static void for_each_child_start (ForEachChildData *fec);
+static void 
+for_each_child_done (ForEachChildData *fec)
+{
+	fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+}
+
+
+static void for_each_child_start_current (ForEachChildData *fec);
 
 
 static gboolean
@@ -245,13 +242,53 @@
 	ForEachChildData *fec = user_data;
 	
 	g_source_remove (fec->source_id);
-	for_each_child_start (fec);
+	for_each_child_start_current (fec);
 	
 	return FALSE;
 }
 
 
-void
+static void 
+for_each_child_start (ForEachChildData *fec)
+{
+	fec->source_id = g_idle_add (for_each_child_start_cb, fec);
+}
+
+
+static void
+for_each_child_set_current (ForEachChildData *fec,
+			    const char       *directory)
+{
+	if (fec->current != NULL)
+		g_object_unref (fec->current);
+	fec->current = g_file_new_for_uri (directory);
+}
+
+
+static void
+for_each_child_start_next_sub_directory (ForEachChildData *fec)
+{
+	char *sub_directory = NULL;
+	
+	if (fec->to_visit != NULL) {
+		GList *tmp;
+				
+		sub_directory = (char*) fec->to_visit->data;
+		tmp = fec->to_visit;
+		fec->to_visit = g_list_remove_link (fec->to_visit, tmp);
+		g_list_free (tmp);
+	}
+	
+	if (sub_directory != NULL) {
+		for_each_child_set_current (fec, sub_directory);
+		for_each_child_start (fec);
+	}
+	else
+		for_each_child_done (fec);
+}
+
+
+static void
 for_each_child_close_enumerator (GObject      *source_object,
 	              		 GAsyncResult *result,
 		      		 gpointer      user_data)
@@ -269,26 +306,10 @@
 			g_clear_error (&error);
 	}
 	
-	if ((fec->error == NULL) && fec->recursive) {
-		char *sub_directory = NULL;
-			
-		if (fec->to_visit != NULL) {
-			GList *tmp;
-				
-			sub_directory = (char*) fec->to_visit->data;
-			tmp = fec->to_visit;
-			fec->to_visit = g_list_remove_link (fec->to_visit, tmp);
-			g_list_free (tmp);
-		}
-			
-		if (sub_directory != NULL) {
-			for_each_child_set_current (fec, sub_directory);
-			fec->source_id = g_idle_add (for_each_child_start_cb, fec);
-			return;
-		}
-	}
-	
-	fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+	if ((fec->error == NULL) && fec->recursive) 
+		for_each_child_start_next_sub_directory (fec);
+	else
+		for_each_child_done (fec);
 }
 
 
@@ -358,7 +379,7 @@
 	
 	fec->enumerator = g_file_enumerate_children_finish (fec->current, result, &(fec->error));
 	if (fec->enumerator == NULL) {
-		fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+		for_each_child_done (fec);
 		return;
 	}
 	
@@ -372,18 +393,26 @@
 
 
 static void
-for_each_child_start (ForEachChildData *fec)
+for_each_child_start_current (ForEachChildData *fec)
 {
 	if (fec->start_dir_func != NULL) {
-		char *directory;
+		char  *directory;
+		DirOp  op;
 		
 		directory = g_file_get_uri (fec->current);
-		if (! fec->start_dir_func (directory, &(fec->error), fec->user_data)) {
-			g_free (directory);
-			fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+		op = fec->start_dir_func (directory, &(fec->error), fec->user_data);
+		g_free (directory);
+		
+		switch (op) {
+		case DIR_OP_SKIP:
+			for_each_child_start_next_sub_directory (fec);
 			return;
+		case DIR_OP_STOP:
+			for_each_child_done (fec);
+			return;
+		case DIR_OP_CONTINUE:
+			break;
 		}
-		g_free (directory);
 	}
 		
 	g_file_enumerate_children_async (fec->current,
@@ -448,7 +477,7 @@
 						      NULL);
 	
 	for_each_child_set_current (fec, fec->base_directory);
-	for_each_child_start (fec);	
+	for_each_child_start_current (fec);	
 }
 
 
@@ -467,6 +496,7 @@
 	GList             *current_dir;
 	Filter            *include_filter;
 	Filter            *exclude_filter;
+	Filter            *exclude_folders_filter;
 	guint              visit_timeout;
 } GetFileListData;
 
@@ -479,6 +509,7 @@
 
 	filter_destroy (gfl->include_filter);
 	filter_destroy (gfl->exclude_filter);
+	filter_destroy (gfl->exclude_folders_filter);
 	path_list_free (gfl->files);
 	path_list_free (gfl->dirs);
 	path_list_free (gfl->to_visit);
@@ -656,6 +687,20 @@
 }
 
 
+static DirOp
+get_file_list_start_dir (const char  *uri,
+			 GError     **error,
+			 gpointer     user_data)
+{
+	GetFileListData *gfl = user_data;
+	
+	if ((gfl->exclude_folders_filter->pattern == NULL) || ! filter_matches (gfl->exclude_folders_filter, uri))
+		return DIR_OP_CONTINUE;
+	else 
+		return DIR_OP_SKIP;		
+}
+
+
 void
 g_directory_list_async (const char           *directory, 
 		       const char            *base_dir,
@@ -665,6 +710,7 @@
 		       gboolean               no_dot_files,
 		       const char            *include_files,
 		       const char            *exclude_files,
+		       const char            *exclude_folders,
 		       gboolean               ignorecase,
 		       GCancellable          *cancellable,
 		       ListReadyCallback      done_func,
@@ -688,12 +734,13 @@
 		filter_options |= FILTER_IGNORECASE;
 	gfl->include_filter = filter_new (include_files, filter_options);
 	gfl->exclude_filter = filter_new (exclude_files, ignorecase ? FILTER_IGNORECASE : FILTER_DEFAULT);
+	gfl->exclude_folders_filter = filter_new (exclude_folders, ignorecase ? FILTER_IGNORECASE : FILTER_DEFAULT);
 	
 	g_directory_foreach_child (directory,
 				   recursive,
 				   follow_links,
 				   cancellable,
-				   NULL,
+				   get_file_list_start_dir,
 				   get_file_list_for_each_file,
 				   get_file_list_done,
 				   gfl);
@@ -1378,7 +1425,7 @@
 }
 
 
-static gboolean
+static DirOp
 g_directory_copy_start_dir (const char  *uri, 
 			    GError     **error,
 			    gpointer     user_data)
@@ -1393,7 +1440,7 @@
 	
 	dcd->tot_files++;
 	
-	return TRUE;
+	return DIR_OP_CONTINUE;
 }
 
 

Modified: trunk/src/gio-utils.h
==============================================================================
--- trunk/src/gio-utils.h	(original)
+++ trunk/src/gio-utils.h	Tue Apr 15 16:34:43 2008
@@ -28,7 +28,13 @@
 
 /* callback types */
 
-typedef gboolean (*StartDirCallback) (const char  *uri,
+typedef enum {
+	DIR_OP_CONTINUE,
+	DIR_OP_SKIP,
+	DIR_OP_STOP
+} DirOp;
+
+typedef DirOp (*StartDirCallback)    (const char  *uri,
 				      GError     **error,
 				      gpointer     user_data);
 typedef void (*ForEachChildCallback) (const char  *uri, 
@@ -68,6 +74,7 @@
 				      gboolean               no_dot_files,
 				      const char            *include_files,
 				      const char            *exclude_files,
+				      const char            *exclude_folders,
 				      gboolean               ignorecase,
 				      GCancellable          *cancellable,
 				      ListReadyCallback      done_func,
@@ -138,6 +145,6 @@
  * 
  */
 #define g_directory_list_all_async(directory, base_dir, recursive, cancellable, done_func, done_data) \
-    g_directory_list_async ((directory), (base_dir), (recursive), TRUE, FALSE, FALSE, NULL, NULL, FALSE, (cancellable), (done_func), (done_data))
+    g_directory_list_async ((directory), (base_dir), (recursive), TRUE, FALSE, FALSE, NULL, NULL, NULL, FALSE, (cancellable), (done_func), (done_data))
 
 #endif /* _GIO_UTILS_H */

Modified: trunk/src/preferences.h
==============================================================================
--- trunk/src/preferences.h	(original)
+++ trunk/src/preferences.h	Tue Apr 15 16:34:43 2008
@@ -59,6 +59,7 @@
 #define PREF_ADD_FILENAME             "/apps/file-roller/dialogs/add/filename"
 #define PREF_ADD_INCLUDE_FILES        "/apps/file-roller/dialogs/add/include_files"
 #define PREF_ADD_EXCLUDE_FILES        "/apps/file-roller/dialogs/add/exclude_files"
+#define PREF_ADD_EXCLUDE_FOLDERS      "/apps/file-roller/dialogs/add/exclude_folders"
 #define PREF_ADD_UPDATE               "/apps/file-roller/dialogs/add/update"
 #define PREF_ADD_RECURSIVE            "/apps/file-roller/dialogs/add/recursive"
 #define PREF_ADD_NO_SYMLINKS          "/apps/file-roller/dialogs/add/no_symlinks"



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