summaryrefslogtreecommitdiff
path: root/tests/testpopupat.c
blob: cf9a4538e8edb1fe8750ca1a3e9becee137d7716 (plain)
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
#include <gtk/gtk.h>

static void
destroy_cb (GtkWidget  *window,
            GtkBuilder *builder)
{
  gtk_main_quit ();
}

static void
populate_popup_cb (GtkAppChooserWidget *app_chooser_widget,
                   GtkMenu             *menu,
                   GAppInfo            *app_info,
                   gpointer             user_data)
{
  GtkWidget *menu_item;

  menu_item = gtk_menu_item_new_with_label ("Menu Item A");
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

  menu_item = gtk_menu_item_new_with_label ("Menu Item B");
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

  menu_item = gtk_menu_item_new_with_label ("Menu Item C");
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

  menu_item = gtk_menu_item_new_with_label ("Menu Item D");
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

  menu_item = gtk_menu_item_new_with_label ("Menu Item E");
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
}

int
main (int   argc,
      char *argv[])
{
  GtkBuilder *builder;
  GtkWidget *window;
  GtkWidget *app_chooser_widget;

  gtk_init (&argc, &argv);

  builder = gtk_builder_new_from_file ("popupat.ui");

  window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
  g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), builder);

  app_chooser_widget = GTK_WIDGET (gtk_builder_get_object (builder, "appchooserwidget"));
  g_signal_connect (app_chooser_widget, "populate-popup", G_CALLBACK (populate_popup_cb), builder);

  gtk_widget_show_all (window);

  gtk_main ();

  g_object_unref (builder);

  return 0;
}