Forum: Ruby-Gnome 2 Style Property - How to change?

Posted by Robux Biz (robux)
on 2010-06-05 19:39
Hi everybody!

I can see style property:

  btn = Gtk::Button.new
  puts btn.style_get_property('image-spacing')  # "2"

But how can change the value?
Posted by Robux Biz (robux)
on 2010-06-05 21:00
I did that:
  class ClsBtn < Gtk::Button
     type_register
         install_style_property(GLib::Param::Int.new('image-spacing', 
'image-spacing',
           '', 0, 10000, 5, 
GLib::Param::READABLE|GLib::Param::WRITABLE))
   end
   closebtn = ClsBtn.new
   image = Gtk::Image.new(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)
   closebtn.add(image)
   p closebtn.style_get_property('image-spacing')
Property became "0",
but border around image is still big (not equals 0)
How can I to decrease the button? (The button is needed for Notebook 
tabs)
Posted by Robux Biz (robux)
on 2010-06-05 21:45
>            '', 0, 10000, 5, 

It should read as:

'', 0, 10000, 0,

I have tried to play with parameter :)
Posted by Robux Biz (robux)
on 2010-06-06 09:56
I did that:

[CODE]  style = closebtn.modifier_style
  style.xthickness = 0
  style.ythickness = 0
  closebtn.modify_style(style) [/CODE]

But fields are still exist. Any else ideas?
Posted by Robux Biz (robux)
on 2010-06-06 11:47
I find solution in Geany source code:

[CODE]    label_box = Gtk::HBox.new(false, 0)
    label = Gtk::Label.new('Page1')
    label_box.pack_start(label, false, false, 0)

    btn = Gtk::Button.new
    btn.relief = Gtk::RELIEF_NONE
    btn.focus_on_click = false
    style = btn.modifier_style
    style.xthickness = 0
    style.ythickness = 0
    btn.modify_style(style)
    btn.set_tooltip_text("Close page1")
    wim,him = Gtk::IconSize.lookup(Gtk::IconSize::MENU)
    btn.set_size_request(wim+2,him+2)
    btn.signal_connect('clicked') do
      $notebook.remove_page($notebook.children.index(treeview))
      store.clear
      label_box.destroy
      treeview.destroy
    end

    image = Gtk::Image.new(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)
    btn.add(image)

    align = Gtk::Alignment.new(1.0, 0.0, 0.0, 0.0)
    align.add(btn)
    label_box.pack_start(align, false, false, 0)

    label_box.spacing = 3
    label_box.show_all

    page = $notebook.append_page(treeview, label_box)
    treeview.show_all
    $notebook.page = $notebook.n_pages-1 [/CODE]
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.