Hello thunar hackers! I'm a new Thunar user. First of all I must say that Thunar is a great file manager !!
The invert-selection is a feature request in thunar to have an option to invert the current selection. That is, if we have 25 items in a folder, and we select any 10 random items, on clicking Invert Selection, the other 15 items will be selected, and the original 10 items will be de-selected. Please, take a look at: http://foo-projects.org/pipermail/thunar-dev/2005-March/000493.html Use Case: When I'm backing up data from a certain directory, I select some files that would fit on a CD. After burning these files, I'd like to be able to select the remaining ones easily, so I can put them on another disc. Right now I have to unselect the files, and then manually choose the ones I haven't burned carefully. Or, insert the burnt disc and compare visually myself to only choose the files which haven't been burnt. This is tedious and not very confortable when you're doing the same operation repeatedly or when the number of files is large. This email contain my first patch to contribute with Thunar File Manager Revolution :-) I hope that is useful. Cheers. Fernando Maróstica.
--- thunar.orig/thunar/thunar-standard-view-ui.xml 2007-10-29 11:56:21.000000000 -0300 +++ thunar/thunar/thunar-standard-view-ui.xml 2007-10-29 10:02:30.000000000 -0300 @@ -30,6 +30,7 @@ </placeholder> <placeholder name="placeholder-edit-select-actions"> <menuitem action="select-all-files" /> + <menuitem action="invert-selection" /> <menuitem action="select-by-pattern" /> </placeholder> <placeholder name="placeholder-edit-alter-actions"> --- thunar.orig/thunar/thunar-standard-view.h 2007-10-29 11:56:21.000000000 -0300 +++ thunar/thunar/thunar-standard-view.h 2007-10-29 10:18:27.000000000 -0300 @@ -65,6 +65,10 @@ void (*select_path) (ThunarStandardView *standard_view, GtkTreePath *path); + /* Invert selection of items in the view */ + void (*invert_selection) (ThunarStandardView *standard_view); + + /* Called by the ThunarStandardView class to let derived class * place the cursor on the item/row referred to by path. If * start_editing is TRUE, the derived class should also start @@ -74,7 +78,7 @@ GtkTreePath *path, gboolean start_editing); - /* Called by the ThunarStandardView class to let derived class + /* Callet by the ThunarStandardView class to let derived class * scroll the view to the given path. */ void (*scroll_to_path) (ThunarStandardView *standard_view, --- thunar.orig/thunar/thunar-standard-view.c 2007-10-29 11:56:21.000000000 -0300 +++ thunar/thunar/thunar-standard-view.c 2007-10-29 10:10:48.000000000 -0300 @@ -178,6 +178,8 @@ ThunarStandardView *standard_view); static void thunar_standard_view_action_select_by_pattern (GtkAction *action, ThunarStandardView *standard_view); +static void thunar_standard_view_action_invert_selection (GtkAction *action, + ThunarStandardView *standard_view); static void thunar_standard_view_action_duplicate (GtkAction *action, ThunarStandardView *standard_view); static void thunar_standard_view_action_make_link (GtkAction *action, @@ -265,6 +267,7 @@ GtkAction *action_paste_into_folder; GtkAction *action_select_all_files; GtkAction *action_select_by_pattern; + GtkAction *action_invert_selection; GtkAction *action_duplicate; GtkAction *action_make_link; GtkAction *action_rename; @@ -329,6 +332,7 @@ { "paste-into-folder", GTK_STOCK_PASTE, N_ ("Paste Into Folder"), NULL, N_ ("Move or copy files previously selected by a Cut or Copy command into the selected folder"), G_CALLBACK (thunar_standard_view_action_paste_into_folder), }, { "select-all-files", NULL, N_ ("Select _all Files"), NULL, N_ ("Select all files in this window"), G_CALLBACK (thunar_standard_view_action_select_all_files), }, { "select-by-pattern", NULL, N_ ("Select _by Pattern..."), "<control>S", N_ ("Select all files that match a certain pattern"), G_CALLBACK (thunar_standard_view_action_select_by_pattern), }, + { "invert-selection", NULL, N_ ("Invert Selection"), NULL, N_ ("Invert selection of files"), G_CALLBACK (thunar_standard_view_action_invert_selection), }, { "duplicate", NULL, N_ ("Du_plicate"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_duplicate), }, { "make-link", NULL, N_ ("Ma_ke Link"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_make_link), }, { "rename", NULL, N_ ("_Rename..."), "F2", NULL, G_CALLBACK (thunar_standard_view_action_rename), }, @@ -586,6 +590,7 @@ standard_view->priv->action_paste_into_folder = gtk_action_group_get_action (standard_view->action_group, "paste-into-folder"); standard_view->priv->action_select_all_files = gtk_action_group_get_action (standard_view->action_group, "select-all-files"); standard_view->priv->action_select_by_pattern = gtk_action_group_get_action (standard_view->action_group, "select-by-pattern"); + standard_view->priv->action_invert_selection = gtk_action_group_get_action (standard_view->action_group, "invert-select"); standard_view->priv->action_duplicate = gtk_action_group_get_action (standard_view->action_group, "duplicate"); standard_view->priv->action_make_link = gtk_action_group_get_action (standard_view->action_group, "make-link"); standard_view->priv->action_rename = gtk_action_group_get_action (standard_view->action_group, "rename"); @@ -2103,6 +2108,22 @@ static void +thunar_standard_view_action_invert_selection (GtkAction *action, + ThunarStandardView *standard_view) +{ + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view)); + + /* grab the focus to the view */ + gtk_widget_grab_focus (GTK_WIDGET (standard_view)); + + /* select all files in the real view */ + (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->invert_selection) (standard_view); +} + + + +static void thunar_standard_view_action_duplicate (GtkAction *action, ThunarStandardView *standard_view) { --- thunar.orig/thunar/thunar-details-view.c 2007-10-29 11:56:21.000000000 -0300 +++ thunar/thunar/thunar-details-view.c 2007-10-29 10:41:01.000000000 -0300 @@ -62,6 +62,7 @@ static void thunar_details_view_unselect_all (ThunarStandardView *standard_view); static void thunar_details_view_select_path (ThunarStandardView *standard_view, GtkTreePath *path); +static void thunar_details_view_invert_selection (ThunarStandardView *standard_view); static void thunar_details_view_set_cursor (ThunarStandardView *standard_view, GtkTreePath *path, gboolean start_editing); @@ -189,6 +190,7 @@ thunarstandard_view_class->select_all = thunar_details_view_select_all; thunarstandard_view_class->unselect_all = thunar_details_view_unselect_all; thunarstandard_view_class->select_path = thunar_details_view_select_path; + thunarstandard_view_class->invert_selection = thunar_details_view_invert_selection; thunarstandard_view_class->set_cursor = thunar_details_view_set_cursor; thunarstandard_view_class->scroll_to_path = thunar_details_view_scroll_to_path; thunarstandard_view_class->get_path_at_pos = thunar_details_view_get_path_at_pos; @@ -508,6 +510,37 @@ static void +thunar_details_view_invert_selection (ThunarStandardView *standard_view) +{ + guint number_of_rows; + guint total_number_of_rows; + GtkTreeSelection *selection; + GtkTreePath *path; + + _thunar_return_if_fail (THUNAR_IS_DETAILS_VIEW (standard_view)); + + total_number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (standard_view->model), NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (GTK_BIN(standard_view)->child)); + + for(number_of_rows=0; number_of_rows < total_number_of_rows; number_of_rows++) { + path = gtk_tree_path_new_from_string (g_strdup_printf ("%d", number_of_rows)); + + if (gtk_tree_selection_path_is_selected (selection, path)) + gtk_tree_selection_unselect_path (selection, path); + else + gtk_tree_selection_select_path (selection, path); + + gtk_tree_path_free (path); + } +} + + + + + + + +static void thunar_details_view_set_cursor (ThunarStandardView *standard_view, GtkTreePath *path, gboolean start_editing) --- thunar.orig/thunar/thunar-abstract-icon-view.c 2007-10-29 11:56:21.000000000 -0300 +++ thunar/thunar/thunar-abstract-icon-view.c 2007-10-29 10:39:46.000000000 -0300 @@ -48,6 +48,7 @@ static void thunar_abstract_icon_view_unselect_all (ThunarStandardView *standard_view); static void thunar_abstract_icon_view_select_path (ThunarStandardView *standard_view, GtkTreePath *path); +static void thunar_abstract_icon_view_invert_selection (ThunarStandardView *standard_view); static void thunar_abstract_icon_view_set_cursor (ThunarStandardView *standard_view, GtkTreePath *path, gboolean start_editing); @@ -188,6 +189,7 @@ thunarstandard_view_class->select_all = thunar_abstract_icon_view_select_all; thunarstandard_view_class->unselect_all = thunar_abstract_icon_view_unselect_all; thunarstandard_view_class->select_path = thunar_abstract_icon_view_select_path; + thunarstandard_view_class->invert_selection = thunar_abstract_icon_view_invert_selection; thunarstandard_view_class->set_cursor = thunar_abstract_icon_view_set_cursor; thunarstandard_view_class->scroll_to_path = thunar_abstract_icon_view_scroll_to_path; thunarstandard_view_class->get_path_at_pos = thunar_abstract_icon_view_get_path_at_pos; @@ -363,6 +365,30 @@ static void +thunar_abstract_icon_view_invert_selection (ThunarStandardView *standard_view) +{ + guint number_of_rows; + guint total_number_of_rows; + GtkTreePath *path; + + _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (standard_view)); + total_number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (standard_view->model), NULL); + + for (number_of_rows=0; number_of_rows < total_number_of_rows; number_of_rows++) { + path = gtk_tree_path_new_from_string (g_strdup_printf ("%d", number_of_rows)); + + if (exo_icon_view_path_is_selected (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), path)) + exo_icon_view_unselect_path (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), path); + else + exo_icon_view_select_path (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), path); + + gtk_tree_path_free (path); + } +} + + + +static void thunar_abstract_icon_view_set_cursor (ThunarStandardView *standard_view, GtkTreePath *path, gboolean start_editing)
_______________________________________________ Thunar-dev mailing list Thunar-dev@xfce.org http://foo-projects.org/mailman/listinfo/thunar-dev