Author: colossus
Date: 2008-10-23 11:39:17 +0000 (Thu, 23 Oct 2008)
New Revision: 28380

Modified:
   xarchiver/trunk/src/add_dialog.c
   xarchiver/trunk/src/archive.c
   xarchiver/trunk/src/archive.h
   xarchiver/trunk/src/interface.c
   xarchiver/trunk/src/interface.h
   xarchiver/trunk/src/lha.c
   xarchiver/trunk/src/tar.c
   xarchiver/trunk/src/window.c
Log:
Fixed tar error when opening files from tar-compressed archives under FreeBSD.
Fixed issues when deleting the temp dir whith the cmd-line switches.
Fixed inability to extract directories in the archive with drag and drop.
Symbolic links stored in lha archives are now displayed correctly.
Fixed inability to add files in archive directory through the sidepane with 
drag and drop.
Fixed crash when dropping for the second time an icon in the sidepane and the 
row expands.


Modified: xarchiver/trunk/src/add_dialog.c
===================================================================
--- xarchiver/trunk/src/add_dialog.c    2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/add_dialog.c    2008-10-23 11:39:17 UTC (rev 28380)
@@ -434,7 +434,7 @@
 void xa_execute_add_commands (XArchive *archive,GSList *list,gchar 
*compression_string)
 {
        gchar *new_path = NULL;
-       gchar *esc,*esc2,*basename;
+       gchar *esc,*esc2,*basedir;
        gboolean result = FALSE;
        GString *items;
        gchar *command = NULL;
@@ -467,9 +467,14 @@
                                g_string_append_c(items,' ');
                                slist = slist->next;
                        }
-                       basename = g_path_get_basename(items->str);
-                       command = g_strconcat ("cp -f ",basename," 
",new_path,NULL);
-                       g_free(basename);
+                       basedir = g_path_get_dirname(items->str);
+                       if (archive->working_dir != NULL)
+                       {
+                               g_free(archive->working_dir);
+                               archive->working_dir = g_strdup(basedir);
+                       }
+                       g_free(basedir);
+                       command = g_strconcat ("cp -f ",items->str," 
",new_path,NULL);
                        g_free(new_path);
                        g_string_free(items,TRUE);
                        cmd_list = g_slist_append(cmd_list,command);
@@ -478,12 +483,7 @@
                archive->status = XA_ARCHIVESTATUS_ADD;
                xa_set_button_state (0,0,0,0,0,0,0,0,0,0,0);
        }
-       if (archive->working_dir != NULL)
-       {
-               g_free(archive->working_dir);
-               archive->working_dir = g_path_get_dirname(list->data);
-       }
-       
+
        while (list)
        {
                
xa_recurse_local_directory((gchar*)list->data,&dirlist,archive->add_recurse,archive->type);

Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c       2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/archive.c       2008-10-23 11:39:17 UTC (rev 28380)
@@ -286,7 +286,7 @@
 
        if (archive->tmp != NULL)
        {
-               xa_delete_temp_directory (archive,0);
+               xa_delete_temp_directory (archive);
                g_free (archive->tmp);
        }
 
@@ -309,12 +309,19 @@
        g_free (archive);
 }
 
-void xa_delete_temp_directory (XArchive *archive,gboolean flag)
+void xa_delete_temp_directory (XArchive *archive)
 {
-       gchar *command = g_strconcat("rm -rf ",archive->tmp,NULL);
-       archive->parse_output = 0;
-       xa_spawn_async_process(archive,command);
-       g_free(command);
+       if (xa_main_window)
+               xa_launch_external_program("rm -rf",archive->tmp);
+       else
+       {
+               char *argv[4];
+               argv[0] = "rm";
+               argv[1] = "-rf";
+               argv[2] = archive->tmp;
+               argv[3] = NULL;
+               g_spawn_sync (NULL, argv, NULL,G_SPAWN_SEARCH_PATH,NULL, 
NULL,NULL,NULL, NULL,NULL);
+       }
 }
 
 gboolean xa_create_temp_directory (XArchive *archive)

Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h       2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/archive.h       2008-10-23 11:39:17 UTC (rev 28380)
@@ -159,7 +159,7 @@
 void xa_clean_archive_structure (XArchive *);
 gboolean xa_dump_child_error_messages (GIOChannel *, GIOCondition , gpointer );
 gboolean xa_create_temp_directory(XArchive *);
-void xa_delete_temp_directory(XArchive *,gboolean );
+void xa_delete_temp_directory(XArchive *);
 gboolean xa_run_command (XArchive *,GSList *);
 gint xa_find_archive_index (gint );
 gint xa_get_new_archive_idx();

Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c     2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/interface.c     2008-10-23 11:39:17 UTC (rev 28380)
@@ -724,9 +724,9 @@
        gtk_drag_source_set 
(archive->treeview,GDK_BUTTON1_MASK,drag_targets,1,GDK_ACTION_COPY | 
GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
        g_signal_connect ((gpointer) sel,                          "changed",   
        G_CALLBACK (xa_row_selected),archive);
        g_signal_connect (G_OBJECT (archive->treeview),"drag-begin",    
G_CALLBACK (drag_begin),archive);
-       g_signal_connect (G_OBJECT 
(archive->treeview),"drag-data-get",G_CALLBACK (drag_data_get),archive);
+       g_signal_connect (G_OBJECT (archive->treeview),"drag-data-get", 
G_CALLBACK (drag_data_get),archive);
        g_signal_connect (G_OBJECT (archive->treeview),"drag-end",              
G_CALLBACK (drag_end),NULL);
-       g_signal_connect (G_OBJECT 
(archive->treeview),"row-activated",G_CALLBACK 
(xa_treeview_row_activated),archive);
+       g_signal_connect (G_OBJECT (archive->treeview),"row-activated", 
G_CALLBACK (xa_treeview_row_activated),archive);
        g_signal_connect (G_OBJECT 
(archive->treeview),"button-press-event",G_CALLBACK 
(xa_mouse_button_event),archive);
 }
 
@@ -1456,43 +1456,35 @@
        gtk_drag_finish (context,TRUE,FALSE,time);
 }
 
-gboolean xa_sidepane_drag_motion_expand_timeout (GtkTreePath **path)
+gboolean xa_sidepane_drag_motion_expand_timeout (gpointer data)
 {
-       if (path == NULL || *path == NULL)
-               return FALSE;
+       GtkTreePath *path;
 
-       if (! 
gtk_tree_view_row_expanded(GTK_TREE_VIEW(archive_dir_treeview),*path))
-               
gtk_tree_view_expand_to_path(GTK_TREE_VIEW(archive_dir_treeview),*path);
-       return FALSE;
+       gtk_tree_view_get_drag_dest_row (GTK_TREE_VIEW(archive_dir_treeview), 
&path, NULL);
+       if (G_LIKELY (path != NULL))
+       {
+               gtk_tree_view_expand_row (GTK_TREE_VIEW(archive_dir_treeview), 
path, FALSE);
+               gtk_tree_path_free (path);
+               return FALSE;
+       }
+       else
+               return TRUE;
 }
 
 gboolean xa_sidepane_drag_motion (GtkWidget *widget,GdkDragContext 
*context,gint x,gint y,guint time,gpointer user_data)
 {
        GtkTreeModel *model;
        GtkTreePath *path;
-       static GtkTreePath *lastpath;
-
+       
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
        gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW 
(widget),x,y,&path,NULL);
        if (path)
        {
-               if ( lastpath != NULL && lastpath != path)
-                       g_source_remove_by_user_data(&lastpath);
-
-               if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget),path))
-                       g_timeout_add(1000,(GSourceFunc) 
xa_sidepane_drag_motion_expand_timeout,&lastpath);
-
+               g_timeout_add_full (G_PRIORITY_LOW, 1000,(GSourceFunc) 
xa_sidepane_drag_motion_expand_timeout,NULL,NULL);
                g_object_set_data(G_OBJECT(context),"current_path",path);
-               /* This to set the focus on the dropped row */
-               
gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(widget),path,GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
        }
-       else
-               g_source_remove_by_user_data(&lastpath);
-
-       if (lastpath)
-               gtk_tree_path_free(lastpath);
-
-       lastpath = path;
+       /* This to set the focus on the dropped row */
+       
gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(widget),path,GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
        gdk_drag_status (context,context->suggested_action,time);
        return TRUE;
 }
@@ -1613,13 +1605,13 @@
 
 static gboolean xa_progress_dialog_delete_event (GtkWidget *caller,GdkEvent 
*event,GPid pid)
 {
-       kill (pid,SIGABRT);
+       kill (pid,SIGINT);
        return TRUE;
 }
 
 static void xa_progress_dialog_stop_action (GtkWidget *widget,GPid pid)
 {
-       kill (pid,SIGABRT);
+       kill (pid,SIGINT);
 }
 
 gboolean xa_pulse_progress_bar_window (Progress_bar_data *pb)

Modified: xarchiver/trunk/src/interface.h
===================================================================
--- xarchiver/trunk/src/interface.h     2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/interface.h     2008-10-23 11:39:17 UTC (rev 28380)
@@ -71,7 +71,7 @@
 void xa_disable_delete_buttons (gboolean);
 void xa_sidepane_row_expanded(GtkTreeView *,GtkTreeIter *,GtkTreePath 
*,gpointer );
 void xa_sidepane_drag_data_received ( GtkWidget*,GdkDragContext *, int x, int 
y, GtkSelectionData *, unsigned int, unsigned int, gpointer );
-gboolean xa_sidepane_drag_motion_expand_timeout (GtkTreePath **);
+gboolean xa_sidepane_drag_motion_expand_timeout (gpointer );
 gboolean xa_sidepane_drag_motion ( GtkWidget*,GdkDragContext *,gint x,gint 
y,guint ,gpointer );
 Progress_bar_data *xa_create_progress_bar(gboolean,XArchive *archive);
 void xa_increase_progress_bar(Progress_bar_data *,gchar *,double);

Modified: xarchiver/trunk/src/lha.c
===================================================================
--- xarchiver/trunk/src/lha.c   2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/lha.c   2008-10-23 11:39:17 UTC (rev 28380)
@@ -35,7 +35,7 @@
        archive->dummy_size = 0;
        archive->nr_of_files = 0;
        archive->format ="LHA";
-       archive->nc = 5;
+       archive->nc = 6;
        archive->parse_output = xa_get_lha_line_content;
        xa_spawn_async_process (archive,command);
        g_free (command);
@@ -43,12 +43,12 @@
        if (archive->child_pid == 0)
                return;
 
-       GType types[]= 
{GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_POINTER};
+       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_POINTER};
        archive->column_types = g_malloc0(sizeof(types));
-       for (i = 0; i < 7; i++)
+       for (i = 0; i < 8; i++)
                archive->column_types[i] = types[i];
                
-       char *names[]= 
{(_("Permissions")),(_("UID/GID")),(_("Size")),(_("Ratio")),(_("Timestamp"))};
+       char *names[]= {(_("Points 
to")),(_("Permissions")),(_("UID/GID")),(_("Size")),(_("Ratio")),(_("Timestamp"))};
        xa_create_liststore (archive,names);
 }
 
@@ -56,7 +56,7 @@
 {
        XArchive *archive = data;
        XEntry *entry = NULL;
-       gpointer item[5];
+       gpointer item[6];
        unsigned int linesize,n,a;
        gboolean dir = FALSE;
        gchar *filename;
@@ -82,13 +82,13 @@
 
        /* Permission */
        line[10] = '\0';
-       item[0] = line;
+       item[1] = line;
        if(line[0] == 'd')
                dir = TRUE;
 
        /* UID/GID */
        line[22] = '\0';
-       item[1] = line + 11;
+       item[2] = line + 11;
 
        //TODO verify the len of the size column with a big archive
        /* Size */
@@ -102,20 +102,32 @@
                break;
 
        line[a+(n-a)] = '\0';
-       item[2] = line + a;
+       item[3] = line + a;
        archive->dummy_size += strtoll(item[2],NULL,0);
 
     /* Ratio */
     line[37] = '\0';
-    item[3] = line + 31;
+    item[4] = line + 31;
 
     /* Timestamp */
     line[50] = '\0';
-    item[4] = line + 38;
+    item[5] = line + 38;
 
        line[(linesize- 1)] = '\0';
        filename = line + 51;
 
+       /* Symbolic link */
+       gchar *temp = g_strrstr (filename,"->"); 
+       if (temp) 
+       {
+               gint len = strlen(filename) - strlen(temp);
+               item[0] = (filename +=3) + len;
+               filename -= 3;
+               filename[strlen(filename) - strlen(temp)-1] = '\0';
+       }
+       else
+               item[0] = NULL;
+
        entry = xa_set_archive_entries_for_each_row (archive,filename,item);
 }
 

Modified: xarchiver/trunk/src/tar.c
===================================================================
--- xarchiver/trunk/src/tar.c   2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/tar.c   2008-10-23 11:39:17 UTC (rev 28380)
@@ -450,7 +450,11 @@
                return FALSE;
 
        command = g_strconcat (string, archive->escaped_path,
-                                                                               
archive->overwrite ? " --overwrite" : " --keep-old-files",
+                                                                               
#ifdef __FreeBSD__
+                                                                               
        archive->overwrite ? " " : " -k",
+                                                                               
#else
+                                                                               
        archive->overwrite ? " --overwrite" : " --keep-old-files",
+                                                                               
#endif
                                                                                
archive->tar_touch ? " --touch" : "",
                                                                                
" --no-wildcards -C ",
                                                                                
archive->tmp," ",files_to_extract,NULL);

Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c        2008-10-23 09:37:07 UTC (rev 28379)
+++ xarchiver/trunk/src/window.c        2008-10-23 11:39:17 UTC (rev 28380)
@@ -22,6 +22,8 @@
 
 #include "window.h"
 
+#define        XDS_FILENAME "xds.txt"
+
 extern GList *ArchiveType;
 extern GList *ArchiveSuffix;
 extern gboolean unrar;
@@ -1321,7 +1323,7 @@
        if (GTK_WIDGET_VISIBLE(multi_extract_window->multi_extract))
        {
                multi_extract_window->stop_pressed = TRUE;
-               kill (multi_extract_window->archive->child_pid,SIGABRT);
+               kill (multi_extract_window->archive->child_pid,SIGINT);
        }
        else
        {
@@ -1333,7 +1335,7 @@
                }
                if (archive[idx]->child_pid)
                {
-                       kill (archive[idx]->child_pid,SIGABRT);
+                       kill (archive[idx]->child_pid,SIGINT);
                        archive[idx]->child_pid = 0;
                }
                /* This in case the user cancels the opening of a password 
protected archive */
@@ -1626,7 +1628,6 @@
 {
     GtkTreeSelection *selection;
     GtkTreeIter       iter;
-    gchar            *name;
     GList            *row_list;
        XEntry *entry;
        
@@ -1639,64 +1640,50 @@
 
        gtk_tree_model_get_iter(archive->model,&iter,(GtkTreePath*) 
(row_list->data));
        gtk_tree_model_get (GTK_TREE_MODEL 
(archive->liststore),&iter,archive->nc+1,&entry,-1);
-       name = xa_build_full_path_name_from_entry(entry,0);
-       gchar *no_slashes = g_strrstr(name,"/");
-       if (no_slashes != NULL)
-               no_slashes++;
+
        gdk_property_change (context->source_window,
-                              gdk_atom_intern ("XdndDirectSave0",FALSE),
-                                  gdk_atom_intern ("text/plain",FALSE),8,
-                                      GDK_PROP_MODE_REPLACE,
-                                          (const guchar *) (no_slashes != NULL 
? no_slashes : name),no_slashes != NULL ? strlen (no_slashes) : strlen (name));
+                                       gdk_atom_intern 
("XdndDirectSave0",FALSE),
+                                       gdk_atom_intern ("text/plain",FALSE),
+                                       8,GDK_PROP_MODE_REPLACE,
+                                       (guchar *) XDS_FILENAME,
+                               strlen (XDS_FILENAME));
 
        g_list_foreach (row_list,(GFunc) gtk_tree_path_free,NULL);
        g_list_free (row_list);
-       g_free (name);
 }
 
 void drag_end (GtkWidget *treeview1,GdkDragContext *context,gpointer data)
 {
-   /* Nothing to do */
+       /* Nothing to do */
 }
 
 void drag_data_get (GtkWidget *widget,GdkDragContext *dc,GtkSelectionData 
*selection_data,guint info,guint t,XArchive *archive)
 {
        GtkTreeSelection *selection;
-       guchar *fm_path;
-       int fm_path_len,response;
-       gchar *no_uri_path;
-       gchar *to_send = "E";
        GList *row_list = NULL;
        GSList *names = NULL;
        gboolean full_path,overwrite;
+       guchar *_destination;
+       gchar *destination,*to_send;
+       int response;
 
-    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW 
(archive->treeview));
+       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW 
(archive->treeview));
        row_list = gtk_tree_selection_get_selected_rows (selection,NULL);
 
-       if ( row_list == NULL)
+       if (row_list == NULL)
                return;
+
        if (archive->child_pid!= 0)
        {
                response = xa_show_message_dialog (GTK_WINDOW 
(xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't 
perform another extraction:"),_("Please wait until the completion of the 
current one!"));
                return;
        }
-       if ( gdk_property_get (dc->source_window,
-                                                       gdk_atom_intern 
("XdndDirectSave0",FALSE),
-                                                       gdk_atom_intern 
("text/plain",FALSE),
-                                                       
0,1024,FALSE,NULL,NULL,&fm_path_len,&fm_path)
-                                                       && fm_path != NULL)
+       gdk_property_get (      dc->source_window,
+                                               gdk_atom_intern 
("XdndDirectSave0",FALSE),
+                                               gdk_atom_intern 
("text/plain",FALSE),
+                                               
0,4096,FALSE,NULL,NULL,NULL,&_destination );
+       if (_destination)
        {
-               /*  Zero-Terminate the string */
-               fm_path = g_realloc (fm_path,fm_path_len + 1);
-               fm_path[fm_path_len] = '\0';
-               no_uri_path = g_filename_from_uri ( (gchar*)fm_path,NULL,NULL);
-               /* g_message ("%s - %s",fm_path,no_uri_path); */
-               g_free ( fm_path);
-               if (no_uri_path == NULL)
-               {
-                       gtk_drag_finish (dc,FALSE,FALSE,t);
-                       return;
-               }
                if (archive->has_passwd)
                {
                        if (archive->passwd == NULL)
@@ -1709,30 +1696,48 @@
                                }
                        }
                }
-               archive->extraction_path = xa_remove_level_from_path 
(no_uri_path);
-               g_free (no_uri_path);
-               if (archive->extraction_path != NULL)
-                       to_send = "S";
+               destination = 
g_filename_from_uri((gchar*)_destination,NULL,NULL);
+               g_free(_destination);
 
-               gtk_tree_selection_selected_foreach 
(selection,(GtkTreeSelectionForeachFunc) xa_concat_filenames,&names);
-               full_path = archive->full_path;
-               overwrite = archive->overwrite;
-               archive->full_path = 0;
-               archive->overwrite = 1;
-               (*archive->extract) (archive,names);
+               archive->extraction_path = xa_remove_level_from_path 
(destination);
+               g_free(destination);
 
-               archive->full_path = full_path;
-               archive->overwrite = overwrite;
+               if (access (archive->extraction_path,R_OK | W_OK | X_OK))
+               {
+                       gchar *utf8_path;
+                       gchar  *msg;
+
+                       utf8_path = g_filename_to_utf8 
(archive->extraction_path,-1,NULL,NULL,NULL);
+                       msg = g_strdup_printf (_("You don't have the right 
permissions to extract the files to the directory \"%s\"."),utf8_path);
+                       response = xa_show_message_dialog (GTK_WINDOW 
(xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't 
perform extraction!"),msg );
+                       g_free (utf8_path);
+                       g_free (msg);
+                       to_send = "E";
+               }
+               else
+               {
+                       gtk_tree_selection_selected_foreach 
(selection,(GtkTreeSelectionForeachFunc) xa_concat_filenames,&names);
+                       full_path = archive->full_path;
+                       overwrite = archive->overwrite;
+                       archive->full_path = 0;
+                       archive->overwrite = 1;
+                       (*archive->extract) (archive,names);
+
+                       archive->full_path = full_path;
+                       archive->overwrite = overwrite;
+
+
+                       g_list_foreach (row_list,(GFunc) 
gtk_tree_path_free,NULL);
+                       g_list_free (row_list);
+                       to_send = "S";
+               }
+               if (archive->extraction_path != NULL)
+               {
+                       g_free (archive->extraction_path);
+                       archive->extraction_path = NULL;
+               }
                gtk_selection_data_set 
(selection_data,selection_data->target,8,(guchar*)to_send,1);
        }
-
-       if (archive->extraction_path != NULL)
-       {
-               g_free (archive->extraction_path);
-               archive->extraction_path = NULL;
-       }
-       g_list_foreach (row_list,(GFunc) gtk_tree_path_free,NULL);
-       g_list_free (row_list);
 }
 
 void on_drag_data_received (GtkWidget *widget,GdkDragContext *context,int 
x,int y,GtkSelectionData *data,unsigned int info,unsigned int time,gpointer 
user_data)

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to