~ubuntu-branches/ubuntu/edgy/gnome-system-tools/edgy-proposed

« back to all changes in this revision

Viewing changes to backends/mouse-conf.in

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-10-14 18:49:22 UTC
  • Revision ID: james.westby@ubuntu.com-20041014184922-efvh7u8kpyy67a3z
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
3
 
 
4
# Pointing Device configurator : Manage your mouse etc
 
5
#
 
6
# Copyright (C) 2000-2001 Ximian, Inc.
 
7
#
 
8
# Authors: Ravi Pratap <ravi@che.iitm.ac.in>
 
9
#
 
10
# This program is free software; you can redistribute it and/or modify
 
11
# it under the terms of the GNU Library General Public License as published
 
12
# by the Free Software Foundation; either version 2 of the License, or
 
13
# (at your option) any later version.
 
14
#
 
15
# This program is distributed in the hope that it will be useful,
 
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
# GNU Library General Public License for more details.
 
19
#
 
20
# You should have received a copy of the GNU Library General Public License
 
21
# along with this program; if not, write to the Free Software
 
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
23
 
 
24
# Best viewed with 100 columns of width.
 
25
 
 
26
# Configuration files affected:
 
27
#
 
28
# /etc/X11/XF86Config
 
29
 
 
30
# Running programs affected:
 
31
#
 
32
# /etc/X11/X
 
33
 
 
34
 
 
35
BEGIN {
 
36
  $SCRIPTSDIR = "@scriptsdir@";
 
37
  if ($SCRIPTSDIR =~ /^@scriptsdir[@]/)
 
38
  {
 
39
      $SCRIPTSDIR = ".";
 
40
      $DOTIN = ".in";
 
41
  }
 
42
  
 
43
  require "$SCRIPTSDIR/general.pl$DOTIN";
 
44
  require "$SCRIPTSDIR/platform.pl$DOTIN";
 
45
  require "$SCRIPTSDIR/util.pl$DOTIN";  
 
46
  require "$SCRIPTSDIR/file.pl$DOTIN";  
 
47
  require "$SCRIPTSDIR/xml.pl$DOTIN";   
 
48
  require "$SCRIPTSDIR/parse.pl$DOTIN";
 
49
#require "$SCRIPTSDIR/mouse.pl$DOTIN";
 
50
}
 
51
 
 
52
 
 
53
# -- Tool information --- #
 
54
 
 
55
$name = "mouse";
 
56
$version = "@VERSION@";
 
57
@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", 
 
58
              "redhat-7.0", "redhat-7.1", "redhat-7.2", "turbolinux-7.0");
 
59
 
 
60
$description =<<"end_of_desc;";
 
61
       Configures Pointing Tool Device
 
62
end_of_desc;
 
63
 
 
64
@conf_files = ("/etc/X11/XF86Config");
 
65
 
 
66
# Helper functions
 
67
 
 
68
sub gst_mouse_conf_get
 
69
{
 
70
    my %hash;
 
71
    my $config_file;
 
72
    local *CONFIG_FILE;
 
73
 
 
74
    $config_file = &gst_file_open_read_from_names (@conf_files);
 
75
    if (not $config_file) { return; }
 
76
    *CONFIG_FILE = $config_file;
 
77
 
 
78
    while (<CONFIG_FILE>) {
 
79
        chomp;
 
80
 
 
81
        # We're only interested in the pointer section
 
82
        
 
83
        next if (/^\#/ || /^$/);
 
84
        last if (/Pointer/);
 
85
    }
 
86
    
 
87
    while (<CONFIG_FILE>) {
 
88
        my ($a, $b);
 
89
        
 
90
        chomp;
 
91
        next if (/^\#/ || /^$/);
 
92
        last if (/EndSection/);
 
93
 
 
94
        ($a, $b) = split (" ", $_, 2);
 
95
 
 
96
        if ($b) { $hash{"$a"} = $b; }
 
97
        else    { $hash{"$a"} = "on"; }
 
98
    }
 
99
    
 
100
    return \%hash;
 
101
 
 
102
}
 
103
 
 
104
 
 
105
sub xml_print ()
 
106
{
 
107
    my $h = $_[0];
 
108
    my @tags = ('Protocol', 'Device', 'BaudRate', 'SampleRate', 'Emulate3Buttons', 'Emulate3Timeout', 'ChordMiddle');
 
109
    my $i;
 
110
 
 
111
    &gst_xml_print_begin ();
 
112
    
 
113
    while ($i = shift @tags) {
 
114
        if (exists $$h{$i} && $$h{$i} eq "on") { gst_xml_print_line ("<$i/>\n"); } 
 
115
        elsif (exists $$h{$i}) { gst_xml_print_line ("<$i>$$h{$i}</$i>\n"); }
 
116
    }
 
117
    
 
118
    &gst_xml_print_end ();
 
119
}
 
120
 
 
121
 
 
122
 
 
123
 
 
124
# The main stuff 
 
125
 
 
126
# --- Write new configuration to file --- #
 
127
 
 
128
sub set
 
129
{
 
130
    print "Not implemented yet! \n";
 
131
    
 
132
    &gst_report_end ();
 
133
    
 
134
}
 
135
 
 
136
 
 
137
# --- Get configuration from file --- #
 
138
 
 
139
sub get 
 
140
{
 
141
    my $hash;
 
142
    
 
143
    $hash = &gst_mouse_conf_get ();
 
144
    
 
145
    &xml_print ($hash);
 
146
    &gst_report_end ();
 
147
 
 
148
}
 
149
 
 
150
 
 
151
# --- Filter config: XML in, XML out --- #
 
152
 
 
153
sub filter
 
154
{
 
155
    print "Not implemented yet! \n";
 
156
    
 
157
    &gst_report_end ();
 
158
}
 
159
 
 
160
# --- Main --- #
 
161
 
 
162
# get, set and filter are special cases that don't need more parameters than a ref to their function.
 
163
# Read general.pl.in:gst_run_directive to know about the format of this hash.
 
164
 
 
165
$directives = {
 
166
  "get"    => [ \&get,    [], "" ],
 
167
  "set"    => [ \&set,    [], "" ],
 
168
  "filter" => [ \&filter, [], "" ]
 
169
    };
 
170
 
 
171
$tool = &gst_init ($name, $version, $description, $directives, @ARGV);
 
172
&gst_platform_ensure_supported ($tool, @platforms);
 
173
&gst_run ($tool);