Forum: Ruby-Gnome 2 hbox alignment with pack_start

Ff312ec21b0fd1d07c8708e29df7d242?d=identicon&s=25 Ebru Akagunduz (ebruakagunduz)
on 2014-01-22 22:46
Hi, I tried to make an interface like this.

http://i.imgur.com/hwfq1n6.png

But my interface:

http://i.imgur.com/F6OQ1nX.png

I want to adjoin toolbar and gtk.entry line. How can I do this? And
source code:

 win = Gtk::Window.new
    swin =  Gtk::ScrolledWindow.new
    swin_vpaned = Gtk::Paned.new(:horizontal)
    viewport  = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)
    @file_store = Gtk::ListStore.new(String, String, TrueClass,
Gdk::Pixbuf)
    main_vbox = Gtk::Box.new(:vertical, 2)
    toolbar_hbox = Gtk::Box.new(:horizontal, 0)
    menus = create_menubar
    create_toolbar()
    toolbar_hbox.pack_start(@toolbar, :expand => false, :fill => true,
:padding =>0)
    toolbar_hbox.pack_start(@file_path_entry, :expand => true, :fill =>
true, :padding => 0)

    main_vbox.pack_start(menus, :expand => false, :fill => false,
:padding => 2)
    main_vbox.pack_start(toolbar_hbox, :expand => true, :fill => true,
:padding => 2)
    main_vbox.pack_start(swin_vpaned, :expand => true, :fill => true,
:padding => 1)
    treeview_vbox = Gtk::Box.new(:vertical, 1)
    # devices treeview
    dev_treeview = create_devices_treeview
    treeview_vbox.pack_start(dev_treeview, :expand => false, :fill =>
false, :padding => 2)
    create_places_treeview

    treeview_vbox.pack_start(@places_treeview)
    swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
    swin_vpaned.pack2(swin, :resize => true, :shrink => false)

 win = Gtk::Window.new
    swin =  Gtk::ScrolledWindow.new
    swin_vpaned = Gtk::Paned.new(:horizontal)
    viewport  = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)
    @file_store = Gtk::ListStore.new(String, String, TrueClass,
Gdk::Pixbuf)
    main_vbox = Gtk::Box.new(:vertical, 2)
    toolbar_hbox = Gtk::Box.new(:horizontal, 0)
    menus = create_menubar
    create_toolbar()
    toolbar_hbox.pack_start(@toolbar, :expand => false, :fill => true,
:padding =>0)
    toolbar_hbox.pack_start(@file_path_entry, :expand => true, :fill =>
true, :padding => 0)

    main_vbox.pack_start(menus, :expand => false, :fill => false,
:padding => 2)
    main_vbox.pack_start(toolbar_hbox, :expand => true, :fill => true,
:padding => 2)
    main_vbox.pack_start(swin_vpaned, :expand => true, :fill => true,
:padding => 1)
    treeview_vbox = Gtk::Box.new(:vertical, 1)
    # devices treeview
    dev_treeview = create_devices_treeview
    treeview_vbox.pack_start(dev_treeview, :expand => false, :fill =>
false, :padding => 2)
    create_places_treeview

    treeview_vbox.pack_start(@places_treeview)
    swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
    swin_vpaned.pack2(swin, :resize => true, :shrink => false)


def create_toolbar
  @toolbar = Gtk::Toolbar.new
  @toolbar.set_size_request(30,30)
  # tool buttons
  @back_toolbut = Gtk::ToolButton.new(:stock_id => Gtk::Stock::GO_BACK)
  @next_toolbut = Gtk::ToolButton.new(:stock_id =>
Gtk::Stock::GO_FORWARD)
  home_toolbut = Gtk::ToolButton.new(:stock_id => Gtk::Stock::HOME)
  up_toolbut = Gtk::ToolButton.new(:stock_id => Gtk::Stock::GO_UP)

  @back_toolbut.sensitive = false
  @next_toolbut.sensitive = false
  @back_toolbut.signal_connect("clicked"){fill_store("back")}
  @next_toolbut.signal_connect("clicked"){fill_store("next")}
  @toolbar.insert(@back_toolbut, 0)
  @toolbar.insert(@next_toolbut, 1)
  @toolbar.insert(up_toolbut, 2)
  @toolbar.insert(home_toolbut, 3)
#  @toolbar.set_size_request(5, 5)
end

Thanks.
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-01-23 15:29
Ebru Akagunduz wrote in post #1134048:

> I want to adjoin toolbar and gtk.entry line. How can I do this? And
> source code:

> create_toolbar()
> toolbar_hbox.pack_start(@toolbar, :expand => false, :fill => true,
> toolbar_hbox.pack_start(@file_path_entry, :expand => true, :fill => true,
> main_vbox.pack_start(menus, :expand => false, :fill => false,
> main_vbox.pack_start(toolbar_hbox, :expand => true, :fill => true
> main_vbox.pack_start(swin_vpaned, :expand => true, :fill => true,


Perhaps you should expand false on packing tollbar_hbox :
main_vbox.pack_start(toolbar_hbox, :expand => *false*, :fill => true
Ff312ec21b0fd1d07c8708e29df7d242?d=identicon&s=25 Ebru Akagunduz (ebruakagunduz)
on 2014-01-23 17:16
I tried your suggestion but still it doesn't fix.
http://i.imgur.com/hwfq1n6.png
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-01-23 18:05
Ebru Akagunduz wrote in post #1134151:

this intruction can trouble your toolbar :
@toolbar.set_size_request(30,30)


see example at :
http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk...
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-01-23 18:37
with gtk3, this must be done :

main_vbox.homogeneous=false
and
toolbar_hbox..homogeneous=false
Ff312ec21b0fd1d07c8708e29df7d242?d=identicon&s=25 Ebru Akagunduz (ebruakagunduz)
on 2014-01-23 18:47
Ebru Akagunduz wrote in post #1134151:
> I tried your suggestion but still it doesn't fix.
> http://i.imgur.com/hwfq1n6.png

So sorry, I've sent wrong screenshot, actually it is:

http://i.imgur.com/7bFUvfN.png
Ff312ec21b0fd1d07c8708e29df7d242?d=identicon&s=25 Ebru Akagunduz (ebruakagunduz)
on 2014-01-23 18:51
Regis d'Aubarede wrote in post #1134162:
> with gtk3, this must be done :
>
> main_vbox.homogeneous=false
> and
> toolbar_hbox..homogeneous=false

I set homogeneous=false but again it doesn't fix. I don't get any error.
Source code:

 win = Gtk::Window.new
    swin =  Gtk::ScrolledWindow.new
    swin_vpaned = Gtk::Paned.new(:horizontal)
    viewport  = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)
    @file_store = Gtk::ListStore.new(String, String, TrueClass,
Gdk::Pixbuf)
    main_vbox = Gtk::Box.new(:vertical, 2)
    toolbar_hbox = Gtk::Box.new(:horizontal, 0)
    menus = create_menubar
    create_toolbar()
    toolbar_hbox.pack_start(@toolbar, :expand => false, :fill => true,
:padding =>0)
    toolbar_hbox.pack_start(@file_path_entry, :expand => true, :fill =>
true, :padding => 0)

    main_vbox.pack_start(menus, :expand => false, :fill => false,
:padding => 2)
    main_vbox.pack_start(toolbar_hbox, :expand => false, :fill => true,
:padding => 2)
    main_vbox.pack_start(swin_vpaned, :expand => true, :fill => true,
:padding => 1)
    treeview_vbox = Gtk::Box.new(:vertical, 1)
    create_devices_treeview()
    treeview_vbox.pack_start(@devices_treeview, :expand => false, :fill
=> false, :padding => 2)
    create_places_treeview

    main_vbox.homogeneous=false
    toolbar_hbox.homogeneous=false
    treeview_vbox.pack_start(@places_treeview)
    swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
    swin_vpaned.pack2(swin, :resize => true, :shrink => false)


And screenshot:
http://i.imgur.com/0Zy1heT.png
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-01-23 20:01
for me, it is better : hbox (toolbar+entry) take only necessary vertical
space.
Toolbar display only an arrow, I do not know why...
What append if the entry is not packed ?
Ff312ec21b0fd1d07c8708e29df7d242?d=identicon&s=25 Ebru Akagunduz (ebruakagunduz)
on 2014-01-23 23:34
Regis d'Aubarede wrote in post #1134172:
> for me, it is better : hbox (toolbar+entry) take only necessary vertical
> space.
> Toolbar display only an arrow, I do not know why...
> What append if the entry is not packed ?

When I remove Gtk.entry it seems like this:
http://i.imgur.com/SK0AecT.png

Probably cause of hbox I think.

But I couldn't find out how can I ensure interface that i want, I think
I should use vbox, hbox. But it wasn't.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.