Commit 38cbd87c authored by Matthias Clasen's avatar Matthias Clasen

tests: Stop using GtkAlignment

Fix up all other tests to not use GtkAlignment anymore.
parent 1af417a8
......@@ -311,7 +311,6 @@ do_image (const char *filename)
GtkWidget *vbox;
GtkWidget *image;
GtkWidget *label;
GtkWidget *align;
GtkWidget *window;
gchar *str, *escaped;
LoadContext *lc;
......@@ -338,12 +337,9 @@ do_image (const char *filename)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
/* The alignment keeps the frame from growing when users resize
* the window
*/
align = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_container_add (GTK_CONTAINER (align), frame);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
image = gtk_image_new_from_pixbuf (NULL);
gtk_container_add (GTK_CONTAINER (frame), image);
......@@ -373,7 +369,6 @@ do_nonprogressive (const gchar *filename)
GtkWidget *vbox;
GtkWidget *image;
GtkWidget *label;
GtkWidget *align;
GtkWidget *window;
gchar *str, *escaped;
......@@ -399,12 +394,9 @@ do_nonprogressive (const gchar *filename)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
/* The alignment keeps the frame from growing when users resize
* the window
*/
align = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_container_add (GTK_CONTAINER (align), frame);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
image = gtk_image_new_from_file (filename);
gtk_container_add (GTK_CONTAINER (frame), image);
......
......@@ -108,13 +108,12 @@ apply_callback (GtkWidget *widget)
static gboolean
progress_timeout (GtkWidget *assistant)
{
GtkWidget *page, *progress;
GtkWidget *progress;
gint current_page;
gdouble value;
current_page = gtk_assistant_get_current_page (GTK_ASSISTANT (assistant));
page = gtk_assistant_get_nth_page (GTK_ASSISTANT (assistant), current_page);
progress = gtk_bin_get_child (GTK_BIN (page));
progress = gtk_assistant_get_nth_page (GTK_ASSISTANT (assistant), current_page);
value = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress));
value += 0.1;
......@@ -122,7 +121,7 @@ progress_timeout (GtkWidget *assistant)
if (value >= 1.0)
{
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE);
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), progress, TRUE);
return FALSE;
}
......@@ -136,11 +135,8 @@ prepare_callback (GtkWidget *widget, GtkWidget *page)
g_print ("prepare: %s\n", gtk_label_get_text (GTK_LABEL (page)));
else if (gtk_assistant_get_page_type (GTK_ASSISTANT (widget), page) == GTK_ASSISTANT_PAGE_PROGRESS)
{
GtkWidget *progress;
progress = gtk_bin_get_child (GTK_BIN (page));
gtk_assistant_set_page_complete (GTK_ASSISTANT (widget), page, FALSE);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 0.0);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (page), 0.0);
gdk_threads_add_timeout (300, (GSourceFunc) progress_timeout, widget);
}
else
......@@ -293,8 +289,11 @@ create_generous_assistant (GtkWidget *widget)
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_CONFIRM);
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE);
page = gtk_alignment_new (0.5, 0.5, 0.9, 0.0);
gtk_container_add (GTK_CONTAINER (page), gtk_progress_bar_new ());
page = gtk_progress_bar_new ();
gtk_widget_set_halign (page, GTK_ALIGN_FILL);
gtk_widget_set_valign (page, GTK_ALIGN_CENTER);
gtk_widget_set_margin_start (page, 20);
gtk_widget_set_margin_end (page, 20);
gtk_widget_show_all (page);
gtk_assistant_append_page (GTK_ASSISTANT (assistant), page);
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Progress");
......
......@@ -333,18 +333,23 @@ calendar_toggle_details (GtkWidget *widget,
static GtkWidget*
create_expander (const char *caption,
GtkWidget *child,
gdouble xscale,
gdouble yscale)
GtkAlign halign,
GtkAlign valign)
{
GtkWidget *expander = gtk_expander_new ("");
GtkWidget *label = gtk_expander_get_label_widget (GTK_EXPANDER (expander));
GtkWidget *align = gtk_alignment_new (0, 0, xscale, yscale);
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 0, 18, 0);
g_object_set (child,
"margin-top", 6,
"margin-bottom", 0,
"margin-start", 18,
"margin-end", 0,
"halign", halign,
"valign", valign,
NULL);
gtk_label_set_markup (GTK_LABEL (label), caption);
gtk_container_add (GTK_CONTAINER (expander), align);
gtk_container_add (GTK_CONTAINER (align), child);
gtk_container_add (GTK_CONTAINER (expander), child);
return expander;
}
......@@ -352,19 +357,24 @@ create_expander (const char *caption,
static GtkWidget*
create_frame (const char *caption,
GtkWidget *child,
gdouble xscale,
gdouble yscale)
GtkAlign halign,
GtkAlign valign)
{
GtkWidget *frame = gtk_frame_new ("");
GtkWidget *label = gtk_frame_get_label_widget (GTK_FRAME (frame));
GtkWidget *align = gtk_alignment_new (0, 0, xscale, yscale);
g_object_set (child,
"margin-top", 6,
"margin-bottom", 0,
"margin-start", 18,
"margin-end", 0,
"halign", halign,
"valign", valign,
NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 0, 18, 0);
gtk_label_set_markup (GTK_LABEL (label), caption);
gtk_container_add (GTK_CONTAINER (frame), align);
gtk_container_add (GTK_CONTAINER (align), child);
gtk_container_add (GTK_CONTAINER (frame), child);
return frame;
}
......@@ -392,7 +402,7 @@ create_calendar(void)
GtkWidget *window, *hpaned, *vbox, *rpane, *hbox;
GtkWidget *calendar, *toggle, *scroller, *button;
GtkWidget *frame, *label, *bbox, *align, *details;
GtkWidget *frame, *label, *bbox, *details;
GtkSizeGroup *size;
GtkStyleContext *context;
......@@ -436,7 +446,7 @@ create_calendar(void)
calendar = gtk_calendar_new ();
calendar_data.calendar_widget = calendar;
frame = create_frame ("<b>Calendar</b>", calendar, 0, 0);
frame = create_frame ("<b>Calendar</b>", calendar, GTK_ALIGN_CENTER, GTK_ALIGN_CENTER);
gtk_paned_pack1 (GTK_PANED (hpaned), frame, TRUE, FALSE);
calendar_data.window = calendar;
......@@ -471,7 +481,7 @@ create_calendar(void)
/* Build the right font-button */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
frame = create_frame ("<b>Options</b>", vbox, 1, 0);
frame = create_frame ("<b>Options</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);
size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
......@@ -543,7 +553,7 @@ create_calendar(void)
/* Build the right details frame */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
frame = create_frame ("<b>Details</b>", vbox, 1, 1);
frame = create_frame ("<b>Details</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_FILL);
gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);
details = gtk_text_view_new();
......@@ -565,9 +575,9 @@ create_calendar(void)
gtk_box_pack_start (GTK_BOX (vbox), scroller, FALSE, TRUE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), hbox);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, TRUE, 0);
gtk_widget_set_halign (hbox, GTK_ALIGN_START);
gtk_widget_set_valign (hbox, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
button = gtk_button_new_with_mnemonic ("Demonstrate _Details");
......@@ -596,7 +606,7 @@ create_calendar(void)
/* Build the Right frame with the flags in */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
frame = create_expander ("<b>Flags</b>", vbox, 1, 0);
frame = create_expander ("<b>Flags</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);
for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
......@@ -618,7 +628,7 @@ create_calendar(void)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
frame = create_frame ("<b>Signal Events</b>", vbox, 1, 0);
frame = create_frame ("<b>Signal Events</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
......
......@@ -123,7 +123,7 @@ int
main (int argc, char *argv[])
{
GtkWidget *window, *vbox, *label;
GtkWidget *combo, *scale, *align, *ebox;
GtkWidget *combo, *scale, *ebox;
gtk_init (&argc, &argv);
......@@ -146,12 +146,12 @@ main (int argc, char *argv[])
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "END");
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), label);
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
ebox = gtk_event_box_new ();
gtk_widget_set_app_paintable (ebox, TRUE);
gtk_container_add (GTK_CONTAINER (ebox), align);
gtk_container_add (GTK_CONTAINER (ebox), label);
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, TRUE, 0);
......
......@@ -44,7 +44,6 @@ create_box_window (void)
GtkWidget *window;
GtkWidget *box1, *box2, *box3;
GtkWidget *toggle;
GtkWidget *alignment;
GtkWidget *colorbox;
GdkRGBA red, blue;
......@@ -88,33 +87,27 @@ create_box_window (void)
colorbox = gtk_event_box_new ();
gtk_widget_override_background_color (colorbox, 0, &red);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("H Expand");
gtk_widget_set_halign (toggle, GTK_ALIGN_CENTER);
gtk_widget_set_valign (toggle, GTK_ALIGN_CENTER);
g_object_set (toggle, "margin", 5, NULL);
g_signal_connect (G_OBJECT (toggle), "toggled",
G_CALLBACK (on_toggle_hexpand), NULL);
gtk_container_add (GTK_CONTAINER (alignment), toggle);
gtk_container_add (GTK_CONTAINER (colorbox), toggle);
gtk_box_pack_start (GTK_BOX (box3),
colorbox,
FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box3), colorbox, FALSE, TRUE, 0);
colorbox = gtk_event_box_new ();
gtk_widget_override_background_color (colorbox, 0, &blue);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("V Expand");
gtk_widget_set_halign (toggle, GTK_ALIGN_CENTER);
gtk_widget_set_valign (toggle, GTK_ALIGN_CENTER);
g_object_set (toggle, "margin", 5, NULL);
g_signal_connect (G_OBJECT (toggle), "toggled",
G_CALLBACK (on_toggle_vexpand), NULL);
gtk_container_add (GTK_CONTAINER (alignment), toggle);
gtk_box_pack_start (GTK_BOX (box3),
colorbox,
FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (colorbox), toggle);
gtk_box_pack_start (GTK_BOX (box3), colorbox, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show_all (window);
......@@ -126,7 +119,6 @@ create_grid_window (void)
GtkWidget *window;
GtkWidget *grid;
GtkWidget *toggle;
GtkWidget *alignment;
GtkWidget *colorbox;
GdkRGBA red, blue;
......@@ -135,18 +127,10 @@ create_grid_window (void)
grid = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (grid),
gtk_label_new ("Top"),
1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
gtk_label_new ("Bottom"),
1, 3, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
gtk_label_new ("Left"),
0, 1, 1, 2);
gtk_grid_attach (GTK_GRID (grid),
gtk_label_new ("Right"),
2, 1, 1, 2);
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Top"), 1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Bottom"), 1, 3, 1, 1);
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Left"), 0, 1, 1, 2);
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Right"), 2, 1, 1, 2);
gdk_rgba_parse (&red, "red");
gdk_rgba_parse (&blue, "blue");
......@@ -154,34 +138,28 @@ create_grid_window (void)
colorbox = gtk_event_box_new ();
gtk_widget_override_background_color (colorbox, GTK_STATE_NORMAL, &red);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("H Expand");
gtk_widget_set_halign (toggle, GTK_ALIGN_CENTER);
gtk_widget_set_valign (toggle, GTK_ALIGN_CENTER);
g_object_set (toggle, "margin", 5, NULL);
g_signal_connect (G_OBJECT (toggle), "toggled",
G_CALLBACK (on_toggle_hexpand), NULL);
gtk_container_add (GTK_CONTAINER (alignment), toggle);
gtk_container_add (GTK_CONTAINER (colorbox), toggle);
gtk_grid_attach (GTK_GRID (grid),
colorbox,
1, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), colorbox, 1, 1, 1, 1);
colorbox = gtk_event_box_new ();
gtk_widget_override_background_color (colorbox, 0, &blue);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("V Expand");
gtk_widget_set_halign (toggle, GTK_ALIGN_CENTER);
gtk_widget_set_valign (toggle, GTK_ALIGN_CENTER);
g_object_set (toggle, "margin", 5, NULL);
g_signal_connect (G_OBJECT (toggle), "toggled",
G_CALLBACK (on_toggle_vexpand), NULL);
gtk_container_add (GTK_CONTAINER (alignment), toggle);
gtk_container_add (GTK_CONTAINER (colorbox), toggle);
gtk_grid_attach (GTK_GRID (grid),
colorbox,
1, 2, 1, 1);
gtk_grid_attach (GTK_GRID (grid), colorbox, 1, 2, 1, 1);
gtk_container_add (GTK_CONTAINER (window), grid);
gtk_widget_show_all (window);
......
......@@ -223,7 +223,7 @@ int
main (int argc,
char *argv[])
{
GtkWidget *win, *vbox, *frame, *alignment, *group_box;
GtkWidget *win, *vbox, *frame, *group_box;
GtkWidget *hbox, *label, *chooser, *button;
GtkSizeGroup *label_group;
GOptionContext *context;
......@@ -258,14 +258,14 @@ main (int argc,
gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
gtk_widget_set_valign (frame, GTK_ALIGN_FILL);
g_object_set (frame, "margin-top", 6, "margin-start", 12, NULL);
label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
group_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (alignment), group_box);
gtk_container_add (GTK_CONTAINER (frame), group_box);
/* OPEN */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
......
......@@ -63,7 +63,6 @@ main(int argc, char **argv)
{
GtkWidget *window, *vbox;
GtkWidget *combo_box;
GtkWidget *alignment;
GtkWidget *hbox, *label, *hscale;
GtkAdjustment *adjustment;
GtkRequisition scratch_requisition;
......@@ -110,8 +109,8 @@ main(int argc, char **argv)
G_CALLBACK (set_interp_type),
NULL);
alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
gtk_widget_set_halign (combo_box, GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (vbox), combo_box, FALSE, FALSE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
......@@ -127,7 +126,6 @@ main(int argc, char **argv)
gtk_scale_set_digits (GTK_SCALE (hscale), 0);
gtk_box_pack_start (GTK_BOX (hbox), hscale, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (alignment), combo_box);
gtk_widget_show_all (vbox);
/* Compute the size without the drawing area, so we know how big to make the default size */
......
......@@ -43,7 +43,6 @@ int main (int argc, char *argv[])
GtkWidget *label;
GtkWidget *check;
GtkWidget *combo;
GtkWidget *align;
gtk_init (&argc, &argv);
......@@ -57,14 +56,22 @@ int main (int argc, char *argv[])
overlay = gtk_overlay_new ();
gtk_container_add (GTK_CONTAINER (win), overlay);
align = gtk_alignment_new (0.5, 0.5, 0, 0);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
gtk_widget_set_valign (grid, GTK_ALIGN_FILL);
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
gtk_container_add (GTK_CONTAINER (overlay), align);
gtk_container_add (GTK_CONTAINER (align), grid);
gtk_container_add (GTK_CONTAINER (overlay), grid);
label = gtk_label_new ("");
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
label = gtk_label_new ("");
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1);
builder = gtk_builder_new_from_file ("popover.ui");
model = (GMenuModel *)gtk_builder_get_object (builder, "menu");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment