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::ComboBox,
Gtk2::Ex::ComboBox::Enum
Gtk2::ComboBox
Gtk2::Widget Gtk2::Container Gtk2::Bin Gtk2::ComboBox Gtk2::Ex::ComboBox::Enum
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.
Glib::Enum
active-nick
active
+--------------------+ | 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.
to_display
(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.)
nick-to-display
enum-type
$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.
Enum
Glib::Object->new
my $combo = Gtk2::Ex::ComboBox::Enum->new (enum_type => 'Gtk2::TextDirection', active => 0); # the first row
$str = $combobox->get_active_nick
$combobox->set_active_nick ($str)
Get or set the active-nick property described below. set_active_nick does nothing if $str is already the active nick, in particular it doesn't emit a notify.
set_active_nick
$str
notify
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 new enough Glib and Perl-Glib, or a Glib::Param::String otherwise. In both cases it's a type name string at the Perl level, but GType checks a setting really is an enum.)
Glib::Param::GType
Glib::Param::String
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.
There's no way to set mnemonics for each enum value. A semi-automatic way to pick sensible ones might be good.
The enum-type paramspec 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 "".
get_default_value
GType
"Glib::Enum"
String
""
# should be undef, but isn't $combobox->find_property('enum-type')->get_default_value
Gtk2::ComboBox, Glib::Ex::EnumBits, Gtk2::Ex::ComboBox::Text
http://user42.tuxfamily.org/gtk2-ex-comboboxbits/index.html
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/.
To install Gtk2::Ex::ComboBoxBits, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Ex::ComboBoxBits
CPAN shell
perl -MCPAN -e shell install Gtk2::Ex::ComboBoxBits
For more information on module installation, please visit the detailed CPAN module installation guide.