13
12
* GNU General Public License for more details.
15
14
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
15
* along with this program; if not,write to the Free Software
16
* Foundation,Inc.,59 Temple Street #330,Boston,MA 02111-1307,USA.
20
19
#include <gtk/gtk.h>
21
20
#include <stdlib.h>
22
21
#include "extract_dialog.h"
23
#include "interface.h"
24
#include "callbacks.h"
22
#include "sexy-icon-entry.h"
25
24
#include "string_utils.h"
26
25
#include "support.h"
30
extern gboolean unrar;
27
extern gboolean unrar,batch_mode;
28
extern Prefs_dialog_data *prefs_window;
29
extern Progress_bar_data *pb;
30
extern extract_func extract [XARCHIVETYPE_COUNT];
33
Extract_dialog_data *xa_create_extract_dialog (gint selected , XArchive *archive)
33
static gchar *xa_multi_extract_archive(Multi_extract_data *,gchar *,gboolean,gboolean,gchar *);
34
static void xa_select_where_to_extract(SexyIconEntry *,SexyIconEntryPosition ,int ,Multi_extract_data *);
35
static void xa_remove_files_liststore (GtkWidget *,Multi_extract_data *);
36
static void xa_multi_extract_dialog_select_files_to_add (GtkButton*,Multi_extract_data *);
37
static void xa_multi_extract_dialog_selection_changed(GtkTreeSelection *selection,Multi_extract_data *);
38
static void remove_foreach_func (GtkTreeModel *,GtkTreePath *,GtkTreeIter *,GList **);
39
static void xa_multi_extract_dialog_drag_data_received (GtkWidget *,GdkDragContext *,int x,int y,GtkSelectionData *,unsigned int,unsigned int,gpointer );
40
static const GtkTargetEntry drop_targets[] =
42
{ "text/uri-list",0,0 },
45
Extract_dialog_data *xa_create_extract_dialog()
47
GSList *radiobutton1_group = NULL;
35
48
Extract_dialog_data *dialog_data;
38
dialog_data = g_new0 (Extract_dialog_data, 1);
39
dialog_data->radio_group = NULL;
40
dialog_data->dialog1 = gtk_dialog_new ();
41
if (archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP)
42
gtk_window_set_title (GTK_WINDOW (dialog_data->dialog1), _("Decompress file"));
44
gtk_window_set_title (GTK_WINDOW (dialog_data->dialog1), _("Extract files from archive"));
45
gtk_window_set_type_hint (GTK_WINDOW (dialog_data->dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
46
gtk_window_set_transient_for ( GTK_WINDOW (dialog_data->dialog1) , GTK_WINDOW (MainWindow) );
48
dialog_data->option_tooltip = gtk_tooltips_new ();
50
dialog_data = g_new0 (Extract_dialog_data,1);
51
dialog_data->dialog1 = gtk_dialog_new();
53
gtk_window_set_position (GTK_WINDOW (dialog_data->dialog1),GTK_WIN_POS_CENTER_ON_PARENT);
54
gtk_window_set_type_hint (GTK_WINDOW (dialog_data->dialog1),GDK_WINDOW_TYPE_HINT_DIALOG);
55
gtk_dialog_set_has_separator (GTK_DIALOG(dialog_data->dialog1),FALSE);
56
gtk_window_set_destroy_with_parent(GTK_WINDOW (dialog_data->dialog1),TRUE);
58
option_tooltip = gtk_tooltips_new ();
49
59
dialog_data->dialog_vbox1 = GTK_DIALOG (dialog_data->dialog1)->vbox;
50
gtk_widget_show (dialog_data->dialog_vbox1);
52
dialog_data->vbox1 = gtk_vbox_new (FALSE, 0);
53
gtk_widget_show (dialog_data->vbox1);
54
gtk_box_pack_start (GTK_BOX (dialog_data->dialog_vbox1), dialog_data->vbox1, TRUE, TRUE, 0);
56
dialog_data->hbox3 = gtk_hbox_new (FALSE, 0);
57
gtk_widget_show (dialog_data->hbox3);
58
gtk_box_pack_start (GTK_BOX (dialog_data->vbox1), dialog_data->hbox3, FALSE, TRUE, 17);
60
dialog_data->extract_to_label = gtk_label_new (_("Extract to:"));
61
gtk_widget_show (dialog_data->extract_to_label);
62
gtk_box_pack_start (GTK_BOX (dialog_data->hbox3), dialog_data->extract_to_label, FALSE, TRUE, 0);
64
dialog_data->destination_path_entry = gtk_entry_new ();
65
gtk_widget_show (dialog_data->destination_path_entry);
66
gtk_box_pack_start (GTK_BOX (dialog_data->hbox3), dialog_data->destination_path_entry, TRUE, TRUE, 0);
67
gtk_widget_set_size_request (dialog_data->destination_path_entry, 385, -1);
68
gtk_entry_set_activates_default (GTK_ENTRY (dialog_data->destination_path_entry), TRUE);
70
gchar *dummy = g_strrstr (archive->path, ".");
74
unsigned short int x = strlen (archive->path) - strlen ( dummy );
75
gchar *extraction_string = (gchar *) g_malloc ( x + 1);
76
strncpy ( extraction_string, archive->path, x );
77
extraction_string [x-1] = '\0';
79
if ( strstr (extraction_string , ".tar") )
81
extraction_string = g_realloc ( extraction_string, x - 5);
82
strncpy ( extraction_string, archive->path, x - 5);
83
extraction_string[x-5] = '\0';
85
gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry), extraction_string);
86
g_free (extraction_string);
89
gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry), archive->path);
91
dialog_data->button1 = gtk_button_new ();
92
gtk_widget_set_size_request (dialog_data->button1, 33, 27);
93
gtk_widget_show (dialog_data->button1);
95
dialog_data->image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
96
gtk_widget_show (dialog_data->image1);
97
gtk_box_pack_end(GTK_BOX (dialog_data->hbox3), dialog_data->button1, FALSE, TRUE, 0);
98
gtk_widget_set_size_request (dialog_data->image1, 30, 30);
100
gtk_container_add(GTK_CONTAINER(dialog_data->button1), dialog_data->image1);
101
gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->button1 , _("Choose a folder where to extract files"), NULL );
102
g_signal_connect ( (gpointer) dialog_data->button1, "clicked", G_CALLBACK (xa_choose_extraction_directory) , dialog_data );
104
dialog_data->hbox4 = gtk_hbox_new (TRUE, 7);
105
gtk_widget_show (dialog_data->hbox4);
106
gtk_box_pack_start (GTK_BOX (dialog_data->vbox1), dialog_data->hbox4, FALSE, FALSE, 0);
108
dialog_data->frame1 = gtk_frame_new (NULL);
109
gtk_widget_show (dialog_data->frame1);
110
gtk_box_pack_start (GTK_BOX (dialog_data->hbox4), dialog_data->frame1, TRUE, TRUE, 0);
111
gtk_widget_set_size_request (dialog_data->frame1, 1, -1);
112
gtk_frame_set_shadow_type (GTK_FRAME (dialog_data->frame1), GTK_SHADOW_OUT);
114
dialog_data->alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
115
gtk_widget_show (dialog_data->alignment1);
116
gtk_container_add (GTK_CONTAINER (dialog_data->frame1), dialog_data->alignment1);
117
gtk_alignment_set_padding (GTK_ALIGNMENT (dialog_data->alignment1), 0, 0, 12, 0);
119
dialog_data->vbox3 = gtk_vbox_new (FALSE, 0);
120
gtk_widget_show (dialog_data->vbox3);
121
gtk_container_add (GTK_CONTAINER (dialog_data->alignment1), dialog_data->vbox3);
123
dialog_data->all_files_radio = gtk_radio_button_new_with_mnemonic (NULL, _("All"));
124
gtk_widget_show (dialog_data->all_files_radio);
125
gtk_box_pack_start (GTK_BOX (dialog_data->vbox3), dialog_data->all_files_radio, FALSE, FALSE, 0);
126
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->all_files_radio), dialog_data->radio_group);
127
dialog_data->radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->all_files_radio));
129
dialog_data->selected_files_radio = gtk_radio_button_new_with_mnemonic (NULL, _("Only selected"));
130
gtk_widget_show (dialog_data->selected_files_radio);
131
gtk_box_pack_start (GTK_BOX (dialog_data->vbox3), dialog_data->selected_files_radio, FALSE, FALSE, 0);
132
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->selected_files_radio), dialog_data->radio_group);
133
dialog_data->radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->selected_files_radio));
136
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->selected_files_radio), TRUE);
138
gtk_widget_set_sensitive (dialog_data->selected_files_radio , FALSE);
140
dialog_data->files_frame_label = gtk_label_new (_("<b>Files to extract </b>"));
141
gtk_widget_show (dialog_data->files_frame_label);
142
gtk_frame_set_label_widget (GTK_FRAME (dialog_data->frame1), dialog_data->files_frame_label);
143
gtk_label_set_use_markup (GTK_LABEL (dialog_data->files_frame_label), TRUE);
145
dialog_data->frame2 = gtk_frame_new (NULL);
146
gtk_widget_show (dialog_data->frame2);
147
gtk_box_pack_start (GTK_BOX (dialog_data->hbox4), dialog_data->frame2, TRUE, TRUE, 0);
148
gtk_frame_set_shadow_type (GTK_FRAME (dialog_data->frame2), GTK_SHADOW_OUT);
150
dialog_data->alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
151
gtk_widget_show (dialog_data->alignment2);
152
gtk_container_add (GTK_CONTAINER (dialog_data->frame2), dialog_data->alignment2);
153
gtk_alignment_set_padding (GTK_ALIGNMENT (dialog_data->alignment2), 0, 0, 12, 0);
155
dialog_data->vbox4 = gtk_vbox_new (FALSE, 0);
156
gtk_widget_show (dialog_data->vbox4);
157
gtk_container_add (GTK_CONTAINER (dialog_data->alignment2), dialog_data->vbox4);
61
vbox1 = gtk_vbox_new (FALSE,2);
62
gtk_box_pack_start (GTK_BOX (dialog_data->dialog_vbox1),vbox1,TRUE,TRUE,0);
63
gtk_container_set_border_width (GTK_CONTAINER (vbox1),2);
65
label1 = gtk_label_new (_("Extract to:"));
66
gtk_box_pack_start (GTK_BOX (vbox1),label1,FALSE,FALSE,0);
67
gtk_misc_set_alignment (GTK_MISC (label1),0,0.5);
69
dialog_data->destination_path_entry = sexy_icon_entry_new();
70
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(dialog_data->destination_path_entry),dialog_data,xa_select_where_to_extract);
71
sexy_icon_entry_set_icon_highlight( SEXY_ICON_ENTRY(dialog_data->destination_path_entry),SEXY_ICON_ENTRY_PRIMARY,TRUE );
72
gtk_box_pack_start (GTK_BOX (vbox1),dialog_data->destination_path_entry,FALSE,FALSE,0);
74
hbox1 = gtk_hbox_new (TRUE,10);
75
gtk_box_pack_start (GTK_BOX (vbox1),hbox1,TRUE,TRUE,0);
77
vbox2 = gtk_vbox_new (FALSE,5);
78
gtk_box_pack_start (GTK_BOX (hbox1),vbox2,TRUE,TRUE,0);
80
frame1 = gtk_frame_new (NULL);
81
gtk_box_pack_start (GTK_BOX (vbox2),frame1,TRUE,TRUE,0);
82
gtk_frame_set_shadow_type (GTK_FRAME (frame1),GTK_SHADOW_OUT);
84
alignment1 = gtk_alignment_new (0.5,0.5,1,1);
85
gtk_container_add (GTK_CONTAINER (frame1),alignment1);
86
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1),0,0,12,0);
88
vbox3 = gtk_vbox_new (FALSE,0);
89
gtk_container_add (GTK_CONTAINER (alignment1),vbox3);
91
dialog_data->all_files_radio = gtk_radio_button_new_with_mnemonic (NULL,_("All files"));
92
gtk_box_pack_start (GTK_BOX (vbox3),dialog_data->all_files_radio,FALSE,FALSE,0);
93
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->all_files_radio),radiobutton1_group);
94
radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->all_files_radio));
96
dialog_data->selected_radio = gtk_radio_button_new_with_mnemonic (NULL,_("Selected files"));
97
gtk_box_pack_start (GTK_BOX (vbox3),dialog_data->selected_radio,FALSE,FALSE,0);
98
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->selected_radio),radiobutton1_group);
99
radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->selected_radio));
101
hbox2 = gtk_hbox_new (FALSE,0);
102
gtk_box_pack_start (GTK_BOX (vbox3),hbox2,FALSE,FALSE,0);
104
dialog_data->files_radio = gtk_radio_button_new_with_mnemonic (NULL,_("Files: "));
105
gtk_box_pack_start (GTK_BOX (hbox2),dialog_data->files_radio,FALSE,FALSE,0);
106
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->files_radio),radiobutton1_group);
107
radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->files_radio));
109
dialog_data->entry2 = gtk_entry_new ();
110
gtk_box_pack_start (GTK_BOX (hbox2),dialog_data->entry2,TRUE,TRUE,0);
111
gtk_entry_set_width_chars (GTK_ENTRY (dialog_data->entry2),10);
112
gtk_widget_set_sensitive(dialog_data->entry2,FALSE);
113
g_signal_connect (G_OBJECT (dialog_data->files_radio),"toggled",G_CALLBACK(xa_activate_entry),dialog_data);
115
label2 = gtk_label_new (_("Files "));
116
gtk_frame_set_label_widget (GTK_FRAME (frame1),label2);
118
frame2 = gtk_frame_new (NULL);
119
gtk_box_pack_start (GTK_BOX (vbox2),frame2,TRUE,TRUE,0);
120
gtk_frame_set_shadow_type (GTK_FRAME (frame2),GTK_SHADOW_OUT);
122
alignment2 = gtk_alignment_new (0.5,0.5,1,1);
123
gtk_container_add (GTK_CONTAINER (frame2),alignment2);
124
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2),0,0,12,0);
126
vbox5 = gtk_vbox_new (FALSE,0);
127
gtk_container_add (GTK_CONTAINER (alignment2),vbox5);
159
129
dialog_data->overwrite_check = gtk_check_button_new_with_mnemonic (_("Overwrite existing files"));
160
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->overwrite_check), archive->overwrite);
161
gtk_widget_show (dialog_data->overwrite_check);
162
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->overwrite_check, FALSE, FALSE, 0);
130
gtk_box_pack_start (GTK_BOX (vbox5),dialog_data->overwrite_check,FALSE,FALSE,0);
164
132
dialog_data->extract_full = gtk_check_button_new_with_mnemonic (_("Extract files with full path"));
165
if (cli && (archive->type == XARCHIVETYPE_TAR || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_DEB || archive->type == XARCHIVETYPE_TAR_BZ2) )
167
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->extract_full), TRUE);
168
gtk_widget_set_sensitive (dialog_data->extract_full, FALSE);
171
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->extract_full), archive->full_path);
172
gtk_widget_show (dialog_data->extract_full);
173
gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->extract_full , _("The archive's directory structure is recreated in the extraction directory."), NULL );
174
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->extract_full, FALSE, FALSE, 0);
176
if (archive->type == XARCHIVETYPE_TAR || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR_BZ2 || archive->type == XARCHIVETYPE_DEB)
178
dialog_data->touch = gtk_check_button_new_with_mnemonic (_("Touch files"));
179
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->touch), archive->tar_touch);
180
gtk_widget_show (dialog_data->touch);
181
gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->touch, _("When this option is used, tar leaves the data modification times of the files it extracts as the times when the files were extracted, instead of setting it to the times recorded in the archive."), NULL );
182
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->touch, FALSE, FALSE, 0);
184
dialog_data->hbox6 = gtk_hbox_new (FALSE, 2);
185
gtk_widget_show (dialog_data->hbox6);
186
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->hbox6, FALSE, FALSE, 0);
190
dialog_data->touch = NULL;
133
gtk_tooltips_set_tip(option_tooltip,dialog_data->extract_full,_("The archive's directory structure is recreated in the extraction directory"),NULL );
134
gtk_box_pack_start (GTK_BOX (vbox5),dialog_data->extract_full,FALSE,FALSE,0);
136
dialog_data->touch = gtk_check_button_new_with_mnemonic (_("Touch files"));
137
gtk_tooltips_set_tip (option_tooltip,dialog_data->touch,_("When this option is used,tar leaves the data modification times of the files it extracts as the times when the files were extracted,instead of setting it to the times recorded in the archive"),NULL );
138
gtk_box_pack_start (GTK_BOX (vbox5),dialog_data->touch,FALSE,FALSE,0);
140
dialog_data->fresh = gtk_check_button_new_with_mnemonic (_("Freshen existing files"));
141
gtk_tooltips_set_tip (option_tooltip,dialog_data->fresh,_("Extract only those files that already exist on disk and that are newer than the disk copies"),NULL );
142
gtk_box_pack_start (GTK_BOX (vbox5),dialog_data->fresh,FALSE,FALSE,0);
143
g_signal_connect (G_OBJECT (dialog_data->fresh),"toggled",G_CALLBACK (fresh_update_toggled_cb),dialog_data);
145
dialog_data->update = gtk_check_button_new_with_mnemonic (_("Update existing files"));
146
gtk_tooltips_set_tip (option_tooltip,dialog_data->update,_("This option performs the same function as the freshen one,extracting files that are newer than those with the same name on disk,and in addition it extracts those files that do not already exist on disk"),NULL );
147
gtk_box_pack_start (GTK_BOX (vbox5),dialog_data->update,FALSE,FALSE,0);
148
g_signal_connect (G_OBJECT (dialog_data->update),"toggled",G_CALLBACK (update_fresh_toggled_cb),dialog_data);
150
label3 = gtk_label_new (_("Options "));
151
gtk_frame_set_label_widget (GTK_FRAME (frame2),label3);
153
hbox3 = gtk_hbox_new (FALSE,0);
154
gtk_box_pack_start (GTK_BOX (vbox5),hbox3,TRUE,TRUE,0);
156
label_password = gtk_label_new (_("Password:"));
157
gtk_box_pack_start (GTK_BOX (hbox3),label_password,FALSE,FALSE,0);
159
dialog_data->password_entry = gtk_entry_new ();
160
gtk_box_pack_start (GTK_BOX (hbox3),dialog_data->password_entry,TRUE,TRUE,0);
161
gtk_entry_set_visibility (GTK_ENTRY (dialog_data->password_entry),FALSE);
163
dialog_action_area1 = GTK_DIALOG (dialog_data->dialog1)->action_area;
164
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1),GTK_BUTTONBOX_END);
166
cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
167
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->dialog1),cancel_button,GTK_RESPONSE_CANCEL);
168
GTK_WIDGET_SET_FLAGS (cancel_button,GTK_CAN_DEFAULT);
170
extract_button = gtk_button_new();
171
extract_image = xa_main_window_find_image("xarchiver-extract.png",GTK_ICON_SIZE_SMALL_TOOLBAR);
172
extract_hbox = gtk_hbox_new(FALSE,4);
173
extract_label = gtk_label_new_with_mnemonic(_("_Extract"));
175
alignment3 = gtk_alignment_new (0.5,0.5,0,0);
176
gtk_container_add (GTK_CONTAINER (alignment3),extract_hbox);
177
gtk_box_pack_start(GTK_BOX(extract_hbox),extract_image,FALSE,FALSE,0);
178
gtk_box_pack_start(GTK_BOX(extract_hbox),extract_label,FALSE,FALSE,0);
179
gtk_container_add(GTK_CONTAINER(extract_button),alignment3);
181
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->dialog1),extract_button,GTK_RESPONSE_OK);
182
GTK_WIDGET_SET_FLAGS (extract_button,GTK_CAN_DEFAULT);
183
gtk_dialog_set_default_response (GTK_DIALOG (dialog_data->dialog1),GTK_RESPONSE_OK);
187
void xa_activate_entry(GtkToggleButton *button,gpointer data)
189
Extract_dialog_data *dialog = data;
191
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->files_radio)))
193
gtk_widget_set_sensitive (dialog->entry2,TRUE);
194
gtk_widget_grab_focus (dialog->entry2);
197
gtk_widget_set_sensitive (dialog->entry2,FALSE);
200
void fresh_update_toggled_cb (GtkToggleButton *button,Extract_dialog_data *data)
202
gboolean active = gtk_toggle_button_get_active(button);
204
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->update),FALSE);
207
void update_fresh_toggled_cb (GtkToggleButton *button,Extract_dialog_data *data)
209
if (data->fresh == NULL)
211
gboolean active = gtk_toggle_button_get_active (button);
213
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh),FALSE);
216
void xa_set_extract_dialog_options(Extract_dialog_data *dialog_data,gint selected,XArchive *archive)
218
gchar *archive_dir = NULL;
219
gboolean flag = TRUE;
221
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_save_geometry))&& prefs_window->extract_dialog[0] != -1)
222
gtk_window_set_default_size (GTK_WINDOW(dialog_data->dialog1),prefs_window->extract_dialog[0],prefs_window->extract_dialog[1]);
224
gtk_widget_set_size_request (dialog_data->dialog1,-1,370);
226
if (archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_LZOP)
227
gtk_window_set_title (GTK_WINDOW (dialog_data->dialog1),_("Decompress file"));
229
gtk_window_set_title (GTK_WINDOW (dialog_data->dialog1),_("Extract files"));
231
if (archive->type != XARCHIVETYPE_RPM)
235
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->selected_radio),TRUE);
236
gtk_widget_set_sensitive (dialog_data->selected_radio,TRUE);
240
gtk_widget_set_sensitive (dialog_data->selected_radio,FALSE);
241
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog_data->all_files_radio),TRUE);
245
gtk_widget_set_sensitive (dialog_data->selected_radio,FALSE);
247
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 || archive->type == XARCHIVETYPE_LZOP)
249
gtk_widget_set_sensitive (dialog_data->extract_full,flag);
251
if (archive->type != XARCHIVETYPE_TAR && archive->type != XARCHIVETYPE_TAR_GZ && archive->type != XARCHIVETYPE_TAR_LZMA && archive->type != XARCHIVETYPE_TAR_BZ2 && archive->type != XARCHIVETYPE_DEB && archive->type != XARCHIVETYPE_TAR_LZOP)
255
gtk_widget_set_sensitive (dialog_data->touch,flag);
192
257
if (archive->type == XARCHIVETYPE_RAR || archive->type == XARCHIVETYPE_ZIP || archive->type == XARCHIVETYPE_ARJ)
194
dialog_data->fresh = gtk_check_button_new_with_mnemonic (_("Freshen existing files"));
195
gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->fresh , _("Extract only those files that already exist on disk and that are newer than the disk copies."), NULL );
196
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->fresh), archive->freshen);
197
gtk_widget_show (dialog_data->fresh);
198
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->fresh, FALSE, FALSE, 0);
199
g_signal_connect (G_OBJECT (dialog_data->fresh),"toggled",G_CALLBACK (fresh_update_toggled_cb) , dialog_data);
201
dialog_data->update = gtk_check_button_new_with_mnemonic (_("Update existing files"));
202
gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->update , _("This option performs the same function as the freshen one, extracting files that are newer than those with the same name on disk, and in addition it extracts those files that do not already exist on disk."), NULL );
203
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->update), archive->update);
204
gtk_widget_show (dialog_data->update);
205
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->update, FALSE, FALSE, 0);
206
g_signal_connect (G_OBJECT (dialog_data->update),"toggled",G_CALLBACK (update_fresh_toggled_cb) , dialog_data);
262
gtk_widget_set_sensitive(dialog_data->fresh,flag);
263
gtk_widget_set_sensitive(dialog_data->update,flag);
265
if (archive->extraction_path == NULL)
210
dialog_data->fresh = NULL;
211
dialog_data->update = NULL;
267
archive_dir = xa_remove_level_from_path (archive->path);
268
gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry),archive_dir);
213
dialog_data->hbox5 = gtk_hbox_new (FALSE, 2);
214
gtk_widget_show (dialog_data->hbox5);
215
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->hbox5, FALSE, FALSE, 0);
217
dialog_data->label_password = gtk_label_new (_("Password:"));
218
gtk_widget_show (dialog_data->label_password);
219
gtk_box_pack_start (GTK_BOX (dialog_data->hbox5), dialog_data->label_password, FALSE, FALSE, 0);
221
dialog_data->password_entry = gtk_entry_new ();
222
gtk_widget_show (dialog_data->password_entry);
223
gtk_box_pack_start (GTK_BOX (dialog_data->hbox5), dialog_data->password_entry, FALSE, FALSE, 0);
224
gtk_entry_set_visibility (GTK_ENTRY (dialog_data->password_entry), FALSE);
225
if ( archive->has_passwd )
271
if (archive->has_passwd)
227
gtk_widget_set_sensitive (dialog_data->label_password, TRUE);
228
gtk_widget_set_sensitive (dialog_data->password_entry, TRUE);
273
gtk_widget_set_sensitive (label_password,TRUE);
274
gtk_widget_set_sensitive (dialog_data->password_entry,TRUE);
229
275
if (archive->passwd != NULL)
230
gtk_entry_set_text (GTK_ENTRY(dialog_data->password_entry) , archive->passwd);
276
gtk_entry_set_text (GTK_ENTRY(dialog_data->password_entry),archive->passwd);
234
gtk_widget_set_sensitive (dialog_data->label_password, FALSE);
235
gtk_widget_set_sensitive (dialog_data->password_entry, FALSE);
280
gtk_widget_set_sensitive (label_password,FALSE);
281
gtk_widget_set_sensitive (dialog_data->password_entry,FALSE);
238
dialog_data->options_frame_label = gtk_label_new (_("<b>Options </b>"));
239
gtk_widget_show (dialog_data->options_frame_label);
240
gtk_frame_set_label_widget (GTK_FRAME (dialog_data->frame2), dialog_data->options_frame_label);
241
gtk_label_set_use_markup (GTK_LABEL (dialog_data->options_frame_label), TRUE);
243
dialog_data->dialog_action_area1 = GTK_DIALOG (dialog_data->dialog1)->action_area;
244
gtk_widget_show (dialog_data->dialog_action_area1);
245
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_data->dialog_action_area1), GTK_BUTTONBOX_END);
247
dialog_data->cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
248
gtk_widget_show (dialog_data->cancel_button);
249
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->dialog1), dialog_data->cancel_button, GTK_RESPONSE_CANCEL);
250
GTK_WIDGET_SET_FLAGS (dialog_data->cancel_button, GTK_CAN_DEFAULT);
252
dialog_data->extract_button = gtk_button_new();
253
dialog_data->extract_image = xa_main_window_find_image("xarchiver-extract_button.png", GTK_ICON_SIZE_SMALL_TOOLBAR);
254
dialog_data->extract_hbox = gtk_hbox_new(FALSE, 4);
255
dialog_data->extract_label = gtk_label_new_with_mnemonic(_("_Extract"));
257
dialog_data->alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
258
gtk_widget_show (dialog_data->alignment3);
259
gtk_container_add (GTK_CONTAINER (dialog_data->alignment3), dialog_data->extract_hbox);
261
gtk_box_pack_start(GTK_BOX(dialog_data->extract_hbox), dialog_data->extract_image, FALSE, FALSE, 0);
262
gtk_box_pack_start(GTK_BOX(dialog_data->extract_hbox), dialog_data->extract_label, FALSE, FALSE, 0);
263
gtk_widget_show_all(dialog_data->extract_hbox);
264
gtk_container_add(GTK_CONTAINER(dialog_data->extract_button), dialog_data->alignment3);
265
gtk_widget_show (dialog_data->extract_button);
266
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->dialog1), dialog_data->extract_button, GTK_RESPONSE_OK);
267
GTK_WIDGET_SET_FLAGS (dialog_data->extract_button, GTK_CAN_DEFAULT);
268
gtk_dialog_set_default_response (GTK_DIALOG (dialog_data->dialog1), GTK_RESPONSE_OK);
272
void fresh_update_toggled_cb (GtkToggleButton *button, Extract_dialog_data *data)
274
gboolean active = gtk_toggle_button_get_active (button);
276
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->update), FALSE);
279
void update_fresh_toggled_cb (GtkToggleButton *button, Extract_dialog_data *data)
281
if (data->fresh == NULL)
283
gboolean active = gtk_toggle_button_get_active (button);
285
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh), FALSE);
288
gchar *xa_parse_extract_dialog_options ( XArchive *archive , Extract_dialog_data *dialog_data, GtkTreeSelection *selection)
290
gchar *command = NULL;
292
gchar *destination_path = NULL;
283
gtk_widget_show_all(dialog_data->dialog1);
286
void xa_parse_extract_dialog_options (XArchive *archive,Extract_dialog_data *dialog_data,GtkTreeSelection *selection)
288
gchar *destination_path = NULL,*string;
293
289
gboolean done = FALSE;
294
gboolean end = FALSE;
290
GSList *names = NULL;
305
switch (gtk_dialog_run ( GTK_DIALOG (dialog_data->dialog1 ) ) )
301
switch (gtk_dialog_run(GTK_DIALOG(dialog_data->dialog1)))
307
303
case GTK_RESPONSE_CANCEL:
308
304
case GTK_RESPONSE_DELETE_EVENT:
310
if (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_BZIP2)
306
if (xa_main_window && (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_LZOP))
312
308
gtk_widget_set_sensitive (Stop_button,FALSE);
313
Update_StatusBar (_("Operation canceled.") );
314
gtk_widget_hide (viewport2);
315
xa_set_button_state (1,1,0,0,0,0);
309
xa_set_button_state (1,1,GTK_WIDGET_IS_SENSITIVE(save1),GTK_WIDGET_IS_SENSITIVE(close1),0,0,0,0,0,0,0);
316
310
archive->status = XA_ARCHIVESTATUS_IDLE;
320
314
case GTK_RESPONSE_OK:
321
destination_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (dialog_data->destination_path_entry) ));
322
if (archive->type != XARCHIVETYPE_ISO)
323
archive->extraction_path = EscapeBadChars ( destination_path , "$\'`\"\\!?* ()&|@#:;" );
325
archive->extraction_path = g_strdup ( destination_path );
315
destination_path = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog_data->destination_path_entry)));
316
archive->extraction_path = xa_escape_bad_chars (destination_path,"$\'`\"\\!?* ()&|@#:;");
327
if ( strlen ( archive->extraction_path ) == 0 )
318
if (strlen(archive->extraction_path)== 0)
329
response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("You missed where to extract the files!"),_("Please enter the extraction path.") );
320
response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("You missed where to extract the files!"),_("Please enter the extraction path."));
323
if (archive->extraction_path[0] != '/')
325
gchar *cur_dir = g_get_current_dir();
326
archive->extraction_path = g_strconcat(cur_dir,"/",archive->extraction_path,NULL);
332
329
if (archive->has_passwd)
333
archive->passwd = g_strdup (gtk_entry_get_text ( GTK_ENTRY (dialog_data->password_entry) ));
330
archive->passwd = g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog_data->password_entry)));
335
if (archive->has_passwd && strlen( archive->passwd ) == 0 )
332
if (archive->has_passwd && strlen(archive->passwd)== 0 )
337
response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("This archive is encrypted!"),_("Please enter the password.") );
334
response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("This archive is encrypted!"),_("Please enter the password."));
340
if (g_file_test (destination_path , G_FILE_TEST_EXISTS) == FALSE)
342
int result = mkdir (destination_path , S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXGRP);
345
gchar *msg = g_strdup_printf(_("Can't create directory \"%s\""), destination_path);
346
response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, msg, g_strerror(errno ) );
351
if ( g_file_test (destination_path , G_FILE_TEST_IS_DIR) && access (destination_path, R_OK | W_OK | X_OK ) )
338
if (g_file_test (destination_path,G_FILE_TEST_IS_DIR)&& access (destination_path,R_OK | W_OK | X_OK ))
353
340
gchar *utf8_path;
356
utf8_path = g_filename_to_utf8 (destination_path, -1, NULL, NULL, NULL);
357
msg = g_strdup_printf (_("You don't have the right permissions to extract the files to the folder \"%s\"."), utf8_path);
358
response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("Can't perform extraction!"),msg );
343
utf8_path = g_filename_to_utf8 (destination_path,-1,NULL,NULL,NULL);
344
msg = g_strdup_printf (_("You don't have the right permissions to extract the files to the directory \"%s\"."),utf8_path);
345
response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't perform extraction!"),msg );
359
346
g_free (utf8_path);
361
348
g_free (destination_path);
365
archive->overwrite = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->overwrite_check ));
366
if ( dialog_data->touch != NULL)
367
archive->tar_touch = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->touch ));
369
if (dialog_data->extract_full != NULL)
370
archive->full_path = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->extract_full ));
372
if (dialog_data->fresh != NULL)
373
archive->freshen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->fresh ));
375
if (dialog_data->update != NULL)
376
archive->update = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->update ));
378
gtk_widget_set_sensitive (Stop_button,TRUE);
352
g_free (destination_path);
354
archive->overwrite = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->overwrite_check));
355
archive->tar_touch = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->touch));
357
archive->full_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->extract_full));
359
archive->full_path = TRUE;
360
archive->freshen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->fresh));
361
archive->update = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->update));
379
363
gtk_widget_hide (dialog_data->dialog1);
380
364
archive->status = XA_ARCHIVESTATUS_EXTRACT;
381
/* Are all files selected? */
382
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->all_files_radio )) )
365
/* Is the radiobutton Files selected? */
366
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dialog_data->files_radio)))
386
gchar *text = g_strdup_printf(_("Extracting files to %s"), destination_path);
387
Update_StatusBar ( text );
390
g_free (destination_path);
391
tar = g_find_program_in_path ("gtar");
393
tar = g_strdup ("tar");
394
switch ( archive->type )
396
case XARCHIVETYPE_BZIP2:
397
gzip_bzip2_extract (archive , 0);
400
case XARCHIVETYPE_GZIP:
401
gzip_bzip2_extract (archive , 1);
404
case XARCHIVETYPE_RAR:
405
if (archive->passwd != NULL)
406
command = g_strconcat ( rar, " " , archive->full_path ? "x " : "e ",
407
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
408
" -p",archive->passwd,
409
archive->overwrite ? " -o+" : " -o-",
411
archive->escaped_path , " " , archive->extraction_path , NULL );
413
command = g_strconcat ( rar, " ", archive->full_path ? "x " : "e ",
414
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
415
archive->overwrite ? "-o+" : "-o-",
417
archive->escaped_path , " " , archive->extraction_path , NULL );
420
case XARCHIVETYPE_TAR:
421
if (archive->full_path == 1)
423
command = g_strconcat (tar, " -xvf ", archive->escaped_path,
424
archive->overwrite ? " --overwrite" : " --keep-old-files",
425
archive->tar_touch ? " --touch" : "",
426
" -C " , archive->extraction_path , NULL );
430
xa_extract_tar_without_directories ( "tar -xvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
435
case XARCHIVETYPE_TAR_BZ2:
436
if (archive->full_path == 1)
438
command = g_strconcat (tar, " -xvjf " , archive->escaped_path,
439
archive->overwrite ? " --overwrite" : " --keep-old-files",
440
archive->tar_touch ? " --touch" : "",
441
" -C " , archive->extraction_path , NULL );
445
xa_extract_tar_without_directories ( "tar -xvjf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path , FALSE );
450
case XARCHIVETYPE_TAR_GZ:
451
if (archive->full_path == 1)
453
command = g_strconcat (tar, " -xvzf " , archive->escaped_path,
454
archive->overwrite ? " --overwrite" : " --keep-old-files",
455
archive->tar_touch ? " --touch" : "",
456
" -C " , archive->extraction_path , NULL );
460
xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
465
case XARCHIVETYPE_DEB:
466
if (archive->full_path == 1)
468
command = g_strconcat (tar, " -xvzf " , archive->tmp,
469
archive->overwrite ? " --overwrite" : " --keep-old-files",
470
archive->tar_touch ? " --touch" : "",
471
" -C " , archive->extraction_path , NULL );
475
xa_extract_tar_without_directories ( "tar -xvzf " , archive->tmp, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
480
case XARCHIVETYPE_ZIP:
481
if ( archive->passwd != NULL )
482
command = g_strconcat ( "unzip ", archive->freshen ? "-f " : "",
483
archive->update ? "-u " : "" ,
484
archive->overwrite ? "-o" : "-n",
485
" -P " , archive->passwd,
486
archive->full_path ? "" : " -j ",
487
archive->escaped_path , " -d ", archive->extraction_path , NULL );
489
command = g_strconcat ( "unzip ", archive->freshen ? "-f " : "",
490
archive->update ? "-u " : "",
491
archive->overwrite ? "-o " : "-n ",
492
archive->full_path ? "" : " -j ",
493
archive->escaped_path , " -d ", archive->extraction_path , NULL );
496
case XARCHIVETYPE_RPM:
497
if (archive->full_path == 1)
499
chdir ( archive->extraction_path );
500
command = g_strconcat ( "cpio --make-directories -F " , archive->tmp , " -i" , NULL );
504
xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path , TRUE);
509
case XARCHIVETYPE_7ZIP:
510
if (archive->passwd != NULL)
511
command = g_strconcat ( "7za " , archive->full_path ? "x " : "e ",
512
archive->overwrite ? "-aoa" : "-aos",
513
" -bd -p",archive->passwd," ",
514
archive->escaped_path , " -o" , archive->extraction_path , NULL );
516
command = g_strconcat ( "7za " , archive->full_path ? "x " : "e ",
517
archive->overwrite ? "-aoa" : "-aos",
519
archive->escaped_path , " -o" , archive->extraction_path , NULL );
522
case XARCHIVETYPE_ARJ:
523
if (archive->passwd != NULL)
524
command = g_strconcat ( "arj " , archive->full_path ? "x " : "e ",
525
"-g",archive->passwd,
526
archive->overwrite ? "" : " -n" , " -i ",
527
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
528
"-y " , archive->escaped_path , " " , archive->extraction_path , NULL );
530
command = g_strconcat ( "arj " , archive->full_path ? "x " : "e ",
531
archive->overwrite ? "" : " -n" , " -i ",
532
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
533
"-y " , archive->escaped_path , " " , archive->extraction_path , NULL );
536
case XARCHIVETYPE_LHA:
537
command = g_strconcat ("lha ", archive->full_path ? "x" : "xi",
538
archive->overwrite ? "f" : "", "w=",
539
archive->extraction_path, " ", archive->escaped_path , NULL);
542
case XARCHIVETYPE_ISO:
543
end = gtk_tree_model_get_iter_first (archive->model , &iter);
544
gtk_widget_show ( viewport2 );
545
g_timeout_add (200, xa_progressbar_pulse, NULL );
548
xa_set_button_state (0,0,0,0,0,0);
551
gtk_tree_model_get (archive->model, &iter,
557
if (xa_extract_iso_file (archive, permissions, archive->extraction_path, name , file_size, file_offset ) == FALSE )
560
g_free (permissions);
563
end = gtk_tree_model_iter_next (archive->model,&iter);
565
g_free (permissions);
567
xa_set_button_state (1,1,0,1,0,1);
568
xa_hide_progress_bar_stop_button(archive);
569
Update_StatusBar ( _("Operation completed.") );
577
if ( command != NULL )
368
model = gtk_tree_view_get_model(GTK_TREE_VIEW(archive->treeview));
369
string = g_strdup (gtk_entry_get_text(GTK_ENTRY(dialog_data->entry2)));
370
gtk_tree_model_foreach(model,(GtkTreeModelForeachFunc)select_matched_rows,string);
371
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(archive->treeview));
372
gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_selected_filenames,&names);
375
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dialog_data->selected_radio)))
376
gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc)xa_concat_selected_filenames,&names);
582
names = g_string_new ( " " );
583
gtk_tree_selection_selected_foreach (selection, (GtkTreeSelectionForeachFunc) ConcatenateFileNames, names );
584
command = xa_extract_single_files ( archive , names, archive->extraction_path );
585
g_string_free (names, TRUE);
380
xa_set_button_state (0,0,0,0,0,0,0,0,0,0,0);
381
gtk_widget_set_sensitive (Stop_button,TRUE);
382
gtk_label_set_text(GTK_LABEL(total_label),_("Extracting files from archive,please wait..."));
384
(*archive->extract)(archive,names);
592
gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar *path)
594
gchar *command = NULL;
603
gchar *msg = g_strdup_printf ( _("Extracting archive to %s") , path);
604
Update_StatusBar (msg);
606
tar = g_find_program_in_path ("gtar");
608
tar = g_strdup ("tar");
609
switch (archive->type)
611
case XARCHIVETYPE_BZIP2:
612
gzip_bzip2_extract (archive , 0);
615
case XARCHIVETYPE_GZIP:
616
gzip_bzip2_extract (archive , 1);
619
case XARCHIVETYPE_RAR:
620
if (archive->passwd != NULL)
621
command = g_strconcat ( rar," ", archive->full_path ? "x " : "e " ,
622
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
623
" -p",archive->passwd,
624
archive->overwrite ? " -o+" : " -o-",
626
archive->escaped_path , " " , files->str , " " , path , NULL );
628
command = g_strconcat ( rar," ", archive->full_path ? "x " : "e " ,
629
archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
630
archive->overwrite ? "-o+" : "-o-",
632
archive->escaped_path , " " , files->str , " ", path ,NULL);
635
case XARCHIVETYPE_TAR:
636
if (archive->full_path == 1)
638
command = g_strconcat (tar, " -xvf " , archive->escaped_path,
639
archive->overwrite ? " --overwrite" : " --keep-old-files",
640
archive->tar_touch ? " --touch" : "",
641
" -C " , path , files->str , NULL );
645
xa_extract_tar_without_directories ( "tar -xvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
650
case XARCHIVETYPE_TAR_BZ2:
651
if (archive->full_path == 1)
653
command = g_strconcat (tar, " -xjvf " , archive->escaped_path,
654
archive->overwrite ? " --overwrite" : " --keep-old-files",
655
archive->tar_touch ? " --touch" : "",
656
" -C " , path , files->str , NULL );
660
xa_extract_tar_without_directories ( "tar -xjvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
665
case XARCHIVETYPE_TAR_GZ:
666
if (archive->full_path == 1)
668
command = g_strconcat (tar, " -xzvf " , archive->escaped_path,
669
archive->overwrite ? " --overwrite" : " --keep-old-files",
670
archive->tar_touch ? " --touch" : "",
671
" -C " , path , files->str , NULL );
675
xa_extract_tar_without_directories ( "tar -xzvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
680
case XARCHIVETYPE_DEB:
681
if (archive->full_path == 1)
683
command = g_strconcat (tar, " -xvzf " , archive->tmp,
684
archive->overwrite ? " --overwrite" : " --keep-old-files",
685
archive->tar_touch ? " --touch" : "",
686
" -C " , archive->extraction_path , files->str, NULL );
690
xa_extract_tar_without_directories ( "tar -xvzf " , archive->tmp, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
695
case XARCHIVETYPE_ZIP:
696
if ( archive->passwd != NULL )
697
command = g_strconcat ( "unzip ", archive->freshen ? "-f " : "",
698
archive->update ? "-u " : "",
699
archive->overwrite ? "-o" : "-n",
700
" -P " , archive->passwd,
701
archive->full_path ? " " : " -j ",
702
archive->escaped_path , files->str," -d " , path , NULL );
704
command = g_strconcat ( "unzip ", archive->freshen ? "-f " : "",
705
archive->update ? "-u " : "",
706
archive->overwrite ? "-o " : "-n ",
707
archive->full_path ? "" : " -j ",
708
archive->escaped_path , files->str," -d " , path , NULL );
711
case XARCHIVETYPE_RPM:
712
if (archive->full_path == 1)
715
command = g_strconcat ( "cpio --make-directories " , files->str , " -F " , archive->tmp , " -i" , NULL);
719
xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path , TRUE);
724
case XARCHIVETYPE_7ZIP:
725
if ( archive->passwd != NULL)
726
command = g_strconcat ("7za " , archive->full_path ? "x" : "e",
727
" -p",archive->passwd,
728
archive->overwrite ? " -aoa" : " -aos",
730
archive->escaped_path , files->str , " -o" , path , NULL );
732
command = g_strconcat ( "7za " , archive->full_path ? "x" : "e",
733
archive->overwrite ? " -aoa" : " -aos",
735
archive->escaped_path , files->str , " -o" , path , NULL );
738
case XARCHIVETYPE_ARJ:
739
if (archive->passwd != NULL)
740
command = g_strconcat ( "arj ",archive->full_path ? "x" : "e",
741
" -g",archive->passwd,
742
archive->overwrite ? "" : " -n" ,
744
archive->freshen ? "-f " : "" ,
745
archive->update ? "-u " : " ",
747
archive->escaped_path , " " , path , files->str , NULL );
749
command = g_strconcat ( "arj ",archive->full_path ? "x" : "e",
750
archive->overwrite ? "" : " -n" ,
751
" -i " , archive->freshen ? "-f " : "",
752
archive->update ? "-u " : " ",
754
archive->escaped_path , " " , path , files->str, NULL );
757
case XARCHIVETYPE_LHA:
758
command = g_strconcat ("lha ", archive->full_path ? "x" : "xi",
759
archive->overwrite ? "f" : "", "w=",
760
path, " ", archive->escaped_path , files->str, NULL);
763
case XARCHIVETYPE_ISO:
765
GList *row_list = NULL;
766
GtkTreeSelection *selection;
768
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (archive->treeview) );
769
row_list = gtk_tree_selection_get_selected_rows (selection, &archive->model);
772
xa_set_button_state (0,0,0,0,0,0);
775
gtk_tree_model_get_iter(archive->model, &iter, row_list->data);
776
gtk_tree_model_get (archive->model, &iter,
782
gtk_tree_path_free (row_list->data);
784
xa_extract_single_iso_file (archive, permissions, archive->extraction_path, name , file_size, file_offset );
786
g_free (permissions);
787
row_list = row_list->next;
789
g_list_free (row_list);
790
xa_set_button_state (1,1,0,1,0,1);
791
xa_hide_progress_bar_stop_button(archive);
792
Update_StatusBar ( _("Operation completed.") );
804
gboolean xa_extract_tar_without_directories ( gchar *string, gchar *escaped_path, gboolean overwrite, gboolean tar_touch, gchar *extract_path, gboolean cpio_flag )
806
gchar *command = NULL;
808
gchar *permission = NULL;
809
gchar tmp_dir[14] = "";
387
gtk_widget_hide (dialog_data->dialog1);
390
Multi_extract_data *xa_create_multi_extract_dialog()
392
Multi_extract_data *dialog_data;
393
GtkWidget *dialog_vbox1,*vbox1,*scrolledwindow1,*hbox1,*frame1,*alignment1,*vbox2,*hbox3,*remove_button,*add_button,*cancelbutton1;
394
GtkCellRenderer *renderer;
810
395
GtkTreeSelection *selection;
811
GString *names, *unescaped_names;
812
gboolean end = FALSE;
815
GSList *filenames = NULL;
819
current_page = gtk_notebook_get_current_page(notebook);
820
names = g_string_new ("");
821
unescaped_names = g_string_new ("");
823
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (archive[current_page]->treeview) );
824
row_list = gtk_tree_selection_get_selected_rows (selection, &archive[current_page]->model);
826
if (row_list != NULL)
830
gtk_tree_model_get_iter(archive[current_page]->model, &iter, row_list->data);
831
gtk_tree_model_get (archive[current_page]->model, &iter,
835
gtk_tree_path_free (row_list->data);
837
if (strstr (permission ,"d") == NULL)
839
ConcatenateFileNames2 ( name , names );
840
filenames = g_slist_append ( filenames,name );
843
row_list = row_list->next;
845
g_list_free (row_list);
849
end = gtk_tree_model_get_iter_first (archive[current_page]->model , &iter);
852
gtk_tree_model_get (archive[current_page]->model, &iter, 0, &name,
854
if (strstr (permission ,"d") == NULL)
856
ConcatenateFileNames2 ( name , names );
857
filenames = g_slist_append ( filenames,name );
860
end = gtk_tree_model_iter_next (archive[current_page]->model,&iter);
863
result = xa_create_temp_directory (tmp_dir);
870
command = g_strconcat ( "cpio --make-directories -F " , archive[current_page]->tmp , " -i" , NULL );
873
command = g_strconcat ( string, escaped_path,
874
overwrite ? " --overwrite" : " --keep-old-files",
875
tar_touch ? " --touch" : "",
876
" -C " , tmp_dir , names->str, NULL );
877
result = xa_run_command (command , 0);
878
g_string_free (names, TRUE);
881
if (result == 0 || stop_flag)
883
xa_delete_temp_directory ( tmp_dir, 0 );
884
gtk_widget_hide (viewport2);
885
Update_StatusBar (_("Operation canceled."));
891
gchar *unescaped = EscapeBadChars ( filenames->data , "$\'`\"\\!?* ()[]&|@#:;");
892
g_string_prepend ( unescaped_names, unescaped );
893
g_string_prepend_c (unescaped_names, ' ');
895
filenames = filenames->next;
897
command = g_strconcat ( "mv -f ", unescaped_names->str, " " , extract_path , NULL );
898
result = xa_run_command (command , 0);
900
g_slist_free (filenames);
901
g_string_free ( unescaped_names, TRUE );
903
if (result == 0 || stop_flag)
905
xa_delete_temp_directory ( tmp_dir, 0 );
906
gtk_widget_hide (viewport2);
907
Update_StatusBar (_("Operation canceled."));
911
xa_delete_temp_directory ( tmp_dir, 0 );
913
xa_delete_temp_directory ( tmp_dir, 1 );
918
gboolean xa_delete_temp_directory ( gchar *dir_name, gboolean flag)
923
command = g_strconcat ( "rm -rf ", dir_name , NULL );
924
result = xa_run_command (command , flag );
929
gboolean xa_create_temp_directory ( gchar tmp_dir[] )
931
strcpy (tmp_dir,"/tmp/xa-XXXXXX");
932
if ( mkdtemp ( tmp_dir ) == 0)
934
response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't create temporary directory in /tmp:"),g_strerror(errno) );
935
gtk_widget_set_sensitive (Stop_button, FALSE);
936
Update_StatusBar (_("Operation failed."));
942
void xa_choose_extraction_directory (GtkWidget *widget, gpointer data)
944
Extract_dialog_data *dialog_data = data;
945
GtkWidget *File_Selector;
396
GtkTreeViewColumn *column;
397
GSList *radiobutton1_group = NULL;
398
GtkTooltips *multi_tooltip;
399
char *column_names[]= {(_("Archive Name")),(_("Size")),(_("Path")),NULL};
402
multi_tooltip = gtk_tooltips_new ();
403
dialog_data = g_new0 (Multi_extract_data,1);
404
dialog_data->multi_extract = gtk_dialog_new();
406
gtk_window_set_position (GTK_WINDOW (dialog_data->multi_extract),GTK_WIN_POS_CENTER_ON_PARENT);
407
gtk_window_set_type_hint (GTK_WINDOW (dialog_data->multi_extract),GDK_WINDOW_TYPE_HINT_DIALOG);
408
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_data->multi_extract),TRUE);
409
gtk_widget_set_size_request(dialog_data->multi_extract,-1,300);
410
gtk_dialog_set_has_separator (GTK_DIALOG (dialog_data->multi_extract),FALSE);
411
gtk_window_set_title (GTK_WINDOW (dialog_data->multi_extract),_("Multi-Extract"));
413
dialog_vbox1 = GTK_DIALOG (dialog_data->multi_extract)->vbox;
414
vbox1 = gtk_vbox_new (FALSE,5);
415
gtk_box_pack_start (GTK_BOX (dialog_vbox1),vbox1,TRUE,TRUE,0);
416
scrolledwindow1 = gtk_scrolled_window_new (NULL,NULL);
417
gtk_box_pack_start (GTK_BOX (vbox1),scrolledwindow1,TRUE,TRUE,0);
418
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
419
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1),GTK_SHADOW_IN);
421
dialog_data->files_liststore = gtk_list_store_new (4,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_INT);
422
dialog_data->files_treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog_data->files_liststore));
423
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog_data->files_treeview));
424
g_signal_connect (selection,"changed",G_CALLBACK (xa_multi_extract_dialog_selection_changed),dialog_data);
426
for (x = 0; x < 3; x++)
428
renderer = gtk_cell_renderer_text_new();
429
column = gtk_tree_view_column_new_with_attributes ( column_names[x],renderer,"text",x,NULL);
430
gtk_tree_view_column_set_resizable (column,TRUE);
431
gtk_tree_view_append_column(GTK_TREE_VIEW(dialog_data->files_treeview),column);
433
column = gtk_tree_view_column_new();
434
gtk_tree_view_column_set_visible(column,FALSE);
435
gtk_tree_view_append_column(GTK_TREE_VIEW(dialog_data->files_treeview),column);
437
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog_data->files_treeview),TRUE);
438
gtk_container_add (GTK_CONTAINER (scrolledwindow1),dialog_data->files_treeview);
440
gtk_drag_dest_set (dialog_data->files_treeview,GTK_DEST_DEFAULT_ALL,drop_targets,1,GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
441
g_signal_connect (G_OBJECT (dialog_data->files_treeview),"drag-data-received",G_CALLBACK (xa_multi_extract_dialog_drag_data_received),dialog_data);
443
hbox2 = gtk_hbox_new (TRUE,5);
444
gtk_box_pack_start (GTK_BOX (vbox1),hbox2,FALSE,TRUE,0);
446
add_button = gtk_button_new_from_stock ("gtk-add");
447
gtk_box_pack_end (GTK_BOX (hbox2),add_button,FALSE,FALSE,0);
448
gtk_button_set_focus_on_click (GTK_BUTTON (add_button),FALSE);
449
g_signal_connect ( (gpointer)add_button,"clicked",G_CALLBACK (xa_multi_extract_dialog_select_files_to_add),dialog_data);
451
remove_button = gtk_button_new_from_stock ("gtk-remove");
452
gtk_widget_set_sensitive (remove_button,FALSE);
453
gtk_box_pack_end (GTK_BOX (hbox2),remove_button,FALSE,FALSE,0);
454
gtk_button_set_focus_on_click (GTK_BUTTON (remove_button),FALSE);
455
g_signal_connect ( (gpointer)remove_button,"clicked",G_CALLBACK (xa_remove_files_liststore),dialog_data);
456
g_signal_connect (G_OBJECT (dialog_data->files_liststore),"row-inserted",G_CALLBACK (xa_activate_remove_button),remove_button);
458
/* Destination dirs frame */
459
hbox1 = gtk_hbox_new (TRUE,8);
460
gtk_box_pack_start (GTK_BOX (vbox1),hbox1,FALSE,TRUE,0);
461
frame1 = gtk_frame_new (NULL);
462
gtk_box_pack_start (GTK_BOX (hbox1),frame1,TRUE,TRUE,0);
463
gtk_frame_set_shadow_type (GTK_FRAME (frame1),GTK_SHADOW_OUT);
464
alignment1 = gtk_alignment_new (0.5,0.5,1,1);
465
gtk_container_add (GTK_CONTAINER (frame1),alignment1);
466
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1),0,0,12,0);
468
vbox2 = gtk_vbox_new (TRUE,0);
469
gtk_container_add (GTK_CONTAINER (alignment1),vbox2);
470
hbox3 = gtk_hbox_new (FALSE,2);
471
gtk_box_pack_start (GTK_BOX (vbox2),hbox3,FALSE,FALSE,0);
472
dialog_data->extract_to = gtk_radio_button_new_with_mnemonic (NULL,_("Extract to:"));
473
gtk_box_pack_start (GTK_BOX (hbox3),dialog_data->extract_to,FALSE,FALSE,0);
474
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->extract_to),radiobutton1_group);
475
radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->extract_to));
477
dialog_data->entry1 = sexy_icon_entry_new();
478
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(dialog_data->entry1),dialog_data,xa_select_where_to_extract);
479
sexy_icon_entry_set_icon_highlight( SEXY_ICON_ENTRY(dialog_data->entry1),SEXY_ICON_ENTRY_PRIMARY,TRUE );
480
gtk_box_pack_start (GTK_BOX (hbox3),dialog_data->entry1,TRUE,TRUE,0);
482
dialog_data->extract_to_archive_name = gtk_radio_button_new_with_mnemonic (NULL,_("Extract to dir \"Archive Name\""));
483
gtk_tooltips_set_tip (multi_tooltip,dialog_data->extract_to_archive_name,_("This option extracts archives in directories named with the archive names"),NULL);
484
gtk_box_pack_start (GTK_BOX (vbox2),dialog_data->extract_to_archive_name,FALSE,FALSE,0);
485
gtk_radio_button_set_group (GTK_RADIO_BUTTON (dialog_data->extract_to_archive_name),radiobutton1_group);
486
radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog_data->extract_to_archive_name));
487
label1 = gtk_label_new (_("Destination dirs:"));
488
gtk_frame_set_label_widget (GTK_FRAME (frame1),label1);
491
frame2 = gtk_frame_new (NULL);
492
gtk_box_pack_start (GTK_BOX (hbox1),frame2,TRUE,TRUE,0);
493
gtk_frame_set_shadow_type (GTK_FRAME (frame2),GTK_SHADOW_OUT);
494
alignment2 = gtk_alignment_new (0.5,0.5,1,1);
495
gtk_container_add (GTK_CONTAINER (frame2),alignment2);
496
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2),0,0,12,0);
497
vbox3 = gtk_vbox_new (TRUE,0);
498
gtk_container_add (GTK_CONTAINER (alignment2),vbox3);
499
dialog_data->overwrite = gtk_check_button_new_with_mnemonic (_("Overwrite existing files"));
500
gtk_box_pack_start (GTK_BOX (vbox3),dialog_data->overwrite,FALSE,FALSE,0);
501
dialog_data->full_path = gtk_check_button_new_with_mnemonic (_("Extract pathnames"));
502
gtk_box_pack_start (GTK_BOX (vbox3),dialog_data->full_path,FALSE,FALSE,0);
503
label2 = gtk_label_new (_("Options:"));
504
gtk_frame_set_label_widget(GTK_FRAME(frame2),label2);
506
dialog_action_area1 = GTK_DIALOG (dialog_data->multi_extract)->action_area;
507
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1),GTK_BUTTONBOX_END);
508
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
509
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->multi_extract),cancelbutton1,GTK_RESPONSE_CANCEL);
510
GTK_WIDGET_SET_FLAGS (cancelbutton1,GTK_CAN_DEFAULT);
512
extract_button = gtk_button_new();
513
extract_image = xa_main_window_find_image("xarchiver-extract.png",GTK_ICON_SIZE_SMALL_TOOLBAR);
514
extract_hbox = gtk_hbox_new(FALSE,4);
515
extract_label = gtk_label_new_with_mnemonic(_("_Extract"));
517
alignment3 = gtk_alignment_new (0.5,0.5,0,0);
518
gtk_container_add (GTK_CONTAINER (alignment3),extract_hbox);
519
gtk_box_pack_start(GTK_BOX(extract_hbox),extract_image,FALSE,FALSE,0);
520
gtk_box_pack_start(GTK_BOX(extract_hbox),extract_label,FALSE,FALSE,0);
521
gtk_container_add(GTK_CONTAINER(extract_button),alignment3);
523
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_data->multi_extract),extract_button,GTK_RESPONSE_OK);
524
GTK_WIDGET_SET_FLAGS (extract_button,GTK_CAN_DEFAULT);
525
gtk_dialog_set_default_response (GTK_DIALOG (dialog_data->multi_extract),GTK_RESPONSE_OK);
529
void xa_multi_extract_dialog_select_files_to_add (GtkButton* button,Multi_extract_data *dialog)
531
GtkWidget *file_selector;
532
GSList *dummy = NULL;
535
file_selector = gtk_file_chooser_dialog_new (_("Please select the archives you want to extract"),
536
GTK_WINDOW (xa_main_window),
537
GTK_FILE_CHOOSER_ACTION_OPEN,
543
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(file_selector),TRUE);
544
response = gtk_dialog_run (GTK_DIALOG(file_selector));
545
if (response == GTK_RESPONSE_ACCEPT)
547
dummy = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (file_selector));
548
g_slist_foreach( dummy,(GFunc)xa_add_files_liststore,dialog);
551
g_slist_free (dummy);
552
gtk_widget_destroy(file_selector);
556
void xa_multi_extract_dialog_selection_changed(GtkTreeSelection *selection,Multi_extract_data *dialog_data)
562
if (gtk_tree_selection_get_selected (selection,&model,&iter))
564
gtk_tree_model_get(model,&iter,3,&type,-1);
565
if (type == 4 || type == 5 || type == 6 || type == 9)
566
gtk_widget_set_sensitive(dialog_data->full_path,FALSE);
568
gtk_widget_set_sensitive(dialog_data->full_path,TRUE);
572
void xa_add_files_liststore (gchar *file_path,Multi_extract_data *dialog)
575
gchar *file_utf8,*_file_utf8;
949
File_Selector = gtk_file_chooser_dialog_new ( _("Choose the destination folder where to extract the current archive"),
950
GTK_WINDOW (MainWindow),
951
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
957
response = gtk_dialog_run (GTK_DIALOG (File_Selector));
579
unsigned long long int file_size;
581
type = xa_detect_archive_type(file_path);
585
stat (file_path,&my_stat);
586
file_size = my_stat.st_size;
587
file_utf8 = g_filename_display_name (file_path);
588
path = xa_remove_level_from_path(file_utf8);
589
_file_utf8 = xa_remove_path_from_archive_name(file_utf8);
591
file_utf8 = _file_utf8;
592
gtk_list_store_append(dialog->files_liststore,&iter);
593
gtk_list_store_set (dialog->files_liststore,&iter,0,file_utf8,1,file_size,2,path,3,type,-1);
599
void xa_remove_files_liststore (GtkWidget *widget,Multi_extract_data *multi_extract_data)
602
GtkTreeSelection *sel;
605
GList *rr_list = NULL;
608
model = gtk_tree_view_get_model(GTK_TREE_VIEW(multi_extract_data->files_treeview));
609
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(multi_extract_data->files_treeview));
610
gtk_tree_selection_selected_foreach(sel,(GtkTreeSelectionForeachFunc)remove_foreach_func,&rr_list);
612
for (node = rr_list; node != NULL; node = node->next)
614
path = gtk_tree_row_reference_get_path((GtkTreeRowReference *)node->data);
617
if ( gtk_tree_model_get_iter(GTK_TREE_MODEL(model),&iter,path))
618
gtk_list_store_remove(multi_extract_data->files_liststore,&iter);
619
gtk_tree_path_free(path);
622
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),&iter)== FALSE)
623
gtk_widget_set_sensitive (widget,FALSE);
624
g_list_foreach(rr_list,(GFunc)gtk_tree_row_reference_free,NULL);
625
g_list_free(rr_list);
628
static void remove_foreach_func (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,GList **rowref_list)
630
GtkTreeRowReference *rowref;
632
rowref = gtk_tree_row_reference_new(model,path);
633
*rowref_list = g_list_append(*rowref_list,rowref);
636
void xa_activate_remove_button (GtkTreeModel *tree_model,GtkTreePath *path,GtkTreeIter *iter,GtkWidget *remove_button)
638
if (gtk_tree_model_get_iter_first(tree_model,iter)== TRUE)
639
gtk_widget_set_sensitive (remove_button,TRUE );
642
static void xa_multi_extract_dialog_drag_data_received (GtkWidget *widget,GdkDragContext *context,int x,int y,GtkSelectionData *data,unsigned int info,unsigned int time,gpointer user_data)
644
Multi_extract_data *dialog_data = user_data;
645
gchar **array = NULL;
647
unsigned int len = 0;
650
model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
651
array = gtk_selection_data_get_uris (data);
654
xa_show_message_dialog(GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,"",_("Sorry,I could not perform the operation!"));
655
gtk_drag_finish (context,FALSE,FALSE,time);
658
gtk_drag_finish (context,TRUE,FALSE,time);
661
filename = g_filename_from_uri (array[len],NULL,NULL);
662
xa_add_files_liststore (filename,dialog_data);
669
void xa_select_where_to_extract(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,int button,Multi_extract_data *dialog_data)
671
GtkWidget *file_selector;
673
const char *current_path;
676
file_selector = gtk_file_chooser_dialog_new (_("Please select the destination directory"),
677
GTK_WINDOW (xa_main_window),
678
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
685
current_path = gtk_entry_get_text(GTK_ENTRY(entry));
686
if (strlen(current_path) > 0)
687
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (file_selector),current_path);
689
response = gtk_dialog_run (GTK_DIALOG(file_selector));
958
690
if (response == GTK_RESPONSE_ACCEPT)
960
path = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER (File_Selector) );
961
gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry),path);
964
gtk_widget_destroy (File_Selector);
692
dest_dir = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (file_selector));
693
gtk_entry_set_text(GTK_ENTRY(entry),dest_dir);
696
gtk_widget_destroy(file_selector);
699
void xa_parse_multi_extract_archive(Multi_extract_data *dialog)
702
gchar *filename = NULL,*file,*path,*message = NULL,*name,*dest_path = NULL;
703
GString *output = g_string_new("");
704
gboolean overwrite,full_path;
706
double percent = 0.0;
708
gtk_widget_show_all(dialog->multi_extract);
710
response = gtk_dialog_run(GTK_DIALOG(dialog->multi_extract));
711
if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT)
713
gtk_list_store_clear(dialog->files_liststore);
714
gtk_widget_hide(dialog->multi_extract);
717
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dialog->files_liststore),&iter)== FALSE)
719
xa_show_message_dialog(GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't multi-extract archives:"),_("You haven't added any of them!"));
722
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->extract_to)))
724
dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->entry1)));
725
if (strlen(dest_path)== 0)
727
xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("You missed where to extract the files!"),_("Please fill the \"Extract to\" field!"));
731
gtk_widget_hide(dialog->multi_extract);
733
overwrite = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->overwrite));
734
double fraction = 1.0 / dialog->nr;
735
pb = xa_create_progress_bar(FALSE,NULL);
738
gtk_tree_model_get (GTK_TREE_MODEL(dialog->files_liststore),&iter,0,&file,2,&path,3,&type,-1);
739
full_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->full_path));
740
filename = g_strconcat (path,"/",file,NULL);
741
xa_increase_progress_bar(pb,filename,percent);
744
message = xa_multi_extract_archive(dialog,filename,overwrite,full_path,dest_path);
747
name = g_strconcat(filename,": ",message,"\n",NULL);
748
g_string_append(output,name);
751
if (dialog->stop_pressed)
755
while (gtk_tree_model_iter_next (GTK_TREE_MODEL(dialog->files_liststore),&iter));
757
if (strlen(output->str)> 0)
758
xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Some errors occurred:"),output->str );
760
g_string_free(output,TRUE);
761
if (dest_path != NULL)
764
gtk_list_store_clear(dialog->files_liststore);
767
static gchar *xa_multi_extract_archive(Multi_extract_data *dialog,gchar *filename,gboolean overwrite,gboolean full_path,gchar *dest_path)
769
XArchive *archive = NULL;
770
gchar *dirname = NULL;
771
gchar *new_path = NULL;
772
gchar *_filename = NULL;
775
if (dest_path == NULL)
777
_filename = strstr(filename,".");
779
_filename = g_strndup(filename,(_filename-filename));
781
_filename = filename;
782
dest_path = xa_remove_level_from_path(_filename);
783
dirname = xa_remove_path_from_archive_name(_filename);
784
new_path = g_strconcat(dest_path,"/",dirname,NULL);
787
if (g_mkdir(new_path,0700)< 0)
790
return strerror(errno);
792
dest_path = new_path;
794
type = xa_detect_archive_type(filename);
795
archive = xa_init_archive_structure(type);
796
dialog->archive = archive;
797
archive->overwrite = overwrite;
798
archive->full_path = full_path;
799
archive->escaped_path = xa_escape_bad_chars (filename,"$\'`\"\\!?* ()&|@#:;");
800
archive->extraction_path = g_strdup(dest_path);
801
if (g_str_has_suffix (archive->escaped_path,".tar.gz")|| g_str_has_suffix (archive->escaped_path,".tgz"))
803
archive->type = XARCHIVETYPE_TAR_GZ;
804
archive->extract = extract[XARCHIVETYPE_TAR_GZ];
806
else if (g_str_has_suffix(archive->escaped_path,".tar.bz2")|| g_str_has_suffix (archive->escaped_path,".tar.bz")
807
|| g_str_has_suffix ( archive->escaped_path,".tbz")|| g_str_has_suffix (archive->escaped_path,".tbz2"))
809
archive->type = XARCHIVETYPE_TAR_BZ2;
810
archive->extract = extract[XARCHIVETYPE_TAR_BZ2];
812
else if (g_str_has_suffix(archive->escaped_path,".tar.lzma")|| g_str_has_suffix (archive->escaped_path,".tlz"))
814
archive->type = XARCHIVETYPE_TAR_LZMA;
815
archive->extract = extract[XARCHIVETYPE_TAR_LZMA];
817
else if (g_str_has_suffix(archive->escaped_path,".tar.lzop")|| g_str_has_suffix (archive->escaped_path,".tzo"))
819
archive->type = XARCHIVETYPE_TAR_LZOP;
820
archive->extract = extract[XARCHIVETYPE_TAR_LZOP];
822
(*archive->extract)(archive,NULL);
823
xa_clean_archive_structure(archive);