Aligning ToolItem To Right in Toolbar

2013-08-26 Thread Joshua Strobl
Hello folks,
I'm currently diving into developing Gtk applications with Vala (which I'm just 
starting to learn as well). At this moment in time, I have created a couple 
ToolItem(s) that are properly inserted into my Toolbar(). This Toolbar() is 
within a Grid() and set to expand horizontally (set_hexpand(true)).
As my Pastebin (link below) shows, the second (exampleGlobalMenuContainer) 
ToolItem is left aligned, which is completely understandable as it hasn't been 
set to do otherwise.

LINK: http://pastebin.com/M2nnuynk
My question is, how on earth do I set it (the exampleGlobalMenuContainer 
ToolItem) to horizontally align to the right? I looked into using set_halign to 
GTK_ALIGN_END and was contemplating using margin-left (although I'd have to 
have an event listener that'd evaluate the window width and change the 
margin-left otherwise).
What would the appropriate method be to align the ToolItem? Have a second grid 
within the ToolBar and use columns?
Thanks a bunch!
- Joshua Strobl   
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Aligning ToolItem To Right in Toolbar

2013-08-27 Thread Colomban Wendling
Le 27/08/2013 08:07, Joshua Strobl a écrit :
> [...] and set to expand horizontally (set_hexpand(true)).

Tip: you could use the Vala-style property setter, toolbar.hexpand=true

> As my Pastebin (link below) shows, the second
> (exampleGlobalMenuContainer) ToolItem is left aligned, which is
> completely understandable as it hasn't been set to do otherwise.
> 
> LINK: http://pastebin.com/M2nnuynk My question is, how on earth do I 
> set it (the exampleGlobalMenuContainer ToolItem) to horizontally 
> align to the right? I looked into using set_halign to GTK_ALIGN_END 
> and was contemplating using margin-left (although I'd have to have
> an event listener that'd evaluate the window width and change the 
> margin-left otherwise). What would the appropriate method be to
> align the ToolItem?

AFAIK the correct solution is using a separator item set to be invisible
and to expand.  I didn't do Vala for at least a year so excuse the maybe
crappy style, but:

var sep = new Gtk.SeparatorToolItem();
sep.draw = false;
toolbar.add(sep);
toolbar.child_set(sep, expand:true);

This way you have the items after the separator pushed to the right[1]
-- and as a bonus you see a nice separator in the overflowing items menu
if the toolbar has to show it.

https://developer.gnome.org/gtk3/stable/GtkSeparatorToolItem.html#GtkSeparatorToolItem.description
https://developer.gnome.org/gtk3/stable/GtkToolbar.html#GtkToolbar--c-expand


Regards,
Colomban


[1] or to the left if locale is RTL
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Aligning ToolItem To Right in Toolbar

2013-08-27 Thread Joshua Strobl
On 08/27/2013 02:18 AM, Colomban Wendling wrote:
> Le 27/08/2013 08:07, Joshua Strobl a écrit :
>> [...] and set to expand horizontally (set_hexpand(true)).
> Tip: you could use the Vala-style property setter, toolbar.hexpand=true

I think at the time I was getting compile-time errors so I thought it was
an issue with my syntax. I much prefer to "Vala-style" property setting as
compared to using a set_* function for everything. Much cleaner. Thanks
for the suggestion, I'll certainly make use of it!

> AFAIK the correct solution is using a separator item set to be invisible
> and to expand.  I didn't do Vala for at least a year so excuse the maybe
> crappy style, but:
>
>   var sep = new Gtk.SeparatorToolItem();
>   sep.draw = false;
>   toolbar.add(sep);
>   toolbar.child_set(sep, expand:true);
>
> This way you have the items after the separator pushed to the right[1]
> -- and as a bonus you see a nice separator in the overflowing items menu
> if the toolbar has to show it.
>
> https://developer.gnome.org/gtk3/stable/GtkSeparatorToolItem.html#GtkSeparatorToolItem.description
> https://developer.gnome.org/gtk3/stable/GtkToolbar.html#GtkToolbar--c-expand
>

Thanks for linking me to it. At the time I was using the offline docs I
downloaded (and dealing with slow McDonalds wifi when I was away from
the house) and it isn't so parsable / digestible that way.

> Regards,
> Colomban

Thank you Colomban and Florian for your assistance =) It was appreciated.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list