mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
gtk-demo: replace uses of GtkTable by GtkGrid
This commit is contained in:
parent
ce58d8887f
commit
a6899f2a9d
@ -416,7 +416,7 @@ do_appwindow (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
table = gtk_table_new (1, 5, FALSE);
|
||||
table = gtk_grid_new ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
|
||||
@ -464,21 +464,13 @@ do_appwindow (GtkWidget *do_widget)
|
||||
|
||||
bar = gtk_ui_manager_get_widget (merge, "/MenuBar");
|
||||
gtk_widget_show (bar);
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
bar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
gtk_widget_set_halign (bar, GTK_ALIGN_FILL);
|
||||
gtk_grid_attach (GTK_GRID (table), bar, 0, 0, 1, 1);
|
||||
|
||||
bar = gtk_ui_manager_get_widget (merge, "/ToolBar");
|
||||
gtk_widget_show (bar);
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
bar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
gtk_widget_set_halign (bar, GTK_ALIGN_FILL);
|
||||
gtk_grid_attach (GTK_GRID (table), bar, 0, 1, 1, 1);
|
||||
|
||||
/* Create document
|
||||
*/
|
||||
@ -495,12 +487,8 @@ do_appwindow (GtkWidget *do_widget)
|
||||
g_signal_connect (infobar, "response",
|
||||
G_CALLBACK (gtk_widget_hide), NULL);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
infobar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
gtk_widget_set_halign (infobar, GTK_ALIGN_FILL);
|
||||
gtk_grid_attach (GTK_GRID (table), infobar, 0, 2, 1, 1);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
||||
@ -511,12 +499,11 @@ do_appwindow (GtkWidget *do_widget)
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
sw,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 3, 4,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
gtk_widget_set_halign (sw, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (sw, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_hexpand (sw, TRUE);
|
||||
gtk_widget_set_vexpand (sw, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), sw, 0, 3, 1, 1);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
200, 200);
|
||||
@ -530,12 +517,8 @@ do_appwindow (GtkWidget *do_widget)
|
||||
/* Create statusbar */
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
statusbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 4, 5,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
gtk_widget_set_halign (sw, GTK_ALIGN_FILL);
|
||||
gtk_grid_attach (GTK_GRID (table), statusbar, 0, 4, 1, 1);
|
||||
|
||||
/* Show text widget info in the statusbar */
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
|
||||
|
@ -61,27 +61,23 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 4);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 4);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
local_entry1 = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), local_entry1, 1, 2, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), local_entry1, 1, 0, 1, 1);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry1);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
|
||||
local_entry2 = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (local_entry2), gtk_entry_get_text (GTK_ENTRY (entry2)));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (table), local_entry2, 1, 1, 1, 1);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2);
|
||||
|
||||
gtk_widget_show_all (hbox);
|
||||
@ -146,29 +142,23 @@ do_dialog (GtkWidget *do_widget)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 4);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 4);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
entry1 = gtk_entry_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), entry1, 1, 0, 1, 1);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
|
||||
entry2 = gtk_entry_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
|
||||
gtk_grid_attach (GTK_GRID (table), entry2, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@ -87,44 +87,35 @@ create_pane_options (GtkPaned *paned,
|
||||
frame = gtk_frame_new (frame_label);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
||||
|
||||
table = gtk_table_new (3, 2, TRUE);
|
||||
table = gtk_grid_new ();
|
||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
|
||||
label = gtk_label_new (label1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label,
|
||||
0, 1, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
0, 1, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
0, 1, 2, 3);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child1);
|
||||
|
||||
label = gtk_label_new (label2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label,
|
||||
1, 2, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
1, 2, 1, 2);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child2);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
1, 2, 2, 3);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child2);
|
||||
|
||||
|
@ -25,9 +25,9 @@ do_pickers (GtkWidget *do_widget)
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
||||
|
||||
table = gtk_table_new (5, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 10);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 3);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
|
||||
@ -35,40 +35,44 @@ do_pickers (GtkWidget *do_widget)
|
||||
label = gtk_label_new ("Color:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
picker = gtk_color_button_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), picker, 1, 2, 0, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Font:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
picker = gtk_font_button_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), picker, 1, 2, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("File:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
picker = gtk_file_chooser_button_new ("Pick a File",
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), picker, 1, 2, 2, 3);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Folder:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
picker = gtk_file_chooser_button_new ("Pick a Folder",
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), picker, 1, 2, 3, 4);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 3, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Mail:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
picker = gtk_app_chooser_button_new ("x-scheme-handler/mailto");
|
||||
gtk_app_chooser_button_set_show_dialog_item (GTK_APP_CHOOSER_BUTTON (picker), TRUE);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), picker, 1, 2, 4, 5);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 4, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 4, 1, 1);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@ -36,7 +36,7 @@ create_combo_box (const char **strings)
|
||||
}
|
||||
|
||||
static void
|
||||
add_row (GtkTable *table,
|
||||
add_row (GtkGrid *table,
|
||||
int row,
|
||||
GtkSizeGroup *size_group,
|
||||
const char *label_text,
|
||||
@ -48,18 +48,13 @@ add_row (GtkTable *table,
|
||||
label = gtk_label_new_with_mnemonic (label_text);
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_END);
|
||||
gtk_table_attach (GTK_TABLE (table), label,
|
||||
0, 1, row, row + 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (table, label, 0, row, 1, 1);
|
||||
|
||||
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);
|
||||
gtk_grid_attach (table, combo_box, 1, row, 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -130,28 +125,28 @@ do_sizegroup (GtkWidget *do_widget)
|
||||
frame = gtk_frame_new ("Color Options");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
table = gtk_grid_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 5);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (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_GRID (table), 0, size_group, "_Foreground", color_options);
|
||||
add_row (GTK_GRID (table), 1, size_group, "_Background", color_options);
|
||||
|
||||
/* And another frame holding line style options
|
||||
*/
|
||||
frame = gtk_frame_new ("Line Options");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
table = gtk_grid_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 5);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (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_GRID (table), 0, size_group, "_Dashing", dash_options);
|
||||
add_row (GTK_GRID (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_mnemonic ("_Enable grouping");
|
||||
|
Loading…
Reference in New Issue
Block a user