Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
select.c
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
3 Copyright (C) 2023 Alynx Zhou.
4 Copyright (C) 2023, 2025 Aurélien PIERRE.
5
6 Ansel is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Ansel is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "gui/actions/menu.h"
20#include "common/selection.h"
21#include "common/collection.h"
22
23// Select menu is unavailable in anything else than lighttable
24
30
31
32static gboolean select_all_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
33{
36 return TRUE;
37}
38
39
45
46
47static gboolean clear_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
48{
51 return TRUE;
52}
53
54
55static gboolean invert_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
56{
59 return TRUE;
60}
61
62static gboolean scroll_to_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
63{
66 return TRUE;
67}
68
69void append_select(GtkWidget **menus, GList **lists, const dt_menus_t index)
70{
71 add_sub_menu_entry(menus, lists, _("Select all"), index, NULL, select_all_callback, NULL, NULL, select_all_sensitive_callback, GDK_KEY_a, GDK_CONTROL_MASK);
72
73 add_sub_menu_entry(menus, lists, _("Clear selection"), index, NULL, clear_selection_callback, NULL, NULL, clear_selection_sensitive_callback, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
74
75 add_sub_menu_entry(menus, lists, _("Invert selection"), index, NULL, invert_selection_callback, NULL, NULL, clear_selection_sensitive_callback, GDK_KEY_i, GDK_CONTROL_MASK);
76
77 add_menu_separator(menus[index]);
78
79 add_sub_menu_entry(menus, lists, _("Scroll back to selection"), index, NULL, scroll_to_selection_callback, NULL, NULL, NULL, 0, 0);
80}
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
uint32_t dt_collection_get_count(const dt_collection_t *collection)
Definition collection.c:836
darktable_t darktable
Definition darktable.c:181
gboolean _is_lighttable()
Definition menu.c:641
void add_sub_menu_entry(GtkWidget **menus, GList **lists, const gchar *label, const dt_menus_t index, void *data, gboolean(*action_callback)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data), gboolean(*checked_callback)(GtkWidget *widget), gboolean(*active_callback)(GtkWidget *widget), gboolean(*sensitive_callback)(GtkWidget *widget), guint key_val, GdkModifierType mods)
Definition menu.c:542
void add_menu_separator(GtkWidget *menu)
Definition menu.c:598
dt_menus_t
Definition menu.h:42
static gboolean invert_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
Definition select.c:55
void append_select(GtkWidget **menus, GList **lists, const dt_menus_t index)
Definition select.c:69
static gboolean clear_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
Definition select.c:47
gboolean select_all_sensitive_callback()
Definition select.c:25
static gboolean select_all_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
Definition select.c:32
gboolean clear_selection_sensitive_callback()
Definition select.c:40
static gboolean scroll_to_selection_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
Definition select.c:62
int dt_selection_get_length(struct dt_selection_t *selection)
Definition selection.c:179
void dt_selection_clear(dt_selection_t *selection)
Definition selection.c:266
struct _GtkWidget GtkWidget
Definition splash.h:29
struct dt_gui_gtk_t * gui
Definition darktable.h:775
struct dt_collection_t * collection
Definition darktable.h:781
struct dt_selection_t * selection
Definition darktable.h:782
dt_ui_t * ui
Definition gtk.h:164
dt_thumbtable_t * thumbtable_lighttable
dt_thumbtable_t * thumbtable_filmstrip
int dt_thumbtable_scroll_to_selection(dt_thumbtable_t *table)
Scroll to show selected content.
Definition thumbtable.c:572
void dt_thumbtable_invert_selection(dt_thumbtable_t *table)
Invert the current selection.
void dt_thumbtable_select_all(dt_thumbtable_t *table)
Select all images in the current grid.