Re: version checking... take II



On Thursday, February 12, 2004, at 12:14 AM, Emmanuele Bassi wrote:

So, I advocate for option 2, and not 1 which is, in my way of seeing
this matter, outsmarting both developers and package maintainers.

that's fairly convincing, if i'm understanding it correctly.

in general:

a) $Gtk2::VERSION tells you what version of the bindings you are using. feature support, etc.

b) some API call tells you what's available in gtk+ by telling you which version of Gtk+ we're compiled against, e.g. the new 2.4 widgets are available, that is, features.

a+b = what's available to you.

there are some things which are completely dynamic, however, and can change out from under you. a property's type may change, a new property may appear, or a bug may be fixed between micro versions without affecting API. in each of these situations (most notably the last) it can be important to be able to know at runtime which actual gtk+ version is under the hood so you can work around a buggy implementation. thus, we still need

c) a way to retrieve the actual runtime gtk+ version for esoteric needs.


since a+b is by far the most common case, we should make b) easy and do the right thing.

on further reflection, changing the behavior of get_version_info() and adding get_linked_version_info() makes a lot more sense than making get_version_info() complain and adding get_bound_version().


so, i vote for option 2 as well.


  # action-based menus appeared in gtk+ 2.4.0, and
  # were first supported in Gtk2 1.040.
  if ('' ne ($msg = Gtk2->check_version (2, 4, 0))
      or $Gtk2::VERSION < 1.040) {
      warn "$msg\n"
. "Action-based menus not available, falling back to ItemFactory\n";
      $use_item_factory = 1;
  }

  # suppose there's a weird bug that causes you to need to
  # perform an expensive workaround, but it was fixed in
  # a specific micro version, e.g. 2.2.4...  we can find out at
  # start up if we need to work around it.
  @info = Gtk2->get_linked_version_info;
  # assuming $_[0] == 2, which it should be for Gtk2
  if ($info[1] < 2 || ($info[1] == 2 && $info[2] < 3)) {
      $work_around_bug_fixed_in_2_2_4 = 1;
  }

--
I bring the rock, and provided it is fiscally responsible, I will bring the funk as well. And that's fo-shizzle.
        -- Saturday Night Live




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