if (lw->vf) vf_select_none(lw->vf);
}
+void layout_select_invert(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return;
+
+ if (lw->vf) vf_select_invert(lw->vf);
+}
+
void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode)
{
if (!layout_valid(&lw)) return;
gint layout_selection_count(LayoutWindow *lw, gint64 *bytes);
void layout_select_all(LayoutWindow *lw);
void layout_select_none(LayoutWindow *lw);
+void layout_select_invert(LayoutWindow *lw);
void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode);
void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode);
layout_select_none(lw);
}
+static void layout_menu_invert_selection_cb(GtkAction *action, gpointer data)
+{
+ LayoutWindow *lw = data;
+
+ layout_select_invert(lw);
+}
+
static void layout_menu_marks_cb(GtkToggleAction *action, gpointer data)
{
LayoutWindow *lw = data;
{ "Properties",GTK_STOCK_PROPERTIES, N_("_Properties"), "<control>P", NULL, CB(layout_menu_info_cb) },
{ "SelectAll", NULL, N_("Select _all"), "<control>A", NULL, CB(layout_menu_select_all_cb) },
{ "SelectNone", NULL, N_("Select _none"), "<control><shift>A",NULL, CB(layout_menu_unselect_all_cb) },
+ { "SelectInvert", NULL, N_("_Invert Selection"), "<control><shift>I", NULL, CB(layout_menu_invert_selection_cb) },
+
{ "Preferences",GTK_STOCK_PREFERENCES,N_("P_references..."), "<control>O", NULL, CB(layout_menu_config_cb) },
{ "Maintenance", NULL, N_("_Thumbnail maintenance..."),NULL, NULL, CB(layout_menu_remove_thumb_cb) },
{ "Wallpaper", NULL, N_("Set as _wallpaper"),NULL, NULL, CB(layout_menu_wallpaper_cb) },
" <menu action='SelectMenu'>"
" <menuitem action='SelectAll'/>"
" <menuitem action='SelectNone'/>"
+" <menuitem action='SelectInvert'/>"
" <separator/>"
" <menuitem action='ShowMarks'/>"
" <separator/>"
}
}
+void vf_select_invert(ViewFile *vf)
+{
+ switch(vf->type)
+ {
+ case FILEVIEW_LIST: vflist_select_invert(vf); break;
+ case FILEVIEW_ICON: vficon_select_invert(vf); break;
+ }
+}
+
void vf_select_by_fd(ViewFile *vf, FileData *fd)
{
switch(vf->type)
void vf_select_all(ViewFile *vf);
void vf_select_none(ViewFile *vf);
+void vf_select_invert(ViewFile *vf);
void vf_select_by_fd(ViewFile *vf, FileData *fd);
void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
vficon_send_update(vf);
}
+void vficon_select_invert(ViewFile *vf)
+{
+ GList *work;
+
+ work = vf->list;
+ while (work)
+ {
+ IconData *id = work->data;
+ work = work->next;
+
+ if (id->selected & SELECTION_SELECTED)
+ {
+ VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id);
+ vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL);
+ }
+ else
+ {
+ VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id);
+ vficon_selection_add(vf, id, SELECTION_SELECTED, NULL);
+ }
+ }
+
+ vficon_send_update(vf);
+}
+
static void vficon_select(ViewFile *vf, IconData *id)
{
VFICON_INFO(vf, prev_selection) = id;
void vficon_select_all(ViewFile *vf);
void vficon_select_none(ViewFile *vf);
+void vficon_select_invert(ViewFile *vf);
void vficon_select_by_fd(ViewFile *vf, FileData *fd);
void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
gtk_tree_selection_unselect_all(selection);
}
+static gboolean tree_model_iter_prev(GtkTreeModel *store, GtkTreeIter *iter)
+{
+ GtkTreePath *tpath;
+ gboolean result;
+
+ tpath = gtk_tree_model_get_path(store, iter);
+ result = gtk_tree_path_prev(tpath);
+ if (result)
+ gtk_tree_model_get_iter(store, iter, tpath);
+
+ gtk_tree_path_free(tpath);
+
+ return result;
+}
+
+static gboolean tree_model_get_iter_last(GtkTreeModel *store, GtkTreeIter *iter)
+{
+ if (!gtk_tree_model_get_iter_first(store, iter))
+ return FALSE;
+
+ while (TRUE)
+ {
+ GtkTreeIter next = *iter;
+
+ if (gtk_tree_model_iter_next(store, &next))
+ *iter = next;
+ else
+ break;
+ }
+
+ return TRUE;
+}
+
+void vflist_select_invert(ViewFile *vf)
+{
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *store;
+ gboolean valid;
+
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
+
+ /* Backward iteration prevents scrolling to the end of the list,
+ * it scrolls to the first selected row instead. */
+ valid = tree_model_get_iter_last(store, &iter);
+
+ while (valid)
+ {
+ gint selected = gtk_tree_selection_iter_is_selected(selection, &iter);
+
+ if (selected)
+ gtk_tree_selection_unselect_iter(selection, &iter);
+ else
+ gtk_tree_selection_select_iter(selection, &iter);
+
+ valid = tree_model_iter_prev(store, &iter);
+ }
+}
+
void vflist_select_by_fd(ViewFile *vf, FileData *fd)
{
GtkTreeIter iter;
void vflist_select_all(ViewFile *vf);
void vflist_select_none(ViewFile *vf);
+void vflist_select_invert(ViewFile *vf);
void vflist_select_by_fd(ViewFile *vf, FileData *fd);
void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);