Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
map_settings.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2012, 2014, 2016-2017 Tobias Ellinghaus.
4 Copyright (C) 2013 Thomas Pryds.
5 Copyright (C) 2014-2016 Roman Lebedev.
6 Copyright (C) 2018 Maurizio Paglia.
7 Copyright (C) 2018 rawfiner.
8 Copyright (C) 2019, 2025 Aurélien PIERRE.
9 Copyright (C) 2020-2021 Pascal Obry.
10 Copyright (C) 2020-2021 Philippe Weyland.
11 Copyright (C) 2021 Ralf Brown.
12 Copyright (C) 2022 Diederik Ter Rahe.
13 Copyright (C) 2022 Martin Bařinka.
14
15 darktable is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 darktable is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with darktable. If not, see <http://www.gnu.org/licenses/>.
27*/
28#include "system/macros.h"
30#include "common/conf.h"
31
32#include "gui/application.h"
33#include "libs/lib.h"
34#include "libs/lib_api.h"
35#include "views/view.h"
36#include "gui/preferences.h"
37#include <gdk/gdkkeysyms.h>
38
39#include <osm-gps-map-source.h>
40#include "widgets/label.h"
42
43DT_MODULE(1)
44
45const char *name(struct dt_lib_module_t *self)
46{
47 return _("map settings");
48}
49
50const char **views(dt_lib_module_t *self)
51{
52 static const char *v[] = {"map", NULL};
53 return v;
54}
55
60
66
68{
69 return 990;
70}
71
72static void _show_osd_toggled(GtkToggleButton *button, gpointer data)
73{
75}
76
77static void _parameter_changed(GtkToggleButton *button, gpointer data)
78{
80}
81
82static void _map_source_changed(GtkWidget *widget, gpointer data)
83{
84 GtkTreeIter iter;
85
86 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter) == TRUE)
87 {
88 GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
89 GValue value = {
90 0,
91 };
92 OsmGpsMapSource_t map_source;
93
94 gtk_tree_model_get_value(model, &iter, 1, &value);
95 map_source = g_value_get_int(&value);
96 g_value_unset(&value);
98 }
99}
100
108static gboolean _thumbnail_change_accel(GtkAccelGroup *accel_group, GObject *accelerable, guint keyval,
109 GdkModifierType mods, gpointer user_data)
110{
111 dt_lib_module_t *self = (dt_lib_module_t *)user_data;
113
114 const char *str = dt_conf_get_string_const("plugins/map/images_thumbnail");
115 if(!g_strcmp0(str, "thumbnail"))
116 dt_conf_set_string("plugins/map/images_thumbnail", "count");
117 else if(!g_strcmp0(str, "count"))
118 dt_conf_set_string("plugins/map/images_thumbnail", "none");
119 else
120 dt_conf_set_string("plugins/map/images_thumbnail", "thumbnail");
121
122 dt_gui_preferences_enum_update(d->images_thumb);
123 _parameter_changed(NULL, self);
124 return TRUE;
125}
126
128{
130 self->data = d;
131 self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_GUI_BOX_SPACING);
132 GtkBox *hbox;
133 GtkWidget *label;
134
135 hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_GUI_BOX_SPACING));
136
137 label = dt_ui_label_new(_("map source"));
138 gtk_box_pack_start(hbox, label, TRUE, TRUE, 0);
139
140 GtkListStore *model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
141 d->map_source_dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
142 gtk_widget_set_tooltip_text(d->map_source_dropdown, _("select the source of the map. some entries might not work"));
143 GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
144 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(d->map_source_dropdown), renderer, FALSE);
145 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(d->map_source_dropdown), renderer, "text", 0, NULL);
146
147 const char *map_source = dt_conf_get_string_const("plugins/map/map_source");
148 int selection = OSM_GPS_MAP_SOURCE_OPENSTREETMAP - 1, entry = 0;
149 GtkTreeIter iter;
150 for(int i = 1; i < OSM_GPS_MAP_SOURCE_LAST; i++)
151 {
152 if(osm_gps_map_source_is_valid(i))
153 {
154 const gchar *name = osm_gps_map_source_get_friendly_name(i);
155 gtk_list_store_append(model, &iter);
156 gtk_list_store_set(model, &iter, 0, name, 1, i, -1);
157 if(!g_strcmp0(name, map_source)) selection = entry;
158 entry++;
159 }
160 }
161 gtk_combo_box_set_active(GTK_COMBO_BOX(d->map_source_dropdown), selection);
162 gtk_box_pack_start(hbox, d->map_source_dropdown, TRUE, TRUE, 0);
163 g_signal_connect(G_OBJECT(d->map_source_dropdown), "changed", G_CALLBACK(_map_source_changed), NULL);
164 g_object_unref(model);
165 gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0);
166
167 GtkGrid *grid = GTK_GRID(gtk_grid_new());
168 gtk_grid_set_column_spacing(grid, DT_GUI_BOX_SPACING);
169
170 int line = 0;
171 d->max_outline_nodes = dt_gui_preferences_int(grid, "plugins/map/max_outline_nodes", 0, line++);
172 d->show_osd_checkbutton = dt_gui_preferences_bool(grid, "plugins/map/show_map_osd", 0, line++, FALSE);
173 g_signal_connect(G_OBJECT(d->show_osd_checkbutton), "toggled", G_CALLBACK(_show_osd_toggled), NULL);
174 d->filtered_images_checkbutton = dt_gui_preferences_bool(grid, "plugins/map/filter_images_drawn", 0, line++, FALSE);
175 g_signal_connect(G_OBJECT(d->filtered_images_checkbutton), "toggled", G_CALLBACK(_parameter_changed), NULL);
176 d->max_images_entry = dt_gui_preferences_int(grid, "plugins/map/max_images_drawn", 0, line++);
177 g_signal_connect(G_OBJECT(d->max_images_entry), "value-changed", G_CALLBACK(_parameter_changed), self);
178 d->epsilon_factor = dt_gui_preferences_int(grid, "plugins/map/epsilon_factor", 0, line++);
179 g_signal_connect(G_OBJECT(d->epsilon_factor), "value-changed", G_CALLBACK(_parameter_changed), self);
180 d->min_images = dt_gui_preferences_int(grid, "plugins/map/min_images_per_group", 0, line++);
181 g_signal_connect(G_OBJECT(d->min_images), "value-changed", G_CALLBACK(_parameter_changed), self);
182 d->images_thumb = dt_gui_preferences_enum(grid, "plugins/map/images_thumbnail", 0, line++);
183 g_signal_connect(G_OBJECT(d->images_thumb), "changed", G_CALLBACK(_parameter_changed), self);
184 gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(grid), FALSE, FALSE, 0);
185
186 dt_accels_new_map_action(_thumbnail_change_accel, self, NULL, N_("Map/Actions"),
187 N_("Thumbnail display"), GDK_KEY_s, GDK_SHIFT_MASK,
188 _("Cycles the image display mode on the map"));
189}
190
192{
193 gchar *path = dt_accels_build_path(N_("Map/Actions"), N_("Thumbnail display"));
195 dt_free(path);
196
197 if(IS_NULL_PTR(self->data)) return;
198 dt_free(self->data);
199}
200
202{
204 dt_gui_preferences_bool_reset(d->show_osd_checkbutton);
205 dt_gui_preferences_bool_reset(d->filtered_images_checkbutton);
206 dt_gui_preferences_int_reset(d->max_outline_nodes);
207 dt_gui_preferences_int_reset(d->max_images_entry);
208 dt_gui_preferences_int_reset(d->epsilon_factor);
209 dt_gui_preferences_int_reset(d->min_images);
210 dt_gui_preferences_enum_reset(d->images_thumb);
211}
212
213// clang-format off
214// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
215// vim: shiftwidth=2 expandtab tabstop=2 cindent
216// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
217// clang-format on
gchar * dt_accels_build_path(const gchar *scope, const gchar *feature)
void dt_accels_remove_accel(dt_accels_t *accels, const char *path, gpointer data)
Recursively remove all accels for all shortcuts containing path. This is unneeded for accels attached...
struct dt_accels_t * dt_gui_get_accels(void)
#define dt_accels_new_map_action(a, b, w, c, d, e, f, g)
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
const float v
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition colorspaces.h:98
void dt_conf_set_string(const char *name, const char *val)
const char * dt_conf_get_string_const(const char *name)
Borrow the stored string for name without copying it.
struct dt_view_manager_t * dt_view_manager_get_global(void)
Definition darktable.c:599
const char * model
GtkWidget * dt_ui_label_new(const gchar *str)
Definition label.c:125
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:96
void gui_reset(dt_lib_module_t *self)
static void _map_source_changed(GtkWidget *widget, gpointer data)
void gui_cleanup(dt_lib_module_t *self)
static void _parameter_changed(GtkToggleButton *button, gpointer data)
static void _show_osd_toggled(GtkToggleButton *button, gpointer data)
uint32_t container(dt_lib_module_t *self)
static gboolean _thumbnail_change_accel(GtkAccelGroup *accel_group, GObject *accelerable, guint keyval, GdkModifierType mods, gpointer user_data)
Cycle the map thumbnail rendering mode from the map accel group.
void gui_init(dt_lib_module_t *self)
int position()
const char ** views(dt_lib_module_t *self)
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
#define DT_MODULE(MODVER)
Instantiate the version handshake every module must export. Use once, at file scope,...
const char * name
Definition pdf.h:90
void dt_gui_preferences_enum_reset(GtkWidget *widget)
void dt_gui_preferences_bool_reset(GtkWidget *widget)
void dt_gui_preferences_int_reset(GtkWidget *widget)
void dt_gui_preferences_enum_update(GtkWidget *widget)
GtkWidget * dt_gui_preferences_int(GtkGrid *grid, const char *key, const guint col, const guint line)
GtkWidget * dt_gui_preferences_enum(GtkGrid *grid, const char *key, const guint col, const guint line)
GtkWidget * dt_gui_preferences_bool(GtkGrid *grid, const char *key, const guint col, const guint line, const gboolean swap)
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
GtkWidget * max_images_entry
GtkWidget * show_osd_checkbutton
GtkWidget * filtered_images_checkbutton
GtkWidget * epsilon_factor
GtkWidget * max_outline_nodes
GtkWidget * images_thumb
GtkWidget * map_source_dropdown
GModule *void * data
Definition lib.h:79
GtkWidget * widget
Definition lib.h:83
void dt_view_map_redraw(const dt_view_manager_t *vm)
Definition view.c:1393
void dt_view_map_show_osd(const dt_view_manager_t *vm)
Definition view.c:1356
void dt_view_map_set_map_source(const dt_view_manager_t *vm, OsmGpsMapSource_t map_source)
Definition view.c:1362
#define DT_GUI_BOX_SPACING
@ DT_UI_CONTAINER_PANEL_RIGHT_CENTER