Re: GTK3-Class Extensions not possible

Kouhei Sutou <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
Hi,

In <[email protected]>
  "GTK3-Class Extensions not possible" on Fri, 16 Nov 2018 19:48:43 +0100,
  ulli bei Unity <[email protected]> wrote:

> for some reasons I extend ruby GTK3 class with some functions. This
> works very well with ruby-gtk3 2.2.5-4 build1. With
> ruby-gtk 3.2.4-1 I get always the following error:
> 
> comboboxtext_mod.rb:8: warning: previous definition of ComboBoxText
> was here
> Traceback (most recent call last):
> comboboxtext_mod.rb:31:in `<main>': undefined method `set_names' for
> #<Gtk::ComboBoxText:0x5628eabeb0e0 ptr=0x5628eb0102c0> (NoMethodError)
> Did you mean?  set_name

gtk3 gem generates bindings at run-time. And it's occurred
when you touch methods or classes under the Gtk namespace
for the first time.

Your script works with the modification:

Gtk::ComboBoxText # Add this line or touch other methods or
                  # classes such as Gtk.check_version
                  # (Gtk::Version.or_later? is better than
                  # Gtk.check_version.)
class Gtk::ComboBoxText
  def set_names aL
    aL.each{|x| self.append_text x}
  end
end

Thanks,
--
kou

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.