The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Gtk2::Ex::ComboBox::Enum -- combobox for values of a Glib::Enum

SYNOPSIS

 use Gtk2::Ex::ComboBox::Enum;
 my $combo = Gtk2::Ex::ComboBox::Enum->new
                 (enum_type   => 'Glib::UserDirectory',
                  active_nick => 'home');  # initial selection

WIDGET HIERARCHY

Gtk2::Ex::ComboBox::Enum is a subclass of Gtk2::ComboBox,

    Gtk2::Widget
      Gtk2::Container
        Gtk2::Bin
          Gtk2::ComboBox
            Gtk2::Ex::ComboBox::Enum

DESCRIPTION

Gtk2::Ex::ComboBox::Enum displays the values of a Glib::Enum. The active-nick property is the user's selection. The usual ComboBox active property row number works too, though the nick is normally the useful bit.

The text shown for each entry is per to_display of Glib::Ex::EnumBits, so an enum class can arrange how its values appear, or the default is a sensible word split and capitalization.

(There's a secret experimental might change in the future nick-to-display signal for per-instance control of the display. A signal is a good way to express a callback, but some care may be needed to get it connected early enough, or for the calls to be later than when enum-type is set, since that property will often be set before making signal connections.)

FUNCTIONS

$combobox = Gtk2::Ex::ComboBox::Enum->new (key=>value,...)

Create and return a new Enum combobox object. Optional key/value pairs set initial properties per Glib::Object->new.

    my $combo = Gtk2::Ex::ComboBox::Enum->new
                  (enum_type => 'Gtk2::TextDirection',
                   active    => 0); # the first row

PROPERTIES

enum-type (type name, default undef)

The enum type to display and select from. Until this is set the ComboBox is empty.

When changing enum-type if the current selected active-nick also exists in the new type then it remains selected, possibly on a different row. If the active-nick doesn't exist in the new type then the combobox changes to nothing selected.

This property is a Glib::Param::GType in Glib 2.10 and Glib-Perl 1.240 where that ParamSpec is available, or a plain string otherwise. At the Perl level a GType is a string anyway, but a GType pspec checks a setting really is a Glib::Enum sub-type.

active-nick (string or undef, default undef)

The nick of the selected enum value. The nick is the usual way an enum value appears at the Perl level.

If there's no active row in the combobox or no enum-type has been set then active-nick is undef.

There's no default for active-nick, just as there's no default for the ComboBox active, so when creating an Enum combobox it's usual to set the desired initial selection, either by nick or perhaps just active row 0 for the first value.

SEE ALSO

Gtk2::ComboBox, Glib::Ex::EnumBits, Gtk2::Ex::ComboBox::Text

HOME PAGE

http://user42.tuxfamily.org/gtk2-ex-comboboxbits/index.html

LICENSE

Copyright 2010 Kevin Ryde

Gtk2-Ex-ComboBoxBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Gtk2-Ex-ComboBoxBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Gtk2-Ex-ComboBoxBits. If not, see http://www.gnu.org/licenses/.