summaryrefslogtreecommitdiffstats
path: root/perl-install/share/keymaps_generate
blob: 0265502c9d1d358dfd457605fa8d153ae616efc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

use lib "..";
use keyboard;

my $dir = "keymaps/usr/share/keymaps";
system("rm -rf keymaps ; mkdir -p keymaps/usr/share/keymaps");

foreach (keyboard::keyboards()) {
    my $kmap = keyboard::keyboard2kmap($_);
    if (system("./kmap2bkmap $kmap > $dir/$kmap.bkmap 2>/dev/null") != 0) {
	warn "unknown kmap $kmap\n";
	unlink "$dir/$kmap.bkmap";
    }
}

system("tar cfj keymaps.tar.bz2 -C keymaps usr") == 0 or die;
system("rm -rf keymaps");
'>47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
#!/usr/bin/perl -w

# Theme editor

# Copyright (C) 1999 damien@mandrakesoft.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use Gtk;
use lib qw(/usr/lib/libDrakX);
use my_gtk qw(:helpers :wrappers);
use common;

#- languages that can't be displayed with gtk1, so we unset translations
#- for them until this tool is ported to gtk2
if ($ENV{LANGUAGE} =~ /\b(ar|he|hi|ta)/) { $ENV{LANGUAGE} = "C" };

init Gtk;

if ("@ARGV" =~ /-h/) {
    print q(DrakX theme editor by dam's.

Options :
    -f specify the input theme file. Default is themes-mdk.rc
    -o specify the output file. Default is input file.
    -h print this help.
)
}
my ($file) = "@ARGV" =~ /-f (.+)/;
my ($file2) = "@ARGV" =~ /-o (.+)/;
$file ||= "themes-mdk.rc";
$file2 ||= $file;
my $window1 = new Gtk::Window -toplevel;
$window1->signal_connect ( delete_event => sub { Gtk->exit(0); });
$window1->set_title(N("Theme editor"));
$window1->set_policy(0, 1, 0);
$window1->set_border_width(5);
gtkadd($window1, my $vb = new Gtk::VBox(0,5));
$window1->show_all;
$window1->realize;
my $f;
my $vb2;
my $hb;
my $style;
my $ref = 0;
my %color;
my $cpt = 0;
my $do_style;
foreach (cat_($file)) {
    chomp;
    if(/style "(.*)"/) {
	$style = $1;
	print " -- $style \n";
	$do_style = 1;
    }
    if(/(\w+)\[(\w+)\]\s*=\s*\{\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\}/) {
	my ($a1, $a2) = ($1, $2);
	my $style2 = $style;
	if ($do_style) {
	    $cpt == 0 and gtkpack__($vb, $hb = new Gtk::HBox(0,5));
	    $cpt++;
	    $cpt == 4 and $cpt = 0;
	    gtkpack__($hb,
		      gtkadd(gtkset_shadow_type($f = new Gtk::Frame(" $style "), 'etched_out'),
			     $vb2 = gtkset_border_width(new Gtk::VBox(0,5),5)
			    )
		     );
	    $do_style = 0;
	}
	my $c =my_gtk::gtkcolor($3*65535, $4*65535, $5*65535);
	$color{$style}{$1}{$2} = $c;
	my $gc = new Gtk::Gdk::GC($window1->window);
	$gc->set_foreground($c);
	gtkpack__($vb2,
		  gtkpack_(new Gtk::HBox(0,0),
			   1, gtkpack__(new Gtk::HBox(0,0),"$1 [$2] : "),
			   0, gtksignal_connect(gtkset_relief(my $b = new Gtk::Button(), 'none'), clicked => sub {
						    $c = change_color($c);
						    $gc->set_foreground($c);
						    $color{$style2}{$a1}{$a2} = $c;
						    $_[0]->draw(undef);
						})
			  )
		 );
	$b->add(gtksignal_connect(gtksize(gtkset_usize(new Gtk::DrawingArea(), 60, 20), 60, 20), expose_event => sub{ $_[0]->window->draw_rectangle ($gc, 1, 0, 0, 60, 20)} ));
    }
    /\{/ and $ref++;
    if (/\}/) { $ref--; $ref == 0 and undef $style }
}
gtkpack__($vb,
	  gtkadd(gtkset_layout(new Gtk::HButtonBox, -end),
			      gtksignal_connect(new Gtk::Button(N("OK")), clicked => sub { doit(); Gtk->main_quit() }),
			      gtksignal_connect(new Gtk::Button(N("Cancel")), clicked => sub { Gtk->main_quit() }),
			     )
	 );

$window1->set_position(1);
$window1->show_all;
Gtk->main;
Gtk->exit(0);

sub doit {
    system("rm -f /tmp/plop");
    foreach (cat_($file)) {
	my $output;
	chomp;
	if(/style "(.*)"/) {
	    $style = $1;
	    $do_style = 1;
	}
	if(/(\w+)\[(\w+)\]\s*=\s*\{\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\}/) {
	    #	print " - $_ - \n" foreach ($1, $2, $3, $4, $5);
	    my ($a1, $a2) = ($1, $2);
	    my $c = $color{$style}{$1}{$2};
	    $output = $1 . "[" . $2 . "] = { " .
	      round($c->red()/65535*100)/100 . ", " . round($c->green()/65535*100)/100 . ", " . round($c->blue()/65535*100)/100 . " }";
	}
	/\{/ and $ref++;
	if (/\}/) { $ref--; $ref == 0 and undef $style }
	$output ||= $_;
	$output =~ s/ 1 / 1.0 /;
	$output =~ s/ 1, / 1.0, /;
	$output =~ s/ 1, / 1.0, /;
	system("echo '$output' >> /tmp/plop");
    }
    system("mv -f /tmp/plop $file2");
}

sub change_color {
    my ($color) = @_;
    my $window = new Gtk::Window -toplevel;
    my $doit;
    $window->signal_connect ( delete_event => sub { Gtk->main_quit() });
    $window->set_position(1);
    $window->set_title(N("Color configuration"));
    $window->set_border_width(5);
    gtkadd(gtkset_modal($window,1),
	   gtkpack_(new Gtk::VBox(0,5),
		    1, my $colorsel = new Gtk::ColorSelection,
		    0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -end),
			      gtksignal_connect(new Gtk::Button(N("OK")), clicked => sub { $doit=1; Gtk->main_quit() }),
			      gtksignal_connect(new Gtk::Button(N("Cancel")), clicked => sub { Gtk->main_quit() }),
			     )
		   )
	  );
    $colorsel->set_color($color->red()/65535, $color->green()/65535, $color->blue()/65535, $color->pixel());
    $window->show_all();
    Gtk->main;
    $window->destroy();
    $doit or return $color;
    my (@color) = $colorsel->get_color();
    my_gtk::gtkcolor($color[0]*65535, $color[1]*65535, $color[2]*65535);