File: test-simple-popover.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 (60 lines) | stat: -rw-r--r-- 1,659 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
54
55
56
57
58
59
60
#include <dazzle.h>

static void
text_changed (DzlSimplePopover *popover,
              gpointer          unused)
{
  const gchar *text;

  text = dzl_simple_popover_get_text (popover);
  dzl_simple_popover_set_ready (popover, text && *text);
}

static void
activate_cb (DzlSimplePopover *popover,
             const gchar      *text,
             GtkButton        *button)
{
  g_assert (DZL_IS_SIMPLE_POPOVER (popover));
  g_assert (GTK_IS_BUTTON (button));

  gtk_button_set_label (button, text);
}

gint
main (gint argc,
      gchar *argv[])
{
  DzlSimplePopover *popover;
  GtkMenuButton *button;
  GtkWindow *window;

  gtk_init (&argc, &argv);

  window = g_object_new (GTK_TYPE_WINDOW,
                         "title", "Test Simple Popover",
                         "border-width", 24,
                         "visible", TRUE,
                         NULL);

  popover = g_object_new (DZL_TYPE_SIMPLE_POPOVER,
                          "title", "Change Label",
                          "message", "Type the new text for the label",
                          "button-text", "Change",
                          NULL);

  button = g_object_new (GTK_TYPE_MENU_BUTTON,
                         "label", "Click Me…",
                         "popover", popover,
                         "visible", TRUE,
                         NULL);
  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (button));

  g_signal_connect (popover, "changed", G_CALLBACK (text_changed), NULL);
  g_signal_connect (popover, "activate", G_CALLBACK (activate_cb), button);
  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);

  gtk_main ();

  return 0;
}