1 # Copyright (c) 2003-2009 Mikhael Goikhman
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 package FVWM
::Tracker
::GlobalConfig
;
21 use FVWM
::Tracker
qw(base);
33 $self->add_handler(M_CONFIG_INFO
, sub {
35 $self->calculate_internals($event->args);
38 $self->request_configinfo_events;
40 my $result = $self->SUPER::start
;
42 $self->delete_handlers;
44 $self->add_handler(M_CONFIG_INFO
, sub {
46 my $name = $self->calculate_internals($event->args);
47 return unless defined $name;
48 $self->notify("value changed", $name);
54 sub calculate_internals
($$) {
57 my $data = $self->{data
};
59 my $text = $args->{text
};
60 $self->internal_die("No 'text' arg in M_CONFIG_INFO")
62 return undef if $text =~ /^(?:desktopsize|colorset|\*)/i;
64 return undef unless $text =~ /^(desktopname \d+|[^\s]+) (.*)$/i;
67 $self->{data
}->{$name} = $value;
75 my $data = $self->{data
};
76 return $data unless defined $name;
77 return $data->{$name};
83 my $data = $self->{data
};
84 my @names = defined $name?
($name): sort keys %$data;
88 my $value = $data->{$_};
89 $string .= "$_ $value\n";
100 This is a subclass of B<FVWM::Tracker> that enables to read the global
107 Using B<FVWM::Module> $module object:
109 my $config_tracker = $module->track("GlobalConfig");
110 my $config_hash = $config_tracker->data;
111 my $image_path = $config_hash->{'ImagePath'};
115 my $config_tracker = $module->track("GlobalConfig");
116 my $xinerama_info = $config_tracker->data('XineramaConfig');
117 my $desktop2_name = $config_tracker->data('DesktopName 2');
119 =head1 OVERRIDDEN METHODS
123 =item B<data> [I<key>]
125 Returns either hash ref of all global configuration values, or one value if
128 =item B<dump> [I<key>]
130 Works similarly to B<data>, but returns debug lines for one or all global
131 configuration values.
137 Mikhael Goikhman <migo@homemail.com>.
141 For more information, see L<FVWM::Module> and L<FVWM::Tracker>.