# New patch for ruby-glade-create-template.rb

**URL:** <https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974>\
**Category:** Ruby-Gnome 2\
**Created:** [April 17, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974 "2006-04-17T12:15:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![masoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@masoto](https://www.ruby-forum.com/u/masoto)\
**Post date:** [April 17, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974/1 "2006-04-17T12:15:18Z")

</div>

Hey Masao,

Got another patch for ya, to update the Glade Create Template program.  
This allows widgets that are in the glade xml file, be defined as read  
attributes on the Class object. EG:  
Glade has definition for ‘mainwin’, instead of having to access it  
through @glade[‘mainwin’], you can now use glade\_obj.mainwin. It’s  
sorta a convience method, then anything else. Still working on the  
ZipGlade library, as it’s kinda on back order while I work on my Instant  
Messenger.

Line 184-185:  
@glade = GladeXML.new(path\_or\_data, root, domain, localedir, flag)  
{|handler| method(handler)}  
@glade.widget\_names.each do |name|  
#{classname}.module\_eval(“def #{name}() @glade[’#{name}’]  
end”)  
end

---

<div class="post-metadata">

**Author:** ![masoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@masoto](https://www.ruby-forum.com/u/masoto)\
**Post date:** [April 17, 2006, 3:10pm UTC](https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974/2 "2006-04-17T15:10:56Z")

</div>

Hi Mario,

On Mon, 17 Apr 2006 05:10:58 -0500  
“Mario S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey Masao,
> 
> Got another patch for ya, to update the Glade Create Template program. This allows widgets that are in the glade xml file, be defined as read attributes on the Class object. EG:  
> Glade has definition for ‘mainwin’, instead of having to access it through @glade[‘mainwin’], you can now use glade\_obj.mainwin. It’s sorta a convience method, then anything else. Still working on the ZipGlade library, as it’s kinda on back order while I work on my Instant Messenger.
> 
> Line 184-185:  
> @glade = GladeXML.new(path\_or\_data, root, domain, localedir, flag) {|handler| method(handler)}  
> @glade.widget\_names.each do |name|  
> #{classname}.module\_eval(“def #{name}() @glade[‘#{name}’] end”)  
> end

The idea is good.

But I think it’s better to create the methods when generating code.  
Because it’s faster than evaluating it in runtime.

Could you make patch again?

–  
.:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![masoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@masoto](https://www.ruby-forum.com/u/masoto)\
**Post date:** [April 18, 2006, 4:21pm UTC](https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974/3 "2006-04-18T16:21:07Z")

</div>

Hi,

I rememeber that I’ve implemented it once. But don’t applied.  
Because there are too many methods are created.

Usually, we don’t use all widgets of Glade.  
So, I think it’s better developer choose them obviously.

On Mon, 17 Apr 2006 22:06:51 +0900  
Masao M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Line 184-185:  
> > Could you make patch again?
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

## –

.:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![masoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@masoto](https://www.ruby-forum.com/u/masoto)\
**Post date:** [May 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/new-patch-for-ruby-glade-create-template-rb/57974/4 "2006-05-03T19:06:39Z")

</div>

Hey Masao,

Sorry for the late reply in this, been busy with RL Work. Go figure. 😛  
Anyways, as to your inqury, and retraction, I was actually looking into  
that, and think I have a way to solve that problem, from my own  
experince  
when I goto create a GUI with Glade.

Often enough, if I don’t need to use the Widget myself (As in, needing  
it  
directly apparent in my application), I usually just let Glade pick the  
name  
for it, and leave it at that, where as the controls that I directly want  
to  
work with, I specifically give them names, that I can remember to access  
within my application. Now looking at it from this view-point, I can  
definatly see a way we can work around it, with basically two if  
clauses,  
that will keep the memory requirements to a minimum. So that way, it  
doesn’t add extra time onto the parsing of the Glade file.

The first “Rule” that it must past, is the base requirements, such as,  
is it  
a window, is it a dialog, or is it a menu/popup menu/menu item  
(Excluding  
ofcourse Gtk::Menu::SEPERATOR), if this falls under one of these  
categories  
for names, it’ll create the method for accessing that control handle, as  
a  
variable within the Glade class. Which should be simple enough, cause  
even  
if you don’t rename your base controls like Window, Dialog, or Menus,  
thoes  
are things we primarly need access to. Ofcourse, I can always include a  
little toggle switch to prevent this kind of evaluation, for both types  
of  
scanning, as well as the actual method adding.

The second “Rule” is that will be a bit more strict, is the fact that  
it’ll  
get the Control Type for that control, and see if it’s name, matches to  
what  
Glade gives it, with a Numeric Value added onto the end. Example of  
this  
being, that if you create a window in Glade, it’ll come up with window1,  
if  
you add a button, it’ll name it button1, etc, etc, etc. Now, if the  
control  
has a similar name to this, and unless it’s expressly directed that all  
controls are to be given a method accessor within the Ruby Definition  
file,  
it’ll by pass these. If there’s a name doesn’t match what the control  
type  
is, then it’ll create a method accessor for getting the handle of that  
control.

With this, I’ll have to add some Options parsing to  
ruby-glade-create-template.rb, in order to make it work as I mentioned,  
and  
this will give people the options for either having it, or not having  
it. I  
think these patches wouldn’t be all that hard to put into the parser,  
and  
get to ya, if you think these are worth doing? And if I do add Options  
Parsing to the parser, then I can add which type of creation they want  
to  
use, runtime evaluation definition, or hard code definition as well.

Pass back your thoughts on this Masao, and any suggestions you may have  
for  
adding to this as well, cause I’m very well interested in improving such  
a  
great tool that you have given us to parse Glade files.

L8ers,  
Mario S.  
----- Original Message -----  
From: “Masao M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, April 18, 2006 9:17 AM  
Subject: Re: [ruby-gnome2-devel-en] New patch for  
ruby-glade-create-template.rb

> > > Glade has definition for ‘mainwin’, instead of having to access it  
> > > end")  
> > > .:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> > 
> > * * *
> 
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

* * *

Using Tomcat but need to do more? Need to support web services,  
security?  
Get stuff done quickly with pre-integrated technology to make your job  
easier  
Download IBM WebSphere Application Server v.1.0.1 based on Apache  
Geronimo  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642)
