Expand a Widget Gtk2 and Gtk3
Hey guys,
I've been struggling with getting my designed UI into code and I need some help.
I have a Gtk::Toolbar with a few buttons a space widget and then a few more buttons. The goal is to set h_expand on the space widget in Gtk2 and push the two sets of buttons to either side. The code for Gtk3 is fairly strait forward but C++ isn't letting me call child_set_property and set_expand doesn't do anything; so I'm stuck.
Code: http://paste.ubuntu.com/5655252/
P.S. I'm used to using glade, do we not use it because it's a bad dep or because inkscape was made before glade existed?
Thanks for your help.
Best Regards, Martin Owens
On May 11, 2013, at 10:22 AM, Martin Owens wrote:
Hey guys,
I've been struggling with getting my designed UI into code and I need some help.
I have a Gtk::Toolbar with a few buttons a space widget and then a few more buttons. The goal is to set h_expand on the space widget in Gtk2 and push the two sets of buttons to either side. The code for Gtk3 is fairly strait forward but C++ isn't letting me call child_set_property and set_expand doesn't do anything; so I'm stuck.
Code: http://paste.ubuntu.com/5655252/
P.S. I'm used to using glade, do we not use it because it's a bad dep or because inkscape was made before glade existed?
Generally we avoided glade because it suffered from the general UI "draw app" issues of generating poor code and also of being able to get one 80% of the way quickly but hard to finish the final 20%.
However, I think most important is that the glade markup is still way to focused on the physical layout of widgets and not with the logical. In that regard it is very similar to XUL and others, and not as generally useful.
On Sat, 2013-05-11 at 12:48 -0700, Jon Cruz wrote:
and not as generally useful.
I think my code is broken when using non-references with the class context changer GTK_CONTAINER and GTK_WIDGET. From other code these work with references right? Should I be using references for widgets? The code isn't always consistent and I'm not even sure why there is a difference in an OO language.
Is there a good (and short) explanation of what these things are actually doing? Plus points for diagrams. Because I need help badly and I can't seem to find any between mailing lists, irc and the web.
Regards, Martin Owens
On May 11, 2013, at 11:37 PM, Martin Owens wrote:
On Sat, 2013-05-11 at 12:48 -0700, Jon Cruz wrote:
and not as generally useful.
I think my code is broken when using non-references with the class context changer GTK_CONTAINER and GTK_WIDGET. From other code these work with references right? Should I be using references for widgets? The code isn't always consistent and I'm not even sure why there is a difference in an OO language.
Is there a good (and short) explanation of what these things are actually doing? Plus points for diagrams. Because I need help badly and I can't seem to find any between mailing lists, irc and the web.
GTK_CONTAINER() and GTK_WIDGET() are C macros that work with pointers. Aside from casting the pointer to a different type they also check the gobject runtime structures and warn if the pointer does not match the target type. In general this is all legacy code.
The approach with C++ and gtkmm is to leverage C++ inheritance. Since Gtk::Container is a subclass of Gtk::Widget, one can simple use a reference or pointer to a Gtk::Container anywhere one for Gtk::Widget is called for, and without any need for casts of any kind (C or C++).
Gtkmm objects can hold members directly, but for widget subclasses one can create them via new, feed the pointer through Gtk::manage() and place it in a parent widget. That transfers ownership of the instance.
If you can send me some specific examples, we can get some info on the wiki to address specific points.
The goal is to set h_expand on the space widget in Gtk2
and push the two sets of buttons to either side.
If you are looking to left and right align some buttons you can use a Gtk::ButtonBox/HButtonBox (like LivePathEffects does) // button1 will be right aligned, button2 left aligned set_layout (Gtk::BUTTONBOX_END); add( button1 ); add( button2 ); set_child_secondary( button2 , true);
On Sat, 2013-05-11 at 17:23 -0700, John Smith wrote:
If you are looking to left and right align some buttons you can use a Gtk::ButtonBox/HButtonBox (like LivePathEffects does)
I'm using the toolbar buttons because I wanted the easiest way to do zero border icon buttons. Does ButtonBox do multiple buttons on both sides? [X] [X] .... [x] [x] [x]
Martin,
participants (3)
-
John Smith
-
Jon Cruz
-
Martin Owens