summaryrefslogtreecommitdiff
path: root/tests/testentryicons.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-09-27 22:35:49 +0200
committerBenjamin Otte <otte@redhat.com>2011-09-28 05:29:50 +0200
commit4866b04dcee2a0636592750ea3214a4f57cbac69 (patch)
treec7d73ad5917fc591c3d0678baeafc9554f8e3487 /tests/testentryicons.c
parent32c21ea1b18a8b470cf486d65f2daae2b41085eb (diff)
downloadgtk+-4866b04dcee2a0636592750ea3214a4f57cbac69.tar.gz
tests: Convert testentryicons example from GtkTable to GtkGrid
Diffstat (limited to 'tests/testentryicons.c')
-rw-r--r--tests/testentryicons.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/tests/testentryicons.c b/tests/testentryicons.c
index 781a6c17f6..4c7f4bb952 100644
--- a/tests/testentryicons.c
+++ b/tests/testentryicons.c
@@ -89,7 +89,7 @@ int
main (int argc, char **argv)
{
GtkWidget *window;
- GtkWidget *table;
+ GtkWidget *grid;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *button;
@@ -105,22 +105,21 @@ main (int argc, char **argv)
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
- table = gtk_table_new (2, 4, FALSE);
- gtk_container_add (GTK_CONTAINER (window), table);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+ grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (window), grid);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
/*
* Open File - Sets the icon using a GIcon
*/
label = gtk_label_new ("Open File:");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_set_hexpand (entry, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), entry, 1, 0, 1, 1);
icon = g_themed_icon_new ("folder");
g_themed_icon_append_name (G_THEMED_ICON (icon), "folder");
@@ -137,8 +136,7 @@ main (int argc, char **argv)
"Open a file");
button = gtk_button_new_with_label ("Properties");
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 0, 1, 1);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
@@ -147,13 +145,12 @@ main (int argc, char **argv)
* Save File - sets the icon using a stock id.
*/
label = gtk_label_new ("Save File:");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_set_hexpand (entry, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), entry, 1, 1, 1, 1);
gtk_entry_set_text (GTK_ENTRY (entry), "ā€¸Right-to-left");
gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
@@ -175,8 +172,7 @@ main (int argc, char **argv)
gtk_target_list_unref (tlist);
button = gtk_button_new_with_label ("Properties");
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 1, 1, 1);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
@@ -184,13 +180,12 @@ main (int argc, char **argv)
* Search - Uses a helper function
*/
label = gtk_label_new ("Search:");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_set_hexpand (entry, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), entry, 1, 2, 1, 1);
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
@@ -203,8 +198,7 @@ main (int argc, char **argv)
g_signal_connect (entry, "icon-press", G_CALLBACK (clear_pressed), NULL);
button = gtk_button_new_with_label ("Properties");
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 2, 1, 1);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
@@ -212,13 +206,12 @@ main (int argc, char **argv)
* Password - Sets the icon using a stock id
*/
label = gtk_label_new ("Password:");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 3, 4,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_set_hexpand (entry, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), entry, 1, 3, 1, 1);
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
@@ -230,24 +223,21 @@ main (int argc, char **argv)
FALSE);
button = gtk_button_new_with_label ("Properties");
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 3, 1, 1);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
/* Name - Does not set any icons. */
label = gtk_label_new ("Name:");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 4, 5,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_set_hexpand (entry, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), entry, 1, 4, 1, 1);
button = gtk_button_new_with_label ("Properties");
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 4, 1, 1);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);