Re: Can't locate object method "new_text" via package "Gtk2::ComboBox"




On Jan 24, 2006, at 1:30 AM, Eisenknapp, Josef wrote:

I wrote a program useing a Gtk2::ComboBox. On my computer at home everything works fine, but on the redhat computer in the office keep getting the message:

"Can't locate object method "new_text" via package "Gtk2::ComboBox" (perhaps you forgot to load "Gtk2::ComboBox"?)........"

GtkComboBox was added to gtk+ in version 2.4.0, and support for it was added to Gtk2 in 1.040. However, even if Gtk2 is newer than 1.040, Gtk2::ComboBox will be missing if you compile against gtk+ older than 2.4.

RHEL3 and Fedora Core 1 have gtk+ 2.2.x.
RHEL4 and Fedora Core 2 have gtk+ 2.4.x.

If the object isn't there in gtk+, you simply can't use it.


I have a similar problem with the "->set_keep_above (TRUE)" method for a window.

Same story on versions.


Supporting old systems can be a drag, because you can't use the latest and greatest objects from gtk+. However, i have several archaic systems to maintain, myself, so i've pulled a few of these tricks.

It's a bit more work, but it's possible to add fallback code and determine at runtime which code to execute. For example, collect all the code to deal with comboboxes in one function or class, and maintain two paths:

   sub create_combo {
       my %options = @_;
       if ($Gtk2::VERSION >= 1.040 && Gtk2->CHECK_VERSION(2, 4, 0)) {
           # Gtk2::ComboBox is available!  Use it!
           ...
       } else {
           # We're on an older setup that doesn't have ComboBox.
           # Use Gtk2::OptionMenu or Gtk2::Combo instead.
           ...
       }
   }

See L<Glib::version> and L<Gtk2::version> for more information.

Or, just take the easy route and use only the widgets that are available in gtk+ 2.0 for maximum compatibility. Yes, that does sometimes hurt.


--
Jolt is my co-pilot.
  -- Slogan on a giant paper airplane hung in Lobby 7 at MIT.
     http://hacks.mit.edu/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]