<commit_before>// 12 april 2015
#include "uipriv_unix.h"

// TODOs
// - clean up the bin handling
// 	- in particular, why are we holding a reference to binWidget again? if we should, then get rid of binSetParent() entirely!

struct tab {
	uiTab t;
	GtkWidget *widget;
	GtkContainer *container;
	GtkNotebook *notebook;
	GArray *pages;
};

struct tabPage {
	uiContainer *bin;
	GtkWidget *binWidget;
	int margined;
};

static void onDestroy(void *data)
{
	struct tab *t = (struct tab *) data;
	guint i;
	struct tabPage *p;

	// first hide ourselves to avoid flicker
	gtk_widget_hide(t->widget);
	// the pages do not have a libui parent, so we can simply destroy them
	// we need to remove them from the tab first; see below
	for (i = 0; i < t->pages->len; i++) {
		p = &g_array_index(t->pages, struct tabPage, i);
		gtk_container_remove(t->container, p->binWidget);
		uiControlDestroy(uiControl(p->bin));
	}
	// then free ourselves
	g_array_free(t->pages, TRUE);
	uiFree(t);
}

static void tabShow(uiControl *c)
{
	struct tab *t = (struct tab *) t;

	// don't call gtk_widget_show_all() like the default handler does; that'll override user hiding
	gtk_widget_show(t->widget);
}

#define tabCapGrow 32

static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
{
	struct tab *t = (struct tab *) tt;
	struct tabPage p;

	p.bin = newBin();
	binSetMainControl(p.bin, child);
	// and add it as a tab page
	binSetParent(p.bin, (uintptr_t) (t->container));
	p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin)));
	gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name);

	g_array_append_val(t->pages, p);
}

static void tabDeletePage(uiTab *tt, uintmax_t n)
{
	struct tab *t = (struct tab *) tt;
	struct tabPage *p;<commit_msg>Made a comment in the previous commit more clear.<commit_after>// 12 april 2015
#include "uipriv_unix.h"

// TODOs
// - clean up the bin handling
// 	- in particular, why are we holding a reference to binWidget again? if we should, then get rid of binSetParent() entirely!

struct tab {
	uiTab t;
	GtkWidget *widget;
	GtkContainer *container;
	GtkNotebook *notebook;
	GArray *pages;
};

struct tabPage {
	uiContainer *bin;
	GtkWidget *binWidget;
	int margined;
};

static void onDestroy(void *data)
{
	struct tab *t = (struct tab *) data;
	guint i;
	struct tabPage *p;

	// first hide ourselves to avoid flicker
	gtk_widget_hide(t->widget);
	// the pages do not have a libui parent, so we can simply destroy them
	// we need to remove them from the tab first; see below
	for (i = 0; i < t->pages->len; i++) {
		p = &g_array_index(t->pages, struct tabPage, i);
		gtk_container_remove(t->container, p->binWidget);
		uiControlDestroy(uiControl(p->bin));
	}
	// then free ourselves
	g_array_free(t->pages, TRUE);
	uiFree(t);
}

static void tabShow(uiControl *c)
{
	struct tab *t = (struct tab *) t;

	// don't call gtk_widget_show_all() like the default handler does; that'll override user hiding of children
	gtk_widget_show(t->widget);
}

#define tabCapGrow 32

static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
{
	struct tab *t = (struct tab *) tt;
	struct tabPage p;

	p.bin = newBin();
	binSetMainControl(p.bin, child);
	// and add it as a tab page
	binSetParent(p.bin, (uintptr_t) (t->container));
	p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin)));
	gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name);

	g_array_append_val(t->pages, p);
}

static void tabDeletePage(uiTab *tt, uintmax_t n)
{
	struct tab *t = (struct tab *) tt;
	struct tabPage *p;
{'fraction_non_alphanumeric': 0.12387133182844244, 'fraction_numerical': 0.005079006772009029, 'mean_word_length': 4.291044776119403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7001390', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1273, 'n_words': 407}