[gtk+/multitouch: 15/124] tests: Update testkineticscrolling to use GtkGrid
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 15/124] tests: Update testkineticscrolling to use GtkGrid
- Date: Tue, 24 Jan 2012 11:26:37 +0000 (UTC)
commit f7722c3843ec6a3af71a6d41fc85f92414e061e6
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 24 11:25:45 2011 +0200
tests: Update testkineticscrolling to use GtkGrid
tests/testkineticscrolling.c | 45 ++++++++++++++++++++++-------------------
1 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/tests/testkineticscrolling.c b/tests/testkineticscrolling.c
index 6410ce5..1b093bf 100644
--- a/tests/testkineticscrolling.c
+++ b/tests/testkineticscrolling.c
@@ -19,9 +19,9 @@ on_button_clicked (GtkWidget *widget, gpointer data)
static void
kinetic_scrolling (void)
{
- GtkWidget *window, *swindow, *table;
+ GtkWidget *window, *swindow, *grid;
GtkWidget *label;
- GtkWidget *vbox, *button;
+ GtkWidget *button_grid, *button;
GtkWidget *treeview;
GtkCellRenderer *renderer;
GtkListStore *store;
@@ -30,33 +30,35 @@ kinetic_scrolling (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
g_signal_connect (window, "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
- table = gtk_table_new (2, 3, FALSE);
+ grid = gtk_grid_new ();
label = gtk_label_new ("Non scrollable widget using viewport");
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
+ gtk_widget_set_hexpand (label, TRUE);
gtk_widget_show (label);
label = gtk_label_new ("Scrollable widget: TreeView");
- gtk_table_attach (GTK_TABLE (table), label,
- 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
+ gtk_widget_set_hexpand (label, TRUE);
gtk_widget_show (label);
label = gtk_label_new ("Scrollable widget: TextView");
- gtk_table_attach (GTK_TABLE (table), label,
- 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), label, 2, 0, 1, 1);
+ gtk_widget_set_hexpand (label, TRUE);
gtk_widget_show (label);
- vbox = gtk_vbox_new (FALSE, 1);
+ button_grid = gtk_grid_new ();
for (i = 0; i < 80; i++)
{
gchar *label = g_strdup_printf ("Button number %d", i);
button = gtk_button_new_with_label (label);
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+ gtk_grid_attach (GTK_GRID (button_grid), button, 0, i, 1, 1);
+ gtk_widget_set_hexpand (button, TRUE);
gtk_widget_show (button);
g_signal_connect (button, "clicked",
G_CALLBACK (on_button_clicked),
@@ -66,11 +68,10 @@ kinetic_scrolling (void)
swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_kinetic_scrolling (GTK_SCROLLED_WINDOW (swindow), TRUE);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), vbox);
- gtk_widget_show (vbox);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), button_grid);
+ gtk_widget_show (button_grid);
- gtk_table_attach_defaults (GTK_TABLE (table), swindow,
- 0, 1, 1, 2);
+ gtk_grid_attach (GTK_GRID (grid), swindow, 0, 1, 1, 1);
gtk_widget_show (swindow);
treeview = gtk_tree_view_new ();
@@ -109,8 +110,9 @@ kinetic_scrolling (void)
gtk_container_add (GTK_CONTAINER (swindow), treeview);
gtk_widget_show (treeview);
- gtk_table_attach_defaults (GTK_TABLE (table), swindow,
- 1, 2, 1, 2);
+ gtk_grid_attach (GTK_GRID (grid), swindow, 1, 1, 1, 1);
+ gtk_widget_set_hexpand (swindow, TRUE);
+ gtk_widget_set_vexpand (swindow, TRUE);
gtk_widget_show (swindow);
textview = gtk_text_view_new ();
@@ -119,12 +121,13 @@ kinetic_scrolling (void)
gtk_container_add (GTK_CONTAINER (swindow), textview);
gtk_widget_show (textview);
- gtk_table_attach_defaults (GTK_TABLE (table), swindow,
- 2, 3, 1, 2);
+ gtk_grid_attach (GTK_GRID (grid), swindow, 2, 1, 1, 1);
+ gtk_widget_set_hexpand (swindow, TRUE);
+ gtk_widget_set_vexpand (swindow, TRUE);
gtk_widget_show (swindow);
- gtk_container_add (GTK_CONTAINER (window), table);
- gtk_widget_show (table);
+ gtk_container_add (GTK_CONTAINER (window), grid);
+ gtk_widget_show (grid);
gtk_widget_show (window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]