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 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 166 167 168
|
<object name="mysinktest">
<csink name="mysink" hostname="localhost" port="80"
onconnect="myonconnect" ondisconnect="myondisconnect"
onnewdata="myonnewdata" />
<window ondelete="entity:exit" title="Sink Test" height="500" width="600">
<halign>
<valign expand="true"/>
<label text="Hostname:"/>
<entry name="remote-host" width="100" text="localhost" onenter="sethost"/>
<button name="set-remote-host" label="Change" onclick="sethost"/>
<label text="Port:"/>
<entry name="remote-port" width="50" text="80" onenter="setport"/>
<button name="set-remote-port" label="Change" onclick="setport"/>
<valign expand="true"/>
</halign>
<halign>
<valign expand="true"/>
<button name="connect" label="CONNECT" onclick="myconnect"/>
<button name="disconnect" label="DISCONNECT" onclick="mydisconnect" sensitive="false"/>
<button name="ninja" label="Ninja Magic" onclick="ninjamagic">
<?perl
sub ninjamagic
{
my $button = enode ("button.ninja");
my $xml = qq!
<include file="ninja-magic.e"/>
!;
my $node = enode ("window");
$node->append_xml ($xml);
}
?>
</button>
<valign expand="true"/>
</halign>
<scrollwindow expand="true" name="scroller">
<text name="textfield"/>
</scrollwindow>
<halign>
<entry name="cursor" expand="true" onenter="writemesg"/>
<button name="send" label="Send" onclick="writemesg" sensitive="false"/>
</halign>
</window>
<perl>
<![CDATA[
sub myonnewdata
{
my ($node, $mesg) = @_;
my $text = enode ("text.textfield");
my $scrollbar = enode ("scrollwindow.scroller");
my $do_move = 0;
if ($scrollbar->attrib ("y-scroll") >= 98)
{
$do_move = 1;
}
$text->set_data ($text->get_data() . $mesg);
if ($do_move)
{
$scrollbar->attrib ("y-scroll" => "100");
}
}
sub myonconnect
{
my $node = shift;
my $connbutton = enode ("button.connect");
my $discbutton = enode ("button.disconnect");
my $sendbutton = enode ("button.send");
my $scrollbar = enode ("scrollwindow.scroller");
my $text = enode ("text.textfield");
if ($scrollbar->attrib ("y-scroll") >= 98)
{
$do_move = 1;
}
$text->set_data ($text->get_data() . "Connected...\n");
if ($do_move)
{
$scrollbar->attrib ("y-scroll" => "100");
}
$connbutton->attrib ("sensitive" => "false");
$discbutton->attrib ("sensitive" => "true");
$sendbutton->attrib ("sensitive" => "true");
}
sub myondisconnect
{
my $node = shift;
my $connbutton = enode ("button.connect");
my $discbutton = enode ("button.disconnect");
my $sendbutton = enode ("button.send");
my $scrollbar = enode ("scrollwindow.scroller");
my $text = enode ("text.textfield");
if ($scrollbar->attrib ("y-scroll") >= 98)
{
$do_move = 1;
}
$text->set_data ($text->get_data() . "Disconnected...\n");
if ($do_move)
{
$scrollbar->attrib ("y-scroll" => "100");
}
$connbutton->attrib ("sensitive" => "true");
$discbutton->attrib ("sensitive" => "false");
$sendbutton->attrib ("sensitive" => "false");
}
sub myconnect
{
my $sink = enode ("csink.mysink");
$sink->attrib ("action" => "connect");
}
sub mydisconnect
{
my $sink = enode ("csink.mysink");
$sink->attrib ("action" => "disconnect");
}
sub writemesg
{
my $sink = enode ("csink.mysink");
my $text = enode ("entry.cursor");
my $mesg = $text->attrib ("text");
$sink->attrib ("write" => $mesg . "\n");
$text->attrib ("text" => "");
}
sub sethost
{
my $sink = enode ("csink.mysink");
my $entry = enode ("entry.remote-host");
$sink->attrib ("hostname", $entry->attrib ("text"));
}
sub setport
{
my $sink = enode ("csink.mysink");
my $entry = enode ("entry.remote-port");
$sink->attrib ("port" => $entry->attrib ("text"));
}
]]>
</perl>
</object>
|