[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gigabyte-class SD [or MMC or MMCplus] cards



On Tue, Mar 08, 2005 at 10:57:50PM -0800, Tony Godshall wrote:
> Maybe I'll invest some time porting the apps I like to the
> small screen.  I don't really need that many real pda apps,
> and the apps I used to really want don't seem to exist yet
> (a plaintext quick-search index card thing like InfoSelect 
> was before it became a tree-structured database monster back
> when I used to run it on my on-in-two-seconds Windows-3.1+
> -in-ROM HP Omnibook-300 back in the day.
> 
> What do you recommend for something like that?  Mono/dot-GNU?
> (snicker.  snicker?  hmmm.  They want me to learn C# for work...)

How about running the Windows 3.1 InfoSelect inside Bochs ;-)

On a more serious note, I've experimented with the Perl GTK bindings (see
attachment) which is okay, the startup time isn't great though since it
recompiles the large included files each time. Maybe something
persistently compiled would work out better, I've experimented with clisp
and gtk-server but haven't spent much time on it.

-Klaus
#!/usr/bin/env perl

use Gtk;

use strict;
$^W=1; # use warnings;

#my $Device = "/dev/ircomm0";
my $Device = "/dev/mobilephone";

if (! -e $Device) {
	$Device = "/dev/ircomm";
}
if (! -e $Device) {
	die "$0:No ircomm device found\n";
}

sub send_sms {
	my ($phone, $msg) = @_;

	$phone =~ s/'/'\\''/g;
	$msg =~ s/'/'\\''/g;

	print "SMS to '$phone': '$msg'\n";
	my $result = `gsmsendsms -r -d $Device '$phone' '$msg' 2>&1`;

	return $result;
}

sub packer {
	my ($box, @list) = @_;

	for my $w (@list) {
		$w->show();
		$box->add($w);
	}
	$box->show();

	return $box;
}

sub vbox {
	my ($h, $s, @list) = @_;
	return packer(new Gtk::VBox($h, $s), @list);
}

sub hbox {
	my ($h, $s, @list) = @_;
	return packer(new Gtk::HBox($h, $s), @list);
}

sub main {
	Gtk->init();

	my $win = new Gtk::Window('-toplevel');
	$win->set_policy(0, 0, 0);
	$win->set_title("SMS send");

	my $tip = new Gtk::Tooltips();

	my $phone = new Gtk::Entry();
	$phone->set_editable(1);
	$phone->set_text($ARGV[0]) if defined $ARGV[0];
	$tip->set_tip($phone, "Recipient phone number\n(including dial prefix)");

	my $msg = new Gtk::Text(0, 0);
	$msg->set_editable(1);
	$msg->insert_text($ARGV[1]) if defined $ARGV[0];
	$msg->set_word_wrap(1);
	$tip->set_tip($msg, "SMS text message, maximum 160 characters.");

	my $send = new Gtk::Button("Send");
	$tip->set_tip($send, "Send message via IRDA phone");

	my $status = new Gtk::Label("idle");
	$status->set_justify('left');

	$msg->signal_connect('changed' => sub { 
		my $chars = length($msg->get_chars(0, -1));
		if ($chars > 160) {
			$status->set("$chars/160 *** too big ***");
		} else {
			$status->set("$chars/160");
		}
	});

	$send->signal_connect('clicked' => sub {
		$status->set("Sending...");
		my $ret = send_sms($phone->get_text(), $msg->get_chars(0, -1));
		$status->set($ret);
	});

	$win->signal_connect('destroy' => sub { exit 0 });

	if (defined $ARGV[0]) {
		$win->set_focus($msg);
	} else {
		$win->set_focus($phone);
	}

	$win->signal_connect('key_press_event' => sub {
		my ($event) = $_[1];
		my $string = $event->{'string'};
		if ($string eq "\t") {
			$_[0]->signal_emit_stop_by_name('key_press_event');
			if ($phone->has_focus()) {
				$win->set_focus($msg);
			} elsif ($msg->has_focus()) {
				$win->set_focus($send);
			} else {
				$win->set_focus($phone);
			}
			return 1;
		}
		return 0;
	});

	$win->add(
		vbox(0, 0,
			hbox(0, 0,
				new Gtk::Label("To: "),
				$phone,
				$send,
			),
			$msg,
			$status,
		)
	);
	$win->show();
	Gtk->main();
}

main();
exit 0;

Reply to: