Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
notebook.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/notebook.h"
20
21#include "system/macros.h" // IS_NULL_PTR
22#include "widgets/widget_style.h" // dt_capitalize_label
23#include "widgets/widget_settings.h" // DT_PIXEL_APPLY_DPI, dt_widget_notebook_page_changed
24#include "widgets/widget_style.h" // dt_gui_add_class
25#include <glib/gi18n.h>
26#include "system/mem_alloc.h"
27
28static void _notebook_size_callback(GtkNotebook *notebook, GdkRectangle *allocation, gpointer *data)
29{
32
34
35 for(int i = 0; i < n; i++)
36 {
38 sizes[i].minimum_size = 0;
41 sizes[i].natural_size = natural_size.width;
42 }
43
44 GtkAllocation first, last;
45 gtk_widget_get_allocation(sizes[0].data, &first);
46 gtk_widget_get_allocation(sizes[n - 1].data, &last);
47
48 const gint total_space = last.x + last.width - first.x; // ignore tab padding; CSS sets padding for label
49
50 if(total_space > 0)
51 {
53
54 for(int i = 0; i < n; i++)
56
58
59 for(int i = 0; i < n; i++)
60 gtk_widget_set_size_request(sizes[i].data, -1, -1);
61 }
62
64}
65
66// GTK_STATE_FLAG_PRELIGHT does not seem to get set on the label on hover so
67// state-flags-changed cannot update dt_control_get_global()->element for shortcut mapping
68static gboolean _notebook_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
69{
70 GtkAllocation notebook_alloc, label_alloc;
72
75 for(int i = 0; i < n; i++)
76 {
78 }
79
80 return FALSE;
81}
82
87
111
113 gpointer user_data)
114{
116}
117
119{
120 if(IS_NULL_PTR(notebook)) return;
121
122 // Guard against connecting twice on the same notebook (e.g. a caller re-entering
123 // gui_init after a GUI rebuild); user_data is set per-connection, so re-registering
124 // a different owner on an already-relayed notebook would otherwise leak the old
125 // connection instead of updating it.
129
131}
132
133// clang-format off
134// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
135// vim: shiftwidth=2 expandtab tabstop=2 cindent
136// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
137// clang-format on
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition colorspaces.h:98
const char * tooltip
Definition image.h:284
#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
static gboolean _notebook_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
Definition notebook.c:68
GtkWidget * dt_ui_notebook_page(GtkNotebook *notebook, const char *text, const char *tooltip)
Definition notebook.c:88
GtkNotebook * dt_ui_notebook_new()
Definition notebook.c:83
static void _notebook_size_callback(GtkNotebook *notebook, GdkRectangle *allocation, gpointer *data)
Definition notebook.c:28
static void _notebook_switch_page_signal_relay(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data)
Definition notebook.c:112
void dt_ui_notebook_set_picker_owner(GtkNotebook *notebook, gpointer owner)
Register an opaque owner for a GtkNotebook's page switches, and report every "switch_page" to the hos...
Definition notebook.c:118
GtkWidget * notebook
void dt_widget_notebook_page_changed(gpointer owner)
#define DT_GUI_BOX_SPACING
void dt_capitalize_label(gchar *text)