Author: colossus Date: 2008-08-10 11:04:46 +0000 (Sun, 10 Aug 2008) New Revision: 27438
Modified: xarchiver/trunk/TODO xarchiver/trunk/src/7zip.c xarchiver/trunk/src/add_dialog.c xarchiver/trunk/src/deb.c xarchiver/trunk/src/extract_dialog.c xarchiver/trunk/src/extract_dialog.h xarchiver/trunk/src/interface.c xarchiver/trunk/src/interface.h xarchiver/trunk/src/main.c xarchiver/trunk/src/string_utils.c xarchiver/trunk/src/string_utils.h xarchiver/trunk/src/window.c xarchiver/trunk/src/window.h Log: Updated TODO file. Tried to select the filename in the row up to the dor when renaming entries. Removed key_press_function() from window.c Fixed bug when adding with drag and drop to 7zip. Added multi-extract dialog GUI and made the buttons in to work. Made the add and extract dialog to be centered on the parent window. Removed double function extract_local_path() from string_utils.c Modified: xarchiver/trunk/TODO =================================================================== --- xarchiver/trunk/TODO 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/TODO 2008-08-10 11:04:46 UTC (rev 27438) @@ -1,5 +1,4 @@ - reduce the loading time when opening large archives. -- finish developing the callbacks for the popup menu. - develop the dlg-open dialog. - develop the extract multi archive. - fix crash when opening rar archives produces under winzozz. Modified: xarchiver/trunk/src/7zip.c =================================================================== --- xarchiver/trunk/src/7zip.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/7zip.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -197,7 +197,8 @@ void xa_7zip_add (XArchive *archive,GSList *names,gchar *compression_string) { GSList *list = NULL; - GSList *dirlist; + GSList *dirlist = NULL; + GSList *_names = NULL; gchar *command,*exe = NULL; GString *files = g_string_new(""); @@ -206,12 +207,22 @@ if (sevenza) exe = "7za "; - while (names) + _names = names; + while (_names) { - xa_7zip_recurse_local_directory((gchar*)names->data,&dirlist,archive->add_recurse); - names = names->next; + xa_7zip_recurse_local_directory((gchar*)_names->data,&dirlist,archive->add_recurse); + _names = _names->next; } - xa_cat_filenames(archive,dirlist,files); + if (dirlist == NULL) + xa_cat_filenames(archive,names,files); + else + xa_cat_filenames(archive,dirlist,files); + + if (dirlist != NULL) + { + g_slist_foreach(dirlist,(GFunc)g_free,NULL); + g_slist_free(dirlist); + } g_slist_foreach(names,(GFunc)g_free,NULL); g_slist_free(names); @@ -275,7 +286,7 @@ result = xa_run_command (archive,list); return result; - } +} void xa_7zip_test (XArchive *archive) { Modified: xarchiver/trunk/src/add_dialog.c =================================================================== --- xarchiver/trunk/src/add_dialog.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/add_dialog.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -35,7 +35,8 @@ add_dialog->dialog1 = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (add_dialog->dialog1), _("Add files to the archive")); - gtk_window_set_transient_for (GTK_WINDOW (add_dialog->dialog1),GTK_WINDOW(xa_main_window)); + gtk_window_set_position (GTK_WINDOW (add_dialog->dialog1),GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_type_hint (GTK_WINDOW (add_dialog->dialog1), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator (GTK_DIALOG (add_dialog->dialog1),FALSE); add_dialog->add_option_tooltip = gtk_tooltips_new (); @@ -106,13 +107,13 @@ add_dialog->update = gtk_check_button_new_with_mnemonic (_("Update and add")); gtk_button_set_focus_on_click (GTK_BUTTON (add_dialog->update), FALSE); - gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->update, _("This option will add any new files and update any files which have been modified since the archive was last created/modified."), NULL ); + gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->update, _("This option will add any new files and update any files which have been modified since the archive was last created/modified"), NULL ); gtk_box_pack_start (GTK_BOX (vbox3), add_dialog->update, FALSE, FALSE, 0); add_dialog->freshen = gtk_check_button_new_with_mnemonic (_("Freshen and replace")); gtk_button_set_focus_on_click (GTK_BUTTON (add_dialog->freshen), FALSE); - gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->freshen , _("This option affects the archive only if it has been modified more recently than the version already in the archive; unlike the update option it will not add files that are not already in the archive."), NULL ); + gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->freshen , _("This option affects the archive only if it has been modified more recently than the version already in the archive; unlike the update option it will not add files that are not already in the archive"), NULL ); gtk_box_pack_start (GTK_BOX (vbox3), add_dialog->freshen, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (add_dialog->freshen),"toggled",G_CALLBACK (add_fresh_update_toggled_cb) , add_dialog); @@ -122,7 +123,7 @@ add_dialog->solid_archive = gtk_check_button_new_with_mnemonic (_("Create a solid archive")); gtk_button_set_focus_on_click (GTK_BUTTON (add_dialog->solid_archive), FALSE); - gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->solid_archive , _("In a solid archive the files are grouped together featuring a better compression ratio."), NULL); + gtk_tooltips_set_tip (add_dialog->option_tooltip,add_dialog->solid_archive , _("In a solid archive the files are grouped together featuring a better compression ratio"), NULL); gtk_box_pack_start (GTK_BOX (vbox3), add_dialog->solid_archive, FALSE, FALSE, 0); add_dialog->remove_files = gtk_check_button_new_with_mnemonic (_("Delete files after adding")); @@ -430,6 +431,7 @@ if (xa_main_window) { + gtk_label_set_text(GTK_LABEL(total_label),_("Adding files to the archive, please wait...")); /* This in case the user wants to add files in the archive directories */ if (archive->location_entry_path != NULL) { Modified: xarchiver/trunk/src/deb.c =================================================================== --- xarchiver/trunk/src/deb.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/deb.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -100,7 +100,6 @@ n++; line[linesize-1] = '\0'; - filename = line + n; archive->nr_of_files++; filename = g_strdup(line + n); Modified: xarchiver/trunk/src/extract_dialog.c =================================================================== --- xarchiver/trunk/src/extract_dialog.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/extract_dialog.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -27,6 +27,12 @@ extern Prefs_dialog_data *prefs_window; gchar *rar; +static void remove_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GList **rowref_list); +static const GtkTargetEntry drop_targets[] = +{ + { "text/uri-list", 0, 0 }, +}; + Extract_dialog_data *xa_create_extract_dialog() { GSList *radiobutton1_group = NULL; @@ -35,8 +41,8 @@ dialog_data = g_new0 (Extract_dialog_data,1); dialog_data->dialog1 = gtk_dialog_new(); - gtk_window_set_type_hint (GTK_WINDOW (dialog_data->dialog1), GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_transient_for (GTK_WINDOW(dialog_data->dialog1),GTK_WINDOW (xa_main_window)); + gtk_window_set_position (GTK_WINDOW (dialog_data->dialog1),GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_type_hint (GTK_WINDOW (dialog_data->dialog1),GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator (GTK_DIALOG(dialog_data->dialog1),FALSE); gtk_window_set_destroy_with_parent(GTK_WINDOW (dialog_data->dialog1),TRUE); @@ -114,20 +120,20 @@ gtk_box_pack_start (GTK_BOX (vbox5), dialog_data->overwrite_check,FALSE,FALSE,0); dialog_data->extract_full = gtk_check_button_new_with_mnemonic (_("Extract files with full path")); - gtk_tooltips_set_tip(option_tooltip,dialog_data->extract_full , _("The archive's directory structure is recreated in the extraction directory."), NULL ); + gtk_tooltips_set_tip(option_tooltip,dialog_data->extract_full , _("The archive's directory structure is recreated in the extraction directory"), NULL ); gtk_box_pack_start (GTK_BOX (vbox5), dialog_data->extract_full, FALSE, FALSE, 0); dialog_data->touch = gtk_check_button_new_with_mnemonic (_("Touch files")); - gtk_tooltips_set_tip (option_tooltip,dialog_data->touch, _("When this option is used, tar leaves the data modification times of the files it extracts as the times when the files were extracted, instead of setting it to the times recorded in the archive."), NULL ); + gtk_tooltips_set_tip (option_tooltip,dialog_data->touch, _("When this option is used, tar leaves the data modification times of the files it extracts as the times when the files were extracted, instead of setting it to the times recorded in the archive"), NULL ); gtk_box_pack_start (GTK_BOX (vbox5), dialog_data->touch, FALSE,FALSE,0); dialog_data->fresh = gtk_check_button_new_with_mnemonic (_("Freshen existing files")); - gtk_tooltips_set_tip (option_tooltip,dialog_data->fresh , _("Extract only those files that already exist on disk and that are newer than the disk copies."), NULL ); + gtk_tooltips_set_tip (option_tooltip,dialog_data->fresh , _("Extract only those files that already exist on disk and that are newer than the disk copies"), NULL ); gtk_box_pack_start (GTK_BOX (vbox5), dialog_data->fresh, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (dialog_data->fresh),"toggled",G_CALLBACK (fresh_update_toggled_cb) , dialog_data); dialog_data->update = gtk_check_button_new_with_mnemonic (_("Update existing files")); - gtk_tooltips_set_tip (option_tooltip,dialog_data->update , _("This option performs the same function as the freshen one, extracting files that are newer than those with the same name on disk, and in addition it extracts those files that do not already exist on disk."), NULL ); + gtk_tooltips_set_tip (option_tooltip,dialog_data->update , _("This option performs the same function as the freshen one, extracting files that are newer than those with the same name on disk, and in addition it extracts those files that do not already exist on disk"), NULL ); gtk_box_pack_start (GTK_BOX (vbox5), dialog_data->update, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (dialog_data->update),"toggled",G_CALLBACK (update_fresh_toggled_cb) , dialog_data); @@ -326,7 +332,7 @@ gchar *archive_dir = NULL; gboolean flag = TRUE; - archive_dir = remove_level_from_path (archive->path); + archive_dir = xa_remove_level_from_path (archive->path); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_save_geometry)) && prefs_window->extract_dialog[0] != -1) gtk_window_set_default_size (GTK_WINDOW(dialog_data->dialog1), prefs_window->extract_dialog[0], prefs_window->extract_dialog[1]); @@ -567,3 +573,249 @@ gtk_tree_path_free (path); g_signal_handler_disconnect (G_OBJECT(widget),dialog->signal_id); } + +GtkWidget *xa_create_multi_extract_dialog() +{ + GtkWidget *multi_extract,*dialog_vbox1,*vbox1,*scrolledwindow1,*files_treeview,*hbox2,*remove_button,*add_button,*hbox1,*frame1,*alignment1, + *vbox2,*hbox3,*radiobutton3,*entry1,*button1,*radiobutton2,*label1,*frame2,*alignment2,*vbox3,*overwrite,*full_path,*label2,*dialog_action_area1, + *cancelbutton1,*extract_button,*extract_image,*extract_hbox,*extract_label,*image1; + GtkCellRenderer *renderer; + GtkTreeSelection *selection; + GtkTreeViewColumn *column; + GSList *radiobutton1_group = NULL; + GtkTooltips *multi_tooltip; + int x; + char *column_names[]= {(_("Filename")),(_("Size")),(_("Path")),NULL}; + + multi_tooltip = gtk_tooltips_new (); + multi_extract = gtk_dialog_new(); + gtk_window_set_title (GTK_WINDOW (multi_extract), _("Multi-Extract dialog")); + gtk_window_set_destroy_with_parent (GTK_WINDOW (multi_extract), TRUE); + gtk_window_set_position (GTK_WINDOW (multi_extract),GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_transient_for (GTK_WINDOW (multi_extract),GTK_WINDOW (xa_main_window)); + gtk_window_set_type_hint (GTK_WINDOW (multi_extract), GDK_WINDOW_TYPE_HINT_DIALOG); + gtk_dialog_set_has_separator (GTK_DIALOG (multi_extract), FALSE); + gtk_widget_set_size_request(multi_extract,455,294); + + dialog_vbox1 = GTK_DIALOG (multi_extract)->vbox; + vbox1 = gtk_vbox_new (FALSE, 5); + gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0); + scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); + gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN); + + files_liststore = gtk_list_store_new (3,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING); + files_treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(files_liststore)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(files_treeview) ); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); + + for (x = 0; x < 3; x++) + { + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes ( column_names[x],renderer,"text",x,NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column(GTK_TREE_VIEW(files_treeview),column); + } + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(files_treeview), TRUE); + gtk_container_add (GTK_CONTAINER (scrolledwindow1),files_treeview); + + gtk_drag_dest_set (files_treeview,GTK_DEST_DEFAULT_ALL, drop_targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK); + /*g_signal_connect (G_OBJECT (files_treeview),"drag-data-received",G_CALLBACK (add_drag_data_received),add_dialog);*/ + + hbox2 = gtk_hbox_new (TRUE, 5); + gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, TRUE, 0); + + add_button = gtk_button_new_from_stock ("gtk-add"); + gtk_box_pack_end (GTK_BOX (hbox2), add_button, FALSE, FALSE, 0); + gtk_button_set_focus_on_click (GTK_BUTTON (add_button), FALSE); + g_signal_connect ( (gpointer) add_button, "clicked", G_CALLBACK (xa_select_files_to_add),files_treeview); + + remove_button = gtk_button_new_from_stock ("gtk-remove"); + gtk_widget_set_sensitive (remove_button,FALSE); + gtk_box_pack_end (GTK_BOX (hbox2), remove_button, FALSE, FALSE, 0); + gtk_button_set_focus_on_click (GTK_BUTTON (remove_button), FALSE); + g_signal_connect ( (gpointer) remove_button,"clicked", G_CALLBACK (xa_remove_files_liststore),files_treeview); + g_signal_connect (G_OBJECT (files_liststore),"row-inserted",G_CALLBACK (xa_activate_remove_button),remove_button); + + /* Destination dirs frame */ + hbox1 = gtk_hbox_new (TRUE, 8); + gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0); + frame1 = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (hbox1), frame1, TRUE, TRUE, 0); + gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_OUT); + alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_container_add (GTK_CONTAINER (frame1), alignment1); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0); + vbox2 = gtk_vbox_new (TRUE, 0); + gtk_container_add (GTK_CONTAINER (alignment1), vbox2); + hbox3 = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0); + radiobutton3 = gtk_radio_button_new_with_mnemonic (NULL, _("Extract to:")); + gtk_box_pack_start (GTK_BOX (hbox3), radiobutton3, FALSE, FALSE, 0); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton3), radiobutton1_group); + radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton3)); + entry1 = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox3), entry1, TRUE, TRUE, 0); + gtk_entry_set_width_chars (GTK_ENTRY (entry1), 5); + + button1 = gtk_button_new (); + image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1); + gtk_box_pack_end(GTK_BOX (hbox3),button1, FALSE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(button1),image1); + + radiobutton2 = gtk_radio_button_new_with_mnemonic (NULL, _("Extract to dir \"archive name\"")); + gtk_tooltips_set_tip (multi_tooltip,radiobutton2,_("This option extracts archives in the directories named with their filenames"), NULL ); + gtk_box_pack_start (GTK_BOX (vbox2), radiobutton2, FALSE, FALSE, 0); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton2), radiobutton1_group); + radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton2)); + label1 = gtk_label_new (_("Destination dirs:")); + gtk_frame_set_label_widget (GTK_FRAME (frame1), label1); + + /* Option frame */ + frame2 = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (hbox1), frame2, TRUE, TRUE, 0); + gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_OUT); + alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_container_add (GTK_CONTAINER (frame2), alignment2); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0); + vbox3 = gtk_vbox_new (TRUE, 0); + gtk_container_add (GTK_CONTAINER (alignment2), vbox3); + overwrite = gtk_check_button_new_with_mnemonic (_("Overwrite existing files")); + gtk_box_pack_start (GTK_BOX (vbox3), overwrite, FALSE, FALSE, 0); + full_path = gtk_check_button_new_with_mnemonic (_("Extract pathnames")); + gtk_box_pack_start (GTK_BOX (vbox3), full_path, FALSE, FALSE, 0); + label2 = gtk_label_new (_("Options:")); + gtk_frame_set_label_widget (GTK_FRAME (frame2), label2); + + dialog_action_area1 = GTK_DIALOG (multi_extract)->action_area; + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); + cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); + gtk_dialog_add_action_widget (GTK_DIALOG (multi_extract), cancelbutton1, GTK_RESPONSE_CANCEL); + GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); + + extract_button = gtk_button_new(); + extract_image = xa_main_window_find_image("xarchiver-extract.png", GTK_ICON_SIZE_SMALL_TOOLBAR); + extract_hbox = gtk_hbox_new(FALSE,4); + extract_label = gtk_label_new_with_mnemonic(_("_Extract")); + + alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_container_add (GTK_CONTAINER (alignment3),extract_hbox); + gtk_box_pack_start(GTK_BOX(extract_hbox),extract_image,FALSE,FALSE,0); + gtk_box_pack_start(GTK_BOX(extract_hbox),extract_label,FALSE,FALSE,0); + gtk_container_add(GTK_CONTAINER(extract_button),alignment3); + + gtk_dialog_add_action_widget (GTK_DIALOG (multi_extract),extract_button,GTK_RESPONSE_OK); + GTK_WIDGET_SET_FLAGS (extract_button, GTK_CAN_DEFAULT); + gtk_dialog_set_default_response (GTK_DIALOG (multi_extract),GTK_RESPONSE_OK); + gtk_widget_show_all(multi_extract); + return multi_extract; +} + +void xa_select_files_to_add ( GtkButton* button, gpointer data) +{ + GtkWidget *file_selector; + GSList *dummy = NULL; + gint response; + + file_selector = gtk_file_chooser_dialog_new (_("Please select the archives you want to extract"), + GTK_WINDOW (xa_main_window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, + GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(file_selector),TRUE); + response = gtk_dialog_run (GTK_DIALOG(file_selector)); + if (response == GTK_RESPONSE_ACCEPT) + { + dummy = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (file_selector)); + g_slist_foreach( dummy, (GFunc) xa_add_files_liststore,files_liststore); + } + if (dummy != NULL) + g_slist_free (dummy); + gtk_widget_destroy(file_selector); + return; +} + +void xa_add_files_liststore (gchar *file_path, GtkListStore *liststore) +{ + GtkTreeIter iter; + gchar *file_utf8,*_file_utf8; + gchar *path; + struct stat my_stat; + unsigned long long int file_size; + + if (xa_detect_archive_type(file_path) < 0) + return; + + stat (file_path,&my_stat); + file_size = my_stat.st_size; + file_utf8 = g_filename_display_name (file_path); + path = xa_remove_level_from_path(file_utf8); + _file_utf8 = xa_remove_path_from_archive_name(file_utf8); + g_free (file_utf8); + file_utf8 = _file_utf8; + gtk_list_store_append(liststore, &iter); + gtk_list_store_set (liststore, &iter,0,file_utf8,1,file_size,2,path,-1); + g_free (file_utf8); + g_free (path); +} + +void xa_remove_files_liststore (GtkWidget *widget, GtkTreeView *treeview) +{ + GtkTreeModel *model; + GtkTreeSelection *sel; + GtkTreePath *path; + GtkTreeIter iter; + GList *rr_list = NULL; + GList *node; + + model = gtk_tree_view_get_model(treeview); + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview) ); + gtk_tree_selection_selected_foreach(sel, (GtkTreeSelectionForeachFunc) remove_foreach_func, &rr_list); + + for (node = rr_list; node != NULL; node = node->next) + { + path = gtk_tree_row_reference_get_path((GtkTreeRowReference *) node->data); + if (path) + { + if ( gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path) ) + gtk_list_store_remove(files_liststore, &iter); + gtk_tree_path_free(path); + } + } + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter) == FALSE) + gtk_widget_set_sensitive ( widget, FALSE); + g_list_foreach(rr_list, (GFunc) gtk_tree_row_reference_free, NULL); + g_list_free(rr_list); +} + +static void remove_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GList **rowref_list) +{ + GtkTreeRowReference *rowref; + + rowref = gtk_tree_row_reference_new(model, path); + *rowref_list = g_list_append(*rowref_list, rowref); +} + +void xa_activate_remove_button (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, GtkWidget *remove_button) +{ + if (gtk_tree_model_get_iter_first(tree_model, iter) == TRUE) + gtk_widget_set_sensitive (remove_button, TRUE ); +} + +gboolean xa_multi_extract_archive(GtkWidget *dialog) +{ + /*case GTK_RESPONSE_OK: + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(add_dialog->file_liststore), &iter) == FALSE) + { + response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't extract archives:"), _("You haven't selected any archives!") ); + break; + }*/ + gtk_widget_destroy(dialog); + return TRUE; +} + Modified: xarchiver/trunk/src/extract_dialog.h =================================================================== --- xarchiver/trunk/src/extract_dialog.h 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/extract_dialog.h 2008-08-10 11:04:46 UTC (rev 27438) @@ -52,6 +52,7 @@ GtkTreeStore *model; GtkTreeViewColumn *column; GtkTooltips *option_tooltip; +GtkListStore *files_liststore; Extract_dialog_data *xa_create_extract_dialog(); void xa_create_dir_button_pressed (GtkButton *, gpointer ); @@ -67,5 +68,11 @@ void xa_row_activated(GtkTreeView *,GtkTreePath *,GtkTreeViewColumn *,gpointer ); void xa_expand_dir(GtkTreeView *,GtkTreeIter *,GtkTreePath *,gpointer ); void xa_treeview_exposed (GtkWidget *,GdkEventExpose *,gpointer ); +GtkWidget *xa_create_multi_extract_dialog(); +void xa_remove_files_liststore (GtkWidget *, GtkTreeView *); +void xa_activate_remove_button (GtkTreeModel *, GtkTreePath *, GtkTreeIter *, GtkWidget *); +gboolean xa_multi_extract_archive(GtkWidget *); +void xa_select_files_to_add ( GtkButton* , gpointer ); +void xa_add_files_liststore (gchar *, GtkListStore *); #endif Modified: xarchiver/trunk/src/interface.c =================================================================== --- xarchiver/trunk/src/interface.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/interface.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -181,11 +181,10 @@ gtk_widget_show (image2); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (extract_menu),image2); - delete_menu = gtk_image_menu_item_new_from_stock ("gtk-delete",accel_group); + delete_menu = gtk_image_menu_item_new_from_stock ("gtk-delete",NULL); gtk_widget_set_sensitive (delete_menu,FALSE); gtk_widget_show (delete_menu); gtk_container_add (GTK_CONTAINER (menuitem2_menu),delete_menu); - gtk_widget_add_accelerator (delete_menu,"activate",accel_group,GDK_Delete,GDK_MODE_DISABLED,GTK_ACCEL_VISIBLE); rename_menu = gtk_image_menu_item_new_with_mnemonic (_("Rename")); gtk_widget_set_sensitive (rename_menu,FALSE); @@ -221,6 +220,11 @@ gtk_widget_show (tmp_image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (comment_menu),tmp_image); + multi_extract = gtk_menu_item_new_with_mnemonic (_("_Multi-Extract")); + gtk_widget_show (multi_extract); + gtk_container_add (GTK_CONTAINER (menuitem2_menu),multi_extract); + gtk_widget_add_accelerator (multi_extract,"activate",accel_group,GDK_m,GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE); + separatormenuitem4 = gtk_separator_menu_item_new (); gtk_widget_show (separatormenuitem4); gtk_container_add (GTK_CONTAINER (menuitem2_menu),separatormenuitem4); @@ -253,9 +257,9 @@ gtk_container_add (GTK_CONTAINER (menuitem2_menu),separatormenuitem5); gtk_widget_set_sensitive (separatormenuitem5,FALSE); - view_shell_output1 = gtk_image_menu_item_new_with_mnemonic (_("C_md-line output")); + view_shell_output1 = gtk_image_menu_item_new_with_mnemonic (_("Cmd-line outp_ut")); gtk_container_add (GTK_CONTAINER (menuitem2_menu),view_shell_output1); - gtk_widget_add_accelerator (view_shell_output1,"activate",accel_group,GDK_m,GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (view_shell_output1,"activate",accel_group,GDK_u,GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE); if (show_output_menu_item) gtk_widget_set_sensitive(view_shell_output1,TRUE); else @@ -535,6 +539,7 @@ g_signal_connect ((gpointer) delete_menu,"activate",G_CALLBACK (xa_delete_archive),NULL); g_signal_connect ((gpointer) rename_menu,"activate",G_CALLBACK (xa_rename_archive),NULL); g_signal_connect ((gpointer) comment_menu,"activate",G_CALLBACK (xa_show_archive_comment),NULL); + g_signal_connect ((gpointer) multi_extract,"activate",G_CALLBACK (xa_show_multi_extract_dialog),NULL); g_signal_connect ((gpointer) help1,"activate",G_CALLBACK (xa_show_help),NULL); g_signal_connect ((gpointer) about1,"activate",G_CALLBACK (xa_about),NULL); @@ -549,8 +554,6 @@ g_signal_connect ((gpointer) AddFile_button,"clicked",G_CALLBACK (xa_add_files_archive), NULL); g_signal_connect ((gpointer) Extract_button,"clicked",G_CALLBACK (xa_extract_archive), NULL); g_signal_connect ((gpointer) Stop_button, "clicked",G_CALLBACK (xa_cancel_archive), NULL); - g_signal_connect (xa_main_window, "key-press-event",G_CALLBACK (key_press_function), NULL); - gtk_window_add_accel_group (GTK_WINDOW (xa_main_window),accel_group); } @@ -1048,10 +1051,11 @@ g_signal_connect(archive_properties_window,"response",G_CALLBACK(gtk_widget_destroy),NULL); g_signal_connect(archive_properties_window,"delete-event",G_CALLBACK(gtk_widget_destroy),NULL); - gtk_window_set_position (GTK_WINDOW (archive_properties_window),GTK_WIN_POS_CENTER); + gtk_window_set_position (GTK_WINDOW (archive_properties_window),GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_transient_for (GTK_WINDOW (archive_properties_window),GTK_WINDOW (xa_main_window)); + gtk_window_set_type_hint (GTK_WINDOW (archive_properties_window),GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_resizable (GTK_WINDOW (archive_properties_window),FALSE); gtk_window_set_modal (GTK_WINDOW (archive_properties_window),TRUE); - gtk_window_set_type_hint (GTK_WINDOW (archive_properties_window),GDK_WINDOW_TYPE_HINT_UTILITY); gtk_dialog_set_has_separator(GTK_DIALOG(archive_properties_window),FALSE); table1 = gtk_table_new (9,2,TRUE); @@ -1259,7 +1263,10 @@ new_entry = archive[idx]->current_entry; if (new_entry->prev->prev == NULL) + { + gtk_widget_set_sensitive(back_button,FALSE); xa_update_window_with_archive_entries(archive[idx],NULL); + } else xa_update_window_with_archive_entries(archive[idx],new_entry->prev); @@ -1284,19 +1291,18 @@ gboolean back = FALSE,up = FALSE,forward = FALSE,home=FALSE; /*If the pointers exist,we should show the icon*/ - if(archive[idx]->forward!=NULL) forward=TRUE; - if(archive[idx]->back!=NULL) back=TRUE; + if(archive[idx]->forward !=NULL) + forward = TRUE; + if(archive[idx]->back !=NULL) + back = TRUE; + if(archive[idx]->location_entry_path!=NULL) { /* If there's a slash on the path,we should allow UP and HOME operations */ if(strstr(archive[idx]->location_entry_path,"/")!=NULL) - { - home=TRUE; - up=TRUE; - } + home = up = TRUE; } - gtk_widget_set_sensitive(back_button,back); gtk_widget_set_sensitive(forward_button,forward); gtk_widget_set_sensitive(up_button,up); @@ -1390,7 +1396,7 @@ if (archive[idx]->location_entry_path != NULL) g_free(archive[idx]->location_entry_path); - /* This to store the dragged files inside the dropped archive dir */ + /* This is to have the dragged files stored inside current archive location entry */ archive[idx]->location_entry_path = g_strdup(full_pathname->str); dummy_password = archive[idx]->has_passwd; full_path = archive[idx]->full_path; Modified: xarchiver/trunk/src/interface.h =================================================================== --- xarchiver/trunk/src/interface.h 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/interface.h 2008-08-10 11:04:46 UTC (rev 27438) @@ -35,7 +35,7 @@ *archive_properties_window, *table1, *path_label, *modified_label, *size_label, *content_label, *comment_label, *compression_label, *number_of_files_label, *name_label, *type_label, *compression_data, *number_of_files_data, *content_data, *comment_data, *size_data, *modified_data, *path_data, *type_data, *name_data, *separatormenuitem1, *separatormenuitem2, *separatormenuitem3, *separatormenuitem4, *separatormenuitem5, *separatormenuitem6, *quit1, -*close1, *check_menu, *properties, *menuitem2, *menuitem2_menu, *addfile, *extract_menu, *delete_menu, *comment_menu, *view_shell_output1, +*close1, *check_menu, *properties, *menuitem2, *menuitem2_menu, *addfile, *extract_menu, *delete_menu, *comment_menu, *multi_extract,*view_shell_output1, *prefs_menu,*password_entry_menu, *image1, *image2, *menuitem4, *select_all,*deselect_all,*select_pattern, *exe_menu, *menuitem4_menu, *about1, *help1, *toolbar1, *toolbar2, *hbox1, *tmp_image, *pad_image, *New_button, *Open_button, *back_button, *home_button, *forward_button, *up_button,*separatortoolitem1,*separatortoolitem2,*separatortoolitem3,*AddFile_button,*Extract_button,*Stop_button,*toolitem1,*location_label, Modified: xarchiver/trunk/src/main.c =================================================================== --- xarchiver/trunk/src/main.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/main.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -216,6 +216,8 @@ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs_window->store_output)), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs_window->show_sidebar))); + gtk_window_set_transient_for (GTK_WINDOW (extract_window->dialog1),GTK_WINDOW (xa_main_window)); + gtk_window_set_transient_for (GTK_WINDOW (add_window->dialog1),GTK_WINDOW (xa_main_window)); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_window->check_save_geometry)) && prefs_window->geometry[0] != -1) { gtk_window_move (GTK_WINDOW(xa_main_window), prefs_window->geometry[0], prefs_window->geometry[1]); Modified: xarchiver/trunk/src/string_utils.c =================================================================== --- xarchiver/trunk/src/string_utils.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/string_utils.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -148,9 +148,15 @@ return escaped; } -gchar *remove_level_from_path (const gchar *path) +gchar *xa_remove_level_from_path (const gchar *path) { - return g_path_get_dirname(path); + gchar *local_path; + gchar *local_escaped_path; + + local_path = g_path_get_dirname (path); + local_escaped_path = xa_escape_bad_chars ( local_path ,"$\'`\"\\!?* ()[]&|@#:;"); + g_free (local_path); + return local_escaped_path; } gboolean file_extension_is (const char *filename, const char *ext) @@ -166,17 +172,6 @@ } /* End code from File-Roller */ -gchar *extract_local_path (gchar *path) -{ - gchar *local_path; - gchar *local_escaped_path; - - local_path = g_path_get_dirname (path); - local_escaped_path = xa_escape_bad_chars ( local_path ,"$\'`\"\\!?* ()[]&|@#:;"); - g_free (local_path); - return local_escaped_path; -} - void xa_set_window_title (GtkWidget *window,gchar *title) { gchar *x = NULL; Modified: xarchiver/trunk/src/string_utils.h =================================================================== --- xarchiver/trunk/src/string_utils.h 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/string_utils.h 2008-08-10 11:04:46 UTC (rev 27438) @@ -32,9 +32,8 @@ #endif gchar *xa_escape_bad_chars ( gchar *string , gchar *pattern); char *xa_escape_common_chars (const char *str, const char *meta_chars, const char prefix, const char postfix); -gchar *remove_level_from_path (const gchar *path); +gchar *xa_remove_level_from_path (const gchar *path); gboolean file_extension_is (const char *filename, const char *ext); -gchar *extract_local_path (gchar *path); void xa_set_window_title ( GtkWidget *window , gchar *title); gboolean match_patterns (char **patterns,const char *string,int flags); gchar *xa_remove_path_from_archive_name(gchar *name); Modified: xarchiver/trunk/src/window.c =================================================================== --- xarchiver/trunk/src/window.c 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/window.c 2008-08-10 11:04:46 UTC (rev 27438) @@ -780,6 +780,7 @@ current_page = gtk_notebook_get_current_page (notebook); id = xa_find_archive_index (current_page); + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (archive[id]->treeview)); row_list = gtk_tree_selection_get_selected_rows(selection, &archive[id]->model); @@ -813,7 +814,6 @@ if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) return; } - (*archive[id]->delete) (archive[id],list); } @@ -1392,6 +1392,7 @@ gtk_tree_view_append_column (GTK_TREE_VIEW (archive->treeview), column); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); g_signal_connect (archive->renderer_text, "editing-canceled",G_CALLBACK (xa_rename_cell_edited_canceled),archive); + g_signal_connect (archive->renderer_text, "editing-started" ,G_CALLBACK(xa_rename_cell_editing_started),archive); g_signal_connect (archive->renderer_text, "edited",G_CALLBACK (xa_rename_cell_edited),archive); /* All the others */ @@ -1471,7 +1472,7 @@ gtk_entry_set_text ( GTK_ENTRY (name_data), utf8_string ); g_free (utf8_string); /* Path */ - dummy_string = remove_level_from_path (archive[idx]->path); + dummy_string = xa_remove_level_from_path (archive[idx]->path); if (strlen(dummy_string) == 0 || strcmp(dummy_string,"..") == 0) utf8_string = g_filename_display_name (g_get_current_dir ()); else @@ -1809,7 +1810,7 @@ } } } - archive->extraction_path = extract_local_path (no_uri_path); + archive->extraction_path = xa_remove_level_from_path (no_uri_path); g_free (no_uri_path); if (archive->extraction_path != NULL) to_send = "S"; @@ -1912,6 +1913,7 @@ while (array[len]) { filename = g_filename_from_uri (array[len],NULL,NULL); + g_print ("drag_data: %s\n",filename); list = g_slist_append(list,filename); len++; } @@ -1930,20 +1932,6 @@ g_strfreev (array); } -gboolean key_press_function (GtkWidget *widget, GdkEventKey *event, gpointer data) -{ - if (event == NULL) - return FALSE; - switch (event->keyval) - { - case GDK_Escape: - xa_cancel_archive (NULL, NULL); - break; - - } - return FALSE; -} - void xa_concat_filenames (GtkTreeModel *model, GtkTreePath *treepath, GtkTreeIter *iter, GSList **data) { XEntry *entry = NULL; @@ -2585,6 +2573,32 @@ g_object_set(renderer,"editable",FALSE,NULL); } +void xa_rename_cell_editing_started (GtkCellRenderer *cell,GtkCellEditable *editable,const gchar *path,XArchive *archive) +{ + GtkEntry *gtk_entry; + gchar *text; + XEntry *entry; + glong offset; + GtkTreeModel *model; + GtkTreeIter iter; + + if (GTK_IS_ENTRY (editable)) + { + model = gtk_tree_view_get_model(GTK_TREE_VIEW(archive->treeview)); + gtk_tree_model_get_iter_from_string(model,&iter,path); + gtk_tree_model_get(model,&iter,archive->nc+1,&entry,-1); + text = g_utf8_strrchr (entry->filename,-1,'.'); + if (G_LIKELY (text != NULL)) + { + gtk_entry = GTK_ENTRY (editable); + gtk_widget_grab_focus (GTK_WIDGET(gtk_entry)); + offset = g_utf8_pointer_to_offset (entry->filename,text); + if (G_LIKELY (offset > 0)) + gtk_editable_select_region (GTK_EDITABLE(editable),0,offset); + } + } +} + void xa_rename_cell_edited (GtkCellRendererText *cell,const gchar *path_string,const gchar *new_name,XArchive *archive) { GtkTreeIter iter; @@ -2844,3 +2858,21 @@ xa_fill_dir_sidebar(archive,FALSE); xa_set_statusbar_message_for_displayed_rows(archive); } + +void xa_show_multi_extract_dialog ( GtkMenuItem *menu_item, gpointer data) +{ + GtkWidget *dialog; + gint response; + gboolean result = FALSE; + + dialog = xa_create_multi_extract_dialog(); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) + { + gtk_widget_destroy(dialog); + return; + } + result = xa_multi_extract_archive(dialog); + if (result) + xa_show_cmd_line_output(NULL,NULL); +} Modified: xarchiver/trunk/src/window.h =================================================================== --- xarchiver/trunk/src/window.h 2008-08-09 22:54:29 UTC (rev 27437) +++ xarchiver/trunk/src/window.h 2008-08-10 11:04:46 UTC (rev 27438) @@ -82,6 +82,7 @@ void xa_select_all ( GtkMenuItem *, gpointer); void xa_deselect_all ( GtkMenuItem *, gpointer); void xa_show_archive_comment ( GtkMenuItem *, gpointer); +void xa_show_multi_extract_dialog ( GtkMenuItem *, gpointer); void xa_archive_properties ( GtkMenuItem * , gpointer); void xa_view_file_inside_archive ( GtkMenuItem * , gpointer); void xa_cancel_archive ( GtkMenuItem * , gpointer); @@ -109,6 +110,7 @@ void xa_clipboard_paste(GtkMenuItem*,gpointer ); void xa_rename_archive(GtkMenuItem *,gpointer ); void xa_rename_cell_edited_canceled(GtkCellRenderer *,gpointer ); +void xa_rename_cell_editing_started (GtkCellRenderer *,GtkCellEditable *,const gchar *,XArchive *); void xa_rename_cell_edited (GtkCellRendererText *,const gchar *,const gchar *,XArchive * ); void xa_open_file_from_popupmenu(GtkMenuItem *,gpointer ); void xa_clipboard_cut_copy_operation(XArchive *, XAClipboardMode ); @@ -123,7 +125,6 @@ gboolean xa_launch_external_program(gchar *,gchar *); gboolean xa_detect_archive_comment (int ,gchar *,XArchive *); -gboolean key_press_function ( GtkWidget* , GdkEventKey* ,gpointer ); gboolean treeview_select_search (GtkTreeModel *,gint ,const gchar *,GtkTreeIter *,gpointer ); gboolean xa_check_child_for_error_on_exit(XArchive *,gint ); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits