Forum: Ruby-Gnome 2 Updates to VisualRuby v 1.0.12 released

D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-11 07:40
Hi y'all:

I've had some time lately, so I've been working on a new version of
visualruby.  I just pushed ver1.0.12. I've made a few great improvements
that simplify things even further.

Now, there is a #show() method that
gets included in all GUI objects, so you don't have to manually write
code to include the glade file, or set any variables.  Its all done
automatically.

Here's an example of the "old" way and the "new" way:

OLD WAY:

class MyClass

  include GladeGUI

  def show()
    @button1 = "Hello World"
    @label1 = "Me too"
    load_glade(__FILE__)
    set_glade_all()
    show_window()
  end

  def button1__clicked(*args)
    @builder["button1"].label = "Goodbye"
  end

end

MyClass.new.show()

AND HERE's THE NEW WAY:


class MyClass

  include GladeGUI

  def before_show()
    @button1 = "Hello World"
    @label1 = "Me too"
  end

  def button1__clicked(*args)
    @builder["button1"].label = "Goodbye"
  end

end

MyClass.new.show() (or show(self)  self = parent window

So, now you don't need to use these methods:
load_glade(__FILE__)
set_glade_all()
show_window()
set_parent()

All of this is done automatically in the #show() method.  There is also
a #before_show() method that runs immediately before the window is
shown, so you can update things there.

However, this is all backwards compatible, so any previous code should
work fine.

Other improvements:
1) there are global settings now
2) There is an easier way to create a project:  File -> New Project
3) All of the examples have been updated.  go to
  Help -> Install Examples
  to overwrite your examples.  Also, a treeview example has been added.
4) It is now Ruby 2.0.0 compatible.

Go to Help->install Examples and see the smaller files.

I will be trying to update the docs on the website

Please report any issues.

Thanks,
Eric
092ba06f1a589a68277459a074b0340a?d=identicon&s=25 Greg Hanson (hansgrego)
on 2013-12-11 18:35
Seems there is a bug in the load_glade in 1.0.12.  Specifically in
my_class_file_path.  THis may be a windows only problem?
A path with C:xxx/yyy etc trips up the code.
If I change the line -> caller_path_to_class_file, =
caller[0].partition(":")
TO-> x,y,z = caller[0].partition(":")
  -> caller_path_to_class_file = x + y + z

I can make VR Load again.
Not sure how you'd want to fix this. and I havn't tried anything more
than loading VR
D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-11 21:07
Hi Greg:

Yep, you're right.  The colon in C:\path broke my code in windows.

Its fixed now.  I just pushed v 1.0.13 of vr and vrlib. just do this:

gem install visualruby

Thanks for your help.  Let me know how if it works.

Eric
This topic is locked and can not be replied to.