25#include <glib/gi18n.h>
30 const int n = gtk_notebook_get_n_pages(
notebook);
31 g_return_if_fail(
n > 0);
33 GtkRequestedSize *sizes = g_malloc_n(
n,
sizeof(GtkRequestedSize));
35 for(
int i = 0;
i <
n;
i++)
37 sizes[
i].data = gtk_notebook_get_tab_label(
notebook, gtk_notebook_get_nth_page(
notebook,
i));
38 sizes[
i].minimum_size = 0;
39 GtkRequisition natural_size;
40 gtk_widget_get_preferred_size(sizes[
i].
data, NULL, &natural_size);
41 sizes[
i].natural_size = natural_size.width;
44 GtkAllocation first, last;
45 gtk_widget_get_allocation(sizes[0].
data, &first);
46 gtk_widget_get_allocation(sizes[
n - 1].
data, &last);
48 const gint total_space = last.x + last.width - first.x;
52 gtk_distribute_natural_allocation(total_space,
n, sizes);
54 for(
int i = 0;
i <
n;
i++)
55 gtk_widget_set_size_request(sizes[
i].
data, sizes[
i].minimum_size, -1);
57 gtk_widget_size_allocate(GTK_WIDGET(
notebook), allocation);
59 for(
int i = 0;
i <
n;
i++)
60 gtk_widget_set_size_request(sizes[
i].
data, -1, -1);
70 GtkAllocation notebook_alloc, label_alloc;
71 gtk_widget_get_allocation(widget, ¬ebook_alloc);
73 GtkNotebook *
notebook = GTK_NOTEBOOK(widget);
74 const int n = gtk_notebook_get_n_pages(
notebook);
75 for(
int i = 0;
i <
n;
i++)
77 gtk_widget_get_allocation(gtk_notebook_get_tab_label(
notebook, gtk_notebook_get_nth_page(
notebook,
i)), &label_alloc);
85 return GTK_NOTEBOOK(gtk_notebook_new());
90 gchar *text_cpy = g_strdup(_(text));
92 GtkWidget *label = gtk_label_new(text_cpy);
96 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
100 gint page_num = gtk_notebook_append_page(
notebook, page, label);
101 gtk_container_child_set(GTK_CONTAINER(
notebook), page,
"tab-expand",
TRUE,
"tab-fill",
TRUE, NULL);
126 const gulong existing = g_signal_handler_find(G_OBJECT(
notebook), G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
128 if(existing) g_signal_handler_disconnect(G_OBJECT(
notebook), existing);
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
static gboolean _notebook_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
GtkWidget * dt_ui_notebook_page(GtkNotebook *notebook, const char *text, const char *tooltip)
GtkNotebook * dt_ui_notebook_new()
static void _notebook_size_callback(GtkNotebook *notebook, GdkRectangle *allocation, gpointer *data)
static void _notebook_switch_page_signal_relay(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data)
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...