GladeXML and derived widgets

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

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’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

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:


Take Surveys. Earn Cash. Influence the Future of IT
Join 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

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

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

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’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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs