forked from AuroraMiddleware/gtk
tests: Stop using radio buttons
Use grouped check buttons.
This commit is contained in:
parent
cd284da794
commit
1b6f734019
@ -81,9 +81,9 @@ prepare_dialog (void)
|
||||
gboolean use_file = FALSE;
|
||||
char *content_type = NULL;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_file)))
|
||||
use_file = TRUE;
|
||||
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content)))
|
||||
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_content)))
|
||||
use_file = FALSE;
|
||||
|
||||
if (use_file)
|
||||
@ -208,9 +208,11 @@ main (int argc, char **argv)
|
||||
g_signal_connect (file_l, "clicked",
|
||||
G_CALLBACK (button_clicked), NULL);
|
||||
|
||||
radio_file = gtk_radio_button_new_with_label (NULL, "Use GFile");
|
||||
radio_content = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
|
||||
"Use content type");
|
||||
radio_file = gtk_check_button_new_with_label ("Use GFile");
|
||||
radio_content = gtk_check_button_new_with_label ("Use content type");
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_content), GTK_CHECK_BUTTON (radio_file));
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_file), GTK_CHECK_BUTTON (radio_content));
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (radio_file), TRUE);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), radio_file,
|
||||
0, 1, 1, 1);
|
||||
|
@ -41,7 +41,7 @@ complete_cb (GtkWidget *check,
|
||||
PageData *pdata = data;
|
||||
gboolean complete;
|
||||
|
||||
complete = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
|
||||
complete = gtk_check_button_get_active (GTK_CHECK_BUTTON (check));
|
||||
|
||||
gtk_assistant_set_page_complete (pdata->assistant,
|
||||
pdata->page,
|
||||
@ -64,7 +64,7 @@ add_completion_test_page (GtkWidget *assistant,
|
||||
gtk_box_append (GTK_BOX (page), gtk_label_new (text));
|
||||
gtk_box_append (GTK_BOX (page), check);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), complete);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), complete);
|
||||
|
||||
pdata = g_new (PageData, 1);
|
||||
pdata->assistant = GTK_ASSISTANT (assistant);
|
||||
@ -231,7 +231,7 @@ visible_cb (GtkWidget *check,
|
||||
GtkWidget *page = data;
|
||||
gboolean visible;
|
||||
|
||||
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
|
||||
visible = gtk_check_button_get_active (GTK_CHECK_BUTTON (check));
|
||||
|
||||
g_object_set (G_OBJECT (page), "visible", visible, NULL);
|
||||
}
|
||||
@ -268,7 +268,7 @@ create_generous_assistant (GtkWidget *widget)
|
||||
next = add_completion_test_page (assistant, "More Content", TRUE, TRUE);
|
||||
|
||||
check = gtk_check_button_new_with_label ("Next page visible");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
|
||||
g_signal_connect (G_OBJECT (check), "toggled",
|
||||
G_CALLBACK (visible_cb), next);
|
||||
gtk_box_append (GTK_BOX (page), check);
|
||||
@ -295,9 +295,9 @@ create_generous_assistant (GtkWidget *widget)
|
||||
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Summary");
|
||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_SUMMARY);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page),
|
||||
gtk_assistant_get_page_complete (GTK_ASSISTANT (assistant),
|
||||
page));
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (page),
|
||||
gtk_assistant_get_page_complete (GTK_ASSISTANT (assistant),
|
||||
page));
|
||||
|
||||
pdata = g_new (PageData, 1);
|
||||
pdata->assistant = GTK_ASSISTANT (assistant);
|
||||
@ -348,7 +348,7 @@ create_nonlinear_assistant (GtkWidget *widget)
|
||||
|
||||
if (!assistant)
|
||||
{
|
||||
GtkWidget *page, *button;
|
||||
GtkWidget *page, *button, *group;
|
||||
|
||||
assistant = gtk_assistant_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (assistant), 400, 300);
|
||||
@ -368,13 +368,14 @@ create_nonlinear_assistant (GtkWidget *widget)
|
||||
|
||||
page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
|
||||
button = gtk_radio_button_new_with_label (NULL, "branch A");
|
||||
button = gtk_check_button_new_with_label ("branch A");
|
||||
gtk_box_append (GTK_BOX (page), button);
|
||||
g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (select_branch), GINT_TO_POINTER ('A'));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
|
||||
group = button;
|
||||
|
||||
button = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"branch B");
|
||||
button = gtk_check_button_new_with_label ("branch B");
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_box_append (GTK_BOX (page), button);
|
||||
g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (select_branch), GINT_TO_POINTER ('B'));
|
||||
|
||||
@ -427,7 +428,7 @@ looping_assistant_forward_page (int current_page, gpointer data)
|
||||
assistant = (GtkAssistant*) data;
|
||||
page = gtk_assistant_get_nth_page (assistant, current_page);
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (page)))
|
||||
return 0;
|
||||
else
|
||||
return 4;
|
||||
|
@ -87,6 +87,7 @@ main (int argc,
|
||||
int i, j;
|
||||
GtkCssProvider *provider;
|
||||
gboolean done = FALSE;
|
||||
GtkWidget *group = NULL;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
@ -225,10 +226,18 @@ main (int argc,
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
|
||||
gtk_box_append (GTK_BOX (hbox), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (NULL, "│Xyj,Ö");
|
||||
button = gtk_check_button_new_with_label ("│Xyj,Ö");
|
||||
if (j == 0)
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
|
||||
gtk_box_append (GTK_BOX (hbox), button);
|
||||
if (group == NULL)
|
||||
{
|
||||
group = button;
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
|
||||
}
|
||||
else
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button),
|
||||
GTK_CHECK_BUTTON (group));
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ static void
|
||||
set_blank (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
|
||||
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ static void
|
||||
set_icon_name (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
|
||||
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "media-floppy");
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ set_gicon (GtkWidget *button,
|
||||
{
|
||||
GIcon *icon;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
|
||||
{
|
||||
icon = g_themed_icon_new ("gtk-yes");
|
||||
gtk_entry_set_icon_from_gicon (entry, GTK_ENTRY_ICON_SECONDARY, icon);
|
||||
@ -44,7 +44,7 @@ set_texture (GtkWidget *button,
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
|
||||
{
|
||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/inspector/logo.png");
|
||||
gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, GDK_PAINTABLE (texture));
|
||||
@ -238,23 +238,23 @@ main (int argc, char **argv)
|
||||
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), box, 0, 5, 3, 1);
|
||||
|
||||
button1 = gtk_radio_button_new_with_label (NULL, "Blank");
|
||||
button1 = gtk_check_button_new_with_label ("Blank");
|
||||
gtk_widget_set_valign (button1, GTK_ALIGN_START);
|
||||
g_signal_connect (button1, "toggled", G_CALLBACK (set_blank), entry);
|
||||
gtk_box_append (GTK_BOX (box), button1);
|
||||
button2 = gtk_radio_button_new_with_label (NULL, "Icon Name");
|
||||
button2 = gtk_check_button_new_with_label ("Icon Name");
|
||||
gtk_widget_set_valign (button2, GTK_ALIGN_START);
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button2), GTK_RADIO_BUTTON (button1));
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button2), GTK_CHECK_BUTTON (button1));
|
||||
g_signal_connect (button2, "toggled", G_CALLBACK (set_icon_name), entry);
|
||||
gtk_box_append (GTK_BOX (box), button2);
|
||||
button3 = gtk_radio_button_new_with_label (NULL, "GIcon");
|
||||
button3 = gtk_check_button_new_with_label ("GIcon");
|
||||
gtk_widget_set_valign (button3, GTK_ALIGN_START);
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button3), GTK_RADIO_BUTTON (button1));
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button3), GTK_CHECK_BUTTON (button1));
|
||||
g_signal_connect (button3, "toggled", G_CALLBACK (set_gicon), entry);
|
||||
gtk_box_append (GTK_BOX (box), button3);
|
||||
button4 = gtk_radio_button_new_with_label (NULL, "Texture");
|
||||
button4 = gtk_check_button_new_with_label ("Texture");
|
||||
gtk_widget_set_valign (button4, GTK_ALIGN_START);
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button4), GTK_RADIO_BUTTON (button1));
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button4), GTK_CHECK_BUTTON (button1));
|
||||
g_signal_connect (button4, "toggled", G_CALLBACK (set_texture), entry);
|
||||
gtk_box_append (GTK_BOX (box), button4);
|
||||
|
||||
|
@ -124,21 +124,26 @@ build_alpha_widgets (void)
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *group;
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_vexpand (grid, TRUE);
|
||||
|
||||
radio_button = gtk_radio_button_new_with_label (NULL, "Red");
|
||||
radio_button = gtk_check_button_new_with_label ("Red");
|
||||
gtk_widget_set_hexpand (radio_button, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 0, 1, 1);
|
||||
group = radio_button;
|
||||
|
||||
radio_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_button), "Green");
|
||||
radio_button = gtk_check_button_new_with_label ("Green");
|
||||
gtk_widget_set_hexpand (radio_button, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 1, 1, 1);
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_button), GTK_CHECK_BUTTON (group));
|
||||
|
||||
radio_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_button), "Blue"),
|
||||
radio_button = gtk_check_button_new_with_label ("Blue"),
|
||||
gtk_widget_set_hexpand (radio_button, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 2, 1, 1);
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_button), GTK_CHECK_BUTTON (group));
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (group), TRUE);
|
||||
|
||||
check_button = gtk_check_button_new_with_label ("Sedentary"),
|
||||
gtk_widget_set_hexpand (check_button, TRUE);
|
||||
@ -391,7 +396,7 @@ create_toggle_buttons (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_widget_grid (GType widget_type)
|
||||
create_widget_grid (gboolean group)
|
||||
{
|
||||
GtkWidget *grid;
|
||||
GtkWidget *group_widget = NULL;
|
||||
@ -424,14 +429,13 @@ create_widget_grid (GType widget_type)
|
||||
}
|
||||
else
|
||||
{
|
||||
widget = g_object_new (widget_type, NULL);
|
||||
|
||||
if (g_type_is_a (widget_type, GTK_TYPE_RADIO_BUTTON))
|
||||
widget = gtk_check_button_new ();
|
||||
if (group)
|
||||
{
|
||||
if (!group_widget)
|
||||
group_widget = widget;
|
||||
else
|
||||
g_object_set (widget, "group", group_widget, NULL);
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (widget), GTK_CHECK_BUTTON (group_widget));
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,7 +502,7 @@ create_check_buttons (GtkWidget *widget)
|
||||
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_append (GTK_BOX (box1), separator);
|
||||
|
||||
table = create_widget_grid (GTK_TYPE_CHECK_BUTTON);
|
||||
table = create_widget_grid (FALSE);
|
||||
gtk_widget_set_vexpand (table, TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), table);
|
||||
}
|
||||
@ -522,6 +526,7 @@ create_radio_buttons (GtkWidget *widget)
|
||||
GtkWidget *button;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *table;
|
||||
GtkWidget *group;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@ -543,23 +548,21 @@ create_radio_buttons (GtkWidget *widget)
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_box_append (GTK_BOX (box1), box2);
|
||||
|
||||
button = gtk_radio_button_new_with_label (NULL, "button1");
|
||||
button = gtk_check_button_new_with_label ("button1");
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
group = button;
|
||||
|
||||
button = gtk_check_button_new_with_label ("button2");
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"button2");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
button = gtk_check_button_new_with_label ("button3");
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"button3");
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"inconsistent");
|
||||
button = gtk_check_button_new_with_label ("inconsistent");
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (button), TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
@ -569,24 +572,23 @@ create_radio_buttons (GtkWidget *widget)
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_box_append (GTK_BOX (box1), box2);
|
||||
|
||||
button = gtk_radio_button_new_with_label (NULL, "button4");
|
||||
button = gtk_check_button_new_with_label ("button4");
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
group = button;
|
||||
|
||||
button = gtk_check_button_new_with_label ("button5");
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"button5");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
|
||||
"button6");
|
||||
button = gtk_check_button_new_with_label ("button6");
|
||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_append (GTK_BOX (box1), separator);
|
||||
|
||||
table = create_widget_grid (GTK_TYPE_RADIO_BUTTON);
|
||||
table = create_widget_grid (TRUE);
|
||||
gtk_box_append (GTK_BOX (box1), table);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user