~ubuntu-branches/ubuntu/karmic/xarchiver/karmic

« back to all changes in this revision

Viewing changes to src/extract_dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-11-07 14:54:00 UTC
  • mfrom: (1.1.7 upstream) (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20081107145400-z0j3jmgads8coae2
Tags: 0.5.1-1
MergingĀ upstreamĀ versionĀ 0.5.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2006 Giuseppe Torelli - <colossus73@gmail.com>
3
 
 *  Copyright (C) 2006 Benedikt Meurer - <benny@xfce.org>
 
2
 *  Copyright (C)2008 Giuseppe Torelli - <colossus73@gmail.com>
4
3
 *
5
4
 *  This program is free software; you can redistribute it and/or modify
6
5
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation; either version 2 of the License, or
8
 
 *  (at your option) any later version.
 
6
 *  the Free Software Foundation; either version 2 of the License,or
 
7
 *  (at your option)any later version.
9
8
 *
10
9
 *  This program is distributed in the hope that it will be useful,
11
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
12
 *  GNU General Public License for more details.
14
13
 *
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.
18
17
 */
19
18
 
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"
 
23
#include "window.h"
25
24
#include "string_utils.h"
26
25
#include "support.h"
27
26
 
28
 
gboolean stop_flag;
29
 
extern gboolean cli;
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];
31
31
gchar *rar;
32
32
 
33
 
Extract_dialog_data *xa_create_extract_dialog (gint selected , XArchive *archive)
34
 
{
 
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[] =
 
41
{
 
42
        { "text/uri-list",0,0 },
 
43
};
 
44
 
 
45
Extract_dialog_data *xa_create_extract_dialog()
 
46
{
 
47
        GSList *radiobutton1_group = NULL;
35
48
        Extract_dialog_data *dialog_data;
36
 
        stop_flag = FALSE;
37
 
 
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"));
43
 
        else
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) );
47
 
 
48
 
        dialog_data->option_tooltip = gtk_tooltips_new ();
 
49
 
 
50
        dialog_data = g_new0 (Extract_dialog_data,1);
 
51
        dialog_data->dialog1 = gtk_dialog_new();
 
52
 
 
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);
 
57
 
 
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);
51
 
 
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);
55
 
 
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);
59
 
 
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);
63
 
 
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);
69
 
 
70
 
        gchar *dummy = g_strrstr (archive->path, ".");
71
 
        if (dummy != NULL)
72
 
        {
73
 
                dummy++;
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';
78
 
 
79
 
                if ( strstr (extraction_string , ".tar") )
80
 
                {
81
 
                        extraction_string = g_realloc ( extraction_string, x - 5);
82
 
                        strncpy ( extraction_string, archive->path, x - 5);
83
 
                        extraction_string[x-5] = '\0';
84
 
                }
85
 
                gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry), extraction_string);
86
 
                g_free (extraction_string);
87
 
        }
88
 
        else
89
 
                gtk_entry_set_text (GTK_ENTRY(dialog_data->destination_path_entry), archive->path);
90
 
 
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);
94
 
 
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);
99
 
 
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 );
103
 
 
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);
107
 
 
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);
113
 
 
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);
118
 
 
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);
122
 
 
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));
128
 
 
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));
134
 
 
135
 
        if (selected)
136
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->selected_files_radio), TRUE);
137
 
        else
138
 
                gtk_widget_set_sensitive (dialog_data->selected_files_radio , FALSE);
139
 
 
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);
144
 
 
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);
149
 
 
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);
154
 
 
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);
 
60
 
 
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);
 
64
 
 
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);
 
68
 
 
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);
 
73
 
 
74
        hbox1 = gtk_hbox_new (TRUE,10);
 
75
        gtk_box_pack_start (GTK_BOX (vbox1),hbox1,TRUE,TRUE,0);
 
76
 
 
77
        vbox2 = gtk_vbox_new (FALSE,5);
 
78
        gtk_box_pack_start (GTK_BOX (hbox1),vbox2,TRUE,TRUE,0);
 
79
 
 
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);
 
83
 
 
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);
 
87
 
 
88
        vbox3 = gtk_vbox_new (FALSE,0);
 
89
        gtk_container_add (GTK_CONTAINER (alignment1),vbox3);
 
90
 
 
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));
 
95
 
 
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));
 
100
 
 
101
        hbox2 = gtk_hbox_new (FALSE,0);
 
102
        gtk_box_pack_start (GTK_BOX (vbox3),hbox2,FALSE,FALSE,0);
 
103
 
 
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));
 
108
 
 
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);
 
114
 
 
115
        label2 = gtk_label_new (_("Files "));
 
116
        gtk_frame_set_label_widget (GTK_FRAME (frame1),label2);
 
117
 
 
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);
 
121
 
 
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);
 
125
 
 
126
        vbox5 = gtk_vbox_new (FALSE,0);
 
127
        gtk_container_add (GTK_CONTAINER (alignment2),vbox5);
158
128
 
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);
163
131
 
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) )
166
 
        {
167
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->extract_full), TRUE);
168
 
                gtk_widget_set_sensitive (dialog_data->extract_full, FALSE);
169
 
        }
170
 
        else
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);
175
 
 
176
 
        if (archive->type == XARCHIVETYPE_TAR || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR_BZ2 || archive->type == XARCHIVETYPE_DEB)
177
 
        {
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);
183
 
 
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);
187
 
 
188
 
        }
189
 
        else
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);
 
135
 
 
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);
 
139
 
 
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);
 
144
 
 
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);
 
149
 
 
150
        label3 = gtk_label_new (_("Options "));
 
151
        gtk_frame_set_label_widget (GTK_FRAME (frame2),label3);
 
152
 
 
153
        hbox3 = gtk_hbox_new (FALSE,0);
 
154
        gtk_box_pack_start (GTK_BOX (vbox5),hbox3,TRUE,TRUE,0);
 
155
 
 
156
        label_password = gtk_label_new (_("Password:"));
 
157
        gtk_box_pack_start (GTK_BOX (hbox3),label_password,FALSE,FALSE,0);
 
158
 
 
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);
 
162
 
 
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);
 
165
 
 
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);
 
169
 
 
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"));
 
174
 
 
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);
 
180
 
 
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);
 
184
        return dialog_data;
 
185
}
 
186
 
 
187
void xa_activate_entry(GtkToggleButton *button,gpointer data)
 
188
{
 
189
        Extract_dialog_data *dialog = data;
 
190
 
 
191
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->files_radio)))
 
192
        {
 
193
                gtk_widget_set_sensitive (dialog->entry2,TRUE);
 
194
                gtk_widget_grab_focus (dialog->entry2);
 
195
        }
 
196
        else
 
197
                gtk_widget_set_sensitive (dialog->entry2,FALSE);
 
198
}
 
199
 
 
200
void fresh_update_toggled_cb (GtkToggleButton *button,Extract_dialog_data *data)
 
201
{
 
202
        gboolean active = gtk_toggle_button_get_active(button);
 
203
        if (active)
 
204
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->update),FALSE);
 
205
}
 
206
 
 
207
void update_fresh_toggled_cb (GtkToggleButton *button,Extract_dialog_data *data)
 
208
{
 
209
        if (data->fresh == NULL)
 
210
                return;
 
211
        gboolean active = gtk_toggle_button_get_active (button);
 
212
        if (active)
 
213
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh),FALSE);
 
214
}
 
215
 
 
216
void xa_set_extract_dialog_options(Extract_dialog_data *dialog_data,gint selected,XArchive *archive)
 
217
{
 
218
        gchar *archive_dir = NULL;
 
219
        gboolean flag = TRUE;
 
220
 
 
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]);
 
223
        else
 
224
                gtk_widget_set_size_request (dialog_data->dialog1,-1,370);
 
225
 
 
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"));
 
228
        else
 
229
                gtk_window_set_title (GTK_WINDOW (dialog_data->dialog1),_("Extract files"));
 
230
 
 
231
        if (archive->type != XARCHIVETYPE_RPM)
 
232
        {
 
233
                if (selected)
 
234
                {
 
235
                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->selected_radio),TRUE);
 
236
                        gtk_widget_set_sensitive (dialog_data->selected_radio,TRUE);
 
237
                }
 
238
                else
 
239
                {
 
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);
 
242
                }
 
243
        }
 
244
        else
 
245
                gtk_widget_set_sensitive (dialog_data->selected_radio,FALSE);
 
246
 
 
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)
 
248
                flag = FALSE;
 
249
        gtk_widget_set_sensitive (dialog_data->extract_full,flag);
 
250
 
 
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)
 
252
                flag = FALSE;
 
253
        else
 
254
                flag = TRUE;
 
255
        gtk_widget_set_sensitive (dialog_data->touch,flag);
191
256
 
192
257
        if (archive->type == XARCHIVETYPE_RAR || archive->type == XARCHIVETYPE_ZIP || archive->type == XARCHIVETYPE_ARJ)
193
 
        {
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);
200
 
 
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);
207
 
        }
 
258
                flag = TRUE;
208
259
        else
 
260
                flag = FALSE;
 
261
 
 
262
        gtk_widget_set_sensitive(dialog_data->fresh,flag);
 
263
        gtk_widget_set_sensitive(dialog_data->update,flag);
 
264
        
 
265
        if (archive->extraction_path == NULL)
209
266
        {
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);
212
269
        }
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);
216
 
 
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);
220
 
 
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 )
 
270
        g_free(archive_dir);
 
271
        if (archive->has_passwd)
226
272
    {
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);
231
277
    }
232
278
        else
233
279
        {
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);
236
282
        }
237
 
 
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);
242
 
 
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);
246
 
 
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);
251
 
 
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"));
256
 
 
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);
260
 
 
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);
269
 
        return dialog_data;
270
 
}
271
 
 
272
 
void fresh_update_toggled_cb (GtkToggleButton *button, Extract_dialog_data *data)
273
 
{
274
 
        gboolean active = gtk_toggle_button_get_active (button);
275
 
        if (active)
276
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->update), FALSE);
277
 
}
278
 
 
279
 
void update_fresh_toggled_cb (GtkToggleButton *button, Extract_dialog_data *data)
280
 
{
281
 
        if (data->fresh == NULL)
282
 
                return;
283
 
        gboolean active = gtk_toggle_button_get_active (button);
284
 
        if (active)
285
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh), FALSE);
286
 
}
287
 
 
288
 
gchar *xa_parse_extract_dialog_options ( XArchive *archive , Extract_dialog_data *dialog_data, GtkTreeSelection *selection)
289
 
{
290
 
        gchar *command = NULL;
291
 
        gchar *tar;
292
 
        gchar *destination_path = NULL;
 
283
        gtk_widget_show_all(dialog_data->dialog1);
 
284
}
 
285
 
 
286
void xa_parse_extract_dialog_options (XArchive *archive,Extract_dialog_data *dialog_data,GtkTreeSelection *selection)
 
287
{
 
288
        gchar *destination_path = NULL,*string;
293
289
        gboolean done = FALSE;
294
 
        gboolean end = FALSE;
295
 
        GtkTreeIter iter;
296
 
        GString *names;
 
290
        GSList *names = NULL;
 
291
        GtkTreeModel *model;
 
292
        int response;
297
293
 
298
294
        if (unrar)
299
295
                rar = "unrar";
300
296
        else
301
297
                rar = "rar";
302
298
 
303
 
    while ( ! done )
 
299
    while (! done)
304
300
        {
305
 
                switch (gtk_dialog_run ( GTK_DIALOG (dialog_data->dialog1 ) ) )
 
301
                switch (gtk_dialog_run(GTK_DIALOG(dialog_data->dialog1)))
306
302
                {
307
303
                        case GTK_RESPONSE_CANCEL:
308
304
                        case GTK_RESPONSE_DELETE_EVENT:
309
305
                        done = TRUE;
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))
311
307
                        {
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;
317
311
                        }
318
312
                        break;
319
313
 
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 , "$\'`\"\\!?* ()&|@#:;" );
324
 
                        else
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,"$\'`\"\\!?* ()&|@#:;");
326
317
 
327
 
                        if ( strlen ( archive->extraction_path ) == 0 )
 
318
                        if (strlen(archive->extraction_path)== 0)
328
319
                        {
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."));
330
321
                                break;
331
322
                        }
 
323
                        if (archive->extraction_path[0] != '/')
 
324
                        {
 
325
                                gchar *cur_dir = g_get_current_dir();
 
326
                                archive->extraction_path = g_strconcat(cur_dir,"/",archive->extraction_path,NULL);
 
327
                                g_free (cur_dir);
 
328
                        }
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)));
334
331
 
335
 
                        if (archive->has_passwd && strlen( archive->passwd ) == 0 )
 
332
                        if (archive->has_passwd && strlen(archive->passwd)== 0 )
336
333
                        {
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."));
338
335
                                break;
339
336
                        }
340
 
                        if (g_file_test (destination_path , G_FILE_TEST_EXISTS) == FALSE)
341
 
                        {
342
 
                                int result = mkdir (destination_path , S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXGRP);
343
 
                                if (result == -1)
344
 
                                {
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 ) );
347
 
                                        g_free (msg);
348
 
                                        break;
349
 
                                }
350
 
                        }
351
 
                        if ( g_file_test (destination_path , G_FILE_TEST_IS_DIR) && access (destination_path, R_OK | W_OK | X_OK ) )
 
337
 
 
338
                        if (g_file_test (destination_path,G_FILE_TEST_IS_DIR)&& access (destination_path,R_OK | W_OK | X_OK ))
352
339
                        {
353
340
                                gchar *utf8_path;
354
341
                                gchar  *msg;
355
342
 
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);
360
347
                                g_free (msg);
361
348
                                g_free (destination_path);
362
349
                                break;
363
350
                        }
364
351
                        done = TRUE;
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 ));
368
 
 
369
 
                        if (dialog_data->extract_full != NULL)
370
 
                                archive->full_path = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->extract_full ));
371
 
 
372
 
                        if (dialog_data->fresh != NULL)
373
 
                                archive->freshen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->fresh ));
374
 
 
375
 
                        if (dialog_data->update != NULL)
376
 
                                archive->update = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->update ));
377
 
 
378
 
                        gtk_widget_set_sensitive (Stop_button,TRUE);
 
352
                        g_free (destination_path);
 
353
 
 
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));
 
356
                        if (xa_main_window)
 
357
                                archive->full_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog_data->extract_full));
 
358
                        else
 
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));
 
362
 
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)))
383
367
                        {
384
 
                                if ( ! cli )
385
 
                                {
386
 
                                        gchar *text = g_strdup_printf(_("Extracting files to %s"), destination_path);
387
 
                                        Update_StatusBar ( text );
388
 
                                        g_free (text);
389
 
                                }
390
 
                                g_free (destination_path);
391
 
        tar = g_find_program_in_path ("gtar");
392
 
        if (tar == NULL)
393
 
          tar = g_strdup ("tar");
394
 
                                switch ( archive->type )
395
 
                                {
396
 
                                        case XARCHIVETYPE_BZIP2:
397
 
                                        gzip_bzip2_extract (archive , 0);
398
 
                                        break;
399
 
 
400
 
                                        case XARCHIVETYPE_GZIP:
401
 
                                        gzip_bzip2_extract (archive , 1);
402
 
                                        break;
403
 
 
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-",
410
 
                                                                                                " -idp ",
411
 
                                                                                                archive->escaped_path , " " , archive->extraction_path , NULL );
412
 
                                        else
413
 
                                                command = g_strconcat ( rar, " ", archive->full_path ? "x " : "e ",
414
 
                                                                                                archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
415
 
                                                                                                archive->overwrite ? "-o+" : "-o-",
416
 
                                                                                                " -idp ",
417
 
                                                                                                archive->escaped_path , " " , archive->extraction_path , NULL );
418
 
                                        break;
419
 
 
420
 
                                        case XARCHIVETYPE_TAR:
421
 
                                        if (archive->full_path == 1)
422
 
                                        {
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 );
427
 
                                        }
428
 
                                        else
429
 
                                        {
430
 
                                                xa_extract_tar_without_directories ( "tar -xvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
431
 
                                                command = NULL;
432
 
                                        }
433
 
                                        break;
434
 
 
435
 
                                        case XARCHIVETYPE_TAR_BZ2:
436
 
                                        if (archive->full_path == 1)
437
 
                                        {
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 );
442
 
                                        }
443
 
                                        else
444
 
                                        {
445
 
                                                xa_extract_tar_without_directories ( "tar -xvjf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path , FALSE );
446
 
                                                command = NULL;
447
 
                                        }
448
 
                                        break;
449
 
 
450
 
                                        case XARCHIVETYPE_TAR_GZ:
451
 
                                        if (archive->full_path == 1)
452
 
                                        {
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 );
457
 
                                        }
458
 
                                        else
459
 
                                        {
460
 
                                                xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
461
 
                                                command = NULL;
462
 
                                        }
463
 
                                        break;
464
 
 
465
 
                                        case XARCHIVETYPE_DEB:
466
 
                                        if (archive->full_path == 1)
467
 
                                        {
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 );
472
 
                                        }
473
 
                                        else
474
 
                                        {
475
 
                                                xa_extract_tar_without_directories ( "tar -xvzf " , archive->tmp, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
476
 
                                                command = NULL;
477
 
                                        }
478
 
                                        break;
479
 
 
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 );
488
 
                    else
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 );
494
 
                                        break;
495
 
 
496
 
                                        case XARCHIVETYPE_RPM:
497
 
                                        if (archive->full_path == 1)
498
 
                                        {
499
 
                                                chdir ( archive->extraction_path );
500
 
                                                command = g_strconcat ( "cpio --make-directories -F " , archive->tmp , " -i" , NULL );
501
 
                                        }
502
 
                                        else
503
 
                                        {
504
 
                                                xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,archive->extraction_path , TRUE);
505
 
                                                command = NULL;
506
 
                                        }
507
 
                    break;
508
 
 
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 );
515
 
                                        else
516
 
                                                command = g_strconcat ( "7za " , archive->full_path ? "x " : "e ",
517
 
                                                                                                archive->overwrite ? "-aoa" : "-aos",
518
 
                                                                                                " -bd ",
519
 
                                                                                                archive->escaped_path , " -o" , archive->extraction_path , NULL );
520
 
                    break;
521
 
 
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 );
529
 
                    else
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 );
534
 
                                        break;
535
 
 
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);
540
 
                                        break;
541
 
 
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 );
546
 
                                        while (end)
547
 
                                        {
548
 
                                                xa_set_button_state (0,0,0,0,0,0);
549
 
                                                if (stop_flag)
550
 
                                                        break;
551
 
                                                gtk_tree_model_get (archive->model, &iter,
552
 
                                                0, &name,
553
 
                                                1, &permissions,
554
 
                                                2, &file_size,
555
 
                                                4, &file_offset,
556
 
                                                -1);
557
 
                                                if (xa_extract_iso_file (archive, permissions, archive->extraction_path, name , file_size, file_offset ) == FALSE )
558
 
                                                {
559
 
                                                        g_free (name);
560
 
                                                        g_free (permissions);
561
 
                                                        return NULL;
562
 
                                                }
563
 
                                                end = gtk_tree_model_iter_next (archive->model,&iter);
564
 
                                                g_free (name);
565
 
                                                g_free (permissions);
566
 
                                        }
567
 
                                        xa_set_button_state (1,1,0,1,0,1);
568
 
                                        xa_hide_progress_bar_stop_button(archive);
569
 
                                        Update_StatusBar ( _("Operation completed.") );
570
 
                                        break;
571
 
 
572
 
                                        default:
573
 
                                        command = NULL;
574
 
                                }
575
 
                                g_free (tar);
576
 
 
577
 
                                if ( command != NULL )
578
 
                                        return command;
 
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);
 
373
                                g_free(string);
579
374
                        }
 
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);
580
377
                        else
 
378
                        if (xa_main_window)
581
379
                        {
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..."));
586
383
                        }
 
384
                        (*archive->extract)(archive,names);
587
385
                }
588
386
        }
589
 
        return command;
590
 
}
591
 
 
592
 
gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar *path)
593
 
{
594
 
        gchar *command = NULL;
595
 
        gchar *tar;
596
 
        GtkTreeIter iter;
597
 
 
598
 
        if (unrar)
599
 
                rar = "unrar";
600
 
        else
601
 
                rar = "rar";
602
 
 
603
 
        gchar *msg = g_strdup_printf ( _("Extracting archive to %s") , path);
604
 
        Update_StatusBar (msg);
605
 
        g_free (msg);
606
 
        tar = g_find_program_in_path ("gtar");
607
 
        if (tar == NULL)
608
 
                tar = g_strdup ("tar");
609
 
        switch (archive->type)
610
 
        {
611
 
                case XARCHIVETYPE_BZIP2:
612
 
                gzip_bzip2_extract (archive , 0);
613
 
                break;
614
 
 
615
 
                case XARCHIVETYPE_GZIP:
616
 
                gzip_bzip2_extract (archive , 1);
617
 
                break;
618
 
 
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-",
625
 
                                                                        " -idp ",
626
 
                                                                        archive->escaped_path , " " , files->str , " " , path , NULL );
627
 
        else
628
 
                        command = g_strconcat ( rar," ", archive->full_path ? "x " : "e " ,
629
 
                                                                        archive->freshen ? "-f " : "" , archive->update ? "-u " : "",
630
 
                                                                        archive->overwrite ? "-o+" : "-o-",
631
 
                                                                        " -idp ",
632
 
                                                                        archive->escaped_path , " " , files->str , " ", path ,NULL);
633
 
                break;
634
 
 
635
 
                case XARCHIVETYPE_TAR:
636
 
                if (archive->full_path == 1)
637
 
                {
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 );
642
 
                }
643
 
                else
644
 
                {
645
 
                        xa_extract_tar_without_directories ( "tar -xvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
646
 
                        command = NULL;
647
 
                }
648
 
                break;
649
 
 
650
 
                case XARCHIVETYPE_TAR_BZ2:
651
 
                if (archive->full_path == 1)
652
 
                {
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 );
657
 
                }
658
 
                else
659
 
                {
660
 
                        xa_extract_tar_without_directories ( "tar -xjvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
661
 
                        command = NULL;
662
 
                }
663
 
                break;
664
 
 
665
 
                case XARCHIVETYPE_TAR_GZ:
666
 
                if (archive->full_path == 1)
667
 
                {
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 );
672
 
                }
673
 
                else
674
 
                {
675
 
                        xa_extract_tar_without_directories ( "tar -xzvf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path, FALSE );
676
 
                        command = NULL;
677
 
                }
678
 
                break;
679
 
 
680
 
                case XARCHIVETYPE_DEB:
681
 
                if (archive->full_path == 1)
682
 
                {
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 );
687
 
                }
688
 
                else
689
 
                {
690
 
                        xa_extract_tar_without_directories ( "tar -xvzf " , archive->tmp, archive->overwrite,archive->tar_touch,archive->extraction_path, FALSE );
691
 
                        command = NULL;
692
 
                }
693
 
                break;
694
 
 
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 );
703
 
        else
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 );
709
 
                break;
710
 
 
711
 
        case XARCHIVETYPE_RPM:
712
 
        if (archive->full_path == 1)
713
 
                {
714
 
                        chdir ( path );
715
 
                        command = g_strconcat ( "cpio --make-directories " , files->str , " -F " , archive->tmp , " -i" , NULL);
716
 
                }
717
 
                else
718
 
                {
719
 
                        xa_extract_tar_without_directories ( "tar -xvzf " , archive->escaped_path, archive->overwrite,archive->tar_touch,path , TRUE);
720
 
                        command = NULL;
721
 
                }
722
 
        break;
723
 
 
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",
729
 
                                                                        " -bd ",
730
 
                                                                        archive->escaped_path , files->str , " -o" , path , NULL );
731
 
        else
732
 
                        command = g_strconcat ( "7za " , archive->full_path ? "x" : "e",
733
 
                                                                        archive->overwrite ? " -aoa" : " -aos",
734
 
                                                                        " -bd ",
735
 
                                                                        archive->escaped_path , files->str , " -o" , path , NULL );
736
 
        break;
737
 
 
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" ,
743
 
                                                                        " -i " ,
744
 
                                                                        archive->freshen ? "-f " : "" ,
745
 
                                                                        archive->update ? "-u " : " ",
746
 
                                                                        "-y ",
747
 
                                                                        archive->escaped_path , " " , path , files->str , NULL );
748
 
        else
749
 
                        command = g_strconcat ( "arj ",archive->full_path ? "x" : "e",
750
 
                                                                        archive->overwrite ? "" : " -n" ,
751
 
                                                                        " -i " , archive->freshen ? "-f " : "",
752
 
                                                                        archive->update ? "-u " : " ",
753
 
                                                                        "-y ",
754
 
                                                                        archive->escaped_path , " " , path , files->str, NULL );
755
 
                break;
756
 
 
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);
761
 
                break;
762
 
 
763
 
                case XARCHIVETYPE_ISO:
764
 
                {
765
 
                        GList *row_list = NULL;
766
 
                        GtkTreeSelection *selection;
767
 
 
768
 
                        selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (archive->treeview) );
769
 
                        row_list = gtk_tree_selection_get_selected_rows (selection, &archive->model);
770
 
                        while (row_list)
771
 
                        {
772
 
                                xa_set_button_state (0,0,0,0,0,0);
773
 
                                if (stop_flag)
774
 
                                        break;
775
 
                                gtk_tree_model_get_iter(archive->model, &iter, row_list->data);
776
 
                                gtk_tree_model_get (archive->model, &iter,
777
 
                                0, &name,
778
 
                                1, &permissions,
779
 
                                2, &file_size,
780
 
                                4, &file_offset,
781
 
                                -1);
782
 
                                gtk_tree_path_free (row_list->data);
783
 
 
784
 
                                xa_extract_single_iso_file (archive, permissions, archive->extraction_path, name , file_size, file_offset );
785
 
                                g_free (name);
786
 
                                g_free (permissions);
787
 
                                row_list = row_list->next;
788
 
                        }
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.") );
793
 
                        command = NULL;
794
 
                }
795
 
                break;
796
 
 
797
 
                default:
798
 
                command = NULL;
799
 
    }
800
 
        g_free (tar);
801
 
        return command;
802
 
}
803
 
 
804
 
gboolean xa_extract_tar_without_directories ( gchar *string, gchar *escaped_path, gboolean overwrite, gboolean tar_touch, gchar *extract_path, gboolean cpio_flag )
805
 
{
806
 
        gchar *command = NULL;
807
 
        gchar *name = NULL;
808
 
        gchar *permission = NULL;
809
 
        gchar tmp_dir[14] = "";
 
387
        gtk_widget_hide (dialog_data->dialog1);
 
388
}
 
389
 
 
390
Multi_extract_data *xa_create_multi_extract_dialog()
 
391
{
 
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;
813
 
        GtkTreeIter iter;
814
 
        GList *row_list;
815
 
        GSList *filenames = NULL;
816
 
        gboolean result;
817
 
        gint current_page;
818
 
 
819
 
        current_page = gtk_notebook_get_current_page(notebook);
820
 
        names = g_string_new ("");
821
 
        unescaped_names = g_string_new ("");
822
 
 
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);
825
 
 
826
 
        if (row_list != NULL)
827
 
        {
828
 
                while (row_list)
829
 
                {
830
 
                        gtk_tree_model_get_iter(archive[current_page]->model, &iter, row_list->data);
831
 
                        gtk_tree_model_get (archive[current_page]->model, &iter,
832
 
                                                                0, &name,
833
 
                                                                1, &permission,
834
 
                                                                -1);
835
 
                        gtk_tree_path_free (row_list->data);
836
 
 
837
 
                        if (strstr (permission ,"d") == NULL)
838
 
                        {
839
 
                                ConcatenateFileNames2 ( name , names );
840
 
                                filenames = g_slist_append ( filenames,name );
841
 
                        }
842
 
                        g_free (permission);
843
 
                        row_list = row_list->next;
844
 
                }
845
 
                g_list_free (row_list);
846
 
        }
847
 
        else
848
 
        {
849
 
                end = gtk_tree_model_get_iter_first (archive[current_page]->model , &iter);
850
 
                while (end)
851
 
                {
852
 
                        gtk_tree_model_get (archive[current_page]->model, &iter,        0, &name,
853
 
                                                                                                1, &permission, -1);
854
 
                        if (strstr (permission ,"d") == NULL)
855
 
                        {
856
 
                                ConcatenateFileNames2 ( name , names );
857
 
                                filenames = g_slist_append ( filenames,name );
858
 
                        }
859
 
                        g_free (permission);
860
 
                        end = gtk_tree_model_iter_next (archive[current_page]->model,&iter);
861
 
                }
862
 
        }
863
 
        result = xa_create_temp_directory (tmp_dir);
864
 
        if (result == 0)
865
 
                return FALSE;
866
 
 
867
 
        if (cpio_flag)
868
 
        {
869
 
                chdir (tmp_dir);
870
 
                command = g_strconcat ( "cpio --make-directories -F " , archive[current_page]->tmp , " -i" , NULL );
871
 
        }
872
 
        else
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);
879
 
        g_free (command);
880
 
 
881
 
        if (result == 0 || stop_flag)
882
 
        {
883
 
                xa_delete_temp_directory ( tmp_dir, 0 );
884
 
                gtk_widget_hide (viewport2);
885
 
                Update_StatusBar (_("Operation canceled."));
886
 
                return FALSE;
887
 
        }
888
 
        chdir (tmp_dir);
889
 
        while (filenames)
890
 
        {
891
 
                gchar *unescaped = EscapeBadChars ( filenames->data , "$\'`\"\\!?* ()[]&|@#:;");
892
 
                g_string_prepend ( unescaped_names, unescaped );
893
 
                g_string_prepend_c (unescaped_names, ' ');
894
 
                g_free (unescaped);
895
 
                filenames = filenames->next;
896
 
        }
897
 
        command = g_strconcat ( "mv -f ", unescaped_names->str, " " , extract_path , NULL );
898
 
        result = xa_run_command (command , 0);
899
 
        g_free (command);
900
 
        g_slist_free (filenames);
901
 
        g_string_free ( unescaped_names, TRUE );
902
 
 
903
 
        if (result == 0 || stop_flag)
904
 
        {
905
 
                xa_delete_temp_directory ( tmp_dir, 0 );
906
 
                gtk_widget_hide (viewport2);
907
 
                Update_StatusBar (_("Operation canceled."));
908
 
                return FALSE;
909
 
        }
910
 
        if (cpio_flag)
911
 
                xa_delete_temp_directory ( tmp_dir, 0 );
912
 
        else
913
 
                xa_delete_temp_directory ( tmp_dir, 1 );
914
 
 
915
 
        return result;
916
 
}
917
 
 
918
 
gboolean xa_delete_temp_directory ( gchar *dir_name, gboolean flag)
919
 
{
920
 
        gchar *command;
921
 
        gboolean result;
922
 
 
923
 
        command = g_strconcat ( "rm -rf ", dir_name , NULL );
924
 
        result = xa_run_command (command , flag );
925
 
        g_free (command);
926
 
        return result;
927
 
}
928
 
 
929
 
gboolean xa_create_temp_directory ( gchar tmp_dir[] )
930
 
{
931
 
        strcpy (tmp_dir,"/tmp/xa-XXXXXX");
932
 
        if ( mkdtemp ( tmp_dir ) == 0)
933
 
        {
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."));
937
 
                return FALSE;
938
 
        }
939
 
        return TRUE;
940
 
}
941
 
 
942
 
void xa_choose_extraction_directory (GtkWidget *widget, gpointer data)
943
 
{
944
 
        Extract_dialog_data *dialog_data = data;
945
 
        GtkWidget *File_Selector;
946
 
        int response;
 
396
        GtkTreeViewColumn *column;
 
397
        GSList *radiobutton1_group = NULL;
 
398
        GtkTooltips *multi_tooltip;
 
399
        char *column_names[]= {(_("Archive Name")),(_("Size")),(_("Path")),NULL};
 
400
        int x;
 
401
 
 
402
        multi_tooltip = gtk_tooltips_new ();
 
403
        dialog_data = g_new0 (Multi_extract_data,1);
 
404
        dialog_data->multi_extract = gtk_dialog_new();
 
405
 
 
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"));
 
412
 
 
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);
 
420
 
 
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);
 
425
 
 
426
        for (x = 0; x < 3; x++)
 
427
        {
 
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);
 
432
        }
 
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);
 
436
 
 
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);
 
439
 
 
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);
 
442
        
 
443
        hbox2 = gtk_hbox_new (TRUE,5);
 
444
        gtk_box_pack_start (GTK_BOX (vbox1),hbox2,FALSE,TRUE,0);
 
445
 
 
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);
 
450
 
 
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);
 
457
 
 
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);
 
467
 
 
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));
 
476
 
 
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);
 
481
 
 
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);
 
489
 
 
490
        /* Option frame */
 
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);
 
505
 
 
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);
 
511
        
 
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"));
 
516
 
 
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);
 
522
 
 
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);
 
526
        return dialog_data;
 
527
}
 
528
 
 
529
void xa_multi_extract_dialog_select_files_to_add (GtkButton* button,Multi_extract_data *dialog)
 
530
{
 
531
        GtkWidget *file_selector;
 
532
        GSList *dummy = NULL;
 
533
        gint response;
 
534
 
 
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,
 
538
                                                        GTK_STOCK_CANCEL,
 
539
                                                        GTK_RESPONSE_CANCEL,
 
540
                                                        GTK_STOCK_OPEN,
 
541
                                                        GTK_RESPONSE_ACCEPT,
 
542
                                                        NULL);
 
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)
 
546
        {
 
547
                dummy = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (file_selector));
 
548
                g_slist_foreach( dummy,(GFunc)xa_add_files_liststore,dialog);
 
549
        }
 
550
        if (dummy != NULL)
 
551
                g_slist_free (dummy);
 
552
        gtk_widget_destroy(file_selector);
 
553
        return;
 
554
}
 
555
 
 
556
void xa_multi_extract_dialog_selection_changed(GtkTreeSelection *selection,Multi_extract_data *dialog_data)
 
557
{
 
558
        GtkTreeIter iter;
 
559
        GtkTreeModel *model;
 
560
        gint type;
 
561
 
 
562
        if (gtk_tree_selection_get_selected (selection,&model,&iter))
 
563
        {
 
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);
 
567
                else
 
568
                        gtk_widget_set_sensitive(dialog_data->full_path,TRUE);
 
569
        }
 
570
}
 
571
 
 
572
void xa_add_files_liststore (gchar *file_path,Multi_extract_data *dialog)
 
573
{
 
574
        GtkTreeIter iter;
 
575
        gchar *file_utf8,*_file_utf8;
947
576
        gchar *path;
948
 
 
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,
952
 
                                        GTK_STOCK_CANCEL,
953
 
                                        GTK_RESPONSE_CANCEL,
954
 
                                        GTK_STOCK_OPEN,
955
 
                                        GTK_RESPONSE_ACCEPT,
956
 
                                        NULL );
957
 
        response = gtk_dialog_run (GTK_DIALOG (File_Selector));
 
577
        gint type;
 
578
        struct stat my_stat;
 
579
        unsigned long long int file_size;
 
580
 
 
581
        type = xa_detect_archive_type(file_path);
 
582
        if (type < 0)
 
583
                return;
 
584
 
 
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);
 
590
        g_free (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);
 
594
        dialog->nr++;
 
595
        g_free (file_utf8);
 
596
        g_free (path);
 
597
}
 
598
 
 
599
void xa_remove_files_liststore (GtkWidget *widget,Multi_extract_data *multi_extract_data)
 
600
{
 
601
        GtkTreeModel *model;
 
602
        GtkTreeSelection *sel;
 
603
        GtkTreePath *path;
 
604
        GtkTreeIter iter;
 
605
        GList *rr_list = NULL;
 
606
        GList *node;
 
607
 
 
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);
 
611
 
 
612
        for (node = rr_list; node != NULL; node = node->next)
 
613
        {
 
614
                path = gtk_tree_row_reference_get_path((GtkTreeRowReference *)node->data);
 
615
                if (path)
 
616
                {
 
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);
 
620
                }
 
621
        }
 
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);
 
626
}
 
627
 
 
628
static void remove_foreach_func (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,GList **rowref_list)
 
629
{
 
630
        GtkTreeRowReference *rowref;
 
631
 
 
632
        rowref = gtk_tree_row_reference_new(model,path);
 
633
        *rowref_list = g_list_append(*rowref_list,rowref);
 
634
}
 
635
 
 
636
void xa_activate_remove_button (GtkTreeModel *tree_model,GtkTreePath *path,GtkTreeIter *iter,GtkWidget *remove_button)
 
637
{
 
638
        if (gtk_tree_model_get_iter_first(tree_model,iter)== TRUE)
 
639
                gtk_widget_set_sensitive (remove_button,TRUE );
 
640
}
 
641
 
 
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)
 
643
{
 
644
        Multi_extract_data *dialog_data = user_data;
 
645
        gchar **array = NULL;
 
646
        gchar *filename;
 
647
        unsigned int len = 0;
 
648
        GtkTreeModel *model;
 
649
 
 
650
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
 
651
        array = gtk_selection_data_get_uris (data);
 
652
        if (array == NULL)
 
653
        {
 
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);
 
656
                return;
 
657
        }
 
658
        gtk_drag_finish (context,TRUE,FALSE,time);
 
659
        while (array[len])
 
660
        {
 
661
                filename = g_filename_from_uri (array[len],NULL,NULL);
 
662
                xa_add_files_liststore (filename,dialog_data);
 
663
                g_free (filename);
 
664
                len++;
 
665
        }
 
666
        g_strfreev (array);
 
667
}
 
668
 
 
669
void xa_select_where_to_extract(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,int button,Multi_extract_data *dialog_data)
 
670
{
 
671
        GtkWidget *file_selector;
 
672
        gchar *dest_dir;
 
673
        const char *current_path;
 
674
        gint response;
 
675
 
 
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,
 
679
                                                        GTK_STOCK_CANCEL,
 
680
                                                        GTK_RESPONSE_CANCEL,
 
681
                                                        GTK_STOCK_OPEN,
 
682
                                                        GTK_RESPONSE_ACCEPT,
 
683
                                                        NULL);
 
684
 
 
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);     
 
688
 
 
689
        response = gtk_dialog_run (GTK_DIALOG(file_selector));
958
690
        if (response == GTK_RESPONSE_ACCEPT)
959
691
        {
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);
962
 
                g_free (path);
963
 
        }
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);
 
694
                g_free(dest_dir);
 
695
        }
 
696
        gtk_widget_destroy(file_selector);
 
697
}
 
698
 
 
699
void xa_parse_multi_extract_archive(Multi_extract_data *dialog)
 
700
{
 
701
        GtkTreeIter iter;
 
702
        gchar *filename = NULL,*file,*path,*message = NULL,*name,*dest_path = NULL;
 
703
        GString *output = g_string_new("");
 
704
        gboolean overwrite,full_path;
 
705
        gint response,type;
 
706
        double percent = 0.0;
 
707
 
 
708
        gtk_widget_show_all(dialog->multi_extract);
 
709
run:
 
710
        response = gtk_dialog_run(GTK_DIALOG(dialog->multi_extract));
 
711
        if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT)
 
712
        {
 
713
                gtk_list_store_clear(dialog->files_liststore);
 
714
                gtk_widget_hide(dialog->multi_extract);
 
715
                return;
 
716
        }
 
717
        if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dialog->files_liststore),&iter)== FALSE)
 
718
        {
 
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!"));
 
720
                goto run;
 
721
        }
 
722
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->extract_to)))
 
723
        {
 
724
                dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->entry1)));
 
725
                if (strlen(dest_path)== 0)
 
726
                {
 
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!"));
 
728
                        goto run;
 
729
                }
 
730
        }
 
731
        gtk_widget_hide(dialog->multi_extract);
 
732
 
 
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);
 
736
        do
 
737
        {
 
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);
 
742
                g_free(file);
 
743
                g_free(path);
 
744
                message = xa_multi_extract_archive(dialog,filename,overwrite,full_path,dest_path);
 
745
                if (message != NULL)
 
746
                {
 
747
                        name = g_strconcat(filename,": ",message,"\n",NULL);
 
748
                        g_string_append(output,name);
 
749
                }
 
750
                g_free(filename);
 
751
                if (dialog->stop_pressed)
 
752
                        break;
 
753
                percent += fraction;
 
754
        }
 
755
        while (gtk_tree_model_iter_next (GTK_TREE_MODEL(dialog->files_liststore),&iter));
 
756
 
 
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 );
 
759
 
 
760
        g_string_free(output,TRUE);
 
761
        if (dest_path != NULL)
 
762
                g_free(dest_path);
 
763
 
 
764
        gtk_list_store_clear(dialog->files_liststore);
 
765
}
 
766
 
 
767
static gchar *xa_multi_extract_archive(Multi_extract_data *dialog,gchar *filename,gboolean overwrite,gboolean full_path,gchar *dest_path)
 
768
{
 
769
        XArchive *archive = NULL;
 
770
        gchar *dirname = NULL;
 
771
        gchar *new_path = NULL;
 
772
        gchar *_filename = NULL;
 
773
        gint type;
 
774
 
 
775
        if (dest_path == NULL)
 
776
        {
 
777
                _filename = strstr(filename,".");
 
778
                if (_filename)
 
779
                        _filename = g_strndup(filename,(_filename-filename));
 
780
                else
 
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);
 
785
                g_free(dirname);
 
786
                g_free(dest_path);
 
787
                if (g_mkdir(new_path,0700)< 0)
 
788
                {
 
789
                        g_free(new_path);
 
790
                        return strerror(errno);
 
791
                }
 
792
                dest_path = new_path;
 
793
        }
 
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"))
 
802
        {
 
803
                archive->type = XARCHIVETYPE_TAR_GZ;
 
804
                archive->extract =      extract[XARCHIVETYPE_TAR_GZ];
 
805
        }
 
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"))
 
808
        {
 
809
                archive->type = XARCHIVETYPE_TAR_BZ2;
 
810
                archive->extract =      extract[XARCHIVETYPE_TAR_BZ2];
 
811
        }
 
812
        else if (g_str_has_suffix(archive->escaped_path,".tar.lzma")|| g_str_has_suffix (archive->escaped_path,".tlz"))
 
813
        {
 
814
                archive->type = XARCHIVETYPE_TAR_LZMA;
 
815
                archive->extract =      extract[XARCHIVETYPE_TAR_LZMA];
 
816
        }
 
817
        else if (g_str_has_suffix(archive->escaped_path,".tar.lzop")|| g_str_has_suffix (archive->escaped_path,".tzo"))
 
818
        {
 
819
                archive->type = XARCHIVETYPE_TAR_LZOP;
 
820
                archive->extract =      extract[XARCHIVETYPE_TAR_LZOP];
 
821
        }
 
822
        (*archive->extract)(archive,NULL);
 
823
        xa_clean_archive_structure(archive);
 
824
        return NULL;
965
825
}