Skip to content

Instantly share code, notes, and snippets.

@ptomato
Created September 11, 2013 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptomato/6531362 to your computer and use it in GitHub Desktop.
Save ptomato/6531362 to your computer and use it in GitHub Desktop.
const Gtk = imports.gi.Gtk;
Gtk.init(null);
let w = new Gtk.Window({
default_width: 800,
default_height: 600
});
let g = new Gtk.Grid();
let frame = new Gtk.Frame({ expand: true });
let label = new Gtk.Label({
// Uncomment this to improve the behavior, but not fix it entirely; in
// passing, this shows that max_width_chars is not working properly either
// max_width_chars: 1,
wrap: true,
expand: true,
label: 'AAAAA AAAAA AAAAA AAAAA AAAA AAAAA AAAAA AAAAA'
});
let frame2 = new Gtk.Frame({ expand: true });
g.add(frame);
g.add(label);
// Add frame2 instead of label, to see the expected behavior of two "expand"
// widgets in a grid: both are the same size
w.add(g);
// The problem can actually be fixed using a Gtk.SizeGroup
// let sg = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
// sg.add_widget(frame);
// sg.add_widget(label);
w.show_all();
w.connect('destroy', Gtk.main_quit);
Gtk.main();
@ffarfan
Copy link

ffarfan commented Sep 12, 2013

This looks awesomely minimal!!

Reading about GtkSizeGroup now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment