[Xfce4-commits] r26498 - in xarchiver/trunk: . src
Giuseppe Torelli
colossus at xfce.org
Fri Dec 21 12:15:26 CET 2007
Author: colossus
Date: 2007-12-21 11:15:26 +0000 (Fri, 21 Dec 2007)
New Revision: 26498
Modified:
xarchiver/trunk/ChangeLog
xarchiver/trunk/TODO
xarchiver/trunk/src/add_dialog.c
xarchiver/trunk/src/archive.c
xarchiver/trunk/src/archive.h
xarchiver/trunk/src/bzip2.c
xarchiver/trunk/src/deb.c
xarchiver/trunk/src/extract_dialog.c
xarchiver/trunk/src/lzma.c
xarchiver/trunk/src/main.c
xarchiver/trunk/src/main.h
xarchiver/trunk/src/new_dialog.c
xarchiver/trunk/src/pref_dialog.c
xarchiver/trunk/src/rpm.c
xarchiver/trunk/src/window.c
Log:
Made xa_run_command() to execute multiple commands.
Fixed seg-fault when navigating in a tar.lzma archive.
Fixed seg-faults when using the switches from cmd-line.
Fixed missed column title in bzip2.c and lzma.c.
Removed unnecessary extern cli directives.
Updated ChangeLog and TODO files.
Modified: xarchiver/trunk/ChangeLog
===================================================================
--- xarchiver/trunk/ChangeLog 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/ChangeLog 2007-12-21 11:15:26 UTC (rev 26498)
@@ -3,7 +3,9 @@
xx/01/08 - 0.5:
- Archive directories are now browsable just like a file managers.
- Mime icon for each of the archive entries.
- - Preferences dialog to set Xarchiver's options.
+ - New archive types support: lzma and tar.lzma.
+ - Added a brand new preferences dialog to set Xarchiver's options.
+ - The add and extract dialogs have been improved.
- The cmd-line output window now displays each archiver's output.
- The cmd-line output window has a close button and a better layout.
- Tabs are now reorderable.
Modified: xarchiver/trunk/TODO
===================================================================
--- xarchiver/trunk/TODO 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/TODO 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,9 +1,5 @@
-- fix bug #2176.
-- fix missing add/extract/properties when with one archive loaded Xarchiver doesn't recognize another one (sudoku.tar)
-- get rid of memory leaks notified by valgrind [DONE]
-- 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.
-- loading and saving of add/extraction options and window size.
+- loading and saving of add/extraction options.
- support tar on *BSD.
- avoid reset of extract dialog options when loading a new archive.
- ability to create sfx archives through the Add dialog for those archives which support it.
Modified: xarchiver/trunk/src/add_dialog.c
===================================================================
--- xarchiver/trunk/src/add_dialog.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/add_dialog.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
* Copyright (C) 2006 Benedikt Meurer - <benny at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -60,7 +60,10 @@
add_dialog->filechooserwidget1 = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_box_pack_start (GTK_BOX (vbox1), add_dialog->filechooserwidget1, TRUE, TRUE, 0);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(add_dialog->filechooserwidget1),TRUE);
+ if (archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA)
+ gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(add_dialog->filechooserwidget1),FALSE);
+ else
+ gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(add_dialog->filechooserwidget1),TRUE);
//gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(add_dialog->filechooserwidget1));
add_dialog->frame1 = gtk_frame_new (NULL);
@@ -90,7 +93,7 @@
gtk_button_set_focus_on_click (GTK_BUTTON (add_dialog->no_store_path), FALSE);
/* 7z doesn't appear to let the user chooses if storing full paths */
- if (archive->type == XARCHIVETYPE_7ZIP)
+ if (archive->type == XARCHIVETYPE_7ZIP || archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA)
{
gtk_widget_set_sensitive(label3,FALSE);
gtk_widget_set_sensitive(add_dialog->store_path,FALSE);
@@ -410,13 +413,6 @@
else
xa_cat_filenames(archive,files,names);
- gtk_widget_set_sensitive (Stop_button,TRUE);
- gtk_widget_set_sensitive (check_menu,FALSE);
- gtk_widget_set_sensitive (close1,FALSE);
- gtk_widget_set_sensitive (properties,FALSE);
- xa_set_button_state (0,0,0,0,0,0,0,0);
- gtk_widget_hide (add_dialog->dialog1);
-
command = xa_add_single_files (archive,names,compression_string);
g_string_free (names,TRUE);
g_slist_free(files);
Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/archive.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Giuseppe Torelli <colossus73 at gmail.com>
+ * Copyright (c) 2008 Giuseppe Torelli <colossus73 at gmail.com>
*
* 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
@@ -98,6 +98,45 @@
g_io_add_watch (err_ioc,G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, xa_dump_child_error_messages, archive);
}
+gboolean xa_spawn_sync_process (gchar *command)
+{
+ int exit_status;
+ GError *error = NULL;
+ gboolean result = FALSE;
+ gchar *std_out;
+ gchar *std_err;
+ gchar **argv;
+ int argcp;
+
+ g_shell_parse_argv(command,&argcp,&argv,NULL);
+ if ( ! g_spawn_sync(
+ NULL,
+ argv,
+ NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ &std_out,
+ &std_err,
+ &exit_status,
+ &error))
+ {
+ response = xa_show_message_dialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("Can't spawn the command:"),error->message);
+ g_error_free (error);
+ g_strfreev (argv);
+ return result;
+ }
+ if (WIFEXITED(exit_status))
+ {
+ if (WEXITSTATUS(exit_status))
+ response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("An error occurred!"),std_err);
+ else
+ result = TRUE;
+ }
+ g_strfreev (argv);
+ return result;
+}
+
static gboolean xa_process_output (GIOChannel *ioc, GIOCondition cond, gpointer data)
{
XArchive *archive = data;
@@ -225,11 +264,13 @@
gboolean xa_delete_temp_directory (XArchive *archive,gboolean flag)
{
+ GSList *list = NULL;
gchar *command;
gboolean result;
+
command = g_strconcat ("rm -rf ",archive->tmp,NULL);
- result = xa_run_command (archive,command,flag);
- g_free (command);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive,list);
return result;
}
@@ -250,32 +291,39 @@
return TRUE;
}
-gboolean xa_run_command (XArchive *archive,gchar *command,gboolean set_gui)
+gboolean xa_run_command (XArchive *archive,GSList *commands)
{
int status;
+ int ps;
gboolean waiting = TRUE;
- gboolean result;
- int ps;
+ gboolean result = FALSE;
+ GSList *_commands = commands;
archive->parse_output = 0;
- xa_spawn_async_process (archive,command);
- if (archive->child_pid == 0)
- return FALSE;
-
gtk_widget_show (viewport2);
- while (waiting)
+ while (_commands)
{
- ps = waitpid (archive->child_pid, &status, WNOHANG);
- if (ps < 0)
- waiting = FALSE;
- else
- gtk_main_iteration_do (FALSE);
+ g_print ("%s\n",_commands->data);
+ xa_spawn_async_process (archive,_commands->data);
+ if (archive->child_pid == 0)
+ break;
+ while (waiting)
+ {
+ ps = waitpid (archive->child_pid, &status, WNOHANG);
+ if (ps < 0)
+ break;
+ else
+ gtk_main_iteration_do (FALSE);
+ }
+ result = xa_check_child_for_error_on_exit(archive,status);
+ if (result == FALSE)
+ break;
+ _commands = _commands->next;
}
- result = xa_check_child_for_error_on_exit(archive,status);
+ g_slist_foreach (commands, (GFunc) g_free, NULL);
+ g_slist_free(commands);
- if (set_gui)
- xa_archive_operation_finished(archive,result);
-
+ xa_archive_operation_finished(archive,result);
return result;
}
Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/archive.h 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Giuseppe Torelli <colossus73 at gmail.com>
+ * Copyright (c) 2008 Giuseppe Torelli <colossus73 at gmail.com>
*
* 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
@@ -92,8 +92,6 @@
gboolean can_extract;
gboolean has_properties;
GString *comment;
- //TODO: remove this once you fix the various arj,rar,etc
- GList *cmd_line_output;
GSList *error_output;
GType *column_types;
gboolean add_recurse;
@@ -116,13 +114,14 @@
void (*parse_output) (gchar *line, gpointer data);
};
+gboolean xa_spawn_sync_process (gchar *command);
void xa_spawn_async_process (XArchive *archive, gchar *command);
-XArchive *xa_init_archive_structure ();
-void xa_clean_archive_structure ( XArchive *archive);
+XArchive *xa_init_archive_structure();
+void xa_clean_archive_structure (XArchive *archive);
gboolean xa_dump_child_error_messages (GIOChannel *ioc, GIOCondition cond, gpointer data);
gboolean xa_create_temp_directory(XArchive *archive,gchar tmp_dir[]);
gboolean xa_delete_temp_directory(XArchive *archive,gboolean flag);
-gboolean xa_run_command (XArchive *archive,gchar *command,gboolean set_gui);
+gboolean xa_run_command (XArchive *archive,GSList *commands);
gint xa_find_archive_index (gint page_num);
gint xa_get_new_archive_idx();
XEntry *xa_alloc_memory_for_each_row ( guint nc,GType column_types[]);
@@ -136,5 +135,4 @@
void xa_entries_to_filelist(XEntry *, GSList **, gchar *);
void xa_destroy_filelist(GSList *file_list);
XArchive *archive[100];
-XArchive *archive_cmd;
#endif
Modified: xarchiver/trunk/src/bzip2.c
===================================================================
--- xarchiver/trunk/src/bzip2.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/bzip2.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
*
* 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
@@ -21,10 +21,6 @@
#include "extract_dialog.h"
#include "string_utils.h"
-extern void xa_create_liststore ( XArchive *archive, gchar *columns_names[]);
-extern gboolean xa_tar_open (GIOChannel *ioc, GIOCondition cond, gpointer data);
-extern gboolean cli;
-
short int l;
void xa_open_bzip2 (XArchive *archive)
@@ -71,11 +67,12 @@
for (i = 0; i < 9; i++)
archive->column_types[i] = types[i];
- char *names[]= {(_("Points to")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"),NULL)};
+ char *names[]= {(_("Points to")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time")),NULL};
xa_create_liststore (archive,names);
}
else
{
+ GSList *list = NULL;
archive->can_add = archive->has_test = archive->has_sfx = FALSE;
archive->has_properties = archive->can_extract = TRUE;
archive->nc = 3;
@@ -94,19 +91,9 @@
if (result == 0)
return;
- archive->tmp = strdup(tmp_dir);
/* Let's copy the bzip2 file in the tmp dir */
command = g_strconcat("cp -f ",archive->escaped_path," ",archive->tmp,NULL);
- result = xa_run_command (archive,command,0);
- g_free (command);
- if (!result)
- {
- xa_delete_temp_directory (archive,0);
- gtk_widget_hide (viewport2);
- Update_StatusBar (_("Operation canceled."));
- return;
- }
-
+ list = g_slist_append(list,command);
/* Let's get its compressed file size */
stat (archive->escaped_path,&my_stat);
compressed = g_strdup_printf("%lld",(unsigned long long int)my_stat.st_size);
@@ -120,15 +107,8 @@
else
command = g_strconcat("bzip2 -f -d ",archive->tmp,"/",archive->escaped_path,NULL);
- result = xa_run_command (archive,command,1);
- g_free (command);
- if (!result)
- {
- xa_delete_temp_directory (archive,0);
- gtk_widget_hide (viewport2);
- Update_StatusBar (_("Operation canceled."));
- return;
- }
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive,list);
/* and let's get its uncompressed file size */
if (_filename)
@@ -161,18 +141,19 @@
void gzip_bzip2_extract (XArchive *archive , gboolean flag )
{
+ GSList *list = NULL;
gchar *text = NULL;
gchar *filename_only = NULL;
gchar *command = NULL;
gboolean result = FALSE;
gboolean ext;
- if ( ! cli )
+ if (MainWindow)
archive->extraction_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (extract_window->destination_path_entry) ));
if ( strlen ( archive->extraction_path ) > 0 )
{
- if (! cli)
+ if (MainWindow)
{
if (flag)
text = g_strdup_printf(_("Extracting gzip file to %s"), archive->extraction_path);
@@ -183,29 +164,23 @@
}
filename_only = g_strrstr (archive->escaped_path , "/");
- if (file_extension_is (filename_only,".gz") || file_extension_is (filename_only,".bz2") )
+ 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);
+ 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);
+ command = g_strconcat ("cp -f ",archive->escaped_path," /tmp",filename_only,flag ? ".gz" : ".bz2",NULL);
- result = xa_run_command (archive,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);
+ list = g_slist_append(list,command);
+ 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);
+ command = g_strconcat(flag ? "gzip -f -d -n " : "bzip2 -f -d ","/tmp",filename_only,flag ? ".gz" : ".bz2",NULL);
- result = xa_run_command (archive,command , 0);
- g_free (command);
- if (result == 0)
- return;
+ list = g_slist_append(list,command);
if (ext)
{
@@ -217,34 +192,24 @@
}
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);
+ 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);
+ command = g_strconcat("mv -f /tmp",filename_only," ",archive->extraction_path,NULL);
}
-
- result = xa_run_command (archive,command , 0);
- g_free (command);
- if (result == 0)
- return;
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive,list);
}
- if (result == 0)
- {
- xa_set_button_state (1,1,GTK_WIDGET_IS_SENSITIVE(close1),0,0,0,0,0);
- archive->status = XA_ARCHIVESTATUS_IDLE;
- gtk_widget_set_sensitive (Stop_button, FALSE);
- gtk_widget_hide ( viewport2 );
- Update_StatusBar ( _("Operation canceled."));
- }
}
-void xa_add_delete_tar_bzip2_gzip ( GString *list , XArchive *archive , gboolean dummy , gboolean add )
+void xa_add_delete_tar_bzip2_gzip ( GString *_list , XArchive *archive , gboolean dummy , gboolean add )
{
gchar *command, *msg, *tar,*temp_name,*file_ext;
gboolean result;
+ GSList *list = NULL;
archive->status = XA_ARCHIVESTATUS_DELETE;
- if ( ! cli )
+ if (MainWindow)
{
gtk_widget_show (viewport2);
msg = g_strdup_printf(_("Decompressing tar file with %s, please wait...") , dummy ? "gzip" : "bzip2");
@@ -254,29 +219,12 @@
/* Let's copy the archive to /tmp first */
//TODO: replace /tmp with the user chosen dir in the pref dialog
- temp_name = g_strconcat ( " /tmp", g_strrstr (archive->escaped_path , "/"), NULL);
- command = g_strconcat ("cp -ar " ,archive->escaped_path,temp_name,NULL);
- if ( ! cli)
- result = xa_run_command (archive,command , 0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
+ temp_name = g_strconcat (" /tmp", g_strrstr (archive->escaped_path , "/"),NULL);
+ command = g_strconcat ("cp -a ",archive->escaped_path,temp_name,NULL);
+ list = g_slist_append(list,command);
+
command = g_strconcat (dummy ? "gzip -f " : "bzip2 ", "-f -d ",temp_name,NULL);
- if ( ! cli )
- result = xa_run_command (archive,command , 0);
- else
- result = SpawnSyncCommand (command);
- g_free (command);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
+ list = g_slist_append(list,command);
tar = g_find_program_in_path ("gtar");
if (tar == NULL)
@@ -299,61 +247,30 @@
temp_name[l - 2] = 'a';
temp_name[l - 1] = 'r';
}
-
- if ( add )
+ if (add)
command = g_strconcat (tar, " ",
archive->add_recurse ? "" : "--no-recursion ",
archive->remove_files ? "--remove-files " : "",
archive->update ? "-uvvf " : "-rvvf ",
temp_name,
- list->str , NULL );
+ _list->str , NULL );
else
- command = g_strconcat (tar, " --delete -f " , temp_name , list->str , NULL );
- if ( ! cli)
- result = xa_run_command (archive,command,0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
+ command = g_strconcat (tar, " --delete -f ",temp_name,_list->str,NULL);
+ list = g_slist_append(list,command);
g_free (tar);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
- if ( ! cli )
- {
- msg = g_strdup_printf(_("Recompressing tar file with %s, please wait...") , dummy ? "gzip" : "bzip2");
- Update_StatusBar ( msg );
- g_free (msg);
- }
+ command = g_strconcat(dummy ? "gzip -f " : "bzip2 ", "-f ",temp_name,NULL);
+ list = g_slist_append(list,command);
- command = g_strconcat ( dummy ? "gzip -f " : "bzip2 ", "-f " , temp_name , NULL );
- if ( ! cli )
- result = xa_run_command (archive,command , 0);
- else
- result = SpawnSyncCommand (command);
- g_free (command);
-
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
if (dummy)
file_ext = ".gz";
else
file_ext = ".bz2";
/* Let's move the modified archive from /tmp to the original archive location */
- command = g_strconcat ( "mv " , temp_name , file_ext, " " ,archive->escaped_path, NULL );
- if ( ! cli )
- result = xa_run_command (archive,command,1);
- else
- result = SpawnSyncCommand (command);
- g_free (command);
- g_free (temp_name);
+ command = g_strconcat ( "cp ",temp_name,file_ext," ",archive->escaped_path,NULL);
+ list = g_slist_append(list,command);
- if (result == 0)
- return;
+ result = xa_run_command (archive,list);
+ g_free (temp_name);
}
Modified: xarchiver/trunk/src/deb.c
===================================================================
--- xarchiver/trunk/src/deb.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/deb.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -21,10 +21,11 @@
#include "deb.h"
#include "string_utils.h"
-extern void xa_create_liststore ( XArchive *archive, gchar *columns_names[]);
+extern void xa_create_liststore (XArchive *archive,gchar *columns_names[]);
-void xa_open_deb ( XArchive *archive )
+void xa_open_deb (XArchive *archive)
{
+ GSList *list = NULL;
gchar *command = NULL;
gchar *dummy = NULL;
gchar *archive_no_path = NULL;
@@ -39,36 +40,23 @@
archive_no_path = g_strrstr (archive->escaped_path,"/");
if (archive_no_path == NULL)
- dummy = g_strconcat (" ",tmp_dir,"/",archive->escaped_path,NULL);
+ dummy = g_strconcat (tmp_dir,"/",archive->escaped_path,NULL);
else
{
archive_no_path++;
- dummy = g_strconcat (" ",tmp_dir,"/",archive_no_path,NULL);
+ dummy = g_strconcat (tmp_dir,"/",archive_no_path,NULL);
}
-
/* Copy the .deb archive to the unique dir */
command = g_strconcat ("cp ",archive->escaped_path," ",archive->tmp,NULL);
- result = xa_run_command (archive,command,0);
- g_free (command);
- if (result == FALSE)
- return;
+ list = g_slist_append(list,command);
/* Ok, let's now extract the .deb archive with ar */
- chdir (tmp_dir);
- command = g_strconcat ("ar xv" , dummy, NULL);
- result = xa_run_command (archive,command,0);
- g_free (command);
+ chdir (archive->tmp);
+ command = g_strconcat ("ar xv ",dummy,NULL);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive,list);
g_free (dummy);
- chdir (archive->tmp);
- unlink ("control.tar.gz");
- unlink ("debian-binary");
- /* Delete the .deb archive copied to the unique dir */
- if (archive_no_path != NULL)
- unlink (archive_no_path);
- else
- unlink (archive->escaped_path);
-
if (result == FALSE)
return;
Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/extract_dialog.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
* Copyright (C) 2006 Benedikt Meurer - <benny at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,6 @@
#include "support.h"
gboolean stop_flag;
-extern gboolean cli;
extern gboolean unrar;
gchar *rar;
@@ -162,7 +161,7 @@
dialog_data->extract_full = gtk_check_button_new_with_mnemonic (_("Extract files with full path"));
if (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2 )
goto here;
- if (cli && (archive->type == XARCHIVETYPE_TAR || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR_LZMA || archive->type == XARCHIVETYPE_DEB || archive->type == XARCHIVETYPE_TAR_BZ2) )
+ if (archive->type == XARCHIVETYPE_TAR || archive->type == XARCHIVETYPE_TAR_GZ || archive->type == XARCHIVETYPE_TAR_LZMA || archive->type == XARCHIVETYPE_DEB || archive->type == XARCHIVETYPE_TAR_BZ2)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog_data->extract_full), TRUE);
gtk_widget_set_sensitive (dialog_data->extract_full, FALSE);
@@ -184,7 +183,6 @@
dialog_data->hbox6 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (dialog_data->hbox6);
gtk_box_pack_start (GTK_BOX (dialog_data->vbox4), dialog_data->hbox6, FALSE, FALSE, 0);
-
}
else
dialog_data->touch = NULL;
@@ -282,10 +280,10 @@
return;
gboolean active = gtk_toggle_button_get_active (button);
if (active)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->fresh),FALSE);
}
-gchar *xa_parse_extract_dialog_options ( XArchive *archive , Extract_dialog_data *dialog_data, GtkTreeSelection *selection)
+gchar *xa_parse_extract_dialog_options (XArchive *archive,Extract_dialog_data *dialog_data,GtkTreeSelection *selection)
{
gchar *command = NULL;
gchar *tar;
@@ -298,17 +296,17 @@
else
rar = "rar";
- while ( ! done )
+ while (! done)
{
- switch (gtk_dialog_run ( GTK_DIALOG (dialog_data->dialog1 ) ) )
+ switch (gtk_dialog_run(GTK_DIALOG(dialog_data->dialog1)))
{
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
done = TRUE;
- if (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2 )
+ if (MainWindow && (archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA || archive->type == XARCHIVETYPE_BZIP2) )
{
gtk_widget_set_sensitive (Stop_button,FALSE);
- Update_StatusBar (_("Operation canceled.") );
+ Update_StatusBar (_("Operation canceled."));
gtk_widget_hide (viewport2);
xa_set_button_state (1,1,GTK_WIDGET_IS_SENSITIVE(close1),0,0,0,0,0);
archive->status = XA_ARCHIVESTATUS_IDLE;
@@ -316,10 +314,10 @@
break;
case GTK_RESPONSE_OK:
- destination_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (dialog_data->destination_path_entry) ));
- archive->extraction_path = xa_escape_bad_chars ( destination_path , "$\'`\"\\!?* ()&|@#:;" );
+ destination_path = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog_data->destination_path_entry)));
+ archive->extraction_path = xa_escape_bad_chars (destination_path , "$\'`\"\\!?* ()&|@#:;");
- if ( strlen ( archive->extraction_path ) == 0 )
+ if (strlen(archive->extraction_path) == 0)
{
response = xa_show_message_dialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("You missed where to extract the files!"),_("Please enter the extraction path.") );
break;
@@ -327,13 +325,13 @@
if (archive->extraction_path[0] != '/')
{
gchar *cur_dir = g_get_current_dir();
- archive->extraction_path = g_strconcat(cur_dir, "/", archive->extraction_path, NULL);
+ archive->extraction_path = g_strconcat(cur_dir, "/",archive->extraction_path,NULL);
g_free (cur_dir);
}
if (archive->has_passwd)
- archive->passwd = g_strdup (gtk_entry_get_text ( GTK_ENTRY (dialog_data->password_entry) ));
+ archive->passwd = g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog_data->password_entry)));
- if (archive->has_passwd && strlen( archive->passwd ) == 0 )
+ if (archive->has_passwd && strlen(archive->passwd) == 0 )
{
response = xa_show_message_dialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("This archive is encrypted!"),_("Please enter the password.") );
break;
@@ -376,13 +374,13 @@
if (dialog_data->update != NULL)
archive->update = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->update ));
- gtk_widget_set_sensitive (Stop_button,TRUE);
+ //gtk_widget_set_sensitive (Stop_button,TRUE);
gtk_widget_hide (dialog_data->dialog1);
archive->status = XA_ARCHIVESTATUS_EXTRACT;
/* Are all files selected? */
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( dialog_data->all_files_radio )) )
{
- if ( ! cli )
+ if (MainWindow)
{
gchar *text = g_strdup_printf(_("Extracting files to %s"), destination_path);
Update_StatusBar ( text );
@@ -571,7 +569,7 @@
names = g_string_new ( " " );
gtk_tree_selection_selected_foreach (selection, (GtkTreeSelectionForeachFunc) xa_concat_filenames, names );
command = xa_extract_single_files ( archive , names, archive->extraction_path );
- g_string_free (names, TRUE);
+ g_string_free(names,TRUE);
}
}
}
@@ -579,7 +577,7 @@
return command;
}
-gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar *path)
+gchar *xa_extract_single_files (XArchive *archive,GString *files,gchar *path)
{
gchar *command = NULL;
gchar *tar;
@@ -719,7 +717,7 @@
case XARCHIVETYPE_RPM:
if (archive->full_path == 1)
{
- chdir ( path );
+ chdir (path);
command = g_strconcat ( "cpio --make-directories " , files->str , " -F " , archive->tmp , " -i" , NULL);
}
else
@@ -730,7 +728,7 @@
break;
case XARCHIVETYPE_7ZIP:
- if ( archive->passwd != NULL)
+ if (archive->passwd != NULL)
command = g_strconcat ("7za " , archive->full_path ? "x" : "e",
" -p",archive->passwd,
archive->overwrite ? " -aoa" : " -aos",
@@ -845,7 +843,7 @@
archive->tar_touch ? " --touch" : "",
" --no-wildcards -C ",
archive->tmp,names->str,NULL);
- result = xa_run_command (archive,command,0);
+ result = xa_run_command (archive,command);
g_string_free (names, TRUE);
g_free (command);
@@ -871,7 +869,7 @@
chdir (archive->tmp);
command = g_strconcat ( "mv -f ", unescaped_names->str, " " , extract_path , NULL );
- result = xa_run_command (archive,command,0);
+ result = xa_run_command (archive,command);
g_free (command);
g_slist_free (filenames);
g_string_free (unescaped_names,TRUE);
Modified: xarchiver/trunk/src/lzma.c
===================================================================
--- xarchiver/trunk/src/lzma.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/lzma.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
* Copyright (C) 2007 Thomas Dy - <dysprosium66 at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,26 +17,20 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-//this file is modified from bzip2 module
-
#include "config.h"
#include "lzma.h"
#include "bzip2.h"
#include "extract_dialog.h"
#include "string_utils.h"
-FILE *fd;
-
-extern int output_fd;
-extern gboolean cli;
short int l;
-void xa_open_lzma ( XArchive *archive )
+void xa_open_lzma (XArchive *archive)
{
gchar *command;
unsigned short int i;
- if ( g_str_has_suffix ( archive->escaped_path , ".tar.lzma") || g_str_has_suffix ( archive->escaped_path , ".tlz") )
+ if (g_str_has_suffix(archive->escaped_path , ".tar.lzma") || g_str_has_suffix (archive->escaped_path , ".tlz"))
{
gchar *tar;
tar = g_find_program_in_path ("gtar");
@@ -44,55 +38,55 @@
if (tar == NULL)
tar = g_strdup ("tar");
- command = g_strconcat (tar, " tv --use-compress-program=lzma -f " , archive->escaped_path, NULL );
+ command = g_strconcat(tar," tv --use-compress-program=lzma -f ",archive->escaped_path,NULL);
+ archive->has_properties = archive->can_add = archive->can_extract = TRUE;
archive->dummy_size = 0;
archive->nr_of_files = 0;
archive->nr_of_dirs = 0;
- archive->nc = 6;
+ archive->nc = 7;
archive->format ="TAR.LZMA";
archive->parse_output = xa_get_tar_line_content;
-
xa_spawn_async_process (archive,command);
g_free (command);
g_free (tar);
- if ( archive->child_pid == 0 )
+ if (archive->child_pid == 0)
return;
- GType types[]= {GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_STRING};
+ GType types[]= {GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_POINTER};
archive->column_types = g_malloc0(sizeof(types));
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 9; i++)
archive->column_types[i] = types[i];
- char *names[]= {(_("Points to")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"))};
+ char *names[]= {(_("Points to")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time")),NULL};
xa_create_liststore (archive,names);
archive->type = XARCHIVETYPE_TAR_LZMA;
}
else
{
- extract_window = xa_create_extract_dialog ( 0 , archive);
- command = xa_parse_extract_dialog_options ( archive , extract_window, NULL );
- gtk_widget_destroy ( extract_window->dialog1 );
+ 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);
}
}
-
-void lzma_extract ( XArchive *archive )
+void lzma_extract (XArchive *archive)
{
+ GSList *list = NULL;
gchar *text = NULL;
gchar *filename_only = NULL;
gchar *command = NULL;
gboolean result = FALSE;
gboolean ext;
- if ( ! cli )
+ if (MainWindow)
archive->extraction_path = g_strdup (gtk_entry_get_text ( GTK_ENTRY (extract_window->destination_path_entry) ));
- if ( strlen ( archive->extraction_path ) > 0 )
+ if (strlen(archive->extraction_path) > 0)
{
- if (! cli)
+ if (MainWindow)
{
text = g_strdup_printf(_("Extracting lzma file to %s"), archive->extraction_path);
Update_StatusBar ( text );
@@ -110,19 +104,14 @@
else
command = g_strconcat ("cp -f ", archive->escaped_path, " /tmp" , filename_only, ".lzma", NULL);
- result = xa_run_command (archive,command,0);
- g_free (command);
- if (result == 0)
- return ;
- if ( ext )
+ list = g_slist_append(list,command);
+
+ if (ext)
command = g_strconcat ("lzma -f -d ", "/tmp",filename_only, NULL);
else
command = g_strconcat ("lzma -f -d ","/tmp",filename_only, ".lzma", NULL);
- result = xa_run_command (archive,command,0);
- g_free (command);
- if (result == 0)
- return;
+ list = g_slist_append(list,command);
if (ext)
{
@@ -133,77 +122,50 @@
{
command = g_strconcat ("mv -f /tmp",filename_only, " ", archive->extraction_path,NULL);
}
-
- result = xa_run_command (archive,command,0);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive,list);
g_free (command);
if (result == 0)
return;
}
- if (result == 0)
+/* if (result == 0)
{
xa_set_button_state (1,1,GTK_WIDGET_IS_SENSITIVE(close1),0,0,0,0,0);
archive->status = XA_ARCHIVESTATUS_IDLE;
gtk_widget_set_sensitive (Stop_button, FALSE);
gtk_widget_hide ( viewport2 );
Update_StatusBar ( _("Operation canceled."));
- }
- //TODO:
- /*else
- xa_watch_child (archive->child_pid, 0, archive);*/
+ }*/
}
-void xa_add_delete_tar_lzma ( GString *list , XArchive *archive , gboolean add )
+void xa_add_delete_tar_lzma (GString *list,XArchive *archive,gboolean add)
{
- gchar *command, *msg, *tar,*temp_name,*file_ext;
+ GSList *_list = NULL;
+ gchar *command,*tar,*temp_name,*file_ext;
gboolean result;
- if ( ! cli )
- {
- gtk_widget_show (viewport2);
- msg = g_strdup_printf(_("Decompressing tar file with %s, please wait...") , "lzma");
- Update_StatusBar ( msg );
- g_free (msg);
- }
-
/* Let's copy the archive to /tmp first */
- temp_name = g_strconcat ( " /tmp", g_strrstr (archive->escaped_path , "/"), NULL);
+ temp_name = g_strconcat (" /tmp",g_strrstr (archive->escaped_path,"/"),NULL);
command = g_strconcat ("cp -ar " ,archive->escaped_path,temp_name,NULL);
- if ( ! cli)
- result = xa_run_command (archive,command,0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
- command = g_strconcat ("lzma ", "-f -d ",temp_name,NULL);
- if ( ! cli )
- result = xa_run_command (archive,command,0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
+ _list = g_slist_append(_list,command);
+ command = g_strconcat ("lzma -f -d ",temp_name,NULL);
+ _list = g_slist_append(_list,command);
+
tar = g_find_program_in_path ("gtar");
if (tar == NULL)
tar = g_strdup ("tar");
l = strlen (temp_name);
- if (file_extension_is (archive->escaped_path,".tar.lzma") )
+ if (file_extension_is (archive->escaped_path,".tar.lzma"))
temp_name[l - 5] = 0;
- else if (file_extension_is (archive->escaped_path,".tlz") )
+ else if (file_extension_is (archive->escaped_path,".tlz"))
{
temp_name[l - 2] = 'a';
temp_name[l - 1] = 'r';
}
- if ( add )
+ if (add)
command = g_strconcat (tar, " ",
archive->add_recurse ? "" : "--no-recursion ",
archive->remove_files ? "--remove-files " : "",
@@ -211,50 +173,18 @@
temp_name,
list->str , NULL );
else
- command = g_strconcat (tar, " --delete -f " , temp_name , list->str , NULL );
- if ( ! cli)
- result = xa_run_command (archive,command,0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
+ command = g_strconcat (tar," --no-wildcards --delete -f ",temp_name,list->str,NULL);
g_free (tar);
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
+ _list = g_slist_append(_list,command);
- if ( ! cli )
- {
- msg = g_strdup_printf(_("Recompressing tar file with %s, please wait...") , "lzma");
- Update_StatusBar ( msg );
- g_free (msg);
- }
-
- command = g_strconcat ( "lzma ", "-f " , temp_name , NULL );
- if ( ! cli )
- result = xa_run_command (archive,command,0);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
-
- if (result == 0)
- {
- g_free (temp_name);
- return;
- }
+ command = g_strconcat ("lzma -f ",temp_name,NULL);
+ _list = g_slist_append(_list,command);
file_ext = ".lzma";
/* Let's move the modified archive from /tmp to the original archive location */
- command = g_strconcat ( "mv " , temp_name , file_ext, " " ,archive->escaped_path, NULL );
- if ( ! cli )
- result = xa_run_command (archive,command,1);
- else
- result = SpawnSyncCommand ( command );
- g_free (command);
+ command = g_strconcat ("mv ",temp_name,file_ext," ",archive->escaped_path,NULL);
+ _list = g_slist_append(_list,command);
+ result = xa_run_command (archive,_list);
g_free (temp_name);
-
- if (result == 0)
- return;
}
Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/main.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
*
* 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
@@ -24,7 +24,6 @@
#include "socket.h"
#endif
-gint exit_status;
gchar *cli_command = NULL;
gchar *absolute_path = NULL;
gchar *archive_name = NULL;
@@ -41,11 +40,11 @@
static GOptionEntry entries[] =
{
{ "extract-to", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_FILENAME, &extract_path,
- N_("Extract archive to the directory specified by destination_path and quits."),
- N_("destination_path archive")
+ N_("Extract archive to the destination directory and quits."),
+ N_("destination archive")
},
{ "extract", 'e', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &ask_and_extract,
- N_("Extract archive by asking the destination directory and quits."),
+ N_("Extract archive by asking the extraction directory and quits."),
N_("archive")
},
{ "add-to", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_FILENAME, &archive_name,
@@ -61,6 +60,7 @@
int main (int argc, char **argv)
{
+ XArchive *archive = NULL;
gboolean no_bzip2_gzip;
unsigned short int x;
#ifdef ENABLE_NLS
@@ -92,14 +92,17 @@
if (ask_and_extract || ask_and_add || archive_name != NULL || extract_path != NULL)
cli = TRUE;
+ xa_get_available_archivers();
+ prefs_window = xa_create_prefs_dialog();
+ xa_prefs_load_options(prefs_window);
+
if (cli == TRUE)
{
- xa_get_available_archivers();
- ArchiveSuffix = g_list_reverse (ArchiveSuffix);
- ArchiveType = g_list_reverse (ArchiveType);
MainWindow = NULL;
gtk_main_iteration_do (FALSE);
- g_print ("Xarchiver " VERSION " (\xC2\xA9)2005-2007 Giuseppe Torelli (colossus73)\n\n");
+ if (archive_name == NULL)
+ archive = xa_init_structure_from_cmd_line (argv[1]);
+ g_print ("Xarchiver " VERSION " (\xC2\xA9)2005-2008 Giuseppe Torelli\n");
/* Switch -x */
if (extract_path != NULL)
@@ -109,27 +112,26 @@
response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't extract files from the archive:"),_("You missed the archive name!\n"));
return 0;
}
- for ( x = 1; x < argc; x++)
+ for (x = 1; x < argc; x++)
{
- archive_cmd = xa_init_structure_from_cmd_line ( argv[x] );
- if (archive_cmd != NULL)
+ if (archive != NULL)
{
- if (archive_cmd->has_passwd)
+ if (archive->has_passwd)
{
- archive_cmd->passwd = password_dialog (archive_cmd);
- if (archive_cmd->passwd == NULL)
+ archive->passwd = password_dialog (archive);
+ if (archive->passwd == NULL)
goto done;
}
- GString *string = g_string_new ( "" );
- archive_cmd->full_path = 1;
- archive_cmd->overwrite = 1;
- gchar *escaped_path = xa_escape_bad_chars (extract_path , "$\'`\"\\!?* ()[]&|@#:;");
- archive_cmd->extraction_path = g_strdup (extract_path);
- cli_command = xa_extract_single_files ( archive_cmd , string, escaped_path );
+ GString *string = g_string_new ("");
+ archive->full_path = 1;
+ archive->overwrite = 1;
+ gchar *escaped_path = xa_escape_bad_chars (extract_path,"$\'`\"\\!?* ()[]&|@#:;");
+ 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 )
- error_output = SpawnSyncCommand ( cli_command );
- g_string_free (string, TRUE);
+ if (cli_command != NULL)
+ error_output = xa_spawn_sync_process (cli_command);
+ g_string_free (string,TRUE);
}
}
}
@@ -142,58 +144,56 @@
response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't extract files from the archive:"),_("You missed the archive name!\n"));
return 0;
}
- archive_cmd = xa_init_structure_from_cmd_line ( argv[1] );
- if (archive_cmd != NULL)
+ if (archive != NULL)
{
- extract_window = xa_create_extract_dialog ( 0 , archive_cmd);
- cli_command = xa_parse_extract_dialog_options ( archive_cmd , extract_window, NULL );
- gtk_widget_destroy ( extract_window->dialog1 );
- if ( cli_command != NULL )
- error_output = SpawnSyncCommand ( cli_command );
+ extract_window = xa_create_extract_dialog (0,archive);
+ cli_command = xa_parse_extract_dialog_options (archive,extract_window,NULL);
+ gtk_widget_destroy (extract_window->dialog1);
+ if (cli_command != NULL)
+ error_output = xa_spawn_sync_process (cli_command);
g_free (extract_window);
}
}
/* Switch -d */
else if (archive_name != NULL)
{
- XArchive *archive_cmd = NULL;
- if (argc > 1 || g_file_test ( archive_name,G_FILE_TEST_IS_DIR) )
+ if (argc > 1 || g_file_test (archive_name,G_FILE_TEST_IS_DIR))
no_bzip2_gzip = TRUE;
else
no_bzip2_gzip = FALSE;
- archive_cmd = xa_new_archive_dialog (archive_name, NULL, no_bzip2_gzip);
- if (archive_cmd == NULL)
+ archive = xa_new_archive_dialog (archive_name,NULL,no_bzip2_gzip);
+ if (archive == NULL)
return 0;
- if (archive_cmd->path != NULL)
+ if (archive->path != NULL)
{
_current_dir = g_path_get_dirname(archive_name);
chdir (_current_dir);
g_free (_current_dir);
- GString *string = g_string_new ( "" );
+ GString *string = g_string_new ("");
- if ( g_file_test ( archive_name,G_FILE_TEST_EXISTS) )
+ if (g_file_test (archive_name,G_FILE_TEST_EXISTS))
{
- _current_dir = g_path_get_basename (archive_name);
- xa_shell_quote_filename (_current_dir,string,archive_cmd);
+ _current_dir = g_path_get_basename(archive_name);
+ xa_shell_quote_filename(_current_dir,string,archive);
g_free (_current_dir);
}
for (x = 1; x< argc; x++)
{
- _current_dir = g_path_get_basename ( argv[x] );
- xa_shell_quote_filename (_current_dir,string,archive_cmd);
+ _current_dir = g_path_get_basename(argv[x]);
+ xa_shell_quote_filename(_current_dir,string,archive);
g_free (_current_dir);
}
- if ( archive_cmd->type == XARCHIVETYPE_7ZIP)
- archive_cmd->add_recurse = FALSE;
+ if (archive->type == XARCHIVETYPE_7ZIP)
+ archive->add_recurse = FALSE;
else
- archive_cmd->add_recurse = TRUE;
- cli_command = xa_add_single_files ( archive_cmd , string, NULL);
+ archive->add_recurse = TRUE;
+ cli_command = xa_add_single_files(archive,string,NULL);
if (cli_command != NULL)
- error_output = SpawnSyncCommand ( cli_command );
- g_string_free (string, TRUE);
+ error_output = xa_spawn_sync_process(cli_command);
+ g_string_free (string,TRUE);
}
if (cli_command != NULL)
g_free (cli_command);
@@ -206,33 +206,25 @@
response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't add files to the archive:"),_("You missed the archive name!\n"));
return 0;
}
- archive_cmd = xa_init_structure_from_cmd_line ( argv[1] );
- if (archive_cmd == NULL)
+ if (archive != NULL)
{
- add_window = xa_create_add_dialog (archive_cmd);
- cli_command = xa_parse_add_dialog_options ( archive_cmd, add_window );
- gtk_widget_destroy ( add_window->dialog1 );
+ add_window = xa_create_add_dialog (archive);
+ cli_command = xa_parse_add_dialog_options (archive, add_window);
+ gtk_widget_destroy (add_window->dialog1);
if (cli_command != NULL)
- error_output = SpawnSyncCommand ( cli_command );
+ error_output = xa_spawn_sync_process (cli_command);
g_free (add_window);
}
}
-done: g_list_free ( ArchiveSuffix);
- g_list_free ( ArchiveType);
- if (archive_cmd != NULL)
- xa_clean_archive_structure ( archive_cmd );
- return exit_status;
+done: g_list_free (ArchiveSuffix);
+ g_list_free (ArchiveType);
+ if (archive != NULL)
+ xa_clean_archive_structure (archive);
+ return 0;
}
else
{
- xa_get_available_archivers();
- ArchiveSuffix = g_list_reverse (ArchiveSuffix);
- ArchiveType = g_list_reverse (ArchiveType);
-
MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- prefs_window = xa_create_prefs_dialog();
- xa_prefs_load_options (prefs_window);
-
xa_create_mainwindow (MainWindow,gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs_window->show_location_bar)));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_save_geometry)) && prefs_window->geometry[0] != -1)
@@ -282,10 +274,8 @@
result = g_strdup(filename);
else
{
- //use current dir
gchar *cur_dir = g_get_current_dir();
- result = g_strjoin(
- G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
+ result = g_strjoin("/",cur_dir,filename,NULL);
g_free(cur_dir);
}
return result;
@@ -296,67 +286,67 @@
absolute_path = g_find_program_in_path("arj");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "arj");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.arj");
+ ArchiveType = g_list_append(ArchiveType, "arj");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.arj");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("bzip2");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "bz2");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.bz2");
+ ArchiveType = g_list_append (ArchiveType, "bz2");
+ ArchiveSuffix = g_list_append (ArchiveSuffix, "*.bz2");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("ar");
if ( absolute_path )
{
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.deb");
+ ArchiveSuffix = g_list_append (ArchiveSuffix, "*.deb");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("gzip");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "gz");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.gz");
+ ArchiveType = g_list_append(ArchiveType, "gz");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.gz");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("lzma");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "lzma");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.lzma");
+ ArchiveType = g_list_append(ArchiveType, "lzma");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.lzma");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("lha");
if (absolute_path)
{
- ArchiveType = g_list_prepend(ArchiveType, "lzh");
- ArchiveSuffix = g_list_prepend(ArchiveSuffix, "*.lzh");
+ ArchiveType = g_list_append(ArchiveType, "lzh");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.lzh");
g_free (absolute_path);
- //ArchiveType = g_list_prepend(ArchiveType, ".lha");
- //ArchiveSuffix = g_list_prepend(ArchiveSuffix, "");
+ //ArchiveType = g_list_append(ArchiveType, ".lha");
+ //ArchiveSuffix = g_list_append(ArchiveSuffix, "");
}
absolute_path = g_find_program_in_path ("rar");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "rar");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.rar");
+ ArchiveType = g_list_append(ArchiveType, "rar");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.rar");
g_free (absolute_path);
}
else
{
- absolute_path = g_find_program_in_path ("unrar");
+ 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");
+ ArchiveType = g_list_append(ArchiveType, "rar");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.rar");
g_free (absolute_path);
}
}
@@ -364,31 +354,31 @@
absolute_path = g_find_program_in_path("cpio");
if ( absolute_path )
{
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.rpm");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.rpm");
g_free (absolute_path);
}
absolute_path = g_find_program_in_path("tar");
if ( absolute_path )
{
- ArchiveType = g_list_prepend ( ArchiveType, "tar");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.tar");
+ ArchiveType = g_list_append(ArchiveType, "tar");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.tar");
g_free (absolute_path);
if ( g_list_find ( ArchiveType , "bz2") )
{
- ArchiveType = g_list_prepend ( ArchiveType, "tar.bz2");
+ ArchiveType = g_list_append(ArchiveType, "tar.bz2");
/* The following to avoid double filter when opening */
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "");
}
if ( g_list_find ( ArchiveType , "gz") )
{
- ArchiveType = g_list_prepend ( ArchiveType, "tar.gz");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.tgz");
+ ArchiveType = g_list_append(ArchiveType, "tar.gz");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.tgz");
}
if ( g_list_find ( ArchiveType , "lzma") )
{
- ArchiveType = g_list_prepend ( ArchiveType, "tar.lzma");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.tlz");
+ ArchiveType = g_list_append(ArchiveType, "tar.lzma");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.tlz");
}
}
@@ -400,11 +390,11 @@
if (absolute_path)
{
g_free (absolute_path);
- ArchiveType = g_list_prepend ( ArchiveType, "jar");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.jar");
+ ArchiveType = g_list_append(ArchiveType, "jar");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.jar");
- ArchiveType = g_list_prepend ( ArchiveType, "zip");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.zip");
+ ArchiveType = g_list_append(ArchiveType, "zip");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.zip");
}
}
absolute_path = g_find_program_in_path("7za");
@@ -415,76 +405,37 @@
if (absolute_path != NULL)
{
sevenzr = TRUE;
- ArchiveType = g_list_prepend ( ArchiveType, "7z");
- ArchiveSuffix = g_list_prepend ( ArchiveSuffix, "*.7z");
+ ArchiveType = g_list_append(ArchiveType, "7z");
+ ArchiveSuffix = g_list_append(ArchiveSuffix, "*.7z");
g_free (absolute_path);
}
}
-gboolean SpawnSyncCommand ( gchar *command )
-{
- GError *error = NULL;
- gchar *std_out;
- gchar *std_err;
- gchar **argv;
- int argcp;
-
- g_shell_parse_argv ( command , &argcp , &argv , NULL);
- if ( ! g_spawn_sync (
- NULL,
- argv,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL, //user data
- &std_out,
- &std_err,
- &exit_status,
- &error) )
- {
- response = xa_show_message_dialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("Can't spawn the command:"),error->message);
- g_error_free (error);
- g_strfreev ( argv );
- return FALSE;
- }
- if ( WIFEXITED (exit_status) )
- {
- if ( WEXITSTATUS (exit_status) )
- {
- response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("An error occurred!"),std_err );
- return FALSE;
- }
- }
- g_strfreev ( argv );
- return TRUE;
-}
-
XArchive *xa_init_structure_from_cmd_line (char *filename)
{
- XArchive *archive_cmd;
+ XArchive *archive;
XArchiveType type;
- type = xa_detect_archive_type ( filename );
+ type = xa_detect_archive_type (filename);
if (type == -2)
return NULL;
- archive_cmd = xa_init_archive_structure ();
- if (archive_cmd == NULL)
+ archive = xa_init_archive_structure ();
+ if (archive == NULL)
{
response = xa_show_message_dialog (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't allocate memory for the archive structure!"),"" );
return NULL;
}
- archive_cmd->path = g_strdup (filename);
- archive_cmd->escaped_path = xa_escape_bad_chars(filename , "$\'`\"\\!?* ()&|@#:;");
- archive_cmd->type = type;
+ archive->path = g_strdup (filename);
+ archive->escaped_path = xa_escape_bad_chars(filename , "$\'`\"\\!?* ()&|@#:;");
+ archive->type = type;
- if ( g_str_has_suffix ( archive_cmd->escaped_path , ".tar.bz2") || g_str_has_suffix ( archive_cmd->escaped_path , ".tar.bz") || g_str_has_suffix ( archive_cmd->escaped_path , ".tbz") || g_str_has_suffix ( archive_cmd->escaped_path , ".tbz2" ) )
- archive_cmd->type = XARCHIVETYPE_TAR_BZ2;
- else if ( g_str_has_suffix ( archive_cmd->escaped_path , ".tar.gz") || g_str_has_suffix ( archive_cmd->escaped_path , ".tgz") )
- archive_cmd->type = XARCHIVETYPE_TAR_GZ;
- else if ( g_str_has_suffix ( archive_cmd->escaped_path , ".tar.lzma") || g_str_has_suffix ( archive_cmd->escaped_path , ".tlz") )
- archive_cmd->type = XARCHIVETYPE_TAR_LZMA;
-
- return (archive_cmd);
+ 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" ) )
+ archive->type = XARCHIVETYPE_TAR_BZ2;
+ else if ( g_str_has_suffix ( archive->escaped_path , ".tar.gz") || g_str_has_suffix ( archive->escaped_path , ".tgz") )
+ archive->type = XARCHIVETYPE_TAR_GZ;
+ else if ( g_str_has_suffix ( archive->escaped_path , ".tar.lzma") || g_str_has_suffix ( archive->escaped_path , ".tlz") )
+ archive->type = XARCHIVETYPE_TAR_LZMA;
+ return (archive);
}
Modified: xarchiver/trunk/src/main.h
===================================================================
--- xarchiver/trunk/src/main.h 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/main.h 2007-12-21 11:15:26 UTC (rev 26498)
@@ -34,7 +34,6 @@
void xa_get_available_archivers();
gchar *config_file;
gchar *get_argv_filename(const gchar *filename);
-gboolean SpawnSyncCommand ( gchar *command );
XArchive *xa_init_structure_from_cmd_line (char *filename);
#endif /* MAIN_H */
Modified: xarchiver/trunk/src/new_dialog.c
===================================================================
--- xarchiver/trunk/src/new_dialog.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/new_dialog.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
*
* 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
@@ -25,10 +25,9 @@
#include "main.h"
extern gboolean unrar;
-extern gboolean cli;
extern Prefs_dialog_data *prefs_window;
gchar *current_new_directory = NULL;
-gint new_combo_box = -1;
+gint new_combo_box = -1;
gchar *ComboArchiveType;
XArchive *xa_new_archive_dialog (gchar *path, XArchive *archive_open[], gboolean flag)
@@ -105,15 +104,15 @@
|| (!strcmp(Name->data, "rar") && unrar) )
goto there;
else
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), Name->data );
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box),Name->data);
there:
- Name = g_list_next ( Name );
+ Name = g_list_next (Name);
}
if (new_combo_box == -1)
- gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box),gtk_combo_box_get_active(GTK_COMBO_BOX(prefs_window->combo_prefered_format)));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box),gtk_combo_box_get_active(GTK_COMBO_BOX(prefs_window->combo_prefered_format))-3);
else
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , new_combo_box );
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box),new_combo_box);
gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
@@ -155,7 +154,7 @@
}
}
- if ( ! cli )
+ if (MainWindow)
{
for (x = 0; x < gtk_notebook_get_n_pages ( notebook) ; x++)
{
@@ -205,6 +204,12 @@
if (strcmp ( ComboArchiveType,"arj") == 0)
archive->type = XARCHIVETYPE_ARJ;
+ else if (strcmp ( ComboArchiveType,"bz2") == 0)
+ archive->type = XARCHIVETYPE_BZIP2;
+ else if (strcmp ( ComboArchiveType,"gz") == 0)
+ archive->type = XARCHIVETYPE_GZIP;
+ else if (strcmp ( ComboArchiveType,"lzma") == 0)
+ archive->type = XARCHIVETYPE_LZMA;
else if (strcmp ( ComboArchiveType,"rar") == 0)
archive->type = XARCHIVETYPE_RAR;
else if (strcmp ( ComboArchiveType,"tar") == 0)
Modified: xarchiver/trunk/src/pref_dialog.c
===================================================================
--- xarchiver/trunk/src/pref_dialog.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/pref_dialog.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -49,8 +49,8 @@
gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow1, TRUE, TRUE, 6);
g_object_set (G_OBJECT (scrolledwindow1),"hscrollbar-policy", GTK_POLICY_NEVER,"shadow-type", GTK_SHADOW_IN,"vscrollbar-policy", GTK_POLICY_NEVER, NULL);
- prefs_data->prefs_liststore = gtk_list_store_new ( 3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT);
- gtk_list_store_append (prefs_data->prefs_liststore, &iter);
+ prefs_data->prefs_liststore = gtk_list_store_new (3,GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_UINT);
+ gtk_list_store_append (prefs_data->prefs_liststore,&iter);
gchar *pixbuf_file = g_strconcat(DATADIR,"/pixmaps/xarchiver-behaviour.svg",NULL);
icon_pixbuf = gdk_pixbuf_new_from_file (pixbuf_file,NULL);
g_free (pixbuf_file);
@@ -105,7 +105,7 @@
prefs_data->combo_prefered_format = gtk_combo_box_new_text();
gtk_box_pack_start (GTK_BOX (hbox1), prefs_data->combo_prefered_format, FALSE, TRUE, 0);
- archive_type = g_list_first ( ArchiveType );
+ archive_type = g_list_first (ArchiveType);
while ( archive_type != NULL )
{
if (archive_type->data == "tgz" || archive_type->data == "rpm" || (archive_type->data == "rar" && unrar) )
@@ -113,7 +113,7 @@
else
gtk_combo_box_append_text (GTK_COMBO_BOX (prefs_data->combo_prefered_format),archive_type->data );
next:
- archive_type = g_list_next ( archive_type );
+ archive_type = g_list_next (archive_type);
}
prefs_data->check_save_add_dialog = gtk_check_button_new_with_mnemonic (_("Save settings for add dialog"));
Modified: xarchiver/trunk/src/rpm.c
===================================================================
--- xarchiver/trunk/src/rpm.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/rpm.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -106,7 +106,7 @@
//Now I run dd to have the bzip2 / gzip compressed cpio archive in /tmp
gchar *command = g_strconcat ( "dd if=" , archive->escaped_path, " ibs=" , ibs , " skip=1 of=" , gzip_tmp , NULL );
g_free (ibs);
- result = xa_run_command (archive,command,0);
+ result = xa_run_command (archive,command);
g_free (command);
if (result == FALSE)
{
Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c 2007-12-20 23:49:14 UTC (rev 26497)
+++ xarchiver/trunk/src/window.c 2007-12-21 11:15:26 UTC (rev 26498)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Giuseppe Torelli - <colossus73 at gmail.com>
+ * Copyright (C) 2008 Giuseppe Torelli - <colossus73 at gmail.com>
* Copyright (C) 2006 Benedikt Meurer - <benny at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,6 @@
extern GList *ArchiveType;
extern GList *ArchiveSuffix;
-extern gboolean cli;
extern gboolean stop_flag;
extern gboolean unrar;
extern Prefs_dialog_data *prefs_window;
@@ -44,11 +43,9 @@
gboolean xa_check_child_for_error_on_exit(XArchive *archive,gint status)
{
- gtk_widget_set_sensitive(Stop_button,FALSE);
- gtk_widget_hide(viewport2);
if ( WIFEXITED (status) )
{
- if ( WEXITSTATUS (status) )
+ if (WEXITSTATUS (status))
{
xa_set_button_state (1,1,1,archive->can_add,archive->can_extract,0,archive->has_test,archive->has_properties);
Update_StatusBar ( _("Operation failed."));
@@ -71,7 +68,7 @@
void xa_reload_archive_content(XArchive *archive)
{
XEntry *entry;
- if (! cli)
+ if (MainWindow != NULL)
{
if (archive->type == XARCHIVETYPE_BZIP2 || archive->type == XARCHIVETYPE_GZIP || archive->type == XARCHIVETYPE_LZMA)
Update_StatusBar ( _("Operation completed."));
@@ -134,6 +131,8 @@
void xa_archive_operation_finished(XArchive *archive,gboolean error)
{
+ gtk_widget_set_sensitive(Stop_button,FALSE);
+ gtk_widget_hide(viewport2);
if (archive->status == XA_ARCHIVESTATUS_ADD || archive->status == XA_ARCHIVESTATUS_DELETE)
{
xa_reload_archive_content(archive);
@@ -196,7 +195,7 @@
else
xa_archive_operation_finished(archive,result);
- if (! cli && archive != NULL)
+ if ( MainWindow != NULL && archive != NULL)
{
if (archive->has_passwd == FALSE && archive->passwd == NULL)
gtk_widget_set_sensitive (password_entry,FALSE);
@@ -222,10 +221,10 @@
xa_set_button_state (1,1,1,1,0,0,0,0 );
archive[current_page]->has_passwd = FALSE;
- gtk_widget_set_sensitive ( view_shell_output1 , TRUE );
- gtk_widget_set_sensitive ( check_menu , FALSE);
- gtk_widget_set_sensitive ( properties , FALSE );
- xa_disable_delete_view_buttons (FALSE);
+ gtk_widget_set_sensitive(view_shell_output1,TRUE);
+ gtk_widget_set_sensitive(check_menu,FALSE);
+ gtk_widget_set_sensitive(properties,FALSE );
+ xa_disable_delete_view_buttons(FALSE);
Update_StatusBar ( _("Choose Add to begin creating the archive."));
@@ -236,7 +235,7 @@
xa_set_window_title (MainWindow , archive[current_page]->path );
}
-int xa_show_message_dialog ( GtkWindow *window, int mode,int type,int button, const gchar *message1,const gchar *message2)
+int xa_show_message_dialog (GtkWindow *window,int mode,int type,int button,const gchar *message1,const gchar *message2)
{
dialog = gtk_message_dialog_new (window, mode, type, button,message1);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
@@ -246,7 +245,7 @@
return response;
}
-void xa_open_archive (GtkMenuItem *menuitem, gpointer data)
+void xa_open_archive (GtkMenuItem *menuitem,gpointer data)
{
gchar *path = NULL;
gint current_page;
@@ -403,6 +402,7 @@
void xa_test_archive (GtkMenuItem *menuitem, gpointer user_data)
{
+ GSList *list = NULL;
gchar *command;
gchar *rar;
gint current_page;
@@ -465,8 +465,8 @@
command = NULL;
}
archive[id]->status = XA_ARCHIVESTATUS_TEST;
- xa_run_command (archive[id],command,1);
- g_free (command);
+ list = g_slist_append(list,command);
+ xa_run_command (archive[id],list);
}
void xa_close_archive (GtkMenuItem *menuitem, gpointer user_data)
@@ -541,6 +541,7 @@
void xa_delete_archive (GtkMenuItem *menuitem, gpointer user_data)
{
+ GSList *list = NULL;
gboolean result;
gchar *command = NULL;
gchar *tar;
@@ -572,59 +573,60 @@
switch (archive[id]->type)
{
case XARCHIVETYPE_RAR:
- command = g_strconcat ( "rar d " , archive[id]->escaped_path , names->str , NULL );
+ command = g_strconcat ("rar d ",archive[id]->escaped_path,names->str,NULL);
break;
- case XARCHIVETYPE_TAR:
- command = g_strconcat (tar, " --delete -vf " , archive[id]->escaped_path , names->str , NULL );
+ case XARCHIVETYPE_TAR:
+ command = g_strconcat (tar, " --delete -vf ",archive[id]->escaped_path,names->str,NULL);
break;
- case XARCHIVETYPE_TAR_BZ2:
- xa_add_delete_tar_bzip2_gzip ( names , archive[id] , 0 , 0 );
- break;
+ case XARCHIVETYPE_TAR_BZ2:
+ xa_add_delete_tar_bzip2_gzip (names,archive[id],0,0);
+ break;
- case XARCHIVETYPE_TAR_GZ:
- xa_add_delete_tar_bzip2_gzip ( names , archive[id] , 1 , 0 );
+ case XARCHIVETYPE_TAR_GZ:
+ xa_add_delete_tar_bzip2_gzip (names,archive[id],1,0);
break;
case XARCHIVETYPE_TAR_LZMA:
- xa_add_delete_tar_lzma ( names , archive[id] , 0 );
+ xa_add_delete_tar_lzma ( names , archive[id],0);
break;
- case XARCHIVETYPE_ZIP:
- command = g_strconcat ( "zip -d " , archive[id]->escaped_path , names->str , NULL );
+ case XARCHIVETYPE_ZIP:
+ command = g_strconcat ("zip -d ",archive[id]->escaped_path,names->str,NULL);
break;
- case XARCHIVETYPE_7ZIP:
- command = g_strconcat ( "7za d " , archive[id]->escaped_path , names->str , NULL );
- break;
+ case XARCHIVETYPE_7ZIP:
+ command = g_strconcat ("7za d ",archive[id]->escaped_path,names->str,NULL);
+ break;
- case XARCHIVETYPE_ARJ:
- command = g_strconcat ( "arj d " , archive[id]->escaped_path , names->str, NULL);
- break;
+ case XARCHIVETYPE_ARJ:
+ command = g_strconcat ("arj d ",archive[id]->escaped_path,names->str,NULL);
+ break;
case XARCHIVETYPE_LHA:
- command = g_strconcat("lha d ", archive[id]->escaped_path, names->str, NULL);
+ command = g_strconcat("lha d ",archive[id]->escaped_path, names->str,NULL);
break;
- default:
- break;
+ default:
+ break;
}
if (command != NULL)
{
- archive[id]->status = XA_ARCHIVESTATUS_DELETE;
- xa_set_button_state (0,0,0,0,0,0,0,0);
- gtk_widget_set_sensitive (Stop_button,TRUE);
- result = xa_run_command (archive[id],command,1);
- g_free (command);
- }
- g_string_free (names,TRUE);
- g_free (tar);
+ list = g_slist_append(list,command);
+ archive[id]->status = XA_ARCHIVESTATUS_DELETE;
+ xa_set_button_state (0,0,0,0,0,0,0,0);
+ gtk_widget_set_sensitive (Stop_button,TRUE);
+ result = xa_run_command (archive[id],list);
+ }
+ g_string_free (names,TRUE);
+ g_free (tar);
}
void xa_add_files_archive (GtkMenuItem *menuitem,gpointer data)
{
gchar *command = NULL;
+ GSList *list = NULL;
gint current_page;
gint idx;
@@ -636,50 +638,56 @@
gtk_widget_destroy (add_window->dialog1);
if (command != NULL)
{
+ gtk_widget_set_sensitive (Stop_button,TRUE);
+ gtk_widget_set_sensitive (check_menu,FALSE);
+ gtk_widget_set_sensitive (close1,FALSE);
+ gtk_widget_set_sensitive (properties,FALSE);
+ xa_set_button_state (0,0,0,0,0,0,0,0);
archive[idx]->status = XA_ARCHIVESTATUS_ADD;
- xa_run_command (archive[idx],command,1);
- g_free (command);
+ list = g_slist_append(list,command);
+ xa_run_command (archive[idx],list);
}
g_free (add_window);
add_window = NULL;
}
-void xa_extract_archive ( GtkMenuItem *menuitem , gpointer user_data )
+void xa_extract_archive (GtkMenuItem *menuitem,gpointer user_data)
{
gchar *command = NULL;
+ GSList *list = NULL;
gint current_page;
gint idx;
- current_page = gtk_notebook_get_current_page (notebook);
- idx = xa_find_archive_index ( current_page );
+ current_page = gtk_notebook_get_current_page(notebook);
+ idx = xa_find_archive_index (current_page);
- GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (archive[idx]->treeview) );
- gint selected = gtk_tree_selection_count_selected_rows ( selection );
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(archive[idx]->treeview));
+ gint selected = gtk_tree_selection_count_selected_rows (selection);
- extract_window = xa_create_extract_dialog (selected , archive[idx]);
+ extract_window = xa_create_extract_dialog (selected,archive[idx]);
if (archive[idx]->extraction_path != NULL)
gtk_entry_set_text (GTK_ENTRY(extract_window->destination_path_entry),archive[idx]->extraction_path);
- command = xa_parse_extract_dialog_options ( archive[idx] , extract_window, selection );
+ command = xa_parse_extract_dialog_options(archive[idx],extract_window,selection);
if (extract_window->dialog1 != NULL)
{
- gtk_widget_destroy ( extract_window->dialog1 );
+ gtk_widget_destroy (extract_window->dialog1);
extract_window->dialog1 = NULL;
}
if (command != NULL)
{
- gtk_widget_set_sensitive ( check_menu , FALSE);
- gtk_widget_set_sensitive ( properties , FALSE);
+ gtk_widget_set_sensitive (check_menu,FALSE);
+ gtk_widget_set_sensitive (properties,FALSE);
xa_set_button_state (0,0,0,0,0,0,0,0);
- xa_run_command (archive[idx],command,1);
- g_free (command);
+ list = g_slist_append(list,command);
+ xa_run_command (archive[idx],list);
}
g_free (extract_window);
extract_window = NULL;
}
-void xa_show_prefs_dialog ( GtkMenuItem *menuitem , gpointer user_data )
+void xa_show_prefs_dialog (GtkMenuItem *menuitem,gpointer user_data)
{
gboolean response;
@@ -697,6 +705,7 @@
void xa_convert_sfx ( GtkMenuItem *menuitem , gpointer user_data )
{
gchar *command = NULL;
+ GSList *list = NULL;
gboolean result;
unsigned short int l = 0;
gint current_page;
@@ -713,6 +722,7 @@
case XARCHIVETYPE_RAR:
{
command = g_strconcat ("rar s -o+ " , archive[idx]->escaped_path , NULL);
+ list = g_slist_append(list,command);
if (strstr(archive[idx]->escaped_path,".rar") )
{
archive[idx]->tmp = g_strdup (archive[idx]->escaped_path);
@@ -731,6 +741,7 @@
archive[idx]->tmp[l + 3] = 'x';
archive[idx]->tmp[l + 4] = 0;
}
+ result = xa_run_command(archive[idx],list);
}
break;
@@ -794,13 +805,10 @@
fclose (sfx_archive);
command = g_strconcat ("chmod 755 ", archive_name_escaped , NULL);
- result = xa_run_command (archive[idx],command,1);
- g_free (command);
-
+ list = g_slist_append(list,command);
command = g_strconcat ("zip -A ",archive_name_escaped,NULL);
- result = xa_run_command (archive[idx],command,1);
- g_free (command);
- command = NULL;
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive[idx],list);
}
g_free (archive_name);
g_free (archive_name_escaped);
@@ -895,18 +903,17 @@
g_free (content);
/* Read archive data and write it after the sfx module in the new file */
- while ( ! feof(archive_not_sfx) )
+ while ( ! feof(archive_not_sfx))
{
- fread (&buffer, 1, 1024, archive_not_sfx);
- fwrite (&buffer, 1, 1024, sfx_archive);
+ fread (&buffer,1,1024,archive_not_sfx);
+ fwrite (&buffer,1,1024,sfx_archive);
}
fclose (archive_not_sfx);
fclose (sfx_archive);
- command = g_strconcat ("chmod 755 ", archive_name_escaped , NULL);
- result = xa_run_command (archive[idx],command,1);
- g_free (command);
- command = NULL;
+ command = g_strconcat ("chmod 755 ",archive_name_escaped,NULL);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive[idx],list);
}
g_free (archive_name);
g_free (archive_name_escaped);
@@ -915,16 +922,13 @@
case XARCHIVETYPE_ARJ:
command = g_strconcat ("arj y -je1 " , archive[idx]->escaped_path, NULL);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive[idx],list);
break;
default:
command = NULL;
}
- if (command != NULL)
- {
- xa_run_command (archive[idx],command,1);
- g_free (command);
- }
}
void xa_about (GtkMenuItem *menuitem, gpointer user_data)
@@ -1080,7 +1084,7 @@
if (dummy_ptr == NULL)
{
- if ( !cli )
+ if (MainWindow != NULL)
{
gchar *utf8_path,*msg;
utf8_path = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
@@ -1358,6 +1362,7 @@
gchar *editor_path;
GString *names = g_string_new("");
GList *row_list = NULL;
+ GSList *list = NULL;
gboolean result = FALSE;
gint current_page;
gint idx;
@@ -1419,8 +1424,8 @@
archive[idx]->overwrite = overwrite;
if (command != NULL)
{
- result = xa_run_command (archive[idx],command,0);
- g_free (command);
+ list = g_slist_append(list,command);
+ result = xa_run_command (archive[idx],list);
if (result == 0)
return;
}
@@ -1447,7 +1452,6 @@
current_page = gtk_notebook_get_current_page (notebook);
idx = xa_find_archive_index (current_page);
-
stat (archive[idx]->path , &my_stat );
file_size = my_stat.st_size;
archive_properties_win = create_archive_properties_window();
@@ -1653,7 +1657,9 @@
void Update_StatusBar (gchar *msg)
{
- gtk_label_set_text (GTK_LABEL (info_label), msg);
+ if (MainWindow == NULL)
+ return;
+ gtk_label_set_text (GTK_LABEL(info_label),msg);
}
void xa_disable_delete_view_buttons (gboolean value)
@@ -1710,7 +1716,8 @@
int fm_path_len;
gchar *command , *no_uri_path;
gchar *to_send = "E";
- GList *row_list;
+ GList *row_list = NULL;
+ GSList *list = NULL;
GString *names;
gint current_page;
gint idx;
@@ -1773,9 +1780,8 @@
if ( command != NULL )
{
archive[idx]->status = XA_ARCHIVESTATUS_EXTRACT;
- //TODO if 1 or 0?
- xa_run_command (archive[idx],command,1);
- g_free (command);
+ list = g_slist_append(list,command);
+ xa_run_command (archive[idx],list);
}
archive[idx]->full_path = full_path;
archive[idx]->overwrite = overwrite;
@@ -1794,6 +1800,7 @@
void on_drag_data_received (GtkWidget *widget,GdkDragContext *context, int x,int y,GtkSelectionData *data, unsigned int info, unsigned int time, gpointer user_data)
{
+ GSList *list = NULL;
gchar **array = NULL;
gchar *filename = NULL;
gchar *command = NULL;
@@ -1884,7 +1891,7 @@
archive[idx]->full_path = 0;
archive[idx]->add_recurse = 1;
- command = xa_add_single_files ( archive[idx], names, NULL );
+ command = xa_add_single_files (archive[idx],names,NULL);
archive[idx]->has_passwd = dummy_password;
archive[idx]->full_path = full_path;
@@ -1892,12 +1899,12 @@
if (command != NULL)
{
- gtk_widget_set_sensitive ( Stop_button , TRUE);
- gtk_widget_set_sensitive ( check_menu , FALSE);
- gtk_widget_set_sensitive ( properties , FALSE);
+ gtk_widget_set_sensitive(Stop_button,TRUE);
+ gtk_widget_set_sensitive(check_menu,FALSE);
+ gtk_widget_set_sensitive(properties,FALSE);
xa_set_button_state (0,0,0,0,0,0,0,0);
- xa_run_command (archive[idx],command,1);
- g_free (command);
+ list = g_slist_append(list,command);
+ xa_run_command (archive[idx],list);
}
g_string_free (names, TRUE);
g_strfreev ( array );
More information about the Xfce4-commits
mailing list