Author: colossus Date: 2006-08-23 13:17:37 +0000 (Wed, 23 Aug 2006) New Revision: 22855
Modified: xarchiver/trunk/TODO xarchiver/trunk/src/bzip2.c xarchiver/trunk/src/callbacks.c xarchiver/trunk/src/extract_dialog.c xarchiver/trunk/src/gzip.c xarchiver/trunk/src/main.c Log: Made -x and -e switch to work with gzip/bzip2 compressed files. Updated TODO. Modified: xarchiver/trunk/TODO =================================================================== --- xarchiver/trunk/TODO 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/TODO 2006-08-23 13:17:37 UTC (rev 22855) @@ -4,3 +4,4 @@ - redesign the new dialog. - better handling of current installed archivers. - loading and saving of add/extraction options and window size. +- support tar on *BSD. Modified: xarchiver/trunk/src/bzip2.c =================================================================== --- xarchiver/trunk/src/bzip2.c 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/src/bzip2.c 2006-08-23 13:17:37 UTC (rev 22855) @@ -29,9 +29,9 @@ void OpenBzip2 ( XArchive *archive ) { + gchar *command; if ( g_str_has_suffix ( archive->escaped_path , ".tar.bz2") || g_str_has_suffix ( archive->escaped_path , ".tar.bz") || g_str_has_suffix ( archive->escaped_path , ".tbz") || g_str_has_suffix ( archive->escaped_path , ".tbz2" ) ) { - gchar *command; gchar *tar; tar = g_find_program_in_path ("gtar"); @@ -60,8 +60,10 @@ } else { - gzip_bzip2_extract ( archive , 0 ); - archive->format ="BZIP2"; + extract_window = xa_create_extract_dialog ( 0 , archive); + command = xa_parse_extract_dialog_options ( archive , extract_window, NULL ); + gtk_widget_destroy ( extract_window->dialog1 ); + g_free (extract_window); } } @@ -73,89 +75,67 @@ gboolean result = FALSE; gboolean ext; - extract_window = xa_create_extract_dialog ( 0 , archive); - gtk_dialog_set_default_response (GTK_DIALOG (extract_window->dialog1), GTK_RESPONSE_OK); - done = FALSE; - while ( ! done ) + if ( ! cli ) + archive->extraction_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (extract_window->destination_path_entry) )); + + if ( strlen ( archive->extraction_path ) > 0 ) { - switch (gtk_dialog_run ( GTK_DIALOG (extract_window->dialog1 ) ) ) + if (! cli) { - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_DELETE_EVENT: - done = TRUE; - break; - - case GTK_RESPONSE_OK: - archive->extraction_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (extract_window->destination_path_entry) )); - if ( strlen ( archive->extraction_path ) > 0 ) - { - done = TRUE; + if (flag) + text = g_strdup_printf(_("Extracting gzip file to %s"), archive->extraction_path); + else + text = g_strdup_printf(_("Extracting bzip2 file to %s"), archive->extraction_path); + Update_StatusBar ( text ); + g_free (text); + } - if (! cli) - { - if (flag) - text = g_strdup_printf(_("Extracting gzip file to %s"), archive->extraction_path); - else - text = g_strdup_printf(_("Extracting bzip2 file to %s"), archive->extraction_path); - Update_StatusBar ( text ); - g_free (text); - } - - filename_only = StripPathFromFilename (archive->escaped_path , "/"); - if (file_extension_is (filename_only,".gz") || file_extension_is (filename_only,".bz2") ) - ext = TRUE; - else - ext = FALSE; + filename_only = StripPathFromFilename (archive->escaped_path , "/"); + if (file_extension_is (filename_only,".gz") || file_extension_is (filename_only,".bz2") ) + ext = TRUE; + else + ext = FALSE; - if (ext) - command = g_strconcat ("cp -f ", archive->escaped_path, " /tmp", NULL); - else - command = g_strconcat ("cp -f ", archive->escaped_path, " /tmp" , filename_only, flag ? ".gz" : ".bz2", NULL); + if (ext) + command = g_strconcat ("cp -f ", archive->escaped_path, " /tmp", NULL); + else + command = g_strconcat ("cp -f ", archive->escaped_path, " /tmp" , filename_only, flag ? ".gz" : ".bz2", NULL); - result = xa_run_command (command , 0); - g_free (command); - if (result == 0) - break; - if ( ext ) - command = g_strconcat (flag ? "gzip -f -d -n " : "bzip2 -f -d ", "/tmp",filename_only, NULL); - else - command = g_strconcat (flag ? "gzip -f -d -n " : "bzip2 -f -d ","/tmp",filename_only, flag ? ".gz" : ".bz2", NULL); + result = xa_run_command (command , 0); + g_free (command); + if (result == 0) + return ; + if ( ext ) + command = g_strconcat (flag ? "gzip -f -d -n " : "bzip2 -f -d ", "/tmp",filename_only, NULL); + else + command = g_strconcat (flag ? "gzip -f -d -n " : "bzip2 -f -d ","/tmp",filename_only, flag ? ".gz" : ".bz2", NULL); - result = xa_run_command (command , 0); - g_free (command); - if (result == 0) - break; + result = xa_run_command (command , 0); + g_free (command); + if (result == 0) + return; - if (ext) - { - if (flag) - filename_only[strlen(filename_only) - 3] = '\0'; - else - filename_only[strlen(filename_only) - 4] = '\0'; - command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,NULL); - } - else - { - if ( g_file_test (archive->extraction_path, G_FILE_TEST_IS_DIR) ) - command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,filename_only,NULL); - else - command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,NULL); - } - - result = xa_run_command (command , 0); - g_free (command); - if (result == 0) - break; - } + if (ext) + { + if (flag) + filename_only[strlen(filename_only) - 3] = '\0'; else - response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("You missed the extraction path!"),("Please type it.") ); - break; - } - } - gtk_widget_destroy ( extract_window->dialog1 ); - g_free (extract_window); - extract_window = NULL; + filename_only[strlen(filename_only) - 4] = '\0'; + command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,NULL); + } + else + { + if ( g_file_test (archive->extraction_path, G_FILE_TEST_IS_DIR) ) + command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,filename_only,NULL); + else + command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,NULL); + } + result = xa_run_command (command , 0); + g_free (command); + if (result == 0) + return; + } if (result == 0) { xa_set_button_state (1,1,0,0,0); Modified: xarchiver/trunk/src/callbacks.c =================================================================== --- xarchiver/trunk/src/callbacks.c 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/src/callbacks.c 2006-08-23 13:17:37 UTC (rev 22855) @@ -67,22 +67,37 @@ void xa_watch_child ( GPid pid, gint status, gpointer data) { XArchive *archive = data; - + gboolean new = FALSE; + gboolean open = FALSE; + gboolean add = FALSE; + gboolean extract= FALSE; + gboolean select = FALSE; + gboolean check = FALSE; + gboolean info = FALSE; + if ( archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP ) - xa_set_button_state (1,1,0,0,0); + { + new = open = TRUE; + info = FALSE; + } else if (archive->type == XARCHIVETYPE_RPM) { - xa_set_button_state (1,1,0,1,1); - gtk_widget_set_sensitive ( check_menu , FALSE); + new = open = extract = select = TRUE; + info = FALSE; } else if (archive->type == XARCHIVETYPE_TAR_BZ2 || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR ) - gtk_widget_set_sensitive ( check_menu , FALSE); + { + new = open = add = extract = select = info = TRUE; + check = FALSE; + } else { - gtk_widget_set_sensitive ( check_menu , TRUE); - xa_set_button_state (1,1,1,1,1); + check = TRUE; + new = open = add = extract = select = info = TRUE; } - + gtk_widget_set_sensitive ( check_menu , check); + gtk_widget_set_sensitive ( properties , info); + xa_set_button_state (new,open,add,extract,select); if ( WIFSIGNALED (status) ) { @@ -180,9 +195,8 @@ } gtk_widget_grab_focus (treeview1); gtk_window_set_title ( GTK_WINDOW (MainWindow) , archive->path ); - gtk_widget_set_sensitive ( properties , TRUE ); archive->status = XA_ARCHIVESTATUS_IDLE; - Update_StatusBar ( _("Operation successfully completed.")); + Update_StatusBar ( _("Operation completed.")); } void xa_new_archive (GtkMenuItem *menuitem, gpointer user_data) Modified: xarchiver/trunk/src/extract_dialog.c =================================================================== --- xarchiver/trunk/src/extract_dialog.c 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/src/extract_dialog.c 2006-08-23 13:17:37 UTC (rev 22855) @@ -298,6 +298,13 @@ case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: done = TRUE; + if (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_BZIP2) + { + gtk_widget_set_sensitive (Stop_button,FALSE); + Update_StatusBar (_("Operation canceled.") ); + gtk_widget_hide (viewport2); + archive->status = XA_ARCHIVESTATUS_IDLE; + } break; case GTK_RESPONSE_OK: @@ -328,7 +335,7 @@ break; } } - if (access (destination_path, R_OK | W_OK | X_OK) != 0) + if (access (destination_path, R_OK | W_OK | X_OK | F_OK ) != 0) { gchar *utf8_path; gchar *msg; @@ -372,6 +379,14 @@ tar = g_strdup ("tar"); switch ( archive->type ) { + case XARCHIVETYPE_BZIP2: + gzip_bzip2_extract (archive , 0); + break; + + case XARCHIVETYPE_GZIP: + gzip_bzip2_extract (archive , 1); + break; + case XARCHIVETYPE_RAR: if (archive->passwd != NULL) command = g_strconcat ( "rar " , archive->full_path ? "x " : "e ", @@ -540,7 +555,7 @@ gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar *path) { - gchar *command; + gchar *command = NULL; gchar *tar; gchar *msg = g_strdup_printf( _("Extracting archive to %s") , path); @@ -551,6 +566,14 @@ tar = g_strdup ("tar"); switch (archive->type) { + case XARCHIVETYPE_BZIP2: + gzip_bzip2_extract (archive , 0); + break; + + case XARCHIVETYPE_GZIP: + gzip_bzip2_extract (archive , 1); + break; + case XARCHIVETYPE_RAR: if (archive->passwd != NULL) command = g_strconcat ( "rar " , archive->full_path ? "x " : "e " , Modified: xarchiver/trunk/src/gzip.c =================================================================== --- xarchiver/trunk/src/gzip.c 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/src/gzip.c 2006-08-23 13:17:37 UTC (rev 22855) @@ -26,9 +26,10 @@ void OpenGzip ( XArchive *archive ) { + gchar *command; + if ( g_str_has_suffix ( archive->escaped_path , ".tar.gz") || g_str_has_suffix ( archive->escaped_path , ".tgz") ) { - gchar *command; gchar *tar; tar = g_find_program_in_path ("gtar"); @@ -57,8 +58,10 @@ } else { - archive->format ="GZIP"; - gzip_bzip2_extract ( archive , 1 ); + extract_window = xa_create_extract_dialog ( 0 , archive); + command = xa_parse_extract_dialog_options ( archive , extract_window, NULL ); + gtk_widget_destroy ( extract_window->dialog1 ); + g_free (extract_window); } } Modified: xarchiver/trunk/src/main.c =================================================================== --- xarchiver/trunk/src/main.c 2006-08-23 11:44:38 UTC (rev 22854) +++ xarchiver/trunk/src/main.c 2006-08-23 13:17:37 UTC (rev 22855) @@ -99,6 +99,7 @@ archive->full_path = 1; archive->overwrite = 1; gchar *escaped_path = EscapeBadChars (extract_path , 1); + archive->extraction_path = g_strdup (extract_path); cli_command = xa_extract_single_files ( archive , string, escaped_path ); g_free (escaped_path); if ( cli_command != NULL ) _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits