File: test-box.c

package info (click to toggle)
libdazzle 3.44.0-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,964 kB
  • sloc: ansic: 64,328; xml: 69; javascript: 19; makefile: 12
file content (53 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (5)
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
#include <dazzle.h>

gint
main (gint argc,
      gchar *argv[])
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *label;

  gtk_init (&argc, &argv);

  window = g_object_new (GTK_TYPE_WINDOW,
                         "title", "Box Test",
                         NULL);
  box = g_object_new (DZL_TYPE_BOX,
                      "spacing", 12,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (window), box);

  for (guint i = 0; i < 10; i += 2)
    {
      g_autofree gchar *str = g_strdup_printf ("%u", i);

      label = g_object_new (GTK_TYPE_LABEL,
                            "label", str,
                            "visible", TRUE,
                            NULL);
      gtk_container_add_with_properties (GTK_CONTAINER (box), label,
                                         "position", i,
                                         NULL);
    }

  for (guint i = 1; i < 10; i += 2)
    {
      g_autofree gchar *str = g_strdup_printf ("%u", i);

      label = g_object_new (GTK_TYPE_LABEL,
                            "label", str,
                            "visible", TRUE,
                            NULL);
      gtk_container_add_with_properties (GTK_CONTAINER (box), label,
                                         "position", i,
                                         NULL);
    }

  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
  gtk_window_present (GTK_WINDOW (window));
  gtk_main ();

  return 0;
}