Author: colossus Date: 2008-10-24 08:00:56 +0000 (Fri, 24 Oct 2008) New Revision: 28397
Modified: xarchiver/trunk/src/extract_dialog.c xarchiver/trunk/src/tar.c xarchiver/trunk/src/window.c xarchiver/trunk/src/window.h Log: Fixed another tar error when using FreeBSD, thanks to Bernhard Fr?\195?\182hlich for testing Xarchiver with FreeBSD. Fixed inability to extract files from tar-compressed archives without path. Fixed inability to extract files in the directory when selecting or dragging it. Modified: xarchiver/trunk/src/extract_dialog.c =================================================================== --- xarchiver/trunk/src/extract_dialog.c 2008-10-24 06:42:12 UTC (rev 28396) +++ xarchiver/trunk/src/extract_dialog.c 2008-10-24 08:00:56 UTC (rev 28397) @@ -243,7 +243,7 @@ else gtk_widget_set_sensitive (dialog_data->selected_radio,FALSE); - if (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_RPM) + if ( (xa_main_window == NULL && is_tar_compressed(archive->type)) || archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_RPM) flag = FALSE; gtk_widget_set_sensitive (dialog_data->extract_full,flag); @@ -365,12 +365,12 @@ string = g_strdup (gtk_entry_get_text(GTK_ENTRY(dialog_data->entry2))); gtk_tree_model_foreach(model,(GtkTreeModelForeachFunc)select_matched_rows,string); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(archive->treeview)); - gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_filenames,&names); + gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_selected_filenames,&names); g_free(string); } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dialog_data->selected_radio))) - gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_filenames,&names); - + gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_selected_filenames,&names); + else if (xa_main_window) { xa_set_button_state (0,0,0,0,0,0,0,0,0,0,0); @@ -616,7 +616,7 @@ } } if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),&iter)== FALSE) - gtk_widget_set_sensitive ( widget,FALSE); + gtk_widget_set_sensitive (widget,FALSE); g_list_foreach(rr_list,(GFunc)gtk_tree_row_reference_free,NULL); g_list_free(rr_list); } Modified: xarchiver/trunk/src/tar.c =================================================================== --- xarchiver/trunk/src/tar.c 2008-10-24 06:42:12 UTC (rev 28396) +++ xarchiver/trunk/src/tar.c 2008-10-24 08:00:56 UTC (rev 28397) @@ -24,6 +24,8 @@ extern void xa_create_liststore ( XArchive *archive, gchar *columns_names[]); extern gchar *tar; +static gboolean xa_concat_filenames (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,GSList **list); + void xa_open_tar (XArchive *archive) { gchar *command; @@ -441,23 +443,41 @@ gboolean xa_extract_tar_without_directories (gchar *string,XArchive *archive,gchar *files_to_extract) { - gchar *command = NULL; + gchar *command = NULL, *e_filename = NULL; GSList *list = NULL; + GSList *files = NULL; + GString *names = g_string_new(""); gboolean result; result = xa_create_temp_directory (archive); if (!result) return FALSE; + if (strlen(files_to_extract) == 0) + { + gtk_tree_model_foreach(GTK_TREE_MODEL(archive->liststore),(GtkTreeModelForeachFunc) xa_concat_filenames,&files); + + while (files) + { + e_filename = xa_escape_filename((gchar*)files->data,"$'`\"\\!?* ()[]&|:;<>#"); + g_string_prepend_c (names,' '); + g_string_prepend (names,e_filename); + files = files->next; + } + g_slist_foreach(files,(GFunc)g_free,NULL); + g_slist_free(files); + files_to_extract = names->str; + } + command = g_strconcat (string, archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", + " --no-wildcards ", #endif archive->tar_touch ? " --touch" : "", - " --no-wildcards -C ", - archive->tmp," ",files_to_extract,NULL); + "-C ",archive->tmp," ",files_to_extract,NULL); list = g_slist_append(list,command); if (strcmp(archive->extraction_path,archive->tmp)) { @@ -465,5 +485,22 @@ command = g_strconcat ("mv -f ",files_to_extract," ",archive->extraction_path,NULL); list = g_slist_append(list,command); } + g_string_free(names,TRUE); return xa_run_command (archive,list); } + +static gboolean xa_concat_filenames (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,GSList **list) +{ + XEntry *entry; + gint current_page,idx; + + current_page = gtk_notebook_get_current_page(notebook); + idx = xa_find_archive_index (current_page); + + gtk_tree_model_get(model,iter,archive[idx]->nc+1,&entry,-1); + if (entry == NULL) + return TRUE; + else + xa_fill_list_with_recursed_entries(entry->child,list); + return FALSE; +} Modified: xarchiver/trunk/src/window.c =================================================================== --- xarchiver/trunk/src/window.c 2008-10-24 06:42:12 UTC (rev 28396) +++ xarchiver/trunk/src/window.c 2008-10-24 08:00:56 UTC (rev 28397) @@ -1662,7 +1662,6 @@ GtkTreeSelection *selection; GList *row_list = NULL; GSList *names = NULL; - gboolean full_path,overwrite; guchar *_destination; gchar *destination,*to_send; int response; @@ -1716,17 +1715,11 @@ } else { - gtk_tree_selection_selected_foreach (selection,(GtkTreeSelectionForeachFunc) xa_concat_filenames,&names); - full_path = archive->full_path; - overwrite = archive->overwrite; - archive->full_path = 0; - archive->overwrite = 1; + gtk_tree_selection_selected_foreach (selection,(GtkTreeSelectionForeachFunc) xa_concat_selected_filenames,&names); + archive->full_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (extract_window->extract_full)); + archive->overwrite = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (extract_window->overwrite_check)); (*archive->extract) (archive,names); - archive->full_path = full_path; - archive->overwrite = overwrite; - - g_list_foreach (row_list,(GFunc) gtk_tree_path_free,NULL); g_list_free (row_list); to_send = "S"; @@ -1826,7 +1819,7 @@ g_strfreev (array); } -void xa_concat_filenames (GtkTreeModel *model,GtkTreePath *treepath,GtkTreeIter *iter,GSList **data) +void xa_concat_selected_filenames (GtkTreeModel *model,GtkTreePath *treepath,GtkTreeIter *iter,GSList **data) { XEntry *entry = NULL; gchar *filename = NULL; @@ -1837,7 +1830,11 @@ idx = xa_find_archive_index (current_page); gtk_tree_model_get (model,iter,archive[idx]->nc+1,&entry,-1); - filename = xa_build_full_path_name_from_entry(entry,0); + //TODO controlla che solo tar vada bene e metti if !is_tar_compressed invece di archive[idx]->type + if (entry->is_dir) + xa_fill_list_with_recursed_entries(entry->child,data); + else + filename = xa_build_full_path_name_from_entry(entry,0); *data = g_slist_prepend (*data,filename); } @@ -2381,7 +2378,7 @@ }; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(archive->treeview)); - gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc) xa_concat_filenames,&files); + gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc) xa_concat_selected_filenames,&files); clipboard = gtk_clipboard_get (XA_CLIPBOARD); clipboard_data = xa_clipboard_data_new(); Modified: xarchiver/trunk/src/window.h =================================================================== --- xarchiver/trunk/src/window.h 2008-10-24 06:42:12 UTC (rev 28396) +++ xarchiver/trunk/src/window.h 2008-10-24 08:00:56 UTC (rev 28397) @@ -85,7 +85,7 @@ void on_options1_activate (GtkMenuItem *, gpointer); void xa_extract_archive ( GtkMenuItem *, gpointer); void xa_convert_sfx ( GtkMenuItem *, gpointer); -void xa_concat_filenames (GtkTreeModel *, GtkTreePath *, GtkTreeIter *, GSList **); +void xa_concat_selected_filenames (GtkTreeModel *, GtkTreePath *, GtkTreeIter *, GSList **); void xa_select_all ( GtkMenuItem *, gpointer); void xa_deselect_all ( GtkMenuItem *, gpointer); void xa_show_archive_comment ( GtkMenuItem *, gpointer); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits