Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
label.c
Go to the documentation of this file.
1/*
2 * This file is part of Ansel,
3 * Copyright (C) 2026 Aurélien PIERRE.
4 *
5 * Ansel is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * Ansel is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "widgets/label.h"
20
21#include "common/glib_utils.h" // dt_string_replace
22#include "system/macros.h" // IS_NULL_PTR
23#include "system/mem_alloc.h" // dt_free
24#include "widgets/widget_style.h" // dt_gui_add_class, dt_capitalize_label
25
26#include "system/macros.h" // IS_NULL_PTR
27#include "widgets/widget_settings.h" // DT_PIXEL_APPLY_DPI
28
29void dt_gui_set_symbolic_icon(GtkWidget *image, const char *icon_name, GtkIconSize size, const GdkRGBA *color)
30{
31 gint width = 16, height = 16;
33 // Icon themes only look up square icons: request the larger dimension,
34 // then scale the result down to the exact width/height below if the two differ.
37 if(IS_NULL_PTR(info))
38 {
40 return;
41 }
42
46 g_object_unref(info);
47
49 {
51 {
54 pixbuf = scaled;
55 }
58 }
59}
60
62gchar *delete_underscore(const char *s)
63{
64 return dt_string_replace(s, "_");
65}
66
74gchar *strip_markup(const char *s)
75{
76 if(IS_NULL_PTR(s)) return g_strdup("");
77
79 gchar *plain = NULL;
80
81 const gchar *underscore = "_";
82 gunichar mnemonic = underscore[0];
83 if(!pango_parse_markup(s, -1, mnemonic, &attrs, &plain, NULL, NULL))
85
87 return plain;
88}
89
92{
93 gtk_widget_set_halign(label, GTK_ALIGN_FILL); // make it span the whole available width
94 gtk_label_set_xalign (GTK_LABEL(label), 0.5f);
95 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); // ellipsize labels
96 dt_gui_add_class(label, "dt_section_label"); // make sure that we can style these easily
97}
98
102{
103 gchar *str_cpy = g_strdup(str);
108 return label;
109}
110
123
135
145
146// clang-format off
147// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
148// vim: shiftwidth=2 expandtab tabstop=2 cindent
149// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
150// clang-format on
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition colorspaces.h:98
GdkRGBA color[]
Definition geotagging.c:539
static gchar * dt_string_replace(const char *string, const char *to_replace)
Definition glib_utils.h:64
GtkWidget * dt_ui_section_label_new(const gchar *str)
Definition label.c:101
gchar * delete_underscore(const char *s)
Definition label.c:62
GtkWidget * dt_ui_label_new(const gchar *str)
Definition label.c:112
void dt_gui_textview_set_padding(GtkTextView *textview)
Apply the standard recessed-input text padding to a GtkTextView.
Definition label.c:136
void dt_ellipsize_combo(GtkComboBox *cbox)
Definition label.c:124
void dt_gui_set_symbolic_icon(GtkWidget *image, const char *icon_name, GtkIconSize size, const GdkRGBA *color)
Set a symbolic icon on an image widget, optionally forcing a specific color.
Definition label.c:29
void dt_ui_section_label_set(GtkWidget *label)
Definition label.c:91
gchar * strip_markup(const char *s)
Remove Pango/Gtk markup and accel mnemonics from a text label. If markup parsing fails,...
Definition label.c:74
#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:65
#define dt_free(ptr)
Definition mem_alloc.h:97
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
size_t size
Definition mipmap_cache.c:3
#define MAX(a, b)
Definition thinplate.c:29
#define DT_PIXEL_APPLY_DPI(value)
void dt_capitalize_label(gchar *text)
void dt_gui_add_class(GtkWidget *widget, const gchar *class_name)