| 1 | # Copyright 2008, 2009, 2010, 2011, 2012, 2016 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::TempProperty; | ||
| 18 | use 5.008; | ||
| 19 | use strict; | ||
| 20 | use warnings; | ||
| 21 | use Glib; | ||
| 22 | use Carp; | ||
| 23 | |||
| 24 | sub new { | ||
| 25 | my $class = shift; | ||
| 26 | my $obj = shift; | ||
| 27 | if (@_ & 1) { | ||
| 28 | croak 'TempProperty should have an even number of propname+value arguments'; | ||
| 29 | } | ||
| 30 | my @self = ($obj); | ||
| 31 | my $self = bless \@self, $class; | ||
| 32 | while (@_) { | ||
| 33 | my $pname = shift; | ||
| 34 | my $value = shift; | ||
| 35 | push @self, $pname, $obj->get_property($pname); | ||
| 36 | $obj->set_property($pname,$value); | ||
| 37 | } | ||
| 38 | return $self; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub DESTROY { | ||
| 42 | my ($self) = @_; | ||
| 43 | my $obj = shift @$self; | ||
| 44 | while (@$self) { | ||
| 45 | $obj->set_property(shift @$self, shift @$self); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | 1; | ||
| 50 | __END__ |