Glib::Ex::ObjectBits -- misc Glib object helpers
use Glib::Ex::ObjectBits;
Glib::Ex::ObjectBits::set_property_maybe ($obj, $pname1,$value1, $pname2,$value2, ...)
Set properties on $obj if they exist. Each $pname is a property name (a string) and those which exist on $obj are set to their $value with $obj->set_property().
$obj
$pname
$value
$obj->set_property()
This is a handy way to apply properties which might only exist in a new enough version of a library. For example Gtk2::Widget has a tooltip-text in Gtk 2.12 up,
Gtk2::Widget
tooltip-text
Glib::Ex::ObjectBits::set_property_maybe ($widget, tooltip_text => 'Some description.');
Things like this which are purely visual and don't affect actual operation are good for a set-maybe. Important things might want some sort of proper fallback.
Properties which do always exist can be included in set_property_maybe(), if a single call looks better. But be careful not to mis-spell a property name, since set_property_maybe() of course has no way to identify that.
set_property_maybe()
Nothing is exported by default, but the functions can be requested in usual Exporter style,
Exporter
use Glib::Ex::ObjectBits 'set_property_maybe'; # "tearoff-title" new in Gtk 2.10 set_property_maybe ($combobox, tearoff_title => 'My Menu');
Importing set_property_maybe() is good if making many such settings. The name is tolerably distinctive.
There's no :all tag since this module is meant as a grab-bag of functions and to import as-yet unknown things would be asking for name clashes.
:all
Glib::Object
Glib::Ex::EnumBits, Glib::Ex::FreezeNotify, Glib::Ex::SignalBits, Glib::Ex::SignalIds, Glib::Ex::SourceIds, Glib::Ex::TieProperties
http://user42.tuxfamily.org/glib-ex-objectbits/index.html
Copyright 2010, 2011, 2012, 2014 Kevin Ryde
Glib-Ex-ObjectBits 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.
Glib-Ex-ObjectBits 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 Glib-Ex-ObjectBits. If not, see http://www.gnu.org/licenses/.
To install Glib::Ex::ObjectBits, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Glib::Ex::ObjectBits
CPAN shell
perl -MCPAN -e shell install Glib::Ex::ObjectBits
For more information on module installation, please visit the detailed CPAN module installation guide.