]> Pileus Git - ~andy/gtk/blobdiff - demos/gtk-demo/sizegroup.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / demos / gtk-demo / sizegroup.c
index fe87feff50e4bda16e5426acabcfea1d3576106a..e7a8595d15b3ee51cca57b6f0a55406020f0588e 100644 (file)
 
 static GtkWidget *window = NULL;
 
-/* Convenience function to create an option menu holding a number of strings
+/* Convenience function to create a combo box holding a number of strings
  */
 GtkWidget *
-create_option_menu (const char **strings)
+create_combo_box (const char **strings)
 {
-  GtkWidget *menu;
-  GtkWidget *option_menu;
+  GtkWidget *combo_box;
   const char **str;
 
-  menu = gtk_menu_new ();
+  combo_box = gtk_combo_box_text_new ();
   
   for (str = strings; *str; str++)
-    {
-      GtkWidget *menu_item = gtk_menu_item_new_with_label (*str);
-      gtk_widget_show (menu_item);
-
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-    }
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), *str);
 
-  option_menu = gtk_option_menu_new ();
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
 
-  return option_menu;
+  return combo_box;
 }
 
 static void
@@ -49,19 +42,20 @@ add_row (GtkTable     *table,
         const char   *label_text,
         const char  **options)
 {
-  GtkWidget *option_menu;
+  GtkWidget *combo_box;
   GtkWidget *label;
 
-  label = gtk_label_new (label_text);
+  label = gtk_label_new_with_mnemonic (label_text);
   gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
   gtk_table_attach (GTK_TABLE (table), label,
                    0, 1,                  row, row + 1,
                    GTK_EXPAND | GTK_FILL, 0,
                    0,                     0);
   
-  option_menu = create_option_menu (options);
-  gtk_size_group_add_widget (size_group, option_menu);
-  gtk_table_attach (GTK_TABLE (table), option_menu,
+  combo_box = create_combo_box (options);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
+  gtk_size_group_add_widget (size_group, combo_box);
+  gtk_table_attach (GTK_TABLE (table), combo_box,
                    1, 2,                  row, row + 1,
                    0,                     0,
                    0,                     0);
@@ -86,8 +80,9 @@ toggle_grouping (GtkToggleButton *check_button,
 }
 
 GtkWidget *
-do_sizegroup (void)
+do_sizegroup (GtkWidget *do_widget)
 {
+  GtkWidget *content_area;
   GtkWidget *table;
   GtkWidget *frame;
   GtkWidget *vbox;
@@ -109,19 +104,22 @@ do_sizegroup (void)
   if (!window)
     {
       window = gtk_dialog_new_with_buttons ("GtkSizeGroup",
-                                           NULL, 0,
+                                           GTK_WINDOW (do_widget),
+                                           0,
                                            GTK_STOCK_CLOSE,
                                            GTK_RESPONSE_NONE,
                                            NULL);
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
       
-      gtk_signal_connect (GTK_OBJECT (window), "response",
-                         GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
-      gtk_signal_connect (GTK_OBJECT (window), "destroy",
-                         GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
+      g_signal_connect (window, "response",
+                       G_CALLBACK (gtk_widget_destroy), NULL);
+      g_signal_connect (window, "destroy",
+                       G_CALLBACK (gtk_widget_destroyed), &window);
+
+      content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
 
-      vbox = gtk_vbox_new (FALSE, 5);
-      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
+      gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
       gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
       size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -137,8 +135,8 @@ do_sizegroup (void)
       gtk_table_set_col_spacings (GTK_TABLE (table), 10);
       gtk_container_add (GTK_CONTAINER (frame), table);
 
-      add_row (GTK_TABLE (table), 0, size_group, "Foreground", color_options);
-      add_row (GTK_TABLE (table), 1, size_group, "Background", color_options);
+      add_row (GTK_TABLE (table), 0, size_group, "_Foreground", color_options);
+      add_row (GTK_TABLE (table), 1, size_group, "_Background", color_options);
 
       /* And another frame holding line style options
        */
@@ -151,19 +149,19 @@ do_sizegroup (void)
       gtk_table_set_col_spacings (GTK_TABLE (table), 10);
       gtk_container_add (GTK_CONTAINER (frame), table);
 
-      add_row (GTK_TABLE (table), 0, size_group, "Dashing", dash_options);
-      add_row (GTK_TABLE (table), 1, size_group, "Line ends", end_options);
+      add_row (GTK_TABLE (table), 0, size_group, "_Dashing", dash_options);
+      add_row (GTK_TABLE (table), 1, size_group, "_Line ends", end_options);
 
       /* And a check button to turn grouping on and off */
-      check_button = gtk_check_button_new_with_label ("Enable grouping");
+      check_button = gtk_check_button_new_with_mnemonic ("_Enable grouping");
       gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 0);
       
       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
-      gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
-                         GTK_SIGNAL_FUNC (toggle_grouping), size_group);
+      g_signal_connect (check_button, "toggled",
+                       G_CALLBACK (toggle_grouping), size_group);
     }
 
-  if (!GTK_WIDGET_VISIBLE (window))
+  if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
     gtk_widget_destroy (window);