File: test-panel-notebook.c

package info (click to toggle)
libgedit-tepl 6.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,936 kB
  • sloc: ansic: 18,685; xml: 759; sh: 20; makefile: 9
file content (75 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SPDX-FileCopyrightText: 2024 - Sébastien Wilmet
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include <tepl/tepl.h>
#include <stdlib.h>

static TeplPanelSimple *
create_panel_simple (void)
{
	TeplPanelSimple *panel_simple;
	GtkWidget *label;
	TeplPanelItem *item;

	panel_simple = tepl_panel_simple_new ();

	label = gtk_label_new ("Widget 1");
	item = tepl_panel_item_new (label, "name1", "Title 1", NULL, 0);
	tepl_panel_add (TEPL_PANEL (panel_simple), item);
	g_object_unref (item);

	label = gtk_label_new ("Widget 2");
	item = tepl_panel_item_new (label, "name2", "Title 2", NULL, 0);
	tepl_panel_add (TEPL_PANEL (panel_simple), item);
	g_object_unref (item);

	return panel_simple;
}

static GtkNotebook *
create_notebook (void)
{
	GtkNotebook *notebook;

	notebook = GTK_NOTEBOOK (gtk_notebook_new ());
	gtk_notebook_set_tab_pos (notebook, GTK_POS_BOTTOM);

	return notebook;
}

int
main (int    argc,
      char **argv)
{
	GtkWidget *window;
	TeplPanelSimple *panel_simple;
	GtkNotebook *notebook;
	TeplPanelNotebook *panel_notebook;

	tepl_init ();
	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);

	panel_simple = create_panel_simple ();
	notebook = create_notebook ();
	panel_notebook = tepl_panel_notebook_new (panel_simple, notebook);
	g_object_unref (panel_simple);

	gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (notebook));
	gtk_widget_show_all (window);

	g_signal_connect (window,
			  "destroy",
			  G_CALLBACK (gtk_main_quit),
			  NULL);

	gtk_main ();

	g_object_unref (panel_notebook);
	tepl_finalize ();

	return EXIT_SUCCESS;
}