Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
resetlabel.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010 Bruce Guenter.
4 Copyright (C) 2010-2011 johannes hanika.
5 Copyright (C) 2011 Antony Dovgal.
6 Copyright (C) 2011, 2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2012 Richard Wonka.
8 Copyright (C) 2013 Roman Lebedev.
9 Copyright (C) 2020 Diederik Ter Rahe.
10 Copyright (C) 2020 Pascal Obry.
11 Copyright (C) 2021 Victor Forsiuk.
12 Copyright (C) 2022 Martin Bařinka.
13 Copyright (C) 2026 Aurélien PIERRE.
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
29#include "dtgtk/resetlabel.h"
30#include "develop/develop.h"
31
34
35
39
41{
42}
43
44static gboolean _reset_label_callback(GtkDarktableResetLabel *label, GdkEventButton *event, gpointer user_data)
45{
46 if(event->type == GDK_2BUTTON_PRESS)
47 {
48 memcpy(((char *)label->module->params) + label->offset,
49 ((char *)label->module->default_params) + label->offset, label->size);
50 if(label->module->gui_update) label->module->gui_update(label->module);
52 return TRUE;
53 }
54 return FALSE;
55}
56
57// public functions
58GtkWidget *dtgtk_reset_label_new(const gchar *text, dt_iop_module_t *module, void *param, int param_size)
59{
61 label = g_object_new(dtgtk_reset_label_get_type(), NULL);
62 label->module = module;
63 label->offset = param - (void *)module->params;
64 label->size = param_size;
65
66 label->lb = GTK_LABEL(gtk_label_new(text));
67 gtk_widget_set_halign(GTK_WIDGET(label->lb), GTK_ALIGN_START);
68 gtk_label_set_ellipsize(GTK_LABEL(label->lb), PANGO_ELLIPSIZE_END);
69 gtk_event_box_set_visible_window(GTK_EVENT_BOX(label), FALSE);
70 gtk_widget_set_tooltip_text(GTK_WIDGET(label), _("double-click to reset"));
71 gtk_container_add(GTK_CONTAINER(label), GTK_WIDGET(label->lb));
72 gtk_widget_add_events(GTK_WIDGET(label), GDK_BUTTON_PRESS_MASK);
73 g_signal_connect(G_OBJECT(label), "button-press-event", G_CALLBACK(_reset_label_callback), (gpointer)NULL);
74
75 return (GtkWidget *)label;
76}
77
79{
80 static GType dtgtk_reset_label_type = 0;
81 if(!dtgtk_reset_label_type)
82 {
83 static const GTypeInfo dtgtk_reset_label_info = {
84 sizeof(GtkDarktableResetLabelClass), (GBaseInitFunc)NULL, (GBaseFinalizeFunc)NULL,
85 (GClassInitFunc)_reset_label_class_init, NULL, /* class_finalize */
86 NULL, /* class_data */
87 sizeof(GtkDarktableResetLabel), 0, /* n_preallocs */
88 (GInstanceInitFunc)_reset_label_init,
89 };
90 dtgtk_reset_label_type
91 = g_type_register_static(GTK_TYPE_EVENT_BOX, "GtkDarktableResetLabel", &dtgtk_reset_label_info, 0);
92 }
93 return dtgtk_reset_label_type;
94}
95
97{
98 gtk_label_set_text(label->lb, str);
99}
100
101// clang-format off
102// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
103// vim: shiftwidth=2 expandtab tabstop=2 cindent
104// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
105// clang-format on
106
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
darktable_t darktable
Definition darktable.c:181
#define dt_dev_add_history_item(dev, module, enable, redraw)
GtkWidget * dtgtk_reset_label_new(const gchar *text, dt_iop_module_t *module, void *param, int param_size)
Definition resetlabel.c:58
static void _reset_label_init(GtkDarktableResetLabel *label)
Definition resetlabel.c:40
GType dtgtk_reset_label_get_type()
Definition resetlabel.c:78
static gboolean _reset_label_callback(GtkDarktableResetLabel *label, GdkEventButton *event, gpointer user_data)
Definition resetlabel.c:44
static void _reset_label_class_init(GtkDarktableResetLabelClass *klass)
Definition resetlabel.c:36
void dtgtk_reset_label_set_text(GtkDarktableResetLabel *label, const gchar *str)
Definition resetlabel.c:96
struct _GtkDarktableResetLabelClass GtkDarktableResetLabelClass
struct _GtkDarktableResetLabel GtkDarktableResetLabel
struct _GtkWidget GtkWidget
Definition splash.h:29
const float const float param
dt_iop_module_t *int offset
Definition resetlabel.h:42
struct dt_develop_t * develop
Definition darktable.h:770
dt_iop_params_t * params
Definition imageop.h:307