4 use Gtk
::ColorSelectButton
;
7 print "Usage: $0 image_file color_num\n";
11 my $imageFile = shift;
14 unless (-f
$imageFile) {
15 print "No image $imageFile found\n";
19 unless ($colorNum =~ /^\d+$/ && $colorNum > 2 && $colorNum <= 9) {
20 print "color_num parameter should be in the range [2 .. 9]\n";
25 init Gtk
::ColorSelectButton
;
27 my @colorButtons = ();
28 foreach (0 .. $colorNum - 1) {
29 my $button = new Gtk
::ColorSelectButton
;
30 my $br = int($_ / $colorNum * 256);
31 $button->set(color
=> "$br $br $br");
32 push @colorButtons, $button;
37 foreach (@colorButtons) {
38 push @colors, sprintf "rgb:%02x/%02x/%02x", split / /, $_->color;
40 my $colorStr = join(',', @colors);
41 print $colorStr, "\n";
42 system(qq(fvwm
-themes
-images
--in-file
"$imageFile" --setroot
--colorize
--colorize
-colors
"$colorStr"));
45 # -------- main --------
47 my $dialog = new Gtk
::Dialog
;
48 $dialog->set_title("Colorizing Backround");
49 $dialog->set_border_width(4);
50 $dialog->set_usize(400, 160);
52 my $label = new Gtk
::Label
("Image: " . substr($imageFile, -60));
53 $dialog->vbox->pack_start($label, 1, 1, 8);
55 my $hbox = new Gtk
::HBox
(1, 0);
56 $dialog->vbox->pack_end($hbox, 1, 1, 8);
58 foreach (0 .. $colorNum - 1) {
59 $hbox->pack_start($colorButtons[$_], 1, 1, 8);
64 $button = new Gtk
::Button
" Set Backgound ";
65 $dialog->action_area->pack_start($button, 0, 0, 8);
66 $button->signal_connect("clicked", sub { colorizeRoot
(); });
68 $button = new Gtk
::Button
" Quit ";
69 $dialog->action_area->pack_start($button, 0, 0, 8);
70 $button->signal_connect("clicked", sub { Gtk
->main_quit; });