Author: colossus
Date: 2006-07-03 11:03:40 +0000 (Mon, 03 Jul 2006)
New Revision: 22246

Modified:
   xarchiver/trunk/Makefile.am
   xarchiver/trunk/src/add_dialog.c
   xarchiver/trunk/src/archive.h
   xarchiver/trunk/src/bzip2.c
   xarchiver/trunk/src/callbacks.c
   xarchiver/trunk/src/extract_dialog.c
   xarchiver/trunk/src/gzip.c
   xarchiver/trunk/src/rpm.c
   xarchiver/trunk/src/tar.c
   xarchiver/trunk/src/zip.c
   xarchiver/trunk/xarchiver.desktop.in
Log:
Applied patch from Benny to detect gtar also, for GIOChannels and for 
xarchiver.tap thunar plugin.


Modified: xarchiver/trunk/Makefile.am
===================================================================
--- xarchiver/trunk/Makefile.am 2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/Makefile.am 2006-07-03 11:03:40 UTC (rev 22246)
@@ -5,6 +5,9 @@
 pixmapsdir       = $(datadir)/pixmaps
 pixmaps_DATA     = xarchiver.png
 
+wrapperdir = $(libexecdir)/thunar-archive-plugin/
+wrapper_SCRIPTS = xarchiver.tap
+
 desktopdir = $(datadir)/applications
 desktop_in_files = xarchiver.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@@ -18,7 +21,8 @@
        intltool-merge.in \
        intltool-update.in \
        $(desktop_in_files) \
-       $(pixmaps_DATA)
+       $(pixmaps_DATA) \
+       $(wrapper_DATA)
 
 install-data-local:
        @$(NORMAL_INSTALL)

Modified: xarchiver/trunk/src/add_dialog.c
===================================================================
--- xarchiver/trunk/src/add_dialog.c    2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/add_dialog.c    2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -569,7 +570,12 @@
 gchar *xa_add_single_files ( XArchive *archive , GString *names, gchar 
*compression_string)
 {
        gchar *command = NULL;
+       gchar *tar;
 
+       tar = g_find_program_in_path ("gtar");
+       if (tar == NULL)
+               tar = g_strdup ("tar");
+
        switch (archive->type)
        {
                case XARCHIVETYPE_BZIP2:
@@ -614,14 +620,14 @@
 
                case XARCHIVETYPE_TAR:
                if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) 
)
-                       command = g_strconcat ( "tar ",
+                       command = g_strconcat (tar, " ",
                                                                        
archive->add_recurse ? "" : "--no-recursion ",
                                                                        
archive->remove_files ? "--remove-files " : "",
                                                                        
archive->update ? "-uvvf " : "-rvvf ",
                                                                        
archive->escaped_path,
                                                                        
names->str , NULL );
                else
-                       command = g_strconcat ( "tar ",
+                       command = g_strconcat (tar, " ",
                                                                        
archive->add_recurse ? "" : "--no-recursion ",
                                                                        
archive->remove_files ? "--remove-files " : "",
                                                                        "-cvvf 
",archive->escaped_path,
@@ -632,7 +638,7 @@
                if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) 
)
                        DecompressBzipGzip ( names , archive, 0 , 1 );
                else
-                       command = g_strconcat ( "tar ",
+                       command = g_strconcat (tar, " ",
                                                                        
archive->add_recurse ? "" : "--no-recursion ",
                                                                        
archive->remove_files ? "--remove-files " : "",
                                                                        "-cvvjf 
",archive->escaped_path,
@@ -643,7 +649,7 @@
                if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) 
)
                        DecompressBzipGzip ( names , archive, 1 , 1 );
                else
-                       command = g_strconcat ( "tar ",
+                       command = g_strconcat (tar, " ",
                                                                        
archive->add_recurse ? "" : "--no-recursion ",
                                                                        
archive->remove_files ? "--remove-files " : "",
                                                                        "-cvvzf 
",archive->escaped_path,
@@ -728,6 +734,7 @@
                default:
                command = NULL;            
        }
+       g_free (tar);
        return command;
 }
 

Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h       2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/archive.h       2006-07-03 11:03:40 UTC (rev 22246)
@@ -81,6 +81,6 @@
 gint input_fd, output_fd, error_fd;
 void SpawnAsyncProcess (XArchive *archive, gchar *command , gboolean input, 
gboolean output_flag);
 XArchive *xa_init_archive_structure ();
-void xa_clean_archive_structure ( XArchive *archive);
+void xa_clean_archive_structure (XArchive *archive);
 XArchive *archive;
 #endif

Modified: xarchiver/trunk/src/bzip2.c
===================================================================
--- xarchiver/trunk/src/bzip2.c 2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/bzip2.c 2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -32,13 +33,24 @@
 {
     if ( g_str_has_suffix ( archive->escaped_path , ".tar.bz2") || 
g_str_has_suffix ( archive->escaped_path , ".tar.bz") || g_str_has_suffix ( 
archive->escaped_path , ".tbz") || g_str_has_suffix ( archive->escaped_path , 
".tbz2" ) )
        {
-           gchar *command = g_strconcat ("tar tfjv " , archive->escaped_path, 
NULL );
-               archive->dummy_size = 0;
+         gchar *command;
+    gchar *tar;
+    
+    tar = g_find_program_in_path ("gtar");
+    if (tar == NULL)
+      tar = g_strdup ("tar");
+
+    command = g_strconcat (tar, " tfjv " , archive->escaped_path, NULL );
+         archive->dummy_size = 0;
                archive->nr_of_files = 0;
                archive->nr_of_dirs = 0;
                archive->parse_output = TarOpen;
+
                SpawnAsyncProcess ( archive , command , 0, 0);
-               g_free ( command );
+
+               g_free (command);
+               g_free (tar);
+
                if ( archive->child_pid == 0 )
                        return;
 
@@ -165,24 +177,34 @@
        FILE *stream = data;
        gchar buffer[65536];
        gsize bytes_read;
+  GIOStatus status;
        GError *error = NULL;
 
        if (cond & (G_IO_IN | G_IO_PRI) )
        {
-               while (gtk_events_pending() )
-                       gtk_main_iteration();
-               if ( g_io_channel_read_chars ( ioc, buffer, sizeof(buffer), 
&bytes_read, &error ) != G_IO_STATUS_NORMAL )
-               {
-                       response = ShowGtkMessageDialog (GTK_WINDOW 
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, error->message);
-                       g_error_free (error);
-                       return FALSE;
-               }
-               //Write the content of the bzip/gzip extracted file to the file 
pointed by the file stream
-               fwrite ( buffer, 1 , bytes_read , stream );
-               return TRUE;
+    do
+    {
+                 status = g_io_channel_read_chars (ioc, buffer, 
sizeof(buffer), &bytes_read, &error);
+      if (bytes_read > 0)
+      {
+                   //Write the content of the bzip/gzip extracted file to the 
file pointed by the file stream
+                   fwrite (buffer, 1, bytes_read, stream);
+      }
+      else if (error != NULL)
+      {
+        response = ShowGtkMessageDialog (GTK_WINDOW 
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, error->message);
+        g_error_free (error);
+        return FALSE;
+      }
+    }
+    while (status == G_IO_STATUS_NORMAL);
+
+    if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
+      goto done;
        }
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
+done:
                fclose ( stream );
                g_io_channel_shutdown ( ioc,TRUE,NULL );
                g_io_channel_unref (ioc);
@@ -193,7 +215,7 @@
 
 void DecompressBzipGzip ( GString *list , XArchive *archive , gboolean dummy , 
gboolean add )
 {
-       gchar *command, *msg;
+       gchar *command, *msg, *tar;
        int status;
        gboolean waiting = TRUE;
        int ps;
@@ -231,19 +253,31 @@
                        return;
                }
        }
+  tar = g_find_program_in_path ("gtar");
+  if (tar == NULL)
+    tar = g_strdup ("tar");
+
        if ( add )
-               command = g_strconcat ( "tar ",
+  {
+               command = g_strconcat (tar, " ",
                                                                
archive->add_recurse ? "" : "--no-recursion ",
                                                                
archive->remove_files ? "--remove-files " : "",
                                                                archive->update 
? "-uvvf " : "-rvvf ",
                                                                tmp,
                                                                list->str , 
NULL );
-    else
-               command = g_strconcat ( "tar --delete -f " , tmp , list->str , 
NULL );
+  }
+  else
+  {
+               command = g_strconcat (tar, " --delete -f " , tmp , list->str , 
NULL );
+  }
        waiting = TRUE;
        archive->parse_output = 0;
+
        SpawnAsyncProcess ( archive , command , 0, 0);
-       g_free ( command );
+
+       g_free (command);
+  g_free (tar);
+
        if ( archive->child_pid == 0 )
        {
                unlink ( tmp );

Modified: xarchiver/trunk/src/callbacks.c
===================================================================
--- xarchiver/trunk/src/callbacks.c     2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/callbacks.c     2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -431,38 +432,23 @@
     }
     g_list_free ( Suffix );
        g_list_free ( Name );
-       if (archive != NULL)
-       {
-               if (archive->path)
-                       g_free(archive->path);
+       xa_clean_archive_structure (archive);
 
-               if (archive->escaped_path)
-                       g_free(archive->escaped_path);
-
-               if (archive->tmp)
-               {
-                       unlink (archive->tmp);
-                       g_free(archive->tmp);
-               }
-
-               if (archive->passwd)
-                       g_free(archive->passwd);
-               g_free (archive);
-       }
-
        if ( extract_path != NULL )
-    {
-        if ( strcmp (extract_path,"/tmp/") != 0)
+       {
+               if ( strcmp (extract_path , "/tmp/") != 0)
                        g_free (extract_path);
-        g_free (destination_path);
-    }
-    gtk_main_quit();
+               if ( destination_path != NULL )
+                       g_free (destination_path);
+       }
+       gtk_main_quit();
 }
 
 void xa_delete_archive (GtkMenuItem *menuitem, gpointer user_data)
 {
        gchar *command = NULL;
-    gchar *numbers;
+  gchar *numbers;
+  gchar *tar;
        gint x;
 
        GtkTreeSelection *selection = gtk_tree_view_get_selection ( 
GTK_TREE_VIEW (treeview1) );
@@ -479,6 +465,10 @@
     Update_StatusBar ( _("Deleting files from the archive, please wait..."));
        archive->status = XA_ARCHIVESTATUS_DELETE;
 
+       tar = g_find_program_in_path ("gtar");
+       if (tar == NULL)
+               tar = g_strdup ("tar");
+
        switch (archive->type)
        {
                case XARCHIVETYPE_RAR:
@@ -486,7 +476,7 @@
                break;
 
         case XARCHIVETYPE_TAR:
-               command = g_strconcat ( "tar --delete -vf " , 
archive->escaped_path , names->str , NULL );
+               command = g_strconcat (tar, " --delete -vf " , 
archive->escaped_path , names->str , NULL );
                break;
 
         case XARCHIVETYPE_TAR_BZ2:
@@ -518,6 +508,7 @@
         g_free (command);
     }
     g_string_free (names , TRUE );
+    g_free (tar);
 }
 
 void xa_add_files_archive ( GtkMenuItem *menuitem, gpointer data )
@@ -656,7 +647,7 @@
        {
                title = _("Create a new archive");
                flag = GTK_FILE_CHOOSER_ACTION_SAVE;
-               flag2 = "gtk-new";
+               flag2 = _("Cr_eate");
        }
        else if ( mode == "open" )
        {
@@ -1157,18 +1148,21 @@
                        g_free ( string );
        }
        g_free (data);
-    view_window = view_win();
+       view_window = view_win();
        ioc_view = g_io_channel_new_file ( filename , "r" , &error );
-    if (error == NULL)
-    {
-        g_io_channel_set_encoding (ioc_view, locale , NULL);
-        g_io_channel_set_flags ( ioc_view , G_IO_FLAG_NONBLOCK , NULL );
-        g_io_channel_read_to_end ( ioc_view , &line , NULL, NULL );
-        gtk_text_buffer_get_end_iter ( viewtextbuf, &viewenditer );
-        gtk_text_buffer_insert (viewtextbuf, &viewenditer, line, strlen ( line 
) );
-        g_free ( line );
-        g_io_channel_shutdown ( ioc_view , TRUE , NULL );
-        g_io_channel_unref (ioc_view);
+       if (error == NULL)
+       {
+               g_io_channel_set_encoding (ioc_view, locale , NULL);
+               g_io_channel_set_flags ( ioc_view , G_IO_FLAG_NONBLOCK , NULL );
+               g_io_channel_read_to_end ( ioc_view , &line , NULL, NULL );
+               gtk_text_buffer_get_end_iter ( viewtextbuf, &viewenditer );
+               if (line != NULL)
+               {
+                       gtk_text_buffer_insert (viewtextbuf, &viewenditer, 
line, strlen ( line ) );
+                       g_free ( line );
+               }
+               g_io_channel_shutdown ( ioc_view , TRUE , NULL );
+               g_io_channel_unref (ioc_view);
        }
        else
        {
@@ -1443,24 +1437,30 @@
 
 gboolean xa_report_child_stderr (GIOChannel *ioc, GIOCondition cond, gpointer 
data)
 {
-       if (cond & (G_IO_IN | G_IO_PRI) )
-       {
-               gchar *line = NULL;
-               g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL );
-               while (gtk_events_pending() )
-                       gtk_main_iteration();
-               if (line == NULL)
-                       return TRUE;
+  GIOStatus status;
+  gchar     buffer[4096];
+  gsize     bytes_read;
 
-               gtk_text_buffer_insert (textbuf, &enditer, line, strlen ( line 
) );
-               //gtk_text_buffer_insert_with_tags_by_name (textbuf, &enditer, 
line , -1, "red_foreground", NULL);
-               g_free (line);
-               return TRUE;
-       }
+  if (cond & (G_IO_IN | G_IO_PRI))
+  {
+    do
+    {
+      status = g_io_channel_read_chars (ioc, buffer, sizeof (buffer), 
&bytes_read, NULL);
+      if (bytes_read > 0)
+      {
+        gtk_text_buffer_insert (textbuf, &enditer, buffer, bytes_read);
+      }
+    }
+    while (status == G_IO_STATUS_NORMAL);
+
+    if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
+      goto done;
+  }
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
-               g_io_channel_shutdown ( ioc,TRUE,NULL );
-        g_io_channel_unref (ioc);
+done:
+               g_io_channel_shutdown (ioc, TRUE, NULL);
+    g_io_channel_unref (ioc);
                return FALSE;
        }
        return TRUE;
@@ -1654,7 +1654,10 @@
                gtk_selection_data_set (selection_data, selection_data->target, 
8, (guchar*)to_send, 1);
        }
        if (extract_path != NULL)
+       {
                g_free (extract_path);
+               extract_path = NULL;
+       }
        g_list_foreach (row_list, (GFunc) gtk_tree_path_free, NULL);
        g_list_free (row_list);
        g_string_free (names, TRUE);

Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c        2006-07-02 19:35:59 UTC (rev 
22245)
+++ xarchiver/trunk/src/extract_dialog.c        2006-07-03 11:03:40 UTC (rev 
22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -306,6 +307,7 @@
 {
        gchar *command = NULL;
        gchar *name = NULL;
+       gchar *tar;
        gchar *destination_path = NULL;
        gboolean done = FALSE;
        unsigned long long int file_size, file_offset;
@@ -396,6 +398,9 @@
                                Update_StatusBar ( text );
                                g_free (text);
                                g_free (destination_path);
+        tar = g_find_program_in_path ("gtar");
+        if (tar == NULL)
+          tar = g_strdup ("tar");
                                switch ( archive->type )
                                {
                                        case XARCHIVETYPE_RAR:
@@ -415,7 +420,7 @@
                                        break;
 
                                        case XARCHIVETYPE_TAR:
-                                       command = g_strconcat ( "tar 
",archive->full_path ? "" : strip_string,
+                                       command = g_strconcat (tar, " 
",archive->full_path ? "" : strip_string,
                                                                                
        "-xvf ", archive->escaped_path,
                                                                                
        archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                                
        archive->tar_touch ? " --touch" : "",
@@ -423,7 +428,7 @@
                                        break;
 
                                        case XARCHIVETYPE_TAR_BZ2:
-                                       command = g_strconcat ( "tar 
",archive->full_path ? "" : strip_string,
+                                       command = g_strconcat (tar, " 
",archive->full_path ? "" : strip_string,
                                                                                
        "-xvjf " , archive->escaped_path,
                                                                                
        archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                                
        archive->tar_touch ? " --touch" : "",
@@ -431,7 +436,7 @@
                                        break;
 
                                        case XARCHIVETYPE_TAR_GZ:
-                                       command = g_strconcat ( "tar 
",archive->full_path ? "" : strip_string,
+                                       command = g_strconcat (tar, " 
",archive->full_path ? "" : strip_string,
                                                                                
        "-xvzf " , archive->escaped_path,
                                                                                
        archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                                
        archive->tar_touch ? " --touch" : "",
@@ -514,6 +519,7 @@
                                        default:
                                        command = NULL;
                                }
+        g_free (tar);
                                if ( command != NULL )
                                        return command;
                        }
@@ -563,6 +569,7 @@
 gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar 
*path)
 {
        gchar *command;
+       gchar *tar;
 
        if ( archive->full_path == 0)
        {
@@ -576,6 +583,9 @@
        gchar *msg = g_strconcat ( _("Extracting files to ") , path, NULL);
        Update_StatusBar (msg);
        g_free (msg);
+       tar = g_find_program_in_path ("gtar");
+       if (tar == NULL)
+               tar = g_strdup ("tar");
        switch (archive->type)
        {
                case XARCHIVETYPE_RAR:
@@ -595,7 +605,7 @@
                break;
 
                case XARCHIVETYPE_TAR:
-           command = g_strconcat ( "tar ",archive->full_path ? "" : 
strip_string,
+           command = g_strconcat (tar, " ",archive->full_path ? "" : 
strip_string,
                                                                "-xvf " , 
archive->escaped_path,
                                                                
archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                
archive->tar_touch ? " --touch" : "",
@@ -603,7 +613,7 @@
                break;
 
                case XARCHIVETYPE_TAR_BZ2:
-               command = g_strconcat ( "tar ",archive->full_path ? "" : 
strip_string,
+               command = g_strconcat (tar, " ",archive->full_path ? "" : 
strip_string,
                                                                "-xjvf " , 
archive->escaped_path,
                                                                
archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                
archive->tar_touch ? " --touch" : "",
@@ -611,7 +621,7 @@
                break;
 
                case XARCHIVETYPE_TAR_GZ:
-        command = g_strconcat ( "tar ",archive->full_path ? "" : strip_string,
+        command = g_strconcat (tar, " ",archive->full_path ? "" : strip_string,
                                                                "-xzvf " , 
archive->escaped_path,
                                                                
archive->overwrite ? " --overwrite" : " --keep-old-files",
                                                                
archive->tar_touch ? " --touch" : "",
@@ -675,6 +685,7 @@
         default:
                        command = NULL;
     }
+       g_free (tar);
     if ( strip_string != NULL)
        {
                g_free ( strip_string );

Modified: xarchiver/trunk/src/gzip.c
===================================================================
--- xarchiver/trunk/src/gzip.c  2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/gzip.c  2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -26,13 +27,24 @@
 {
        if ( g_str_has_suffix ( archive->escaped_path , ".tar.gz") || 
g_str_has_suffix ( archive->escaped_path , ".tgz") )
        {
-        gchar *command = g_strconcat ("tar tfzv " , archive->escaped_path, 
NULL );
-               archive->dummy_size = 0;
+    gchar *command;
+    gchar *tar;
+
+    tar = g_find_program_in_path ("gtar");
+    if (tar == NULL)
+      tar = g_strdup ("tar");
+    
+    command = g_strconcat (tar, " tzvf " , archive->escaped_path, NULL );
+         archive->dummy_size = 0;
                archive->nr_of_files = 0;
                archive->nr_of_dirs = 0;
                archive->parse_output = TarOpen;
+
                SpawnAsyncProcess ( archive , command , 0, 0);
-               g_free ( command );
+
+               g_free (command);
+               g_free (tar);
+
                if ( archive->child_pid == 0 )
                        return;
 

Modified: xarchiver/trunk/src/rpm.c
===================================================================
--- xarchiver/trunk/src/rpm.c   2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/rpm.c   2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -130,6 +131,7 @@
                g_child_watch_add ( archive->child_pid , (GChildWatchFunc) 
OpenCPIO , gzip );
     else
                return FALSE;
+    return NULL;
 }
 
 GChildWatchFunc *OpenCPIO (GPid pid , gint exit_code , gpointer data)
@@ -181,6 +183,7 @@
        g_io_channel_set_flags ( ioc_cpio , G_IO_FLAG_NONBLOCK , NULL );
 
        g_child_watch_add ( archive->child_pid, (GChildWatchFunc) 
xa_watch_child, archive);
+  return NULL;
 }
 
 /* input pipe */
@@ -224,6 +227,7 @@
                        return FALSE;
                }
        }
+  return TRUE;
 }
 
 /* output pipe */
@@ -240,84 +244,92 @@
        GValue *hard_link = NULL;
        GValue *owner = NULL;
        GValue *group = NULL;
+  GIOStatus status;
 
     /* Is there output from "cpio -tv" to read ? */
        if (cond & (G_IO_IN | G_IO_PRI) )
        {
-               g_io_channel_read_line ( ioc, &line, NULL, NULL , NULL );
-               if (line == NULL)
-                       return TRUE;
+    do
+    {
+      status = g_io_channel_read_line ( ioc, &line, NULL, NULL , NULL );
+      if (line == NULL)
+        break;
 
-               filename    = g_new0(GValue, 1);
-               permissions = g_new0(GValue, 1);
-               owner       = g_new0(GValue, 1);
-               group       = g_new0(GValue, 1);
-               size        = g_new0(GValue, 1);
-               hard_link   = g_new0(GValue, 1);
+      filename    = g_new0(GValue, 1);
+      permissions = g_new0(GValue, 1);
+      owner       = g_new0(GValue, 1);
+      group       = g_new0(GValue, 1);
+      size        = g_new0(GValue, 1);
+      hard_link   = g_new0(GValue, 1);
 
-               start = eat_spaces (line);
-               end = strchr (start, ' ');
-               permissions = g_value_init(permissions, G_TYPE_STRING);
-               g_value_set_string ( permissions , g_strndup ( start , end - 
start) );
+      start = eat_spaces (line);
+      end = strchr (start, ' ');
+      permissions = g_value_init(permissions, G_TYPE_STRING);
+      g_value_set_string ( permissions , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               hard_link = g_value_init (hard_link, G_TYPE_STRING);
-               g_value_set_string ( hard_link , g_strndup ( start , end - 
start) );
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      hard_link = g_value_init (hard_link, G_TYPE_STRING);
+      g_value_set_string ( hard_link , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               owner = g_value_init (owner, G_TYPE_STRING);
-               g_value_set_string ( owner , g_strndup ( start , end - start) );
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      owner = g_value_init (owner, G_TYPE_STRING);
+      g_value_set_string ( owner , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               group = g_value_init (group, G_TYPE_STRING);
-               g_value_set_string ( group , g_strndup ( start , end - start) );
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      group = g_value_init (group, G_TYPE_STRING);
+      g_value_set_string ( group , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               size = g_value_init(size, G_TYPE_UINT64);
-               _size  = g_strndup ( start , end - start);
-               g_value_set_uint64 (size , atoll (_size) );
-               g_free (_size);
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      size = g_value_init(size, G_TYPE_UINT64);
+      _size  = g_strndup ( start , end - start);
+      g_value_set_uint64 (size , atoll (_size) );
+      g_free (_size);
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
 
-               start = eat_spaces (end);
-               end = strchr (start, '\n');
-               filename = g_value_init (filename, G_TYPE_STRING);
-               g_value_set_string ( filename , g_strndup ( start , end - 
start) );
+      start = eat_spaces (end);
+      end = strchr (start, '\n');
+      filename = g_value_init (filename, G_TYPE_STRING);
+      g_value_set_string ( filename , g_strndup ( start , end - start) );
 
-               archive->row = g_list_prepend (archive->row,filename);
-               archive->row = g_list_prepend (archive->row,permissions);
-               archive->row = g_list_prepend (archive->row,hard_link);
-               archive->row = g_list_prepend (archive->row,owner);
-               archive->row = g_list_prepend (archive->row,group);
-               archive->row = g_list_prepend (archive->row,size);
+      archive->row = g_list_prepend (archive->row,filename);
+      archive->row = g_list_prepend (archive->row,permissions);
+      archive->row = g_list_prepend (archive->row,hard_link);
+      archive->row = g_list_prepend (archive->row,owner);
+      archive->row = g_list_prepend (archive->row,group);
+      archive->row = g_list_prepend (archive->row,size);
 
-        if (  g_str_has_prefix (g_value_get_string (permissions) , "d") == 
FALSE)
+               if (  g_str_has_prefix (g_value_get_string (permissions) , "d") 
== FALSE)
                        archive->nr_of_files++;
         else
                        archive->nr_of_dirs++;
                archive->dummy_size += g_value_get_uint64 (size);
 
-               g_free (line);
-               archive->row_cnt++;
-               if (archive->row_cnt > 99)
-               {
-                       xa_append_rows ( archive , 6 );
-                       archive->row_cnt = 0;
-               }
-               return TRUE;
+      g_free (line);
+      archive->row_cnt++;
+      if (archive->row_cnt > 99)
+      {
+        xa_append_rows ( archive , 6 );
+        archive->row_cnt = 0;
+      }
+    }
+    while (status == G_IO_STATUS_NORMAL);
+
+    if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
+      goto done;
        }
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
+done:
                g_io_channel_shutdown ( ioc,TRUE,NULL );
                g_io_channel_unref (ioc);
                xa_append_rows ( archive , 6 );

Modified: xarchiver/trunk/src/tar.c
===================================================================
--- xarchiver/trunk/src/tar.c   2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/tar.c   2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,6 +1,7 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
  *  Copyright (C) 2006 Stephan Arts - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -21,14 +22,25 @@
  
 void OpenTar ( XArchive *archive )
 {
-       gchar *command = g_strconcat ( "tar tfv " , archive->escaped_path, NULL 
);
+       gchar *command;
+  gchar *tar;
+  
+  tar = g_find_program_in_path ("gtar");
+  if (tar == NULL)
+    tar = g_strdup ("tar");
+
+  command = g_strconcat (tar, " tfv " , archive->escaped_path, NULL);
        archive->dummy_size = 0;
-    archive->nr_of_files = 0;
-    archive->nr_of_dirs = 0;
+  archive->nr_of_files = 0;
+  archive->nr_of_dirs = 0;
        archive->parse_output = TarOpen;
+
        SpawnAsyncProcess ( archive , command , 0, 0);
-       g_free ( command );
-       if ( archive->child_pid == 0 )
+
+       g_free (command);
+       g_free (tar);
+
+       if (archive->child_pid == 0)
                return;
 
        char *names[]= 
{(_("Filename")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"))};
@@ -46,81 +58,89 @@
        GValue *size        = NULL;
        GValue *date        = NULL;
        GValue *time        = NULL;
+  GIOStatus status = G_IO_STATUS_NORMAL;
        gchar *_size            = NULL;
        unsigned short int a = 0, n = 0;
        
        if (cond & (G_IO_IN | G_IO_PRI) )
        {
-               g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
-               if (line == NULL)
-                       return TRUE;
+    do
+    {
+      status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+      if (line == NULL)
+        break;
 
-               filename    = g_new0(GValue, 1);
-               permissions = g_new0(GValue, 1);
-               owner       = g_new0(GValue, 1);
-               size        = g_new0(GValue, 1);
-               date        = g_new0(GValue, 1);
-               time        = g_new0(GValue, 1);
+      filename    = g_new0(GValue, 1);
+      permissions = g_new0(GValue, 1);
+      owner       = g_new0(GValue, 1);
+      size        = g_new0(GValue, 1);
+      date        = g_new0(GValue, 1);
+      time        = g_new0(GValue, 1);
 
-               for(n = 13; n < strlen(line); n++)
-                       if(line[n] == ' ') break;
-               permissions = g_value_init(permissions, G_TYPE_STRING);
-               g_value_set_string(permissions, g_strndup(line, 10));
-       
-               owner = g_value_init(owner , G_TYPE_STRING);
-               g_value_set_string(owner, g_strndup(&line[11], n-11));
+      for(n = 13; n < strlen(line); n++)
+        if(line[n] == ' ') break;
+      permissions = g_value_init(permissions, G_TYPE_STRING);
+      g_value_set_string(permissions, g_strndup(line, 10));
+    
+      owner = g_value_init(owner , G_TYPE_STRING);
+      g_value_set_string(owner, g_strndup(&line[11], n-11));
 
-               for(; n < strlen(line); n++)
-                       if(line[n] >= '0' && line[n] <= '9')
-                               break;
-                       a = n;
-                       for(; n < strlen(line); n++)
-                               if(line[n] == ' ')
-                                       break;
+      for(; n < strlen(line); n++)
+        if(line[n] >= '0' && line[n] <= '9')
+          break;
+        a = n;
+        for(; n < strlen(line); n++)
+          if(line[n] == ' ')
+            break;
 
-               size = g_value_init(size, G_TYPE_UINT64);
-               _size = g_strndup(&line[a], n-a);
-               g_value_set_uint64(size, atoll ( _size ));
-               g_free (_size);
-               a = n++;
-               for(; n < strlen(line); n++) // DATE
-               if(line[n] == ' ')
-                       break;
-               date = g_value_init(date, G_TYPE_STRING);
-               g_value_set_string ( date, g_strndup (&line[n-10], 10) );
+      size = g_value_init(size, G_TYPE_UINT64);
+      _size = g_strndup(&line[a], n-a);
+      g_value_set_uint64(size, atoll ( _size ));
+      g_free (_size);
+      a = n++;
+      for(; n < strlen(line); n++) // DATE
+      if(line[n] == ' ')
+        break;
+      date = g_value_init(date, G_TYPE_STRING);
+      g_value_set_string ( date, g_strndup (&line[n-10], 10) );
 
-               a = n++;
-               for(; n < strlen(line); n++) // TIME
-               if(line[n] == ' ') break;
-               time = g_value_init(time, G_TYPE_STRING);
-               g_value_set_string ( time, g_strndup (&line[n-8], 8) );
+      a = n++;
+      for(; n < strlen(line); n++) // TIME
+      if(line[n] == ' ') break;
+      time = g_value_init(time, G_TYPE_STRING);
+      g_value_set_string ( time, g_strndup (&line[n-8], 8) );
 
-               filename = g_value_init(filename, G_TYPE_STRING);
-               g_value_set_string(filename, g_strstrip(g_strndup(&line[n], 
strlen(line)-n-1)));
+      filename = g_value_init(filename, G_TYPE_STRING);
+      g_value_set_string(filename, g_strstrip(g_strndup(&line[n], 
strlen(line)-n-1)));
 
-               archive->row = g_list_prepend(archive->row, filename);
-               archive->row = g_list_prepend(archive->row, permissions);
-               archive->row = g_list_prepend(archive->row, owner);
-               archive->row = g_list_prepend(archive->row, size);
-               archive->row = g_list_prepend(archive->row, date);
-               archive->row = g_list_prepend(archive->row, time);
+      archive->row = g_list_prepend(archive->row, filename);
+      archive->row = g_list_prepend(archive->row, permissions);
+      archive->row = g_list_prepend(archive->row, owner);
+      archive->row = g_list_prepend(archive->row, size);
+      archive->row = g_list_prepend(archive->row, date);
+      archive->row = g_list_prepend(archive->row, time);
 
-               archive->dummy_size += g_value_get_uint64 (size);
-               if ( strstr (g_value_get_string (permissions) , "d") == NULL )
-                       archive->nr_of_files++;
-               else
-                       archive->nr_of_dirs++;
-               g_free(line);
-               archive->row_cnt++;
-               if (archive->row_cnt > 99)
-               {
-                       xa_append_rows ( archive , 6 );
-                       archive->row_cnt = 0;
-               }
-               return TRUE;
+      archive->dummy_size += g_value_get_uint64 (size);
+      if ( strstr (g_value_get_string (permissions) , "d") == NULL )
+        archive->nr_of_files++;
+      else
+        archive->nr_of_dirs++;
+      g_free(line);
+      archive->row_cnt++;
+      if (archive->row_cnt > 99)
+      {
+        xa_append_rows ( archive , 6 );
+        archive->row_cnt = 0;
+      }
+    }
+    while (status == G_IO_STATUS_NORMAL);
+
+    if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
+      goto done;
        }
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
+done:
                g_io_channel_shutdown ( ioc,TRUE,NULL );
                g_io_channel_unref (ioc);
                xa_append_rows ( archive , 6 );

Modified: xarchiver/trunk/src/zip.c
===================================================================
--- xarchiver/trunk/src/zip.c   2006-07-02 19:35:59 UTC (rev 22245)
+++ xarchiver/trunk/src/zip.c   2006-07-03 11:03:40 UTC (rev 22246)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2006 Giuseppe Torelli - <[EMAIL PROTECTED]>
+ *  Copyright (C) 2006 Benedikt Meurer - <[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
@@ -51,91 +52,100 @@
        GValue *date = NULL;
        GValue *time = NULL;
        GValue *crc32 = NULL;
+  GIOStatus status;
 
        if (cond & (G_IO_IN | G_IO_PRI) )
        {
-               g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL);
-               if (line == NULL)
-                       return TRUE;
+    do
+    {
+      status = g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL);
+      if (line == NULL)
+        break;
 
-               filename    = g_new0(GValue, 1);
-               original    = g_new0(GValue, 1);
-               method      = g_new0(GValue, 1);
-               compressed  = g_new0(GValue, 1);
-               ratio       = g_new0(GValue, 1);
-               date        = g_new0(GValue, 1);
-               time        = g_new0(GValue, 1);
-               crc32       = g_new0(GValue, 1);
-               archive->row_cnt++;
+      filename    = g_new0(GValue, 1);
+      original    = g_new0(GValue, 1);
+      method      = g_new0(GValue, 1);
+      compressed  = g_new0(GValue, 1);
+      ratio       = g_new0(GValue, 1);
+      date        = g_new0(GValue, 1);
+      time        = g_new0(GValue, 1);
+      crc32       = g_new0(GValue, 1);
+      archive->row_cnt++;
 
-               start = eat_spaces (line);
-               end = strchr (start, ' ');
-               original = g_value_init(original, G_TYPE_UINT64);
-               _original = g_strndup ( start , end - start);
-               g_value_set_uint64 ( original , atoll (_original) );
-               g_free (_original);
+      start = eat_spaces (line);
+      end = strchr (start, ' ');
+      original = g_value_init(original, G_TYPE_UINT64);
+      _original = g_strndup ( start , end - start);
+      g_value_set_uint64 ( original , atoll (_original) );
+      g_free (_original);
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               method = g_value_init(method, G_TYPE_STRING);
-               g_value_set_string ( method , g_strndup ( start , end - start) 
);
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      method = g_value_init(method, G_TYPE_STRING);
+      g_value_set_string ( method , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               compressed = g_value_init(compressed, G_TYPE_UINT64);
-               _compressed  = g_strndup ( start , end - start);
-               g_value_set_uint64 (compressed , atoll (_compressed) );
-               g_free (_compressed);
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      compressed = g_value_init(compressed, G_TYPE_UINT64);
+      _compressed  = g_strndup ( start , end - start);
+      g_value_set_uint64 (compressed , atoll (_compressed) );
+      g_free (_compressed);
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               ratio = g_value_init(ratio, G_TYPE_STRING);
-               g_value_set_string ( ratio , g_strndup ( start , end - start) );
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      ratio = g_value_init(ratio, G_TYPE_STRING);
+      g_value_set_string ( ratio , g_strndup ( start , end - start) );
 
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               date = g_value_init(date, G_TYPE_STRING);
-               g_value_set_string ( date , g_strndup ( start , end - start) );
-                       
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               time = g_value_init(time, G_TYPE_STRING);
-               g_value_set_string ( time , g_strndup ( start , end - start) );
-                       
-               start = eat_spaces (end);
-               end = strchr (start, ' ');
-               crc32 = g_value_init(crc32, G_TYPE_STRING);
-               g_value_set_string ( crc32 , g_strndup ( start , end - start) );
-               
-               start = eat_spaces (end);
-               end = strchr (start, '\n');
-               filename = g_value_init(filename, G_TYPE_STRING);
-               g_value_set_string ( filename , g_strndup ( start , end - 
start) );
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      date = g_value_init(date, G_TYPE_STRING);
+      g_value_set_string ( date , g_strndup ( start , end - start) );
+        
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      time = g_value_init(time, G_TYPE_STRING);
+      g_value_set_string ( time , g_strndup ( start , end - start) );
+        
+      start = eat_spaces (end);
+      end = strchr (start, ' ');
+      crc32 = g_value_init(crc32, G_TYPE_STRING);
+      g_value_set_string ( crc32 , g_strndup ( start , end - start) );
+      
+      start = eat_spaces (end);
+      end = strchr (start, '\n');
+      filename = g_value_init(filename, G_TYPE_STRING);
+      g_value_set_string ( filename , g_strndup ( start , end - start) );
 
-               archive->row = g_list_prepend(archive->row, filename);
-               archive->row = g_list_prepend(archive->row, original);
-               archive->row = g_list_prepend(archive->row, method);
-               archive->row = g_list_prepend(archive->row, compressed);
-               archive->row = g_list_prepend(archive->row, ratio);
-               archive->row = g_list_prepend(archive->row, date);
-               archive->row = g_list_prepend(archive->row, time);
-               archive->row = g_list_prepend(archive->row, crc32);
+      archive->row = g_list_prepend(archive->row, filename);
+      archive->row = g_list_prepend(archive->row, original);
+      archive->row = g_list_prepend(archive->row, method);
+      archive->row = g_list_prepend(archive->row, compressed);
+      archive->row = g_list_prepend(archive->row, ratio);
+      archive->row = g_list_prepend(archive->row, date);
+      archive->row = g_list_prepend(archive->row, time);
+      archive->row = g_list_prepend(archive->row, crc32);
 
-               if ( g_str_has_suffix (g_value_get_string (filename) , "/") == 
TRUE)
-                       archive->nr_of_dirs++;
-               else
-                       archive->nr_of_files++;
-               archive->dummy_size += g_value_get_uint64 (original);
-               g_free(line);
+      if ( g_str_has_suffix (g_value_get_string (filename) , "/") == TRUE)
+        archive->nr_of_dirs++;
+      else
+        archive->nr_of_files++;
+      archive->dummy_size += g_value_get_uint64 (original);
+      g_free(line);
 
-               if (archive->row_cnt > 99)
-               {
-                       xa_append_rows ( archive , 8 );
-                       archive->row_cnt = 0;
-               }
+      if (archive->row_cnt > 99)
+      {
+        xa_append_rows ( archive , 8 );
+        archive->row_cnt = 0;
+      }
+    }
+    while (status == G_IO_STATUS_NORMAL);
+
+    if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
+      goto done;
        }
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
+done:
                g_io_channel_shutdown ( ioc,TRUE,NULL );
                g_io_channel_unref (ioc);
                xa_append_rows ( archive , 8 );

Modified: xarchiver/trunk/xarchiver.desktop.in
===================================================================
--- xarchiver/trunk/xarchiver.desktop.in        2006-07-02 19:35:59 UTC (rev 
22245)
+++ xarchiver/trunk/xarchiver.desktop.in        2006-07-03 11:03:40 UTC (rev 
22246)
@@ -5,12 +5,10 @@
 _Comment=A GTK+2 only archive manager
 _GenericName=Archive manager
 Exec=xarchiver
-Icon=xarchiver.png
+Icon=xarchiver
 Terminal=false
 Type=Application
 X-MultipleArgs=false
 Categories=GTK;Application;Utility;
 StartupNotify=true
-MimeType=application/x-arj;application/arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-gzip;application/x-rar;application/x-rar-compressed;application/x-tar;application/x-zip;application/x-zip-compressed;application/zip;multipart/x-zip;application/x-7z-compressed;
-
-
+MimeType=application/x-arj;application/arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-gzip;application/x-rar;application/x-rar-compressed;application/x-tar;application/x-zip;application/x-zip-compressed;application/zip;multipart/x-zip;application/x-7z-compressed;application/x-compressed-tar;

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to