#include <gtk/gtk.h>

void on_action_widget_clicked (GtkButton* button, gpointer data)
{
  static pos = GTK_POS_TOP;
  pos++;
  if (pos > GTK_POS_BOTTOM)
    pos = GTK_POS_LEFT;

  gtk_notebook_set_tab_pos (GTK_NOTEBOOK(data), pos);
}

void on_action_widget2_clicked (GtkButton* button, gpointer data)
{
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK(data), FALSE);
}

int main(int argc, char** argv)
{
  GtkWidget *window, *notebook, *action_widget, *action_widget2;
  
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(window), "Notebook test");

  notebook = gtk_notebook_new ();
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_button_new_with_label ("Focus widget..."),
                            gtk_label_new ("First page"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_label_new ("Page 2"),
                            gtk_label_new ("Second page"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_label_new ("Page 3"),
                            gtk_label_new ("Third page"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_label_new ("Page 4"),
                            gtk_label_new ("Fourth page"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_label_new ("Page 5"),
                            gtk_label_new ("Fifth page"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            gtk_label_new ("Page 6"),
                            gtk_label_new ("Sixth page"));
  
  action_widget = gtk_button_new_with_label ("Change orientation");
  g_signal_connect(action_widget, "clicked", G_CALLBACK(on_action_widget_clicked), notebook);
  
  gtk_notebook_set_action_widget (GTK_NOTEBOOK(notebook),
                                  action_widget, GTK_PACK_START);

  action_widget2 = gtk_button_new_with_label ("Hide tabs");
  g_signal_connect(action_widget2, "clicked", G_CALLBACK(on_action_widget2_clicked), notebook);
  
  gtk_notebook_set_action_widget (GTK_NOTEBOOK(notebook),
                                  action_widget2, GTK_PACK_END);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK(notebook), TRUE);

  

  gtk_container_add (GTK_CONTAINER(window), notebook);

  gtk_window_set_default_size (GTK_WINDOW(window), 500, 400);
  gtk_widget_show_all (window);

  g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
  
  gtk_main();
}
