Author: colossus
Date: 2006-10-02 11:26:11 +0000 (Mon, 02 Oct 2006)
New Revision: 23258

Modified:
   xarchiver/trunk/src/callbacks.c
   xarchiver/trunk/src/interface.c
   xarchiver/trunk/src/interface.h
   xarchiver/trunk/src/main.c
   xarchiver/trunk/src/new_dialog.c
Log:
Fixed a crash in main.c when using the -d switch and clicking Cancel in the new 
dialog.
MAde the new archive dialog remembers the last used filter and last udes path.


Modified: xarchiver/trunk/src/callbacks.c
===================================================================
--- xarchiver/trunk/src/callbacks.c     2006-10-02 08:04:27 UTC (rev 23257)
+++ xarchiver/trunk/src/callbacks.c     2006-10-02 11:26:11 UTC (rev 23258)
@@ -35,6 +35,10 @@
 extern gboolean unrar;
 
 XArchive *archive = NULL;
+gchar *current_open_directory = NULL;
+GtkFileFilter *open_file_filter = NULL;
+GList *Suffix , *Name;
+//gint current_archive_suffix = 0;
 
 #ifndef HAVE_STRCASESTR
 /*
@@ -64,10 +68,6 @@
 }
 #endif /* !HAVE_STRCASESTR */
 
-gchar *CurrentFolder = NULL;
-GList *Suffix , *Name;
-gint current_archive_suffix = 0;
-
 void xa_watch_child ( GPid pid, gint status, gpointer data)
 {
        XArchive *archive = data;
@@ -766,8 +766,9 @@
                gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER 
(File_Selector) , FALSE );
     else
                gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER 
(File_Selector) , TRUE );
-       if (CurrentFolder != NULL)
-               gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER 
(File_Selector) , CurrentFolder );
+
+       if (current_open_directory != NULL)
+               gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER 
(File_Selector) , current_open_directory );
        response = gtk_dialog_run (GTK_DIALOG (File_Selector) );
        if (response == GTK_RESPONSE_ACCEPT)
                list = gtk_file_chooser_get_filenames ( GTK_FILE_CHOOSER 
(File_Selector) );
@@ -818,8 +819,7 @@
                                                        flag2,
                                                        GTK_RESPONSE_ACCEPT,
                                                        NULL);
-       if (CurrentFolder != NULL)
-               gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER 
(File_Selector) , CurrentFolder );
+
        gtk_dialog_set_default_response (GTK_DIALOG (File_Selector), 
GTK_RESPONSE_ACCEPT);
 
        filter = gtk_file_filter_new ();
@@ -840,7 +840,6 @@
        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (File_Selector), filter);
 
        Suffix = g_list_first ( ArchiveSuffix );
-
        while ( Suffix != NULL )
        {
                if ( Suffix->data != "" )       /* To avoid double filtering 
when opening the archive */
@@ -850,14 +849,20 @@
                        gtk_file_filter_add_pattern (filter, Suffix->data );
                        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER 
(File_Selector), filter);
                }
-
                Suffix = g_list_next ( Suffix );
        }
-       //current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX 
(combo_box));
+       if (current_open_directory != NULL)
+               gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER 
(File_Selector) , current_open_directory );
 
+       /*if (open_file_filter != NULL)
+               gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (File_Selector) , 
open_file_filter );*/
+
        gtk_window_set_modal (GTK_WINDOW (File_Selector),TRUE);
        response = gtk_dialog_run (GTK_DIALOG (File_Selector));
-       CurrentFolder = gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER 
(File_Selector) );
+
+       current_open_directory = gtk_file_chooser_get_current_folder ( 
GTK_FILE_CHOOSER (File_Selector) );
+       open_file_filter = gtk_file_chooser_get_filter ( GTK_FILE_CHOOSER 
(File_Selector) );
+
        if (response == GTK_RESPONSE_ACCEPT)
        {
                path = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER 
(File_Selector) );
@@ -1524,7 +1529,7 @@
     t = g_strdup_printf ( "%d", archive->nr_of_dirs);
     gtk_entry_set_text ( GTK_ENTRY (number_of_dirs_data), t );
     g_free (t);
-    gtk_widget_show ( archive_properties_win );
+    gtk_widget_show_all ( archive_properties_win );
 }
 
 void Activate_buttons ()

Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c     2006-10-02 08:04:27 UTC (rev 23257)
+++ xarchiver/trunk/src/interface.c     2006-10-02 11:26:11 UTC (rev 23258)
@@ -529,14 +529,12 @@
        gtk_window_set_type_hint (GTK_WINDOW (archive_properties_window), 
GDK_WINDOW_TYPE_HINT_UTILITY);
 
        table1 = gtk_table_new (9, 2, TRUE);
-       gtk_widget_show (table1);
        gtk_container_add (GTK_CONTAINER (GTK_DIALOG 
(archive_properties_window)->vbox), table1);
        gtk_table_set_row_spacings (GTK_TABLE (table1), 6);
        gtk_table_set_col_spacings (GTK_TABLE (table1), 6);
 
        name_label = gtk_label_new ("");
        set_label ( name_label , _("Name:"));
-       gtk_widget_show (name_label);
        gtk_table_attach (GTK_TABLE (table1), name_label, 0, 1, 0, 1,
                      (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -544,7 +542,6 @@
 
        path_label = gtk_label_new ("");
        set_label ( path_label , _("Path:"));
-       gtk_widget_show (path_label);
        gtk_table_attach (GTK_TABLE (table1), path_label, 0, 1, 1, 2,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -552,7 +549,6 @@
 
        type_label = gtk_label_new ("");
        set_label ( type_label , _("Type:"));
-       gtk_widget_show (type_label);
        gtk_table_attach (GTK_TABLE (table1), type_label, 0, 1, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -560,7 +556,6 @@
 
        modified_label = gtk_label_new ("");
        set_label ( modified_label , _("Modified on:"));
-       gtk_widget_show (modified_label);
        gtk_table_attach (GTK_TABLE (table1), modified_label, 0, 1, 3, 4,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -568,7 +563,6 @@
 
        size_label = gtk_label_new ("");
        set_label ( size_label , _("Archive size:"));
-       gtk_widget_show (size_label);
        gtk_table_attach (GTK_TABLE (table1), size_label, 0, 1, 4, 5,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -576,7 +570,6 @@
 
        content_label = gtk_label_new ("");
        set_label ( content_label , _("Content size:"));
-       gtk_widget_show (content_label);
        gtk_table_attach (GTK_TABLE (table1), content_label, 0, 1, 5, 6,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -584,7 +577,6 @@
 
        compression_label = gtk_label_new ("");
        set_label ( compression_label , _("Compression ratio:"));
-       gtk_widget_show (compression_label);
        gtk_table_attach (GTK_TABLE (table1), compression_label, 0, 1, 8, 9,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -592,7 +584,6 @@
 
        number_of_files_label = gtk_label_new ("");
        set_label ( number_of_files_label , _("Number of files:"));
-       gtk_widget_show (number_of_files_label);
        gtk_table_attach (GTK_TABLE (table1), number_of_files_label, 0, 1, 6, 7,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -600,7 +591,6 @@
 
        number_of_dirs_label = gtk_label_new ("");
        set_label ( number_of_dirs_label , _("Number of dirs:"));
-       gtk_widget_show (number_of_dirs_label);
        gtk_table_attach (GTK_TABLE (table1), number_of_dirs_label, 0, 1, 7, 8,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 
0, 0);
@@ -609,7 +599,6 @@
        compression_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (compression_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (compression_data), FALSE);
-       gtk_widget_show (compression_data);
        gtk_table_attach (GTK_TABLE (table1), compression_data, 1, 2, 8, 9,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -617,7 +606,6 @@
        number_of_dirs_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (number_of_dirs_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (number_of_dirs_data), FALSE);
-       gtk_widget_show (number_of_dirs_data);
        gtk_table_attach (GTK_TABLE (table1), number_of_dirs_data, 1, 2, 7, 8,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -625,7 +613,6 @@
        number_of_files_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (number_of_files_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (number_of_files_data), FALSE);
-       gtk_widget_show (number_of_files_data);
        gtk_table_attach (GTK_TABLE (table1), number_of_files_data, 1, 2, 6, 7,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -633,7 +620,6 @@
        content_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (content_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (content_data), FALSE);
-       gtk_widget_show (content_data);
        gtk_table_attach (GTK_TABLE (table1), content_data, 1, 2, 5, 6,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -641,13 +627,11 @@
        size_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (size_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (size_data), FALSE);
-       gtk_widget_show (size_data);
        gtk_table_attach (GTK_TABLE (table1), size_data, 1, 2, 4, 5,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
 
        modified_data = gtk_entry_new ();
-       gtk_widget_show (modified_data);
        gtk_table_attach (GTK_TABLE (table1), modified_data, 1, 2, 3, 4,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -657,7 +641,6 @@
        type_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (type_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (type_data), FALSE);
-       gtk_widget_show (type_data);
        gtk_table_attach (GTK_TABLE (table1), type_data, 1, 2, 2, 3,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -665,7 +648,6 @@
        path_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (path_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (path_data), FALSE);
-       gtk_widget_show (path_data);
        gtk_table_attach (GTK_TABLE (table1), path_data, 1, 2, 1, 2,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
@@ -673,7 +655,6 @@
        name_data = gtk_entry_new ();
        gtk_editable_set_editable (GTK_EDITABLE (name_data), FALSE);
        gtk_entry_set_has_frame (GTK_ENTRY (name_data), FALSE);
-       gtk_widget_show (name_data);
        gtk_table_attach (GTK_TABLE (table1), name_data, 1, 2, 0, 1,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);

Modified: xarchiver/trunk/src/interface.h
===================================================================
--- xarchiver/trunk/src/interface.h     2006-10-02 08:04:27 UTC (rev 23257)
+++ xarchiver/trunk/src/interface.h     2006-10-02 11:26:11 UTC (rev 23258)
@@ -24,6 +24,7 @@
 GtkWidget *vbox1;
 GtkWidget *vbox_body;
 GtkWidget *hbox_sb;
+GtkWidget *hbox_ap;
 GtkWidget *menubar1;
 GtkWidget *menuitem1;
 GtkWidget *menuitem1_menu;

Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c  2006-10-02 08:04:27 UTC (rev 23257)
+++ xarchiver/trunk/src/main.c  2006-10-02 11:26:11 UTC (rev 23258)
@@ -168,7 +168,7 @@
                        {
                                xa_new_archive ( NULL , archive_name );
                                if (archive == NULL)
-                                       return exit_status;
+                                       return 0;
 
                                if (archive->path != NULL)
                                {

Modified: xarchiver/trunk/src/new_dialog.c
===================================================================
--- xarchiver/trunk/src/new_dialog.c    2006-10-02 08:04:27 UTC (rev 23257)
+++ xarchiver/trunk/src/new_dialog.c    2006-10-02 11:26:11 UTC (rev 23258)
@@ -25,6 +25,8 @@
 #include "main.h"
 
 extern gboolean unrar;
+gchar *current_new_directory = NULL;
+gint new_combo_box = -1;
 
 XArchive *xa_new_archive_dialog (gchar *path)
 {
@@ -36,7 +38,6 @@
        GtkFileFilter *xa_new_archive_dialog_filter;
        GtkTooltips *filter_tooltip;
        GList *Suffix,*Name;
-       gint current_archive_suffix = 0;
        gchar *my_path = NULL;
 
        xa_file_chooser = gtk_file_chooser_dialog_new ( _("Create a new 
archive"),
@@ -81,7 +82,6 @@
                }
                Suffix = g_list_next ( Suffix );
        }
-       //current_archive_suffix = gtk_combo_box_get_active (GTK_COMBO_BOX 
(combo_box));
        hbox = gtk_hbox_new (FALSE, 12);
        gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive 
type:")),FALSE, FALSE, 0);
 
@@ -99,7 +99,11 @@
                Next:
                        Name = g_list_next ( Name );
        }
-       gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , 
current_archive_suffix );
+       if (new_combo_box == -1)
+               gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , 0 );
+       else
+               gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box) , 
new_combo_box );
+
        gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
 
        check_button = gtk_check_button_new_with_label (_("Add the archive 
extension to the filename"));
@@ -110,9 +114,14 @@
 
        if (path != NULL)
                gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER 
(xa_file_chooser),path);
+
        gtk_window_set_modal (GTK_WINDOW (xa_file_chooser),TRUE);
+       if (current_new_directory != NULL)
+               gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER 
(xa_file_chooser) , current_new_directory );
+
        response = gtk_dialog_run (GTK_DIALOG (xa_file_chooser));
-       //CurrentFolder = gtk_file_chooser_get_current_folder ( 
GTK_FILE_CHOOSER (xa_file_chooser) );
+       current_new_directory = gtk_file_chooser_get_current_folder ( 
GTK_FILE_CHOOSER (xa_file_chooser) );
+
        if (response == GTK_RESPONSE_ACCEPT)
        {
                my_path = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER 
(xa_file_chooser) );
@@ -144,7 +153,7 @@
 
                archive = xa_init_archive_structure (archive);
                ComboArchiveType = gtk_combo_box_get_active_text (GTK_COMBO_BOX 
(combo_box));
-               current_archive_suffix = gtk_combo_box_get_active 
(GTK_COMBO_BOX (combo_box));
+               new_combo_box = gtk_combo_box_get_active (GTK_COMBO_BOX 
(combo_box));
 
                if (strcmp ( ComboArchiveType,".arj") == 0)
                        archive->type = XARCHIVETYPE_ARJ;

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

Reply via email to