Author: colossus Date: 2006-09-11 08:20:45 +0000 (Mon, 11 Sep 2006) New Revision: 23126
Added: xarchiver/trunk/src/new_dialog.c xarchiver/trunk/src/new_dialog.h Modified: xarchiver/trunk/ChangeLog xarchiver/trunk/TODO xarchiver/trunk/configure.in.in xarchiver/trunk/src/Makefile.am xarchiver/trunk/src/add_dialog.c xarchiver/trunk/src/callbacks.c xarchiver/trunk/src/callbacks.h xarchiver/trunk/src/extract_dialog.c xarchiver/trunk/src/interface.c xarchiver/trunk/src/iso.c xarchiver/trunk/src/main.c xarchiver/trunk/src/rar.c xarchiver/trunk/src/rpm.c xarchiver/trunk/src/string_utils.c xarchiver/trunk/src/string_utils.h Log: The window title now reports the string "Xarchiver 0.x" and the archive filename without path. Xarchiver now detects and uses unrar if available. Added file new_dialog.c and .h. The new dialog has the ability to choose the archive type by its extension. Fixed bug #2277 and #2286 (duplicate of bug #2277). Updated TODO and ChangeLog. Modified: xarchiver/trunk/ChangeLog =================================================================== --- xarchiver/trunk/ChangeLog 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/ChangeLog 2006-09-11 08:20:45 UTC (rev 23126) @@ -1,5 +1,12 @@ Xarchiver changelog: +0x/09/06 - 0.4.1: + - Fixed Xarchiver not working on Linux box with unrar only. + - Made code to compile under Solaris. + - Added in the new dialog the "By extension" ability. + - Changed some strings for a better usability. + - Fixed bug xxxxxx + 01/09/06 - 0.4: - Added symbolic link column in tar/tar.bz2/tar.gz and RPM archives. - Ability to extract files inside RPM archives without the directory they are contained in. Modified: xarchiver/trunk/TODO =================================================================== --- xarchiver/trunk/TODO 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/TODO 2006-09-11 08:20:45 UTC (rev 23126) @@ -1,5 +1,4 @@ - fix bug #1736, #2176, #2247. -- have a GTK_STOCK_DIRECTORY for directories and GTK_STOCK_FILE for files in the rows before the filename. - allow switching by right click on the toolbar to icons with text/ no text/ small icons. - add a small progress window when using Xarchiver cmd-line switches. - redesign the new dialog. Modified: xarchiver/trunk/configure.in.in =================================================================== --- xarchiver/trunk/configure.in.in 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/configure.in.in 2006-09-11 08:20:45 UTC (rev 23126) @@ -70,7 +70,7 @@ dnl ************************************ dnl *** Check for standard functions *** dnl ************************************ -AC_CHECK_FUNCS([strcasestr]) +AC_CHECK_FUNCS([strcasestr mkdtemp]) dnl ****************************** dnl *** Check for i18n support *** Modified: xarchiver/trunk/src/Makefile.am =================================================================== --- xarchiver/trunk/src/Makefile.am 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/Makefile.am 2006-09-11 08:20:45 UTC (rev 23126) @@ -17,8 +17,8 @@ rpm.c rpm.h \ iso.c iso.h \ extract_dialog.c extract_dialog.h \ - add_dialog.c add_dialog.h -# new_dialog.c new_dialog.h + add_dialog.c add_dialog.h \ + new_dialog.c new_dialog.h xarchiver_CFLAGS = \ @GTK_CFLAGS@ \ Modified: xarchiver/trunk/src/add_dialog.c =================================================================== --- xarchiver/trunk/src/add_dialog.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/add_dialog.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -353,6 +353,8 @@ { Add_dialog_data *add_dialog = _add_dialog; GSList *dummy = NULL; + gchar *title = NULL; + unsigned short int flag; if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(add_dialog->files_radio)) ) Modified: xarchiver/trunk/src/callbacks.c =================================================================== --- xarchiver/trunk/src/callbacks.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/callbacks.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -26,11 +26,13 @@ #include "interface.h" #include "support.h" #include "main.h" +#include "new_dialog.h" extern GList *ArchiveType; extern GList *ArchiveSuffix; extern gboolean cli; extern gboolean stop_flag; +extern gboolean unrar; #ifndef HAVE_STRCASESTR /* @@ -196,49 +198,25 @@ g_object_unref (model); } gtk_widget_grab_focus (treeview1); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , archive->path ); + xa_set_window_title (MainWindow , archive->path); archive->status = XA_ARCHIVESTATUS_IDLE; Update_StatusBar ( _("Operation completed.")); } void xa_new_archive (GtkMenuItem *menuitem, gpointer user_data) { - archive = xa_init_archive_structure (archive); + XArchive *archive = NULL; + gchar *path = NULL; + if (user_data != NULL) - archive->tmp = g_path_get_basename ( user_data); - gchar *path = Show_File_Dialog ( 1 , "new" ); - g_free (archive->tmp); - archive->tmp = NULL; - if (path == NULL) + path = g_path_get_basename ( user_data); + + archive = xa_new_archive_dialog ( path ); + g_free (path); + if (archive == NULL) return; - if ( g_file_test ( path , G_FILE_TEST_EXISTS ) ) - { - gchar *utf8_path; - gchar *msg; - utf8_path = g_filename_to_utf8 (path, -1, NULL, NULL, NULL); - msg = g_strdup_printf (_("The archive \"%s\" already exists!"), utf8_path); - response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow), - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - msg, - _("Do you want to overwrite it?") - ); - g_free (utf8_path); - g_free (msg); - if (response != GTK_RESPONSE_YES) - { - g_free (path); - return; - } - /* The following to avoid to update the archive instead of adding to it since the filename exists */ - unlink ( path ); - } xa_set_button_state (1,1,1,0,0 ); - archive->path = g_strdup (path); - g_free (path); - archive->escaped_path = EscapeBadChars (archive->path , "$\'`\"\\!?* ()&|@#:;"); EmptyTextBuffer(); archive->has_passwd = FALSE; gtk_widget_set_sensitive ( iso_info , FALSE ); @@ -266,7 +244,7 @@ archive->dummy_size = 0; archive->nr_of_files = 0; archive->nr_of_dirs = 0; - gtk_window_set_title ( GTK_WINDOW (MainWindow) , archive->path ); + xa_set_window_title (MainWindow , archive->path ); } int ShowGtkMessageDialog ( GtkWindow *window, int mode,int type,int button, const gchar *message1,const gchar *message2) @@ -310,7 +288,7 @@ gchar *utf8_path,*msg; utf8_path = g_filename_to_utf8 (path, -1, NULL, NULL, NULL); msg = g_strdup_printf (_("Can't open file \"%s\":"), utf8_path); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,msg, _("Archive format is not recognized!")); xa_set_button_state ( 1,1,0,0,0); @@ -394,6 +372,12 @@ void xa_test_archive (GtkMenuItem *menuitem, gpointer user_data) { gchar *command; + gchar *rar; + + if (unrar) + rar = "unrar"; + else + rar = "rar"; if ( archive->has_passwd ) { if ( archive->passwd == NULL) @@ -411,9 +395,9 @@ { case XARCHIVETYPE_RAR: if (archive->passwd != NULL) - command = g_strconcat ("rar t -idp -p" , archive->passwd ," " , archive->escaped_path, NULL); + command = g_strconcat (rar," t -idp -p" , archive->passwd ," " , archive->escaped_path, NULL); else - command = g_strconcat ("rar t -idp " , archive->escaped_path, NULL); + command = g_strconcat (rar," t -idp " , archive->escaped_path, NULL); break; case XARCHIVETYPE_ZIP: @@ -611,7 +595,7 @@ "translator_credits", _("translator-credits"), "logo_icon_name", "xarchiver", "website", "http://xarchiver.xfce.org", - "license", "Copyright (C)2005-2006 Giuseppe Torelli - Colossus <[EMAIL PROTECTED]>\n\n" + "license", "Copyright \xC2\xA9 2005-2006 Giuseppe Torelli - Colossus <[EMAIL PROTECTED]>\n\n" "This is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Library General Public License as\n" "published by the Free Software Foundation; either version 2 of the\n" @@ -637,7 +621,9 @@ GSList *Add_File_Dialog ( gchar *mode ) { GSList *list = NULL; + gchar *title = NULL; int flag; + if ( mode == "file" ) { title = _("Select the files to be added to the current archive; use SHIFT to multiple select"); @@ -681,18 +667,13 @@ GtkFileFilter *filter; GtkTooltips *FilterToolTip ; gchar *path = NULL; + gchar *title = NULL; gchar *dummy_path = NULL; const gchar *flag2 = NULL; unsigned short int flag = 0; - if ( mode == "new" ) + if ( mode == "open" ) { - title = _("Create a new archive"); - flag = GTK_FILE_CHOOSER_ACTION_SAVE; - flag2 = _("Cr_eate"); - } - else if ( mode == "open" ) - { title = _("Open an archive"); flag = GTK_FILE_CHOOSER_ACTION_OPEN; flag2 = "gtk-open"; @@ -762,30 +743,6 @@ Suffix = g_list_next ( Suffix ); } //current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); - if ( mode == "new" ) - { - hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive type:")),FALSE, FALSE, 0); - combo_box = gtk_combo_box_new_text (); - FilterToolTip = gtk_tooltips_new(); - gtk_tooltips_set_tip (FilterToolTip,combo_box, _("Choose the archive type to create") , NULL); - Name = g_list_first ( ArchiveType ); - while ( Name != NULL ) - { - if (Name->data != ".tgz" && Name->data != ".rpm" && Name->data != ".iso" && Name->data != ".gz" && Name->data != ".bz2" ) - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), Name->data ); - Name = g_list_next ( Name ); - } - gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , current_archive_suffix ); - gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0); - check_button = gtk_check_button_new_with_label (_("Add the archive extension to the filename")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check_button),TRUE); - gtk_box_pack_start (GTK_BOX (hbox), check_button, TRUE, TRUE, 0); - gtk_widget_show_all (hbox); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (File_Selector), hbox); - if (archive->tmp != NULL) - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (File_Selector),archive->tmp); - } gtk_window_set_modal (GTK_WINDOW (File_Selector),TRUE); response = gtk_dialog_run (GTK_DIALOG (File_Selector)); @@ -793,28 +750,6 @@ if (response == GTK_RESPONSE_ACCEPT) { path = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER (File_Selector) ); - if ( mode == "new") - { - ComboArchiveType = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_box)); - current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); - if (strcmp ( ComboArchiveType,".arj") == 0) archive->type = XARCHIVETYPE_ARJ; - else if (strcmp ( ComboArchiveType,".rar") == 0) archive->type = XARCHIVETYPE_RAR; - else if (strcmp ( ComboArchiveType,".tar") == 0) archive->type = XARCHIVETYPE_TAR; - else if (strcmp ( ComboArchiveType,".tar.bz2") == 0) archive->type = XARCHIVETYPE_TAR_BZ2; - else if (strcmp ( ComboArchiveType,".tar.gz") == 0) archive->type = XARCHIVETYPE_TAR_GZ; - else if (strcmp ( ComboArchiveType,".jar") == 0 || strcmp ( ComboArchiveType,".zip") == 0 ) archive->type = XARCHIVETYPE_ZIP; - else if (strcmp ( ComboArchiveType,".rpm") == 0) archive->type = XARCHIVETYPE_RPM; - else if (strcmp ( ComboArchiveType,".7z") == 0) archive->type = XARCHIVETYPE_7ZIP; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check_button) ) ) - { - if ( ! g_str_has_suffix ( path , ComboArchiveType ) ) - { - dummy_path = g_strconcat ( path, ComboArchiveType , NULL); - g_free ( path ); - path = dummy_path; - } - } - } gtk_widget_destroy (File_Selector); } else if ( (response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT) ) @@ -987,7 +922,7 @@ void RemoveColumnsListStore() { - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); GList *columns = gtk_tree_view_get_columns ( GTK_TREE_VIEW (treeview1) ); while (columns != NULL) { @@ -1320,7 +1255,7 @@ } else { - measure = " bytes"; + measure = _(" bytes"); content_size = file_size; } @@ -1587,7 +1522,7 @@ gtk_tooltips_disable ( pad_tooltip ); gtk_widget_hide ( pad_image ); gtk_widget_hide ( viewport2 ); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("An error occurred while accessing the archive."),_("Do you want to view the command line output?") ); if (response == GTK_RESPONSE_YES) ShowShellOutput (NULL); @@ -1801,17 +1736,16 @@ return; } } - if (archive == NULL) { - xa_new_archive ( NULL , filename ); - if (archive->path == NULL) + archive = xa_new_archive_dialog ( filename ); + if (archive == NULL) return; } if ( (archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP) && ! one_file) { response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Bzip2 or gzip cannot compress more than one file!"),_("Please choose another archive format!") ); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); Update_StatusBar ( _("Operation failed.")); return; } Modified: xarchiver/trunk/src/callbacks.h =================================================================== --- xarchiver/trunk/src/callbacks.h 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/callbacks.h 2006-09-11 08:20:45 UTC (rev 23126) @@ -60,7 +60,7 @@ GtkTreeIter iter; GtkCellRenderer *renderer; GtkTreeViewColumn *column; -gchar *path, *title , *ComboArchiveType, *destination_path; +gchar *path, *ComboArchiveType, *destination_path; GtkTreeModel *model; GString *names; GSList *Files_to_Add; Modified: xarchiver/trunk/src/extract_dialog.c =================================================================== --- xarchiver/trunk/src/extract_dialog.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/extract_dialog.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -27,6 +27,8 @@ gboolean stop_flag; extern gboolean cli; +extern gboolean unrar; +gchar *rar; Extract_dialog_data *xa_create_extract_dialog (gint selected , XArchive *archive) { @@ -292,6 +294,11 @@ gboolean end = FALSE; GtkTreeIter iter; + if (unrar) + rar = "unrar"; + else + rar = "rar"; + while ( ! done ) { switch (gtk_dialog_run ( GTK_DIALOG (dialog_data->dialog1 ) ) ) @@ -391,14 +398,14 @@ case XARCHIVETYPE_RAR: if (archive->passwd != NULL) - command = g_strconcat ( "rar " , archive->full_path ? "x " : "e ", + command = g_strconcat ( rar, " " , archive->full_path ? "x " : "e ", archive->freshen ? "-f " : "" , archive->update ? "-u " : "", " -p",archive->passwd, archive->overwrite ? " -o+" : " -o-", " -idp ", archive->escaped_path , " " , archive->extraction_path , NULL ); else - command = g_strconcat ( "rar " , archive->full_path ? "x " : "e ", + command = g_strconcat ( rar, " ", archive->full_path ? "x " : "e ", archive->freshen ? "-f " : "" , archive->update ? "-u " : "", archive->overwrite ? "-o+" : "-o-", " -idp ", @@ -579,14 +586,14 @@ case XARCHIVETYPE_RAR: if (archive->passwd != NULL) - command = g_strconcat ( "rar " , archive->full_path ? "x " : "e " , + command = g_strconcat ( rar," ", archive->full_path ? "x " : "e " , archive->freshen ? "-f " : "" , archive->update ? "-u " : "", " -p",archive->passwd, archive->overwrite ? " -o+" : " -o-", " -idp ", archive->escaped_path , " " , files->str , " " , path , NULL ); else - command = g_strconcat ( "rar ", archive->full_path ? "x " : "e " , + command = g_strconcat ( rar," ", archive->full_path ? "x " : "e " , archive->freshen ? "-f " : "" , archive->update ? "-u " : "", archive->overwrite ? "-o+" : "-o-", " -idp ", @@ -738,6 +745,7 @@ command = NULL; } g_free (tar); + g_message (command); return command; } Modified: xarchiver/trunk/src/interface.c =================================================================== --- xarchiver/trunk/src/interface.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/interface.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -50,7 +50,7 @@ accel_group = gtk_accel_group_new (); MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (MainWindow), "Xarchiver " VERSION); + xa_set_window_title (MainWindow , NULL); /* By using GDK_ACTION_MOVE GDK_ACTION_MOVE GDK_ACTION_LINK GDK_ACTION_ASK we should have KDE DnD compatibility. */ gtk_drag_dest_set (MainWindow,GTK_DEST_DEFAULT_ALL, drop_targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK); gtk_window_set_default_icon_from_file (DATADIR "/pixmaps/xarchiver.png", NULL ); @@ -114,18 +114,18 @@ gtk_widget_show (quit1); gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit1); - menuitem2 = gtk_menu_item_new_with_mnemonic (_("A_ction")); + menuitem2 = gtk_menu_item_new_with_mnemonic (_("_Action")); gtk_widget_show (menuitem2); gtk_container_add (GTK_CONTAINER (menubar1), menuitem2); menuitem2_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menuitem2_menu); - addfile = gtk_image_menu_item_new_with_mnemonic (_("Add")); + addfile = gtk_image_menu_item_new_with_mnemonic (_("_Add")); gtk_widget_set_sensitive (addfile,FALSE); gtk_widget_show (addfile); gtk_container_add (GTK_CONTAINER (menuitem2_menu), addfile); - gtk_widget_add_accelerator (addfile, "activate",accel_group,GDK_f, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (addfile, "activate",accel_group,GDK_a, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); image2 = xa_main_window_find_image ("add_button.png", GTK_ICON_SIZE_MENU); gtk_widget_show (image2); @@ -167,11 +167,11 @@ gtk_container_add (GTK_CONTAINER (menuitem2_menu), separatormenuitem3); gtk_widget_set_sensitive (separatormenuitem3, FALSE); - select_all = gtk_image_menu_item_new_with_mnemonic (_("Select _All")); + select_all = gtk_image_menu_item_new_with_mnemonic (_("Sele_ct All")); gtk_widget_show (select_all); gtk_container_add (GTK_CONTAINER (menuitem2_menu), select_all); gtk_widget_set_sensitive (select_all, FALSE); - gtk_widget_add_accelerator (select_all, "activate",accel_group,GDK_a, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (select_all, "activate",accel_group,GDK_c, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); deselect_all = gtk_image_menu_item_new_with_mnemonic (_("Dese_lect All")); gtk_widget_show (deselect_all); Modified: xarchiver/trunk/src/iso.c =================================================================== --- xarchiver/trunk/src/iso.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/iso.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -790,7 +790,7 @@ g_object_unref (model); gtk_widget_set_sensitive ( iso_info , TRUE ); gtk_widget_set_sensitive ( view_shell_output1 , FALSE ); - gtk_window_set_title (GTK_WINDOW(MainWindow),archive->path); + xa_set_window_title (MainWindow , archive->path); gtk_widget_set_sensitive (close1,TRUE); Update_StatusBar ( _("Operation completed.") ); } @@ -876,7 +876,7 @@ gtk_misc_set_alignment (GTK_MISC (size_label), 0.99, 0.5); image_type_label = gtk_label_new (""); - set_label ( image_type_label , _("Image type:")); + set_label ( image_type_label , _("Extension:")); gtk_widget_show (image_type_label); gtk_table_attach (GTK_TABLE (table1), image_type_label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), Modified: xarchiver/trunk/src/main.c =================================================================== --- xarchiver/trunk/src/main.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/main.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -29,6 +29,8 @@ GError *cli_error = NULL; gboolean error_output, file_to_open, ask_and_extract, ask_and_add; gboolean cli = FALSE; +gboolean unrar = FALSE; + static GOptionEntry entries[] = { { "extract-to", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_FILENAME, &extract_path, @@ -236,7 +238,7 @@ gtk_window_set_default_size (GTK_WINDOW(MainWindow), 600, 400); Update_StatusBar ( _("Ready.")); gtk_widget_show (MainWindow); - archive = xa_init_archive_structure(archive); + //archive = xa_init_archive_structure(archive); /* This to open the archive from the command line */ if ( argc == 2 ) @@ -292,14 +294,24 @@ g_free (absolute_path); } - absolute_path = g_find_program_in_path("rar"); + absolute_path = g_find_program_in_path ("rar"); if ( absolute_path ) { ArchiveType = g_list_prepend ( ArchiveType, ".rar"); ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.rar"); g_free (absolute_path); } - + else + { + absolute_path = g_find_program_in_path ("unrar"); + if ( absolute_path ) + { + unrar = TRUE; + ArchiveType = g_list_prepend ( ArchiveType, ".rar"); + ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.rar"); + g_free (absolute_path); + } + } absolute_path = g_find_program_in_path("tar"); if ( absolute_path ) { @@ -319,7 +331,7 @@ } } - absolute_path = g_find_program_in_path("zip"); + absolute_path = g_find_program_in_path ("zip"); if ( absolute_path ) { ArchiveType = g_list_prepend ( ArchiveType, ".jar"); @@ -345,6 +357,8 @@ gtk_widget_set_sensitive ( new1, New); gtk_widget_set_sensitive ( Open_button, Open); gtk_widget_set_sensitive ( open1, Open); + if (unrar) + AddFile = FALSE; gtk_widget_set_sensitive ( AddFile_button, AddFile); gtk_widget_set_sensitive ( addfile, AddFile); gtk_widget_set_sensitive ( Extract_button, Extract); Added: xarchiver/trunk/src/new_dialog.c =================================================================== --- xarchiver/trunk/src/new_dialog.c (rev 0) +++ xarchiver/trunk/src/new_dialog.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" +#include <glib.h> +#include <gtk/gtk.h> +#include "new_dialog.h" +#include "callbacks.h" +#include "string_utils.h" +#include "main.h" + +extern gboolean unrar; + +XArchive *xa_new_archive_dialog (gchar *path) +{ + XArchive *archive = NULL; + GtkWidget *xa_file_chooser; + GtkWidget *hbox = NULL; + GtkWidget *combo_box = NULL; + GtkWidget *check_button = NULL; + GtkFileFilter *xa_new_archive_dialog_filter; + GtkTooltips *filter_tooltip; + GList *Suffix,*Name; + gint current_archive_suffix = 0; + + xa_file_chooser = gtk_file_chooser_dialog_new ( _("Create a new archive"), + GTK_WINDOW (MainWindow), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + _("Cr_eate"), + GTK_RESPONSE_ACCEPT, + NULL); + //if (CurrentFolder != NULL) + //gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER (xa_file_chooser) , CurrentFolder ); + gtk_dialog_set_default_response (GTK_DIALOG (xa_file_chooser), GTK_RESPONSE_ACCEPT); + + xa_new_archive_dialog_filter = gtk_file_filter_new (); + gtk_file_filter_set_name ( xa_new_archive_dialog_filter , _("All files") ); + gtk_file_filter_add_pattern ( xa_new_archive_dialog_filter, "*" ); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (xa_file_chooser), xa_new_archive_dialog_filter); + + xa_new_archive_dialog_filter = gtk_file_filter_new (); + gtk_file_filter_set_name ( xa_new_archive_dialog_filter , _("Only archives") ); + + Suffix = g_list_first ( ArchiveSuffix ); + + while ( Suffix != NULL ) + { + gtk_file_filter_add_pattern (xa_new_archive_dialog_filter, Suffix->data); + Suffix = g_list_next ( Suffix ); + } + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (xa_file_chooser), xa_new_archive_dialog_filter); + + Suffix = g_list_first ( ArchiveSuffix ); + + while ( Suffix != NULL ) + { + if ( Suffix->data != "" ) /* To avoid double filtering when opening the archive */ + { + xa_new_archive_dialog_filter = gtk_file_filter_new (); + gtk_file_filter_set_name (xa_new_archive_dialog_filter, Suffix->data ); + gtk_file_filter_add_pattern (xa_new_archive_dialog_filter, Suffix->data ); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (xa_file_chooser), xa_new_archive_dialog_filter); + } + Suffix = g_list_next ( Suffix ); + } + //current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); + hbox = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive type:")),FALSE, FALSE, 0); + + combo_box = gtk_combo_box_new_text (); + + filter_tooltip = gtk_tooltips_new(); + gtk_tooltips_set_tip (filter_tooltip,combo_box, _("Choose the archive type to create") , NULL); + Name = g_list_first ( ArchiveType ); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("By extension") ); + while ( Name != NULL ) + { + if (Name->data != ".tgz" && Name->data != ".rpm" && Name->data != ".iso" && Name->data != ".gz" && Name->data != ".bz2" ) + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), Name->data ); + Name = g_list_next ( Name ); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , current_archive_suffix ); + gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0); + + check_button = gtk_check_button_new_with_label (_("Add the archive extension to the filename")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check_button),TRUE); + gtk_widget_set_sensitive (check_button,FALSE); + gtk_box_pack_start (GTK_BOX (hbox), check_button, TRUE, TRUE, 0); + + g_signal_connect (G_OBJECT(combo_box), "changed", G_CALLBACK(xa_new_dialog_combo_changed), check_button ); + + gtk_widget_show_all (hbox); + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (xa_file_chooser), hbox); + + if (path != NULL) + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (xa_file_chooser),path); + gtk_window_set_modal (GTK_WINDOW (xa_file_chooser),TRUE); + response = gtk_dialog_run (GTK_DIALOG (xa_file_chooser)); + //CurrentFolder = gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER (File_Selector) ); + if (response == GTK_RESPONSE_ACCEPT) + { + path = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER (xa_file_chooser) ); + if ( g_file_test ( path , G_FILE_TEST_EXISTS ) ) + { + gchar *utf8_path; + gchar *msg; + + utf8_path = g_filename_to_utf8 (path, -1, NULL, NULL, NULL); + msg = g_strdup_printf (_("The archive \"%s\" already exists!"), utf8_path); + response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow), + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + msg, + _("Do you want to overwrite it?") + ); + g_free (utf8_path); + g_free (msg); + if (response != GTK_RESPONSE_YES) + { + g_free (path); + gtk_widget_destroy (xa_file_chooser); + return NULL; + } + /* The following to avoid to update the archive instead of adding to it since the filename exists */ + unlink ( path ); + } + archive = xa_init_archive_structure (archive); + ComboArchiveType = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_box)); + current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); + + if (strcmp ( ComboArchiveType,".arj") == 0) archive->type = XARCHIVETYPE_ARJ; + else if (strcmp ( ComboArchiveType,".rar") == 0 && unrar) archive->type = XARCHIVETYPE_RAR; + else if (strcmp ( ComboArchiveType,".tar") == 0) archive->type = XARCHIVETYPE_TAR; + else if (strcmp ( ComboArchiveType,".tar.bz2") == 0) archive->type = XARCHIVETYPE_TAR_BZ2; + else if (strcmp ( ComboArchiveType,".tar.gz") == 0) archive->type = XARCHIVETYPE_TAR_GZ; + else if (strcmp ( ComboArchiveType,".jar") == 0 || strcmp ( ComboArchiveType,".zip") == 0 ) archive->type = XARCHIVETYPE_ZIP; + else if (strcmp ( ComboArchiveType,".rpm") == 0) archive->type = XARCHIVETYPE_RPM; + else if (strcmp ( ComboArchiveType,".7z") == 0) archive->type = XARCHIVETYPE_7ZIP; + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check_button) ) ) + { + if ( ! g_str_has_suffix ( path , ComboArchiveType ) ) + { + archive->path = g_strconcat ( path, ComboArchiveType , NULL); + archive->escaped_path = EscapeBadChars (archive->path , "$\'`\"\\!?* ()&|@#:;"); + g_free ( path ); + } + } + gtk_widget_destroy (xa_file_chooser); + } + else if ( (response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT) ) + gtk_widget_destroy (xa_file_chooser); + + return archive; +} + +void xa_new_dialog_combo_changed (GtkComboBox *widget, gpointer user_data) +{ + GtkWidget *check_button = user_data; + + if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == 0) + gtk_widget_set_sensitive (user_data,FALSE); + else + gtk_widget_set_sensitive (user_data,TRUE); +} Added: xarchiver/trunk/src/new_dialog.h =================================================================== --- xarchiver/trunk/src/new_dialog.h (rev 0) +++ xarchiver/trunk/src/new_dialog.h 2006-09-11 08:20:45 UTC (rev 23126) @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + */ + +#ifndef __NEW_DIALOG_H +#define __NEW_DIALOG_H + +#include "archive.h" +XArchive *xa_new_archive_dialog (gchar *path); +void xa_new_dialog_combo_changed (GtkComboBox *widget, gpointer user_data); +#endif + Modified: xarchiver/trunk/src/rar.c =================================================================== --- xarchiver/trunk/src/rar.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/rar.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -20,10 +20,20 @@ #include "rar.h" #include "string_utils.h" +extern gboolean unrar; + void OpenRar ( XArchive *archive ) { jump_header = FALSE; - gchar *command = g_strconcat ( "rar vl -c- " , archive->escaped_path, NULL ); + gchar *command = NULL; + gchar *rar = NULL; + + if (unrar) + rar = "unrar"; + else + rar = "rar"; + + command = g_strconcat ( rar," vl -c- " , archive->escaped_path, NULL ); archive->dummy_size = 0; archive->nr_of_files = 0; archive->nr_of_dirs = 0; Modified: xarchiver/trunk/src/rpm.c =================================================================== --- xarchiver/trunk/src/rpm.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/rpm.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -119,7 +119,7 @@ { Update_StatusBar ( _("Operation failed.")); gtk_widget_hide ( viewport2 ); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("Error while extracting the cpio archive from the rpm one."),("Do you want to view the command line output?") ); if (response == GTK_RESPONSE_YES) ShowShellOutput (NULL); @@ -148,7 +148,7 @@ { Update_StatusBar ( _("Operation failed.")); gtk_widget_hide ( viewport2 ); - gtk_window_set_title ( GTK_WINDOW (MainWindow) , "Xarchiver " VERSION ); + xa_set_window_title (MainWindow , NULL); response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("An error occurred while decompressing the cpio archive."),_("Do you want to view the command line output?") ); if (response == GTK_RESPONSE_YES) ShowShellOutput (NULL); Modified: xarchiver/trunk/src/string_utils.c =================================================================== --- xarchiver/trunk/src/string_utils.c 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/string_utils.c 2006-09-11 08:20:45 UTC (rev 23126) @@ -16,11 +16,52 @@ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <gtk/gtk.h> #include <glib.h> #include <string.h> #include "string_utils.h" +#include "errno.h" +#ifndef HAVE_MKDTEMP +static char *mkdtemp (gchar *tmpl) +{ + static const gchar LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static guint64 value = 0; + guint64 v; + gint len; + gint i, j; + + len = strlen (tmpl); + if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0) + { + errno = EINVAL; + return NULL; + } + + value += ((guint64) time (NULL)) ^ getpid (); + + for (i = 0; i < TMP_MAX; ++i, value += 7777) + { + /* fill in the random bits */ + for (j = 0, v = value; j < 6; ++j) + tmpl[(len - 6) + j] = LETTERS[v % 62]; v /= 62; + + /* try to create the directory */ + if (g_mkdir (tmpl, 0700) == 0) + return tmpl; + else if (errno != EEXIST) + return NULL; + } + + errno = EEXIST; + return NULL; +} +#endif + gchar *EscapeBadChars ( gchar *string , gchar *pattern) { return escape_str_common (string, pattern, '\\', 0); @@ -173,3 +214,16 @@ return local_escaped_path; } +void xa_set_window_title ( GtkWidget *window , gchar *title) +{ + gchar *x = NULL; + + if (title == NULL) + gtk_window_set_title ( GTK_WINDOW (window) , "Xarchiver " VERSION ); + else + { + x = g_strconcat ( "Xarchiver " , VERSION , " - ", StripPathFromFilename (title , "/") , NULL); + gtk_window_set_title ( GTK_WINDOW (window) , x); + g_free (x); + } +} Modified: xarchiver/trunk/src/string_utils.h =================================================================== --- xarchiver/trunk/src/string_utils.h 2006-09-10 11:50:35 UTC (rev 23125) +++ xarchiver/trunk/src/string_utils.h 2006-09-11 08:20:45 UTC (rev 23126) @@ -29,6 +29,6 @@ gchar *remove_level_from_path (const gchar *path); gboolean file_extension_is (const char *filename, const char *ext); gchar *extract_local_path (gchar *path , gchar *filename); - +void xa_set_window_title ( GtkWidget *window , gchar *title); #endif _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits