Kevin Ryde > chart > App::Chart::Glib::Ex::MoreUtils

Download:
chart-249.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  16
Open  3
View/Report Bugs
Source  

NAME ^

App::Chart::Glib::Ex::MoreUtils -- more Glib utility functions

SYNOPSIS ^

 use App::Chart::Glib::Ex::MoreUtils;

FUNCTIONS ^

App::Chart::Glib::Ex::MoreUtils::ref_weak ($obj)

Return a reference to a weak reference to $obj. This is good for the "userdata" in signal connections etc when you want some weakening so you don't keep $obj alive forever due to the connection. For example,

    $model->signal_connect (row_deleted, \&deleted_handler,
                            App::Chart::Glib::Ex::MoreUtils::ref_weak($self));

    sub deleted_handler {
      my ($model, $path, $ref_weak_self) = @_;
      my $self = $$ref_weak_self || return;
      ...
    }
App::Chart::Glib::Ex::MoreUtils::lang_select ($lang => $value, ...)

Choose a value according to the user's preferred language. Each $lang argument is a two-letter language code like "en". The $value arguments are any scalars to return. For example

    App::Chart::Glib::Ex::MoreUtils::lang_select (de => 'deutsch',
                                      en => 'english')
    # returns either 'deutsch' or 'english'

The user's preferred language is taken from Glib::get_language_names (see Glib::Utils). If none of the given $lang values are among the user's preferences then the first in the call is used as the default and its $value returned.

This is meant for selecting semi-technical things from a fixed set of possibilities within the program code, for example different URLs for the English or German version of some web page which will be parsed. If it was in a .mo file (per Locale::TextDomain) the choice would be locked down by the translator, but lang_select allows a user preference.

SEE ALSO ^

Glib::Utils

syntax highlighting: