Author: colossus Date: 2006-06-09 07:35:44 +0000 (Fri, 09 Jun 2006) New Revision: 22048
Modified: xarchiver/trunk/src/archive.c xarchiver/trunk/src/archive.h xarchiver/trunk/src/callbacks.c xarchiver/trunk/src/callbacks.h xarchiver/trunk/src/extract_dialog.c Log: Fixed bad behaviour with tar extract option --strip-components. Changed GUI behaviour to allow further archive operations when an error arises. Modified: xarchiver/trunk/src/archive.c =================================================================== --- xarchiver/trunk/src/archive.c 2006-06-09 01:12:13 UTC (rev 22047) +++ xarchiver/trunk/src/archive.c 2006-06-09 07:35:44 UTC (rev 22048) @@ -101,13 +101,13 @@ out_ioc = g_io_channel_unix_new ( output_fd ); //g_io_channel_set_encoding (out_ioc, NULL , NULL); g_io_channel_set_flags ( out_ioc , G_IO_FLAG_NONBLOCK , NULL ); - g_io_add_watch (out_ioc, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, xa_report_child_stderr, (gboolean *)output_flag); + g_io_add_watch (out_ioc, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, xa_report_child_stderr, NULL); } err_ioc = g_io_channel_unix_new ( error_fd ); //g_io_channel_set_encoding (err_ioc, NULL , NULL); g_io_channel_set_flags ( err_ioc , G_IO_FLAG_NONBLOCK , NULL ); - g_io_add_watch (err_ioc, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, xa_report_child_stderr, (gboolean *)output_flag); + g_io_add_watch (err_ioc, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, xa_report_child_stderr, NULL); } Modified: xarchiver/trunk/src/archive.h =================================================================== --- xarchiver/trunk/src/archive.h 2006-06-09 01:12:13 UTC (rev 22047) +++ xarchiver/trunk/src/archive.h 2006-06-09 07:35:44 UTC (rev 22048) @@ -62,7 +62,7 @@ gboolean freshen; gboolean update; gboolean tar_touch; - unsigned short int tar_strip; + unsigned short int tar_strip_value; gchar *passwd; gint nr_of_files; gint nr_of_dirs; Modified: xarchiver/trunk/src/callbacks.c =================================================================== --- xarchiver/trunk/src/callbacks.c 2006-06-09 01:12:13 UTC (rev 22047) +++ xarchiver/trunk/src/callbacks.c 2006-06-09 07:35:44 UTC (rev 22048) @@ -68,7 +68,7 @@ xa_set_button_state (1,1,0,0,0); else if (archive->type == XARCHIVETYPE_RPM) xa_set_button_state (1,1,0,0,1); - else if (archive->type == XARCHIVETYPE_TAR_BZ2 || archive->type == XARCHIVETYPE_TAR_GZ) + else if (archive->type == XARCHIVETYPE_TAR_BZ2 || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR ) { xa_set_button_state (1,1,1,1,1); gtk_widget_set_sensitive ( check_menu , FALSE); @@ -121,12 +121,11 @@ { gtk_tooltips_disable ( pad_tooltip ); gtk_widget_hide ( pad_image ); - xa_set_button_state (1,1,0,0,0); gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("An error occurred while accessing the archive.\nDo you want to open the error messages window?") ); if (response == GTK_RESPONSE_YES) ShowShellOutput (NULL); - archive->status = XA_ARCHIVESTATUS_ERROR; + archive->status = XA_ARCHIVESTATUS_ERROR; Update_StatusBar ( _("Operation failed.")); return; } @@ -1103,7 +1102,7 @@ gtk_container_add (GTK_CONTAINER(OutputWindow), vbox); textbuf = gtk_text_view_get_buffer ( GTK_TEXT_VIEW(textview) ); gtk_text_buffer_get_start_iter (textbuf, &enditer); - gtk_text_buffer_create_tag (textbuf, "red_foreground","foreground", "red", NULL); + //gtk_text_buffer_create_tag (textbuf, "red_foreground","foreground", "red", NULL); gtk_widget_show (vbox); gtk_widget_show (scrollwin); @@ -1453,8 +1452,7 @@ { if ( ! GTK_WIDGET_VISIBLE (Extract_button) ) return; - else if ( archive->status == XA_ARCHIVESTATUS_ERROR) - return; + GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (treeview1) ); gint selected = gtk_tree_selection_count_selected_rows ( selection ); if (selected == 0 ) @@ -1512,7 +1510,7 @@ gtk_label_set_text (GTK_LABEL (info_label), msg); } -gboolean xa_report_child_stderr (GIOChannel *ioc, GIOCondition cond, gboolean output_flag) +gboolean xa_report_child_stderr (GIOChannel *ioc, GIOCondition cond, gpointer data) { if (cond & (G_IO_IN | G_IO_PRI) ) { @@ -1523,11 +1521,8 @@ if (line == NULL) return TRUE; - if (output_flag) - gtk_text_buffer_insert (textbuf, &enditer, line, strlen ( line ) ); - else - gtk_text_buffer_insert_with_tags_by_name (textbuf, &enditer, line , -1, "red_foreground", NULL); - + gtk_text_buffer_insert (textbuf, &enditer, line, strlen ( line ) ); + //gtk_text_buffer_insert_with_tags_by_name (textbuf, &enditer, line , -1, "red_foreground", NULL); g_free (line); return TRUE; } Modified: xarchiver/trunk/src/callbacks.h =================================================================== --- xarchiver/trunk/src/callbacks.h 2006-06-09 01:12:13 UTC (rev 22047) +++ xarchiver/trunk/src/callbacks.h 2006-06-09 07:35:44 UTC (rev 22048) @@ -99,7 +99,7 @@ gboolean treeview_select_search (GtkTreeModel *model,gint column,const gchar *key,GtkTreeIter *iter,gpointer search_data); gboolean isTar ( FILE *ptr ); gboolean isISO ( FILE *ptr ); -gboolean xa_report_child_stderr (GIOChannel *ioc, GIOCondition cond, gboolean output_flag); +gboolean xa_report_child_stderr (GIOChannel *ioc, GIOCondition cond, gpointer data); gboolean DetectPasswordProtectedArchive ( int type , FILE *dummy_ptr , unsigned char magic[6]); void RemoveColumnsListStore (); Modified: xarchiver/trunk/src/extract_dialog.c =================================================================== --- xarchiver/trunk/src/extract_dialog.c 2006-06-09 01:12:13 UTC (rev 22047) +++ xarchiver/trunk/src/extract_dialog.c 2006-06-09 07:35:44 UTC (rev 22048) @@ -146,7 +146,7 @@ dialog_data->touch = gtk_check_button_new_with_mnemonic (_("Touch files")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->touch), archive->tar_touch); gtk_widget_show (dialog_data->touch); - 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 ); + 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 ); gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->touch, FALSE, FALSE, 0); dialog_data->hbox6 = gtk_hbox_new (FALSE, 2); @@ -161,13 +161,15 @@ dialog_data->strip_entry = gtk_entry_new (); gtk_widget_set_size_request (dialog_data->strip_entry, 24, -1); gtk_entry_set_max_length (GTK_ENTRY (dialog_data->strip_entry), 2); - if ( archive->tar_strip > 0) + + if ( ! archive->full_path ) { char strip_text[2]; - sprintf ( strip_text , "%d",archive->tar_strip); + sprintf ( strip_text , "%d",archive->tar_strip_value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->strip), TRUE); gtk_entry_set_text (GTK_ENTRY (dialog_data->strip_entry), strip_text ); gtk_widget_set_sensitive (dialog_data->strip_entry , TRUE); + gtk_widget_grab_focus (dialog_data->strip_entry); } else gtk_widget_set_sensitive (dialog_data->strip_entry , FALSE); @@ -315,25 +317,25 @@ done = TRUE; archive->overwrite = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->overwrite_check )); if ( dialog_data->touch != NULL) + archive->tar_touch = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->touch )); + + if ( dialog_data->strip != NULL) + archive->full_path = ! gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->strip )); + + if (archive->full_path ) { - archive->tar_touch = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->touch )); - if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->strip)) ) - { - archive->tar_strip = atoi (gtk_entry_get_text (GTK_ENTRY(dialog_data->strip_entry)) ); - sprintf ( digit, "%d", archive->tar_strip ); - strip_string = g_strconcat ( "--strip-components=" , digit , " " , NULL ); - } - else - archive->tar_strip = 0; + archive->tar_strip_value = atoi (gtk_entry_get_text (GTK_ENTRY(dialog_data->strip_entry)) ); + sprintf ( digit, "%d", archive->tar_strip_value ); + strip_string = g_strconcat ( "--strip-components=" , digit , " " , NULL ); } + else + archive->tar_strip_value = 0; + if (dialog_data->fresh != NULL) archive->freshen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->fresh )); if (dialog_data->update != NULL) - { archive->update = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->update )); - archive->full_path = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->extract_full )); - } gtk_widget_set_sensitive (Stop_button,TRUE); if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->all_files_radio )) ) @@ -361,7 +363,7 @@ break; case XARCHIVETYPE_TAR: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->tar_strip_value ? strip_string : "", "-xvf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", @@ -369,7 +371,7 @@ break; case XARCHIVETYPE_TAR_BZ2: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->tar_strip_value ? strip_string : "", "-xvjf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", @@ -377,7 +379,7 @@ break; case XARCHIVETYPE_TAR_GZ: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->tar_strip_value ? strip_string : "", "-xvzf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", @@ -503,23 +505,22 @@ gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar *path) { - gchar *command; + gchar *command; - if ( archive->full_path == 0 ) - { - archive->tar_strip = CountCharacter ( files->str , '/'); - sprintf ( digit , "%d" , archive->tar_strip ); - strip_string = g_strconcat ( "--strip-components=" , digit , " " , NULL ); - archive->tar_strip = 0; - } - if ( ! cli) - { - gchar *msg = g_strconcat ( _("Extracting files to ") , path, NULL); - Update_StatusBar (msg); - g_free (msg); - } - switch (archive->type) + if ( archive->full_path == 0) { + archive->tar_strip_value = CountCharacter ( files->str , '/'); + sprintf ( digit , "%d" , archive->tar_strip_value ); + strip_string = g_strconcat ( "--strip-components=" , digit , " " , NULL ); + } + if ( ! cli) + { + gchar *msg = g_strconcat ( _("Extracting files to ") , path, NULL); + Update_StatusBar (msg); + g_free (msg); + } + switch (archive->type) + { case XARCHIVETYPE_RAR: if (archive->passwd != NULL) command = g_strconcat ( "rar " , archive->full_path ? "x " : "e " , @@ -537,7 +538,7 @@ break; case XARCHIVETYPE_TAR: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->full_path ? "" : strip_string, "-xvf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", @@ -545,7 +546,7 @@ break; case XARCHIVETYPE_TAR_BZ2: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->tar_strip_value ? strip_string : "", "-xjvf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", @@ -553,7 +554,7 @@ break; case XARCHIVETYPE_TAR_GZ: - command = g_strconcat ( "tar ",archive->tar_strip ? strip_string : "", + command = g_strconcat ( "tar ",archive->tar_strip_value ? strip_string : "", "-xzvf " , archive->escaped_path, archive->overwrite ? " --overwrite" : " --keep-old-files", archive->tar_touch ? " --touch" : "", _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits