Re: GtkGrid children and GTK_ALIGN_END



On 12 October 2017 at 13:10, Daniel Boles <dboles src gmail com> wrote:
By my understanding, the explanation is this:
  • the Entry is right-aligned within its cell
  • but then the Grid is set to align fill and expand, so it expands empty space beyond the Entry and the cell it's in

Assuming I understand this guide right, then it does kinda make sense to me.

https://developer.gnome.org/gtk3/stable/ch30s02.html

I found that hexpanding the Entry too got around this, but it may not be exactly what you want.


since a test case is always useful...

#include <gtk/gtk.h>

int
main (int    argc,
      char **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *grid = gtk_grid_new ();
  gtk_widget_set_hexpand (grid, TRUE);
  gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
  gtk_orientable_set_orientation ((GtkOrientable *)grid, GTK_ORIENTATION_HORIZONTAL);

  GtkWidget *entry = gtk_entry_new ();
  gtk_widget_set_halign (entry, GTK_ALIGN_END);
  gtk_container_add ((GtkContainer *)grid, entry);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_add ((GtkContainer *)window, grid);
  gtk_widget_show_all (window);

  gtk_main ();
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]