Gtk2::Ex::ComboBox::Enum -- combobox for values of a Glib::Enum
use Gtk2::Ex::ComboBox::Enum; my $combo = Gtk2::Ex::ComboBox::Enum->new (enum_type => 'Glib::UserDirectory', active_nick => 'home'); # initial selection
Gtk2::Ex::ComboBox::Enum is a subclass of
Gtk2::Widget Gtk2::Container Gtk2::Bin Gtk2::ComboBox Gtk2::Ex::ComboBox::Enum
Gtk2::Ex::ComboBox::Enum displays the values of a
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.
+--------------------+ | Enum Value One | +-| |-+---+ + |> Enum Value Two <| | V | ComboBox popped up +-| |-+---+ | Enum Value Third | | | | Enum Value Fourth | +--------------------+
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.)
$combobox = Gtk2::Ex::ComboBox::Enum->new (key=>value,...)
Create and return a new
Enumcombobox object. Optional key/value pairs set initial properties per
my $combo = Gtk2::Ex::ComboBox::Enum->new (enum_type => 'Gtk2::TextDirection', active => 0); # the first row
$str = $combobox->get_active_nick
Get or set the
active-nickproperty described below.
set_active_nickdoes nothing if
$stris already the active nick, in particular it doesn't emit a
enum-type(type name, default
The enum type to display and select from. Until this is set the ComboBox is empty.
enum-typeif the current selected
active-nickalso exists in the new type then it remains selected, possibly on a different row. If the
active-nickdoesn't exist in the new type then the combobox changes to nothing selected.
(This property is a
Glib::Param::GTypein new enough Glib and Perl-Glib, or a
Glib::Param::Stringotherwise. In both cases it's a type name string at the Perl level, but GType checks a setting really is an enum.)
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-typehas been set then
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
activerow 0 for the first value.
There's no way to set mnemonics for each enum value. A semi-automatic way to pick sensible ones might be good.
get_default_value should be
undef but is not. For the
GType case it's
"Glib::Enum", or for the
String it's an empty
# should be undef, but isn't $combobox->find_property('enum-type')->get_default_value
Copyright 2010, 2011 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/.