#!/usr/bin/perl # auto-sized multiline Gtk2 message window : raimo 20061025 -> 20061226 # http://dash.atspace.org/ubuntu/gpopup my $lic = "http://creativecommons.org/licenses/publicdomain/"; my $url = "http://dash.atspace.org/sec/gpopup.txt"; # # gtk2-perl is required: sudo apt-get install libgtk2-perl # INSTALL: # wget -O ~/gpopup.txt http://dash.atspace.org/sec/gpopup.txt # sudo cp ~/gpopup.txt /usr/bin/gpopup # sudo chmod 755 /usr/bin/gpopup # RUN: # gpopup "Hello World" use strict; use Gtk2 "-init"; use Encode; #for Gtk2::Label utf-8 bugfix, look *1 # default size my $width = 220; my $height = 50; my ($w, $h); my $name = $0; $name =~ s/^.*\///; my $vers = 20061226; my $help = < new("toplevel"); $win -> set_position("center-always"); $win -> stick; # visible in all desktops $win -> set_keep_above(1); # on the top my $lab = Gtk2::Label -> new(decode("utf8", $msg)); # *1 $win -> add($lab); $win -> show_all; # must be here -> auto-size $lab -> set_selectable(1); # *2 ($w, $h) = $win -> get_size; $width = $w + 20; $height = $h + 20; $width = 200 if $width < 200; $height = 30 if $height < 30; $win -> set_size_request($width, $height); $win -> signal_connect(delete_event => sub{$win -> destroy}); $win -> signal_connect(destroy => sub{Gtk2 -> main_quit; exit 0}); Gtk2 -> main; exit 0; # original file: http://dash.atspace.org/sec/gpopup.txt # license: http://creativecommons.org/licenses/publicdomain/ # remarks *X # 20061226, added set_selectable(1) for lanbel *2 # 20061218, found strange utf8-bug in Gtk2::Label, "fixed" with decode. *1