Ruby/LibGlade: multiple GladeXML objects

hi,

i am trying to load two glade files one after another. is there a
special trick? or is it not possible?

something like the following, although my program has these two GladeXML
instantiations in seperate methods, the first calling the second when
logon is successful.

g1 = GladeXML.new(‘logon.glade’) { |handler_name|

}
Gtk::main

g2 = GladeXML.new(‘search.glade’) { |handler_name|

}
Gtk::main

i get an error on the second call at g2 = GladeXML …

(eval):13:in ‘doConnect’: undefined method ‘arity’ for nil (NameError)

any help would be much appreciated.

···


~transami

well, i gave up on having two seperate files and stuck both my windows
onto a single .glade file.

same error. i remarked out all my other code. the only thing left is the
basic call:

g1 = GladeXML.new(‘logonandsearch.glade’) { |handler_name|

}
Gtk::main

i even tried changing one of my windows to a dialog, so that they
weren’t both toplevel windows. no good. still:

(eval):13:in ‘doConnect’: undefined method ‘arity’ for nil (NameError)

is there a bug with ruby/libglade?

~transami

this is a follow up on how to properly use glade with ruby, if anyone is
interested.

masao mutoh was extremely helpful with this and even threw together a
smaple framework for my app! too kind. so, as an example, i’ll give you
a simplified version of that framework:

require ‘lglade’

class Test

def initialize
@glade = GladeXML.new(“mygui.glade”) { |handler|
p handler # this will actually print all signals
method(handler)
}
end

def on_some_signal_one
p “on_some_signal_one”
end

def on_some_signal_two
p “on_some_signal_two”
end

def on_some_signal_three
p “on_some_signal_three”
end

def on_some_signal_to_very_last
p “on_some_signal_to_very_last”
end

end

Test.new
Gtk.main

so this is the “correct” approach: every glade file you have will get
its own class. an important thing to remember is that each and every
signal must be accounted for in your methods, otherwise you’ll get an
error, and sometimes it’s not a very obvious one. that’s was the problem
i was having. don’t leave any out, even if they don’t yet do anything as
you are developing.

the above framework is quite elegent, and makes it easy to slice up your
gui windows into multiple .glade files. you simply define a new class
like the one above for each file, then instantiate the class in your
code. you only need to do GTK.main the one time, from then on all new
glade gui windows will appear as they are created anew. (well, if
they’re not designated as hidden, in wich case you;d need to use the
.show method)

of course you can have multiple windows in a sigle glade file, but i
would not over due this approach because of naming conflicts. since
every widget within a single glade file must have a unique name which
you access in your code with @glade.getWidget(‘widget_name’) it is
easier to seperate your windows into seperate glade files by functional
divisions. also, you will find that the method #getWidgetByLongName is
rather useless as you have to know the entire tree of containment to get
at the desired widget. with gtk, this can be down under quite a depth of
layout mananger widgets, so just stick with the unique names.

okay, that should give anyone interested in using glade a good start.
the docs aren’t so great but they are getting better. i have found that
the best thing to do is simply puts #methods on whatever widget object
your trying to understand, and see all that it does. (i could not get
the included rbbc.rb class browser to fully work, by the way)

if anyone has any other questions about glade let me know and i’ll see
what i can do. hope this is helpful.

~transami

p.s. Thanks Masao!

···

On Fri, 2002-08-09 at 01:36, Tom Sawyer wrote:

hi,

i am trying to load two glade files one after another. is there a
special trick? or is it not possible?

something like the following, although my program has these two GladeXML
instantiations in seperate methods, the first calling the second when
logon is successful.

g1 = GladeXML.new(‘logon.glade’) { |handler_name|

}
Gtk::main

g2 = GladeXML.new(‘search.glade’) { |handler_name|

}
Gtk::main

i get an error on the second call at g2 = GladeXML …

(eval):13:in ‘doConnect’: undefined method ‘arity’ for nil (NameError)

any help would be much appreciated.


~transami


~transami

Hi,

I have used ruby-libglade in several projects under
Debian Linux. I have not noticed any problems.

Linudent LinuDent Project download | SourceForge.net

and rbaccount Adminpanel

What environment are you using?

Steven G.

Tom Sawyer transami@transami.net wrote in message news:1028887017.1778.553.camel@silver

···

well, i gave up on having two seperate files and stuck both my windows
onto a single .glade file.

same error. i remarked out all my other code. the only thing left is the
basic call:

g1 = GladeXML.new(‘logonandsearch.glade’) { |handler_name|

}
Gtk::main

i even tried changing one of my windows to a dialog, so that they
weren’t both toplevel windows. no good. still:

(eval):13:in ‘doConnect’: undefined method ‘arity’ for nil (NameError)

is there a bug with ruby/libglade?

~transami

i’m using DEBIAN as well, Woody.

the only thing i can think of is that i might have two widgets with the
same name. would that do it? or perhaps there’s a newer version of
ruby/libglade?

the one odd thing i did was cut and paste the actual xml from one
project to another. but glade loaded it up just fine. i modified it and
resaved it. yet maybe tht has something to do with it?

~transami

···

On Fri, 2002-08-09 at 23:25, Steven G. wrote:

What environment are you using?

Hi,

What environment are you using?

i’m using DEBIAN as well, Woody.

the only thing i can think of is that i might have two widgets with the
same name. would that do it? or perhaps there’s a newer version of
ruby/libglade?

See Ruby-GNOME Language Bindings download | SourceForge.net

the one odd thing i did was cut and paste the actual xml from one
project to another. but glade loaded it up just fine. i modified it and
resaved it. yet maybe tht has something to do with it?

Can you tell me detail of your environment?
GTK+, GNOME version
Ruby/GTK version
Ruby version

And, Could you send your whole sample script?
Then, I may help you.

Cheers,

···

On Sat, 10 Aug 2002 14:42:02 +0900 Tom Sawyer transami@transami.net wrote:

On Fri, 2002-08-09 at 23:25, Steven G. wrote:

.:% Masao Mutohmutoh@highway.ne.jp