| 1 | # Copyright 2008, 2009, 2010, 2011 Kevin Ryde | ||
| 2 | |||
| 3 | # This file is part of Chart. | ||
| 4 | # | ||
| 5 | # Chart is free software; you can redistribute it and/or modify it under the | ||
| 6 | # terms of the GNU General Public License as published by the Free Software | ||
| 7 | # Foundation; either version 3, or (at your option) any later version. | ||
| 8 | # | ||
| 9 | # Chart is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 12 | # details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License along | ||
| 15 | # with Chart. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | package App::Chart::Glib::Ex::MoreUtils; | ||
| 18 | 2 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 0 | ▶ | use Glib; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 22 | use Scalar::Util; | ||
| 23 | |||
| 24 | use base 'Exporter'; | ||
| 25 | our @EXPORT_OK = qw(ref_weak lang_select); | ||
| 26 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | ||
| 27 | |||
| 28 | sub ref_weak { | ||
| 29 | my ($obj) = @_; | ||
| 30 | Scalar::Util::weaken ($obj); | ||
| 31 | return \$obj; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub lang_select { | ||
| 35 | my %choices = @_; | ||
| 36 | my $default = $_[1]; | ||
| 37 | |||
| 38 | foreach my $lang (Glib::get_language_names()) { | ||
| 39 | if (exists $choices{$lang}) { | ||
| 40 | return $choices{$lang}; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | return $default; | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; | ||
| 47 | __END__ | ||