OK, I resolved my problem to set "halign" and "valign" to GTK_ALIGN_START.

(04/02/14 19:40), Takao Fujiwara-san wrote:
> I'd like to port GtkTable to GtkGrid but my cells show big widths.
> I have no problem with GtkTable.
> The following is the test code.
> Could you help me to set no expanded cells with homogeneous in GtkGrid?
> 
>      scrolled = gtk_scrolled_window_new (NULL, NULL);
>      gtk_widget_set_size_request (scrolled, 300, 150);
>      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
>                                      GTK_POLICY_NEVER,
>                                      GTK_POLICY_ALWAYS);
>      gtk_box_pack_start (GTK_BOX (priv->content_box), scrolled, FALSE, FALSE, 
> 0);
> 
>      viewport = gtk_viewport_new (NULL, NULL);
>      gtk_container_add (GTK_CONTAINER (scrolled), viewport);
> 
> #if GTK_CHECK_VERSION(3, 10, 0)
>      table = gtk_grid_new ();
>      gtk_grid_set_row_spacing (GTK_GRID (table), 0);
>      gtk_grid_set_column_spacing (GTK_GRID (table), 0);
>      gtk_grid_set_row_homogeneous (GTK_GRID (table), TRUE);
>      gtk_grid_set_column_homogeneous (GTK_GRID (table), TRUE);
>      gtk_container_add (GTK_CONTAINER (viewport), table);
> 
>      for (i = 0; i < 12; i++) {
>          gchar *text = g_strdup_printf ("%d", i + 1);
> 
>          row = i / 4;
>          col = i % 4;
>          button = gtk_button_new_with_label (text);
>          gtk_grid_attach (GTK_GRID (table), button,
>                            col, row, 1, 1);
>          g_free (text);
>      }
> #else
>      table = gtk_table_new (row, col, TRUE);
>      gtk_table_set_row_spacings (GTK_TABLE (table), 0);
>      gtk_table_set_col_spacings (GTK_TABLE (table), 0);
>      gtk_container_add (GTK_CONTAINER (viewport), table);
> 
>      for (i = 0; i < 12; i++) {
>          gchar *text = g_strdup_printf ("%d", i + 1);
>          GtkStyleContext *context;
> 
>          row = i / 4;
>          col = i % 4;
>          button = gtk_button_new_with_label (text);
>          gtk_table_attach (GTK_TABLE (table), button,
>                            col, col + 1, row, row + 1,
>                            GTK_FILL, GTK_FILL, 0, 0);
>      }
> #endif
> 
> 

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to