Commit 47229472 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Add support for "Invert Selection". Patch by Amos Brocco

2008-03-29  Cosimo Cecchi  <cosimoc@gnome.org>

	* libnautilus-private/nautilus-icon-container.c:
	(nautilus_icon_container_invert_selection):
	* libnautilus-private/nautilus-icon-container.h:
	* libnautilus-private/nautilus-view.c:
	(nautilus_view_invert_selection):
	* libnautilus-private/nautilus-view.h:
	* src/file-manager/fm-actions.h:
	* src/file-manager/fm-directory-view.c:
	(action_invert_selection_callback),
	(fm_directory_view_invert_selection), (real_update_menus),
	(fm_directory_view_class_init):
	* src/file-manager/fm-directory-view.h:
	* src/file-manager/fm-icon-view.c: (fm_icon_view_invert_selection),
	(fm_icon_view_class_init):
	* src/file-manager/fm-list-view.c: (fm_list_view_invert_selection),
	(fm_list_view_class_init):
	* src/file-manager/nautilus-directory-view-ui.xml:
	Add support for "Invert Selection". Patch by Amos Brocco
	<amos.brocco@unifr.ch>. (#305295).

svn path=/trunk/; revision=13999
parent d818b409
2008-03-29 Cosimo Cecchi <cosimoc@gnome.org>
* libnautilus-private/nautilus-icon-container.c:
(nautilus_icon_container_invert_selection):
* libnautilus-private/nautilus-icon-container.h:
* libnautilus-private/nautilus-view.c:
(nautilus_view_invert_selection):
* libnautilus-private/nautilus-view.h:
* src/file-manager/fm-actions.h:
* src/file-manager/fm-directory-view.c:
(action_invert_selection_callback),
(fm_directory_view_invert_selection), (real_update_menus),
(fm_directory_view_class_init):
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-icon-view.c: (fm_icon_view_invert_selection),
(fm_icon_view_class_init):
* src/file-manager/fm-list-view.c: (fm_list_view_invert_selection),
(fm_list_view_class_init):
* src/file-manager/nautilus-directory-view-ui.xml:
Add support for "Invert Selection". Patch by Amos Brocco
<amos.brocco@unifr.ch>. (#305295).
2008-03-29 Christian Neumair <cneumair@gnome.org>
* src/nautilus-application.c
......
......@@ -6217,6 +6217,29 @@ nautilus_icon_container_get_selected_icons (NautilusIconContainer *container)
return g_list_reverse (list);
}
/**
* nautilus_icon_container_invert_selection:
* @container: An icon container.
*
* Inverts the selection in @container.
*
**/
void
nautilus_icon_container_invert_selection (NautilusIconContainer *container)
{
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
for (p = container->details->icons; p != NULL; p = p->next) {
NautilusIcon *icon;
icon = p->data;
icon_toggle_selected (container, icon);
}
}
/* Returns an array of GdkPoints of locations of the icons. */
static GArray *
nautilus_icon_container_get_icon_locations (NautilusIconContainer *container,
......
......@@ -260,6 +260,7 @@ void nautilus_icon_container_select_all (Nautilu
/* operations on the selection */
GList * nautilus_icon_container_get_selection (NautilusIconContainer *view);
void nautilus_icon_container_invert_selection (NautilusIconContainer *view);
void nautilus_icon_container_set_selection (NautilusIconContainer *view,
GList *selection);
GArray * nautilus_icon_container_get_selected_icon_locations (NautilusIconContainer *view);
......
......@@ -159,6 +159,13 @@ nautilus_view_set_selection (NautilusView *view,
list);
}
void
nautilus_view_invert_selection (NautilusView *view)
{
g_return_if_fail (NAUTILUS_IS_VIEW (view));
(* NAUTILUS_VIEW_GET_IFACE (view)->invert_selection) (view);
}
char *
nautilus_view_get_first_visible_file (NautilusView *view)
......
......@@ -83,6 +83,9 @@ struct _NautilusViewIface
void (* set_selection) (NautilusView *view,
GList *list);
/* Inverts the selection in the view */
void (* invert_selection) (NautilusView *view);
/* Return the uri of the first visible file */
char * (* get_first_visible_file) (NautilusView *view);
/* Scroll the view so that the file specified by the uri is at the top
......@@ -138,6 +141,7 @@ int nautilus_view_get_selection_count (NautilusView *v
GList * nautilus_view_get_selection (NautilusView *view);
void nautilus_view_set_selection (NautilusView *view,
GList *list);
void nautilus_view_invert_selection (NautilusView *view);
char * nautilus_view_get_first_visible_file (NautilusView *view);
void nautilus_view_scroll_to_file (NautilusView *view,
const char *uri);
......
......@@ -51,6 +51,7 @@
#define FM_ACTION_DUPLICATE "Duplicate"
#define FM_ACTION_CREATE_LINK "Create Link"
#define FM_ACTION_SELECT_ALL "Select All"
#define FM_ACTION_INVERT_SELECTION "Invert Selection"
#define FM_ACTION_SELECT_PATTERN "Select Pattern"
#define FM_ACTION_TRASH "Trash"
#define FM_ACTION_LOCATION_TRASH "LocationTrash"
......
......@@ -398,6 +398,7 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, select_all)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, set_selection)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, zoom_to_level)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_zoom_level)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, invert_selection)
typedef struct {
GAppInfo *application;
......@@ -1025,6 +1026,16 @@ action_select_all_callback (GtkAction *action,
fm_directory_view_select_all (callback_data);
}
static void
action_invert_selection_callback (GtkAction *action,
gpointer callback_data)
{
g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
fm_directory_view_invert_selection (callback_data);
}
static void
pattern_select_response_cb (GtkWidget *dialog, int response, gpointer user_data)
{
......@@ -3381,6 +3392,16 @@ fm_directory_view_get_selection (FMDirectoryView *view)
get_selection, (view));
}
void
fm_directory_view_invert_selection (FMDirectoryView *view)
{
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
EEL_CALL_METHOD
(FM_DIRECTORY_VIEW_CLASS, view,
invert_selection, (view));
}
GList *
fm_directory_view_get_selection_for_file_transfer (FMDirectoryView *view)
{
......@@ -6345,6 +6366,10 @@ static const GtkActionEntry directory_view_entries[] = {
/* label, accelerator */ N_("Select _Pattern"), "<control>S",
/* tooltip */ N_("Select items in this window matching a given pattern"),
G_CALLBACK (action_select_pattern_callback) },
/* name, stock id */ { "Invert Selection", NULL,
/* label, accelerator */ N_("_Invert Selection"), "<control><shift>I",
/* tooltip */ N_("Select all and only the items that are not currently selected"),
G_CALLBACK (action_invert_selection_callback) },
/* name, stock id */ { "Duplicate", NULL,
/* label, accelerator */ N_("D_uplicate"), NULL,
/* tooltip */ N_("Duplicate each selected item"),
......@@ -7299,6 +7324,10 @@ real_update_menus (FMDirectoryView *view)
FM_ACTION_SELECT_PATTERN);
gtk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_INVERT_SELECTION);
gtk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_CUT);
gtk_action_set_sensitive (action, can_delete_files);
......@@ -8866,6 +8895,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, restore_default_zoom_level);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, select_all);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, set_selection);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, invert_selection);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, zoom_to_level);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_zoom_level);
......
......@@ -158,6 +158,11 @@ struct FMDirectoryViewClass {
void (* set_selection) (FMDirectoryView *view,
GList *selection);
/* invert_selection is a function pointer that subclasses must
* override to invert selection. */
void (* invert_selection) (FMDirectoryView *view);
/* Return an array of locations of selected icons in their view. */
GArray * (* get_selected_icon_locations) (FMDirectoryView *view);
......@@ -336,6 +341,7 @@ gboolean fm_directory_view_can_accept_item (Nautilus
void fm_directory_view_display_selection_info (FMDirectoryView *view);
GList * fm_directory_view_get_selection (FMDirectoryView *view);
GList * fm_directory_view_get_selection_for_file_transfer (FMDirectoryView *view);
void fm_directory_view_invert_selection (FMDirectoryView *view);
void fm_directory_view_stop (FMDirectoryView *view);
guint fm_directory_view_get_item_count (FMDirectoryView *view);
gboolean fm_directory_view_can_zoom_in (FMDirectoryView *view);
......
......@@ -1674,6 +1674,15 @@ fm_icon_view_set_selection (FMDirectoryView *view, GList *selection)
(get_icon_container (FM_ICON_VIEW (view)), selection);
}
static void
fm_icon_view_invert_selection (FMDirectoryView *view)
{
g_return_if_fail (FM_IS_ICON_VIEW (view));
nautilus_icon_container_invert_selection
(get_icon_container (FM_ICON_VIEW (view)));
}
static gboolean
fm_icon_view_using_manual_layout (FMDirectoryView *view)
{
......@@ -2593,6 +2602,7 @@ fm_icon_view_class_init (FMIconViewClass *klass)
fm_directory_view_class->reveal_selection = fm_icon_view_reveal_selection;
fm_directory_view_class->select_all = fm_icon_view_select_all;
fm_directory_view_class->set_selection = fm_icon_view_set_selection;
fm_directory_view_class->invert_selection = fm_icon_view_invert_selection;
fm_directory_view_class->compare_files = compare_files;
fm_directory_view_class->zoom_to_level = fm_icon_view_zoom_to_level;
fm_directory_view_class->get_zoom_level = fm_icon_view_get_zoom_level;
......
......@@ -1920,6 +1920,43 @@ fm_list_view_set_selection (FMDirectoryView *view, GList *selection)
fm_directory_view_notify_selection_changed (view);
}
static void
fm_list_view_invert_selection (FMDirectoryView *view)
{
FMListView *list_view;
GtkTreeSelection *tree_selection;
GList *node;
GList *iters, *l;
NautilusFile *file;
GList *selection = NULL;
list_view = FM_LIST_VIEW (view);
tree_selection = gtk_tree_view_get_selection (list_view->details->tree_view);
g_signal_handlers_block_by_func (tree_selection, list_selection_changed_callback, view);
gtk_tree_selection_selected_foreach (tree_selection,
fm_list_view_get_selection_foreach_func, &selection);
gtk_tree_selection_select_all (tree_selection);
for (node = selection; node != NULL; node = node->next) {
file = node->data;
iters = fm_list_model_get_all_iters_for_file (list_view->details->model, file);
for (l = iters; l != NULL; l = l->next) {
gtk_tree_selection_unselect_iter (tree_selection,
(GtkTreeIter *)l->data);
}
eel_g_list_free_deep (iters);
}
g_list_free (selection);
g_signal_handlers_unblock_by_func (tree_selection, list_selection_changed_callback, view);
fm_directory_view_notify_selection_changed (view);
}
static void
fm_list_view_select_all (FMDirectoryView *view)
{
......@@ -2686,6 +2723,7 @@ fm_list_view_class_init (FMListViewClass *class)
fm_directory_view_class->reveal_selection = fm_list_view_reveal_selection;
fm_directory_view_class->select_all = fm_list_view_select_all;
fm_directory_view_class->set_selection = fm_list_view_set_selection;
fm_directory_view_class->invert_selection = fm_list_view_invert_selection;
fm_directory_view_class->compare_files = fm_list_view_compare_files;
fm_directory_view_class->sort_directories_first_changed = fm_list_view_sort_directories_first_changed;
fm_directory_view_class->start_renaming_file = fm_list_view_start_renaming_file;
......
......@@ -57,6 +57,7 @@
<placeholder name="Select Items">
<menuitem name="Select All" action="Select All"/>
<menuitem name="Select Pattern" action="Select Pattern"/>
<menuitem name="Invert Selection" action="Invert Selection"/>
</placeholder>
<placeholder name="File Items Placeholder">
<menuitem name="Duplicate" action="Duplicate"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment