/* Testing removal of a GtkListBox with a placeholder.
 *
 * Some of the code has been copied from gtk+/tests/testlist.c.
 */

#include <gtk/gtk.h>

static void
dispose_clicked_cb (GtkButton *button,
                    gpointer data)
{
  GObject *object = data;
  g_object_run_dispose (object);
}

int
main (int argc, char *argv[])
{
  GtkWidget *window, *vbox, *list, *label;
  GtkWidget *bbox, *blist, *blabel;

#if GTK_CHECK_VERSION(3,89,3)
  gtk_init ();
#else
  gtk_init (&argc, &argv);
#endif

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  list = gtk_list_box_new ();
  gtk_container_add (GTK_CONTAINER (vbox), list);

  label = gtk_label_new ("ListBox, placeholder");
  gtk_widget_show (label);
  gtk_list_box_set_placeholder (GTK_LIST_BOX (list), label);

  bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_container_add (GTK_CONTAINER (vbox), bbox);

  blist = gtk_button_new_with_label ("Dispose of listbox");
  gtk_container_add (GTK_CONTAINER (bbox), blist);
  g_signal_connect (blist, "clicked", G_CALLBACK (dispose_clicked_cb), list);

  blabel = gtk_button_new_with_label ("Dispose of placeholder");
  gtk_container_add (GTK_CONTAINER (bbox), blabel);
  g_signal_connect (blabel, "clicked", G_CALLBACK (dispose_clicked_cb), label);

#if GTK_CHECK_VERSION(3,89,3)
  gtk_widget_show (window);
#else
  gtk_widget_show_all (window);
#endif

  gtk_main ();

  return 0;
}
