]> Pileus Git - ~andy/gtk/blobdiff - tests/testexpand.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testexpand.c
index e7f0d99cd595522ccdcaf39bc48a45b201eaca03..57e5d355db6b5d357c629c1507a05800181c3d83 100644 (file)
@@ -15,9 +15,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <gtk/gtk.h>
@@ -26,11 +24,6 @@ static void
 on_toggle_hexpand (GtkToggleButton *toggle,
                    void            *data)
 {
-  GtkWidget *parent;
-
-  /* get the event box with color set on it */
-  parent = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (toggle)));
-
   g_object_set (toggle,
                 "hexpand", gtk_toggle_button_get_active (toggle),
                 NULL);
@@ -40,11 +33,6 @@ static void
 on_toggle_vexpand (GtkToggleButton *toggle,
                    void            *data)
 {
-  GtkWidget *parent;
-
-  /* get the event box with color set on it */
-  parent = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (toggle)));
-
   g_object_set (toggle,
                 "vexpand", gtk_toggle_button_get_active (toggle),
                 NULL);
@@ -133,36 +121,32 @@ create_box_window (void)
 }
 
 static void
-create_table_window (void)
+create_grid_window (void)
 {
   GtkWidget *window;
-  GtkWidget *table;
+  GtkWidget *grid;
   GtkWidget *toggle;
   GtkWidget *alignment;
   GtkWidget *colorbox;
   GdkRGBA red, blue;
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_title (GTK_WINDOW (window), "Table");
-
-  table = gtk_table_new (4, 3, FALSE);
-
-  gtk_table_attach (GTK_TABLE (table),
-                    gtk_label_new ("Top"),
-                    1, 2, 0, 1,
-                    GTK_FILL, GTK_FILL, 0, 0);
-  gtk_table_attach (GTK_TABLE (table),
-                    gtk_label_new ("Bottom"),
-                    1, 2, 3, 4,
-                    GTK_FILL, GTK_FILL, 0, 0);
-  gtk_table_attach (GTK_TABLE (table),
-                    gtk_label_new ("Left"),
-                    0, 1, 1, 3,
-                    GTK_FILL, GTK_FILL, 0, 0);
-  gtk_table_attach (GTK_TABLE (table),
-                    gtk_label_new ("Right"),
-                    2, 3, 1, 3,
-                    GTK_FILL, GTK_FILL, 0, 0);
+  gtk_window_set_title (GTK_WINDOW (window), "Grid");
+
+  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);
 
   gdk_rgba_parse (&red, "red");
   gdk_rgba_parse (&blue, "blue");
@@ -179,10 +163,9 @@ create_table_window (void)
                     G_CALLBACK (on_toggle_hexpand), NULL);
   gtk_container_add (GTK_CONTAINER (alignment), toggle);
 
-  gtk_table_attach (GTK_TABLE (table),
-                    colorbox,
-                    1, 2, 1, 2,
-                    GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid),
+                   colorbox,
+                   1, 1, 1, 1);
 
   colorbox = gtk_event_box_new ();
   gtk_widget_override_background_color (colorbox, 0, &blue);
@@ -196,12 +179,11 @@ create_table_window (void)
                     G_CALLBACK (on_toggle_vexpand), NULL);
   gtk_container_add (GTK_CONTAINER (alignment), toggle);
 
-  gtk_table_attach (GTK_TABLE (table),
-                    colorbox,
-                    1, 2, 2, 3,
-                    GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid),
+                   colorbox,
+                   1, 2, 1, 1);
 
-  gtk_container_add (GTK_CONTAINER (window), table);
+  gtk_container_add (GTK_CONTAINER (window), grid);
   gtk_widget_show_all (window);
 }
 
@@ -210,8 +192,11 @@ main (int argc, char *argv[])
 {
   gtk_init (&argc, &argv);
 
+  if (g_getenv ("RTL"))
+    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+
   create_box_window ();
-  create_table_window ();
+  create_grid_window ();
 
   gtk_main ();