File: enview.e

package info (click to toggle)
entity 1.0.1-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,604 kB
  • ctags: 5,394
  • sloc: ansic: 64,242; sh: 7,377; makefile: 776; perl: 319
file content (74 lines) | stat: -rw-r--r-- 1,750 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
#!/usr/bin/env entity

<object name="enview">
  <system-args name="args" />

  <perl>
    <![CDATA[

my $node = enode("system-args.args");
my $working_dir = $node->attrib("startup-directory") . "/";
my $obj = enode("object.enview");
my @children = $node->children();
my $found_image = "false";

foreach my $child (@children)
{
    my $name = $child->attrib("name");
    chomp($name);

    if (! -e $name)
    {
        $name = $working_dir . $name;
    }

    if ( (-e $name) && 
        ($name =~ /.gif/i||$name =~ /.jpg/i||$name =~ /.png/i||$name =~ /.xpm/i))
    {
        my $newimage=qq!
            <window name="image" ondelete="entity:exit">
              <valign expand="true">
                <scrollwindow expand="true">
                  <valign expand="true">
                    <image name="image" src="$name"/>
                  </valign>
                </scrollwindow>
              </valign>
            </window>!;
        $obj->append_xml("$newimage");
        $found_image = "true";
        print "opening file: $name\n";
        last;
    }
}

if ($found_image eq "true")
{
    print ("found image\n");
    my $image = enode("image.image");
    my $window = enode("window.image");
    my $width = int($image->attrib("width")) + 15;
    my $height = int($image->attrib("height")) + 15;

    if ($width > 800)
    {
        $width = 800;
    }
    if ($height > 600)
    {
        $height = 600;
    }
    print ("width is $width, height is $height\n");
    $window->attrib("width" => "$width" );
    $window->attrib("height" => "$height" );	
}
else
{
# Print usage and die.
    print "error processing command line options\n\n";
    print "usage: enview image_name.[jpg | gif | png | xpm ]\n";
    exit;
}
]]>
</perl>
</object>