# -*- perl -*-
package Pronto::Widget;
use strict;

sub determine_widget
{
	my ($tmp,$tmpinstalled);
	$tmpinstalled=0;
	$tmp = "use Csc::HTML;";
	eval $tmp; $tmpinstalled =1 unless $@;
	if ($tmpinstalled == 1) {
		$main::HTMLWIDGET = "CscHTML";
		return 1;
	} else {
		$tmp = "use Gtk::HTML;";
		eval $tmp; $tmpinstalled = 1 unless $@;
		if ($tmpinstalled == 1) {
			$main::HTMLWIDGET = "GtkHTML";
			return 1;
		} else {
			$tmp = "use Gtk::XmHTML;";
			eval $tmp; $tmpinstalled = 1 unless $@;
			if ($tmpinstalled == 1) {
				require "HtmlStripper.pm";
				$main::HTMLWIDGET = "XmHTML";
				return 1;
			} else {
				$main::HTMLWIDGET = "text";
				return 1;
			}
		}
	}	
	return 1;
}


sub init_widget 
{

	if ($main::HTMLWIDGET eq "GtkHTML") {
	 	init Gtk::HTML;
	} elsif ($main::HTMLWIDGET eq "CscHTML") {
		init Csc::HTML;
	} elsif ($main::HTMLWIDGET eq "XmHTML") {
		my ($tmp,$tmpinstalled);
		$tmpinstalled=0;
		$tmp = "init Gtk::XmHTML;";
		eval $tmp; $tmpinstalled = 1 unless $@;
		if ($tmpinstalled == 1) { 
			init Gtk::XmHTML; 
		} else { 
			print(_("Failed to Initlize XmHTML, Falling back to the text widget\n"));
			$main::HTMLWIDGET = "text"; 
       		}	
	}	
}

1;
