#include <gtk/gtk.h>

static void
icon_theme_changed (GtkComboBox *cb,
                    gpointer     user_data)
{
  gchar *theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cb));

  g_object_set (gtk_settings_get_default (),
                "gtk-icon-theme-name",
                theme,
                NULL);

  g_free (theme);
}


int 
main (int   argc,
      char *argv[])
{
  GtkWidget *window, *vbox, *hbox, *image, *combo_box, *button;
  GdkPixbuf *pixbuf;

  gtk_init (&argc, &argv);

  /* Initialize custom icon theme search path */
  gtk_icon_theme_prepend_search_path (gtk_icon_theme_get_default (), "./icons");
  g_object_set (gtk_settings_get_default (), "gtk-icon-theme-name", "GimpColor", NULL);

  /* A window with 4 images from icons */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  vbox = gtk_vbox_new (FALSE, 10);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  hbox = gtk_hbox_new (FALSE, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

  /* load_icon "document-open" */
  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "document-open",
                                     16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
  image = gtk_image_new_from_pixbuf (pixbuf);
  g_object_set (image, "icon-name", "document-open", NULL);
  gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);

  /* image_new_from_icon_name "document-open" */
  image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_MENU);
  gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);

  /* image_new_from_icon_name "gtk-justify-center" */
  image = gtk_image_new_from_icon_name ("gtk-justify-center", GTK_ICON_SIZE_LARGE_TOOLBAR);
  gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);

  /* load_icon "gtk-justify-center" */
  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                     "gtk-justify-center",
                                     22,
                                     GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
  image = gtk_image_new_from_pixbuf (pixbuf);
  g_object_set (image, "icon-name", "gtk-justify-center", NULL);
  gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);


  hbox = gtk_hbox_new (FALSE, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  combo_box = gtk_combo_box_text_new ();
  gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "GimpColor");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "GimpSymbolic");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), "GimpLegacy");
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
  g_signal_connect (combo_box, "changed", G_CALLBACK (icon_theme_changed), NULL);

  button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
  gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);

  gtk_window_set_focus (GTK_WINDOW (window), button);

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}
