# GladeXML and derived widgets

**URL:** <https://www.ruby-forum.com/t/gladexml-and-derived-widgets/82603>\
**Category:** Ruby-Gnome 2\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/gladexml-and-derived-widgets/82603 "2007-01-19T16:31:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Nordholts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Martin\_Nordholts](https://www.ruby-forum.com/u/Martin_Nordholts)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/gladexml-and-derived-widgets/82603/1 "2007-01-19T16:31:37Z")

</div>

Hello,

I am porting a UI from gtkmm to ruby-gnome2. In the gtkmm version I  
create widgets derived from .glade file widgets as described here:  
[http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch23s03.html](http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch23s03.html)

Is derived widgets from .glade files supported in ruby-gnome2? I can’t  
find anything mentioned in the docs.

Thank you,

- Martin Nordholts

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_Nordholts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Martin\_Nordholts](https://www.ruby-forum.com/u/Martin_Nordholts)\
**Post date:** [February 26, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/gladexml-and-derived-widgets/82603/2 "2007-02-26T13:59:40Z")

</div>

For future reference:

Just use anonymous super classes, like this:

```
  gladeXML = GladeXML.new 

```

‘…/data/glade/create-new-image-window.glade’  
createNewImageWindow = gladeXML.get\_widget ‘CreateNewImageWindow’

```
  class << createNewImageWindow
    attr_reader :okButton, :imageNameEntry

    def setup_widgets gladeXML
      @okButton = gladeXML.get_widget 'OkButton'
      @okButton.signal_connect( 'clicked' ) { self.hide }

      @cancelButton = gladeXML.get_widget 'CancelButton'
      @cancelButton.signal_connect( 'clicked' ) { self.hide }

      @imageNameEntry = gladeXML.get_widget 'ImageNameEntry'
    end

    # Returns a new ImageInfo object with the data setup as in the
    # CreateNewImageWindow.
    def get_new_image_info
      ImageInfo.new @imageNameEntry.text
    end
  end

  createNewImageWindow.setup_widgets gladeXML

```

This will probably fulfil most needs.

- Martin Nordholts

sÃ¶n 2007-01-14 klockan 16:20 +0100 skrev Martin Nordholts:

> - Martin Nordholts  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_Nordholts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Martin\_Nordholts](https://www.ruby-forum.com/u/Martin_Nordholts)\
**Post date:** [September 25, 2007, 10:44pm UTC](https://www.ruby-forum.com/t/gladexml-and-derived-widgets/82603/3 "2007-09-25T22:44:59Z")

</div>

Martin Nordholts a écrit :

> Hello,

Hi,

> I am porting a UI from gtkmm to ruby-gnome2. In the gtkmm version I  
> create widgets derived from .glade file widgets as described here:  
> [http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch23s03.html](http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch23s03.html)
> 
> Is derived widgets from .glade files supported in ruby-gnome2? I can’t  
> find anything mentioned in the docs.  
> Have a look at this class  
> [http://svn.gnome.org/viewcvs/fantasdic/trunk/lib/fantasdic/ui/glade\_base.rb?view=markup](http://svn.gnome.org/viewcvs/fantasdic/trunk/lib/fantasdic/ui/glade_base.rb?view=markup)

The following code creates instance variables for each widget found in  
the glade file.

You then create classes that inherit from it in order to create new  
widgets.

I find this class very convenient.

Mathieu B…

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
