forked from darktable-org/darktable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.c
More file actions
169 lines (145 loc) · 5.85 KB
/
Copy pathselect.c
File metadata and controls
169 lines (145 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
This file is part of darktable,
copyright (c) 2009--2010 johannes hanika.
copyright (c) 2010--2011 henrik andersson.
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
darktable is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/darktable.h"
#include "common/collection.h"
#include "common/selection.h"
#include "common/debug.h"
#include "control/control.h"
#include "control/conf.h"
#include "libs/lib.h"
#include "gui/accelerators.h"
#include "gui/gtk.h"
#include <gdk/gdkkeysyms.h>
#include "dtgtk/button.h"
DT_MODULE(1)
const char*
name ()
{
return _("select");
}
uint32_t views()
{
return DT_VIEW_LIGHTTABLE;
}
uint32_t container()
{
return DT_UI_CONTAINER_PANEL_RIGHT_CENTER;
}
typedef struct dt_lib_select_t
{
GtkWidget
*select_all_button, *select_none_button, *select_invert_button,
*select_film_roll_button, *select_untouched_button;
} dt_lib_select_t;
static void
button_clicked(GtkWidget *widget, gpointer user_data)
{
switch((long int)user_data)
{
case 0: // all
dt_selection_select_all(darktable.selection);
break;
case 1: // none
dt_selection_clear(darktable.selection);
break;
case 2: // invert
dt_selection_invert(darktable.selection);
break;
case 4: // untouched
dt_selection_select_unaltered(darktable.selection);
break;
default: // case 3: same film roll
dt_selection_select_filmroll(darktable.selection);
}
dt_control_queue_redraw_center();
}
int
position ()
{
return 800;
}
void
gui_init (dt_lib_module_t *self)
{
dt_lib_select_t *d = (dt_lib_select_t*)malloc(sizeof(dt_lib_select_t));
self->data = d;
self->widget = gtk_vbox_new(TRUE, 5);
GtkBox *hbox;
GtkWidget *button;
hbox = GTK_BOX(gtk_hbox_new(TRUE, 5));
button = gtk_button_new_with_label(_("select all"));
d->select_all_button = button;
g_object_set(G_OBJECT(button), "tooltip-text", _("select all images in current collection (ctrl-a)"), (char *)NULL);
gtk_box_pack_start(hbox, button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), (gpointer)0);
button = gtk_button_new_with_label(_("select none"));
d->select_none_button = button;
g_object_set(G_OBJECT(button), "tooltip-text", _("clear selection (ctrl-shift-a)"), (char *)NULL);
gtk_box_pack_start(hbox, button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), (gpointer)1);
gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0);
hbox = GTK_BOX(gtk_hbox_new(TRUE, 5));
button = gtk_button_new_with_label(_("invert selection"));
g_object_set(G_OBJECT(button), "tooltip-text", _("select unselected images\nin current collection (ctrl-!)"), (char *)NULL);
d->select_invert_button = button;
gtk_box_pack_start(hbox, button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), (gpointer)2);
button = gtk_button_new_with_label(_("select film roll"));
d->select_film_roll_button = button;
g_object_set(G_OBJECT(button), "tooltip-text", _("select all images which are in the same\nfilm roll as the selected images"), (char *)NULL);
gtk_box_pack_start(hbox, button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), (gpointer)3);
gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0);
hbox = GTK_BOX(gtk_hbox_new(TRUE, 5));
button = gtk_button_new_with_label(_("select untouched"));
d->select_untouched_button = button;
g_object_set(G_OBJECT(button), "tooltip-text", _("select untouched images in\ncurrent collection"), (char *)NULL);
gtk_box_pack_start(hbox, button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), (gpointer)4);
// Just a filler, remove if a new button is added
gtk_box_pack_start(hbox,gtk_hbox_new(TRUE, 5),TRUE,TRUE,0);
gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0);
}
void
gui_cleanup (dt_lib_module_t *self)
{
}
void init_key_accels(dt_lib_module_t *self)
{
dt_accel_register_lib(self, NC_("accel", "select all"),
GDK_a, GDK_CONTROL_MASK);
dt_accel_register_lib(self, NC_("accel", "select none"),
GDK_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
dt_accel_register_lib(self, NC_("accel", "invert selection"),
GDK_i, GDK_CONTROL_MASK);
dt_accel_register_lib(self, NC_("accel", "select film roll"), 0, 0);
dt_accel_register_lib(self, NC_("accel", "select untouched"), 0, 0);
}
void connect_key_accels(dt_lib_module_t *self)
{
dt_lib_select_t *d = (dt_lib_select_t*)self->data;
dt_accel_connect_button_lib(self, "select all", d->select_all_button);
dt_accel_connect_button_lib(self, "select none", d->select_none_button);
dt_accel_connect_button_lib(self, "invert selection",
d->select_invert_button);
dt_accel_connect_button_lib(self, "select film roll",
d->select_film_roll_button);
dt_accel_connect_button_lib(self, "select untouched",
d->select_untouched_button);
}
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
// vim: shiftwidth=2 expandtab tabstop=2 cindent
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;