]> Pileus Git - ~andy/gtk/blobdiff - tests/testtoolbar.c
Use gtk_box_new() instead gtk_[v|h]box_new()
[~andy/gtk] / tests / testtoolbar.c
index af7cbee7821a2572b68d1439c9ddd14dc13a620c..cd55b032bd4beb5673dfb2524bc77c21893165e5 100644 (file)
@@ -19,7 +19,6 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#undef GTK_DISABLE_DEPRECATED
 #include "config.h"
 #include <gtk/gtk.h>
 #include "prop-editor.h"
@@ -56,7 +55,7 @@ change_orientation (GtkWidget *button, GtkWidget *toolbar)
 
   g_object_ref (toolbar);
   gtk_container_remove (GTK_CONTAINER (table), toolbar);
-  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), orientation);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar), orientation);
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       gtk_table_attach (GTK_TABLE (table), toolbar,
@@ -87,7 +86,7 @@ set_toolbar_style_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
 
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
     {
-      style = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
+      style = gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu));
 
       gtk_toolbar_set_style (toolbar, style);
       gtk_widget_set_sensitive (option_menu, TRUE);
@@ -104,7 +103,7 @@ change_toolbar_style (GtkWidget *option_menu, GtkWidget *toolbar)
 {
   GtkToolbarStyle style;
 
-  style = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
+  style = gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu));
   gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
 }
 
@@ -322,8 +321,10 @@ set_icon_size_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
 
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
     {
-      icon_size = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
-      icon_size += GTK_ICON_SIZE_SMALL_TOOLBAR;
+      if (gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu)) == 0)
+        icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
+      else
+        icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
 
       gtk_toolbar_set_icon_size (toolbar, icon_size);
       gtk_widget_set_sensitive (option_menu, TRUE);
@@ -336,12 +337,14 @@ set_icon_size_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
 }
 
 static void
-icon_size_history_changed (GtkOptionMenu *menu, GtkToolbar *toolbar)
+icon_size_history_changed (GtkComboBox *menu, GtkToolbar *toolbar)
 {
   int icon_size;
 
-  icon_size = gtk_option_menu_get_history (menu);
-  icon_size += GTK_ICON_SIZE_SMALL_TOOLBAR;
+  if (gtk_combo_box_get_active (menu) == 0)
+    icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
+  else
+    icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
 
   gtk_toolbar_set_icon_size (toolbar, icon_size);
 }
@@ -449,7 +452,7 @@ toolbar_drag_motion (GtkToolbar     *toolbar,
   if (!drag_item)
     {
       drag_item = gtk_tool_button_new (NULL, "A quite long button");
-      gtk_object_sink (GTK_OBJECT (g_object_ref (drag_item)));
+      g_object_ref_sink (g_object_ref (drag_item));
     }
   
   gdk_drag_status (context, GDK_ACTION_MOVE, time);
@@ -527,12 +530,12 @@ main (gint argc, gchar **argv)
   gtk_table_attach (GTK_TABLE (table), toolbar,
                    0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
 
-  hbox1 = gtk_hbox_new (FALSE, 3);
+  hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 3);
   gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);
   gtk_table_attach (GTK_TABLE (table), hbox1,
                    1,2, 1,2, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
 
-  hbox2 = gtk_hbox_new (FALSE, 2);
+  hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 2);
   gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
   gtk_table_attach (GTK_TABLE (table), hbox2,
                    1,2, 2,3, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
@@ -551,23 +554,15 @@ main (gint argc, gchar **argv)
   checkbox = gtk_check_button_new_with_mnemonic("_Set Toolbar Style:");
   g_signal_connect (checkbox, "toggled", G_CALLBACK (set_toolbar_style_toggled), toolbar);
   gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
-  
-  option_menu = gtk_option_menu_new();
+
+  option_menu = gtk_combo_box_text_new ();
   gtk_widget_set_sensitive (option_menu, FALSE);  
   g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
   
-  menu = gtk_menu_new();
   for (i = 0; i < G_N_ELEMENTS (toolbar_styles); i++)
-    {
-      GtkWidget *menuitem;
-
-      menuitem = gtk_menu_item_new_with_label (toolbar_styles[i]);
-      gtk_container_add (GTK_CONTAINER (menu), menuitem);
-      gtk_widget_show (menuitem);
-    }
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
-  gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu),
-                              GTK_TOOLBAR (toolbar)->style);
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), toolbar_styles[i]);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu),
+                            gtk_toolbar_get_style (GTK_TOOLBAR (toolbar)));
   gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
   g_signal_connect (option_menu, "changed",
                    G_CALLBACK (change_toolbar_style), toolbar);
@@ -576,21 +571,12 @@ main (gint argc, gchar **argv)
   g_signal_connect (checkbox, "toggled", G_CALLBACK (set_icon_size_toggled), toolbar);
   gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
 
-  option_menu = gtk_option_menu_new();
+  option_menu = gtk_combo_box_text_new ();
   g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
   gtk_widget_set_sensitive (option_menu, FALSE);
-  menu = gtk_menu_new();
-  menuitem = gtk_menu_item_new_with_label ("small toolbar");
-  g_object_set_data (G_OBJECT (menuitem), "value-id", GINT_TO_POINTER (GTK_ICON_SIZE_SMALL_TOOLBAR));
-  gtk_container_add (GTK_CONTAINER (menu), menuitem);
-  gtk_widget_show (menuitem);
-
-  menuitem = gtk_menu_item_new_with_label ("large toolbar");
-  g_object_set_data (G_OBJECT (menuitem), "value-id", GINT_TO_POINTER (GTK_ICON_SIZE_LARGE_TOOLBAR));
-  gtk_container_add (GTK_CONTAINER (menu), menuitem);
-  gtk_widget_show (menuitem);
-
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "small toolbar");
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "large toolbar");
+
   gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
   g_signal_connect (option_menu, "changed",
                    G_CALLBACK (icon_size_history_changed), toolbar);
@@ -715,12 +701,12 @@ main (gint argc, gchar **argv)
   add_item_to_list (store, item, "Video");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
-  image = gtk_image_new_from_icon_name ("utility-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR);
+  image = gtk_image_new_from_icon_name ("utilities-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR);
   item = gtk_tool_button_new (image, "Terminal");
   add_item_to_list (store, item, "Terminal");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
-  hbox = gtk_hbox_new (FALSE, 5);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 5);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
   gtk_table_attach (GTK_TABLE (table), hbox,
                    1,2, 4,5, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);