Author: colossus
Date: 2008-10-17 13:03:11 +0000 (Fri, 17 Oct 2008)
New Revision: 28283

Modified:
   xarchiver/trunk/TODO
   xarchiver/trunk/src/archive.c
   xarchiver/trunk/src/extract_dialog.c
   xarchiver/trunk/src/interface.c
   xarchiver/trunk/src/interface.h
   xarchiver/trunk/src/main.c
   xarchiver/trunk/src/window.c
   xarchiver/trunk/src/window.h
Log:
Made the status indicator to flash nice when operating on tar-compressed 
archives.
Made Xarchiver to display a nice progress window when using the switches from 
cmd-line.
Made the "Open with" and "View" popupmenu options not to freeze the GUI when an 
entry is protected.
Updated TODO file.


Modified: xarchiver/trunk/TODO
===================================================================
--- xarchiver/trunk/TODO        2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/TODO        2008-10-17 13:03:11 UTC (rev 28283)
@@ -1,4 +1,3 @@
 - reduce the loading time when opening large archives.
 - to fix bugs #4299 and #3235.
 - to fix crashes when using cut/copy/paste
-- add a small progress window when using Xarchiver cmd-line switches.

Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c       2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/archive.c       2008-10-17 13:03:11 UTC (rev 28283)
@@ -38,7 +38,10 @@
 extern Prefs_dialog_data *prefs_window;
 extern gboolean batch_mode;
 
+Progress_bar_data *pb = NULL;
+
 static gboolean xa_process_output (GIOChannel *ioc, GIOCondition cond, 
gpointer data);
+static gboolean xa_process_output_from_command_line (GIOChannel 
*ioc,GIOCondition cond,gpointer data);
 
 XArchive *xa_init_archive_structure(gint type)
 {
@@ -91,7 +94,7 @@
        }
        g_strfreev (argv);
 
-       if (archive->pb_source == 0)
+       if (archive->status == XA_ARCHIVESTATUS_OPEN)
                archive->pb_source = g_timeout_add 
(350,(GSourceFunc)xa_flash_led_indicator,archive);
 
        if (archive->error_output != NULL)
@@ -104,11 +107,14 @@
        ioc = g_io_channel_unix_new (archive->output_fd);
        g_io_channel_set_encoding (ioc,NULL,NULL);
        g_io_channel_set_flags (ioc,G_IO_FLAG_NONBLOCK,NULL);
-
-       g_io_add_watch (ioc, 
G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,xa_process_output,archive);
+       
        if (xa_main_window)
-               g_child_watch_add_full (G_PRIORITY_LOW,archive->child_pid, 
(GChildWatchFunc)xa_watch_child,archive,NULL);
+               g_io_add_watch (ioc, 
G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,xa_process_output,archive);
+       else
+               g_io_add_watch (ioc, 
G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,xa_process_output_from_command_line,archive);
 
+       g_child_watch_add_full (G_PRIORITY_LOW,archive->child_pid, 
(GChildWatchFunc)xa_watch_child,archive,NULL);
+
        err_ioc = g_io_channel_unix_new (archive->error_fd);
        g_io_channel_set_encoding (err_ioc,locale,NULL);
        g_io_channel_set_flags (err_ioc,G_IO_FLAG_NONBLOCK,NULL);
@@ -137,6 +143,40 @@
        return command;
 }
 */
+
+static gboolean xa_process_output_from_command_line (GIOChannel 
*ioc,GIOCondition cond,gpointer data)
+{
+       XArchive *archive = data;
+       GIOStatus status;
+       gchar *line = NULL;
+
+       if (cond & (G_IO_IN | G_IO_PRI))
+       {
+               do
+               {
+                       status = g_io_channel_read_line (ioc, &line, NULL, 
NULL, NULL);
+                       if (line != NULL)
+                       {
+                               xa_increase_progress_bar(pb,line,0.0);
+                               g_free(line);
+                       }
+               }
+               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:
+               if (archive->error_output != NULL)
+                       archive->error_output = g_slist_reverse 
(archive->error_output);
+               g_io_channel_shutdown (ioc,TRUE,NULL);
+               g_io_channel_unref (ioc);
+               return FALSE;
+       }
+       return TRUE;
+}
+
 static gboolean xa_process_output (GIOChannel *ioc,GIOCondition cond,gpointer 
data)
 {
        XArchive *archive = data;
@@ -271,7 +311,9 @@
 
 void xa_delete_temp_directory (XArchive *archive,gboolean flag)
 {
-       xa_launch_external_program("rm -rf",archive->tmp);
+       gchar *command = g_strconcat("rm -rf ",archive->tmp,NULL);
+       xa_spawn_async_process(archive,command);
+       g_free(command);
 }
 
 gboolean xa_create_temp_directory (XArchive *archive)
@@ -301,98 +343,54 @@
 
 gboolean xa_run_command (XArchive *archive,GSList *commands)
 {
-       int ps,argcp;
+       int ps;
        gboolean waiting = TRUE;
        gboolean result = TRUE;
-       int response;
        GSList *_commands = commands;
-       GError *error = NULL;
-    gchar *std_out,*std_err,*new_std_err,*dummy;
-    gchar **argv;
 
-       if (batch_mode)
+       archive->parse_output = 0;
+       if (xa_main_window)
        {
-               while (_commands)
-               {
-                       g_print ("%s\n",(gchar*)_commands->data);
-                       g_shell_parse_argv(_commands->data,&argcp,&argv,NULL);
-                       if ( ! g_spawn_sync(
-                               NULL,
-                               argv,
-                               NULL,
-                               G_SPAWN_SEARCH_PATH,
-                               NULL,
-                               NULL,
-                               &std_out,
-                               &std_err,
-                               &status,
-                               &error))
-                       {
-                               response = xa_show_message_dialog (GTK_WINDOW 
(xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("Can't 
spawn the command:"),error->message);
-                               g_error_free (error);
-                               g_strfreev (argv);
-                               goto here;
-                       }
-                       if (WIFEXITED(status))
-                       {
-                               if (WEXITSTATUS(status))
-                               {
-                                       if (strlen(std_err) > 1954)
-                                       {
-                                               new_std_err = 
g_strndup(std_err,1954);
-                                               dummy = 
g_strconcat(new_std_err,_("\n\n** Output was shortened; too many 
errors!"),NULL);
-                                               g_free(new_std_err);
-                                               response = 
xa_show_message_dialog 
(NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("An error 
occurred!"),dummy);
-                                               g_free(dummy);
-                                       }
-                                       else
-                                               response = 
xa_show_message_dialog 
(NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("An error 
occurred!"),std_err);
-                               }
-                               else
-                                       result = TRUE;
-                       }
-                       _commands = _commands->next;
-               }
-               g_strfreev (argv);
-               goto here;
+               gtk_widget_set_sensitive (Stop_button,TRUE);
+               if (archive->pb_source == 0)
+                       archive->pb_source = g_timeout_add 
(350,(GSourceFunc)xa_flash_led_indicator,archive);
        }
        else
+               pb = xa_create_progress_bar(TRUE,archive);
+
+       while (_commands)
        {
-               archive->parse_output = 0;
-               gtk_widget_set_sensitive (Stop_button,TRUE);
-               while (_commands)
+               g_print ("%s\n",(gchar*)_commands->data);
+               xa_spawn_async_process (archive,_commands->data);
+               if (archive->child_pid == 0)
                {
-                       g_print ("%s\n",(gchar*)_commands->data);
-                       xa_spawn_async_process (archive,_commands->data);
-                       if (archive->child_pid == 0)
+                       result = FALSE;
+                       break;
+               }
+               while (waiting)
+               {
+                       ps = waitpid (archive->child_pid, &status, WNOHANG);
+                       if (ps < 0)
+                               break;
+                       while (gtk_events_pending())
+                               gtk_main_iteration();
+               }
+               if (WIFEXITED (status))
+               {
+                       if (WEXITSTATUS (status))
                        {
                                result = FALSE;
                                break;
                        }
-                       while (waiting)
-                       {
-                               ps = waitpid (archive->child_pid, &status, 
WNOHANG);
-                               if (ps < 0)
-                                       break;
-                               else if(xa_main_window)
-                                       gtk_main_iteration_do (FALSE);
-                       }
-                       if (WIFEXITED (status))
-                       {
-                               if (WEXITSTATUS (status))
-                               {
-                                       result = FALSE;
-                                       break;
-                               }
-                       }
-                       _commands = _commands->next;
                }
-               xa_watch_child (archive->child_pid, status, archive);
-               xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties,1,1);
-here:
-               g_slist_foreach (commands,(GFunc) g_free,NULL);
-               g_slist_free(commands);
+               _commands = _commands->next;
        }
+       xa_watch_child (archive->child_pid, status, archive);
+       if (xa_main_window)
+               xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties,1,1);
+
+       g_slist_foreach (commands,(GFunc) g_free,NULL);
+       g_slist_free(commands);
        return result;
 }
 

Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c        2008-10-17 12:57:45 UTC (rev 
28282)
+++ xarchiver/trunk/src/extract_dialog.c        2008-10-17 13:03:11 UTC (rev 
28283)
@@ -306,6 +306,7 @@
                        {
                                gtk_widget_set_sensitive (Stop_button,FALSE);
                                xa_set_button_state 
(1,1,GTK_WIDGET_IS_SENSITIVE(save1),GTK_WIDGET_IS_SENSITIVE(close1),0,0,0,0,0,0,0);
+                               archive->status = XA_ARCHIVESTATUS_IDLE;
                        }
                        break;
 
@@ -723,7 +724,7 @@
 
        overwrite = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->overwrite));
        double fraction = 1.0 / dialog->nr;
-       pb_struct = xa_create_progress_bar();
+       pb_struct = xa_create_progress_bar(FALSE,NULL);
        do
        {
                gtk_tree_model_get 
(GTK_TREE_MODEL(dialog->files_liststore),&iter,0,&file,2,&path,3,&type,-1);
@@ -732,7 +733,7 @@
                else
                        full_path = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->full_path));
                filename = g_strconcat (path,"/",file,NULL);
-               xa_increase_progress_bar(pb_struct,filename,percent);
+               xa_increase_progress_bar(pb_struct,NULL,percent);
                g_free(file);
                g_free(path);
                message = 
xa_multi_extract_archive(dialog,filename,overwrite,full_path,dest_path);

Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c     2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/interface.c     2008-10-17 13:03:11 UTC (rev 28283)
@@ -47,6 +47,9 @@
 
 extern gboolean unrar,batch_mode;
 
+static gboolean xa_progress_dialog_delete_event (GtkWidget *caller,GdkEvent 
*event,GPid pid);
+static void xa_progress_dialog_stop_action (GtkWidget *widget,GPid pid);
+
 void xa_create_main_window (GtkWidget *xa_main_window,gboolean 
show_location,gboolean show_output_menu_item,gboolean show_sidebar)
 {
        GdkPixbuf *icon;
@@ -1489,11 +1492,13 @@
        return TRUE;
 }
 
-Progress_bar_data *xa_create_progress_bar()
+Progress_bar_data *xa_create_progress_bar(gboolean flag,XArchive *archive)
 {
-       GtkWidget 
*vbox1,*vbox2,*extract_message,*hbox1,*icon_pixbuf,*total_label;
+       GtkWidget 
*vbox1,*vbox2,*message,*hbox1,*icon_pixbuf,*total_label,*action_area;
        GdkPixbuf *pixbuf;
+       PangoAttrList *italic_attr;
        Progress_bar_data *pb = NULL;
+       gchar *text,*markup;
 
        pb = g_new0(Progress_bar_data,1);
        pb->progress_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1521,36 +1526,75 @@
        vbox2 = gtk_vbox_new (FALSE,0);
        gtk_box_pack_start (GTK_BOX (hbox1),vbox2,TRUE,TRUE,0);
 
-       extract_message = gtk_label_new (_("Extracting archive:"));
-       gtk_label_set_use_markup (GTK_LABEL (extract_message),TRUE);
-       gtk_box_pack_start (GTK_BOX (vbox2),extract_message,FALSE,FALSE,0);
-       gtk_misc_set_alignment (GTK_MISC (extract_message),0,0.5);
+       if (archive->status == XA_ARCHIVESTATUS_EXTRACT)
+               text = _("Extracting from archive:");
+       else
+               text = _("Adding to archive:");
 
+       message = gtk_label_new("");
+       markup = g_markup_printf_escaped ("<b>%s</b>", text);
+       gtk_label_set_markup (GTK_LABEL (message), markup);
+       g_free (markup);
+
+       gtk_box_pack_start (GTK_BOX (vbox2),message,FALSE,FALSE,0);
+       gtk_misc_set_alignment (GTK_MISC (message),0,0.5);
+
        pb->archive_label = gtk_label_new("");
        
gtk_label_set_ellipsize(GTK_LABEL(pb->archive_label),PANGO_ELLIPSIZE_END);
        gtk_misc_set_alignment (GTK_MISC (pb->archive_label),0,0.5);
        gtk_box_pack_start (GTK_BOX (vbox2),pb->archive_label,FALSE,FALSE,12);
+       gtk_label_set_text(GTK_LABEL(pb->archive_label),archive->path);
 
-       total_label = gtk_label_new (_("Total Progress:"));
-       gtk_box_pack_start (GTK_BOX (vbox2),total_label,FALSE,FALSE,0);
-       gtk_misc_set_alignment (GTK_MISC (total_label),0,0);
-
+       if ( ! flag)
+       {
+               total_label = gtk_label_new (_("Total Progress:"));
+               gtk_box_pack_start (GTK_BOX (vbox2),total_label,FALSE,FALSE,0);
+               gtk_misc_set_alignment (GTK_MISC (total_label),0,0);
+       }
        pb->progressbar1 = gtk_progress_bar_new ();
        gtk_box_pack_start (GTK_BOX (vbox2),pb->progressbar1,FALSE,FALSE,0);
+
+       if (flag)
+       {
+               pb->file_label = gtk_label_new("");
+               italic_attr = pango_attr_list_new ();
+               pango_attr_list_insert (italic_attr, pango_attr_style_new 
(PANGO_STYLE_ITALIC));
+               gtk_label_set_attributes (GTK_LABEL 
(pb->file_label),italic_attr);
+               pango_attr_list_unref (italic_attr);
+               
gtk_label_set_ellipsize(GTK_LABEL(pb->file_label),PANGO_ELLIPSIZE_END);
+               gtk_misc_set_alignment (GTK_MISC (pb->file_label),0,0.5);
+               gtk_box_pack_start (GTK_BOX 
(vbox2),pb->file_label,FALSE,FALSE,12);
+               
+               action_area = gtk_hbutton_box_new ();
+               gtk_button_box_set_layout (GTK_BUTTON_BOX 
(action_area),GTK_BUTTONBOX_END);  
+               gtk_box_pack_end (GTK_BOX (vbox2),action_area,FALSE, TRUE, 0);
+
+               cancel_button = gtk_button_new_from_stock ("gtk-cancel");
+               gtk_box_pack_end (GTK_BOX 
(action_area),cancel_button,TRUE,TRUE,12);
+
+               g_signal_connect (G_OBJECT (cancel_button),              
"clicked",             G_CALLBACK (xa_progress_dialog_stop_action), 
GINT_TO_POINTER (archive->child_pid));
+               g_signal_connect (G_OBJECT 
(pb->progress_window),"delete_event",G_CALLBACK 
(xa_progress_dialog_delete_event),GINT_TO_POINTER (archive->child_pid));
+       }
        gtk_widget_show_all(pb->progress_window);
        return pb;
 }
 
-void xa_increase_progress_bar(Progress_bar_data *pb,gchar *archive_name,double 
percent)
+void xa_increase_progress_bar(Progress_bar_data *pb,gchar *filename,double 
percent)
 {
        gchar *message = NULL;
 
-       gtk_label_set_text(GTK_LABEL(pb->archive_label),archive_name);
-       gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR 
(pb->progressbar1),percent);
-       message = g_strdup_printf("%.0f%%",(percent*100));
-       gtk_progress_bar_set_text (GTK_PROGRESS_BAR(pb->progressbar1),message);
-       g_free(message);
-
+       if (filename == NULL)
+       {
+               gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR 
(pb->progressbar1),percent);
+               message = g_strdup_printf("%.0f%%",(percent*100));
+               gtk_progress_bar_set_text 
(GTK_PROGRESS_BAR(pb->progressbar1),message);
+               g_free(message);
+       }
+       else
+       {
+               gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pb->progressbar1));
+               gtk_label_set_text(GTK_LABEL(pb->file_label),filename);
+       }
        while (gtk_events_pending())
                gtk_main_iteration();
 }
@@ -1563,16 +1607,13 @@
         * time as the filenames currently displayed. What of the other tabs 
then? */   
 }
 
-gboolean xa_progress_bar_pulse_function(Progress_bar_data *pb)
+static gboolean xa_progress_dialog_delete_event (GtkWidget *caller,GdkEvent 
*event,GPid pid)
 {
-       if (pb != NULL)
-       {
-               while (gtk_events_pending())
-                       gtk_main_iteration();
-               gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pb->progressbar1));
-               return TRUE;
-       }
-       else
-               return FALSE;
-               
+       kill (pid,SIGABRT);
+       return TRUE;
 }
+
+static void xa_progress_dialog_stop_action (GtkWidget *widget,GPid pid)
+{
+       kill (pid,SIGABRT);
+}

Modified: xarchiver/trunk/src/interface.h
===================================================================
--- xarchiver/trunk/src/interface.h     2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/interface.h     2008-10-17 13:03:11 UTC (rev 28283)
@@ -29,6 +29,7 @@
        GtkWidget *progress_window;
        GtkWidget *progressbar1;
        GtkWidget *archive_label;
+       GtkWidget *file_label;
 };
 
 GtkNotebook *notebook;
@@ -70,8 +71,7 @@
 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 ( GtkWidget*,GdkDragContext *,gint x,gint 
y,guint ,gpointer );
-Progress_bar_data *xa_create_progress_bar();
+Progress_bar_data *xa_create_progress_bar(gboolean,XArchive *archive);
 void xa_increase_progress_bar(Progress_bar_data *,gchar *,double);
 void xa_icon_theme_changed (GtkIconTheme *,gpointer );
-gboolean xa_progress_bar_pulse_function(Progress_bar_data *);
 #endif

Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c  2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/main.c  2008-10-17 13:03:11 UTC (rev 28283)
@@ -38,6 +38,8 @@
 int response;
 extern gchar *current_open_directory;
 extern int status;
+
+extern Progress_bar_data *pb;
 Prefs_dialog_data   *prefs_window   = NULL;
 Extract_dialog_data *extract_window = NULL;
 Add_dialog_data     *add_window                = NULL;
@@ -219,9 +221,13 @@
                }
 done:  g_list_free (ArchiveSuffix);
                g_list_free (ArchiveType);
+               if (pb != NULL)
+               {
+                       gtk_widget_destroy(pb->progress_window);
+                       g_free(pb);
+               }
                if (archive != NULL)
                        xa_clean_archive_structure (archive);
-               return WIFEXITED (status);
        }
        else
        {
@@ -270,8 +276,8 @@
                gtk_main ();
                g_list_free (ArchiveSuffix);
                g_list_free (ArchiveType);
-               return 0;
        }
+       return 0;
 }
 
 void xa_set_available_archivers()

Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c        2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/window.c        2008-10-17 13:03:11 UTC (rev 28283)
@@ -21,13 +21,6 @@
 #endif
 
 #include "window.h"
-#include "archive.h"
-#include "mime.h"
-#include "string_utils.h"
-#include "interface.h"
-#include "support.h"
-#include "main.h"
-#include "socket.h"
 
 extern GList *ArchiveType;
 extern GList *ArchiveSuffix;
@@ -50,20 +43,6 @@
        int response;
 
        archive->child_pid = archive->pb_source = 0;
-       if (WIFSIGNALED (status))
-       {
-               if (archive->status == XA_ARCHIVESTATUS_EXTRACT)
-               {
-                       gchar *msg = g_strdup_printf(_("Please check \"%s\" 
since some files could have been already extracted."),archive->extraction_path);
-                       response = xa_show_message_dialog (GTK_WINDOW 
(xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_INFO,GTK_BUTTONS_OK,"",msg);
-                       g_free (msg);
-               }
-               else if (archive->status == XA_ARCHIVESTATUS_OPEN)
-                       gtk_widget_set_sensitive (check_menu,FALSE);
-
-               xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties,archive->has_passwd,1);
-               return;
-       }
        if (WIFEXITED (status))
        {
                if (WEXITSTATUS (status))
@@ -75,48 +54,54 @@
                                response = 
xa_show_message_dialog(GTK_WINDOW(xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("An
 error occurred!"),_("Please check the 'Store archiver output' option to see 
it."));        
                                return;
                        }
-                       xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,0,archive->has_test,archive->has_properties,archive->has_passwd,1);
-                       gtk_widget_set_sensitive(Stop_button,FALSE);
-                       xa_show_cmd_line_output (NULL,GINT_TO_POINTER(1));
-                       /* In case the user supplies a wrong password we reset 
it so he can try again */
-                       if ( (archive->status == XA_ARCHIVESTATUS_TEST || 
archive->status == XA_ARCHIVESTATUS_SFX) && archive->passwd != NULL)
+                       if (xa_main_window)
                        {
-                               g_free (archive->passwd);
-                               archive->passwd = NULL;
+                               xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,0,archive->has_test,archive->has_properties,archive->has_passwd,1);
+                               xa_show_cmd_line_output 
(NULL,GINT_TO_POINTER(1));
+                               /* In case the user supplies a wrong password 
we reset it so he can try again */
+                               if ( (archive->status == XA_ARCHIVESTATUS_TEST 
|| archive->status == XA_ARCHIVESTATUS_SFX) && archive->passwd != NULL)
+                               {
+                                       g_free (archive->passwd);
+                                       archive->passwd = NULL;
+                               }
+                               archive->status = XA_ARCHIVESTATUS_ERROR;
+                               gtk_widget_set_sensitive(Stop_button,FALSE);
+                               return;
                        }
-                       archive->status = XA_ARCHIVESTATUS_ERROR;               
        
-                       return;
                }
        }
 there:
-       archive->child_pid = archive->pb_source = 0;
-       gtk_widget_set_sensitive(Stop_button,FALSE);
+       if (xa_main_window)
+       {
+               archive->child_pid = archive->pb_source = 0;
+               gtk_widget_set_sensitive(Stop_button,FALSE);
 
-       if (archive->type == XARCHIVETYPE_ZIP || archive->type == 
XARCHIVETYPE_RAR || archive->type == XARCHIVETYPE_ARJ)
-               gtk_widget_set_sensitive (comment_menu,TRUE);
-       else
-               gtk_widget_set_sensitive (comment_menu,FALSE);
-       if (archive->type == XARCHIVETYPE_TAR || 
is_tar_compressed(archive->type))
-               gtk_widget_set_sensitive (password_entry_menu,FALSE);
-       else
-               gtk_widget_set_sensitive (password_entry_menu,TRUE);
+               if (archive->type == XARCHIVETYPE_ZIP || archive->type == 
XARCHIVETYPE_RAR || archive->type == XARCHIVETYPE_ARJ)
+                       gtk_widget_set_sensitive (comment_menu,TRUE);
+               else
+                       gtk_widget_set_sensitive (comment_menu,FALSE);
+               if (archive->type == XARCHIVETYPE_TAR || 
is_tar_compressed(archive->type))
+                       gtk_widget_set_sensitive (password_entry_menu,FALSE);
+               else
+                       gtk_widget_set_sensitive (password_entry_menu,TRUE);
 
-       gtk_widget_set_sensitive(listing,TRUE);
+               gtk_widget_set_sensitive(listing,TRUE);
 
-       if (archive->has_comment && archive->status == XA_ARCHIVESTATUS_OPEN && 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_show_comment)))
-               xa_show_archive_comment (NULL,NULL);
+               if (archive->has_comment && archive->status == 
XA_ARCHIVESTATUS_OPEN && 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_show_comment)))
+                       xa_show_archive_comment (NULL,NULL);
 
-       if (GTK_IS_TREE_VIEW(archive->treeview))
-               gtk_widget_grab_focus (GTK_WIDGET(archive->treeview));
-       xa_set_statusbar_message_for_displayed_rows(archive);
+               if (GTK_IS_TREE_VIEW(archive->treeview))
+                       gtk_widget_grab_focus (GTK_WIDGET(archive->treeview));
+               xa_set_statusbar_message_for_displayed_rows(archive);
 
-       if (archive->status == XA_ARCHIVESTATUS_TEST)
-               xa_show_cmd_line_output (NULL,FALSE);
+               if (archive->status == XA_ARCHIVESTATUS_TEST)
+                       xa_show_cmd_line_output (NULL,FALSE);
 
-       if (archive->status == XA_ARCHIVESTATUS_OPEN)
-               xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties,1,1);
+               if (archive->status == XA_ARCHIVESTATUS_OPEN)
+                       xa_set_button_state 
(1,1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties,1,1);
 
-       gtk_label_set_text(GTK_LABEL(total_label),"");
+               gtk_label_set_text(GTK_LABEL(total_label),"");
+       }
 }
 
 void xa_reload_archive_content(XArchive *archive)
@@ -1683,7 +1668,7 @@
 
        if ( row_list == NULL)
                return;
-       if (archive->status == XA_ARCHIVESTATUS_EXTRACT)
+       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;
@@ -2614,6 +2599,7 @@
        row_list = 
gtk_tree_selection_get_selected_rows(selection,&archive[idx]->model);
        if (row_list == NULL)
                return;
+               
        nr = gtk_tree_selection_count_selected_rows(selection);
        while (row_list)
        {
@@ -2689,6 +2675,12 @@
        list = g_slist_append(list,xa_build_full_path_name_from_entry(entry,0));
        g_list_free(row_list);
 
+       if (entry->is_encrypted)
+       {
+               archive[idx]->passwd = xa_create_password_dialog(archive[idx]);
+               if (archive[idx]->passwd == NULL)
+                       return;
+       }
        filename = g_strconcat(archive[idx]->tmp,"/",entry->filename,NULL);
        if (g_file_test(filename,G_FILE_TEST_EXISTS))
                goto here;

Modified: xarchiver/trunk/src/window.h
===================================================================
--- xarchiver/trunk/src/window.h        2008-10-17 12:57:45 UTC (rev 28282)
+++ xarchiver/trunk/src/window.h        2008-10-17 13:03:11 UTC (rev 28283)
@@ -52,6 +52,12 @@
 #include "add_dialog.h"
 #include "pref_dialog.h"
 #include "open-with-dlg.h"
+#include "mime.h"
+#include "string_utils.h"
+#include "interface.h"
+#include "support.h"
+#include "main.h"
+#include "socket.h"
 
 unsigned long long int file_offset;
 Add_dialog_data *add_window;

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

Reply via email to