Commit 279dafe2 authored by Nigel Kukard's avatar Nigel Kukard

* Initial support for Gtk frontend

parent eed42178
Installing on Cygwin:
Use CPAN to get, perl Makefile.PL CC="ccache gcc", make install
- Install perl-Glib-1.160
- Install perl-Cairo-1.042
- Install perl-Gtk2-1.160
Modify Makefile.PL, change find_extra_libs(), remove content, and add ...
return " -L/usr/lib/perl5/site_perl/5.8/cygwin/auto/Glib -lGlib";
#!/usr/bin/perl -w
# Author: Nigel Kukard <nkukard@lbsd.net>
# Date: 26/10/2006
# Desc: Sitemanager booter
# Desc: Wiaflos accounting booter
# License: GPL
use strict;
use Getopt::Long;
use wiaflos::version;
use wiaflos::client::cmdline;
print("Wiaflos Accounting - Admin Interface v$VERSION, Copyright (c) 2006-2007 LinuxRulz\n");
wiaflos::client::cmdline::execute();
# Grab options
my %optctl = ();
GetOptions(\%optctl,
"gtk",
"help"
) or exit 1;
# Check if user wants usage
if (defined($optctl{'help'})) {
displayUsage();
}
# Check which mode we starting in
my $mode = "cmdline";
if (defined($optctl{'gtk'})) {
$mode = "gtk";
}
printf(STDERR $APPSTRING."\n","[$mode Interface]");
# Load module & execute
my $res = eval("
use wiaflos::client::$mode;
wiaflos::client::${mode}::execute();
");
if ($@ || (defined($res) && $res != 0)) {
print(STDERR "Error loading interface $mode ($res:$@)\n");
}
# Display usage
sub displayUsage {
print(<<EOF);
Usage: $0
--gtk Use GTK+ interface
--quiet Be quiet when generating reports
EOF
exit 0;
}
# vim: ts=4
......@@ -20,7 +20,6 @@ our (@ISA,@EXPORT);
# Our vars
our (
$myLibs,
$cfg_soap_URI,
);
......@@ -36,25 +35,11 @@ while ((my $line = <CFG>)) {
# Parse config variables
if ($line =~ /^soap_uri=(\S+)/i) {
$cfg_soap_URI = $1;
} elsif ($line =~ /^Lib=(\S+)/i) {
$myLibs = $1;
}
}
close(CFG);
# Check config
if (!$myLibs) {
print("Error: Lib=xxx must be specified in ~/.wiaflos\n");
exit 1;
} else {
# Pull in using eval() so we don't generate a compile-time error
eval("use lib (\"$myLibs\");");
}
1;
# vim: ts=4
# Author: Nigel Kukard <nkukard@lbsd.net>
# Date: 2007-09-30
# Desc: Gtk user interface
# License: GPL
package wiaflos::client::gtk;
use strict;
# Exporter stuff
require Exporter;
our (@ISA,@EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
execute
);
use wiaflos::version;
use wiaflos::client::config;
use wiaflos::client::soap;
use wiaflos::client::misc;
use SOAP::Lite;
sub menuitem_cb {
my ($callback_data, $callback_action, $widget) = @_;
my $dialog = Gtk2::MessageDialog->new ($callback_data,
'destroy-with-parent',
'info',
'close',
sprintf "You selected or toggled the menu item: \"%s\"",
Gtk2::ItemFactory->path_from_widget ($widget));
# Close dialog on user response
$dialog->signal_connect (response => sub { $dialog->destroy; 1 });
$dialog->show;
}
# Start everything up
sub ui_start
{
use Glib ':constants';
use Gtk2;
# Init Gtk
Gtk2->init();
my $window = Gtk2::Window->new('toplevel');
$window->set_title(sprintf($APPSTRING,""));
# Setup signals
$window->signal_connect(
'destroy' => sub {
Gtk2->main_quit; 1;
}
);
$window->maximize();
# Create table
my $table = Gtk2::Table->new(1, 4, FALSE);
$window->add($table);
# Create menubar
my $accel_group = Gtk2::AccelGroup->new;
$window->add_accel_group($accel_group);
my $item_factory = Gtk2::ItemFactory->new ("Gtk2::MenuBar", "<main>", $accel_group);
# Set up item factory to go away with the window
$window->{'<main>'} = $item_factory;
# Create menu items
my @menu_items = (
[ "/_File", undef, undef, 0, "<Branch>" ],
[ "/File/_Quit", "<control>Q", sub { Gtk2->main_quit; }, 0, "<StockItem>", 'gtk-quit' ],
);
$item_factory->create_items ($window, @menu_items);
# Attach menu
$table->attach($item_factory->get_widget ("<main>"),
# X direction Y direction
0, 1, 0, 1,
[qw/expand fill/], [],
0, 0);
$window->show_all();
Gtk2->main();
}
sub execute
{
ui_start;
}
......@@ -16,15 +16,17 @@ our (@ISA,@EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
$VERSION
$APPSTRING
);
# Our vars
our (
$VERSION
$VERSION,
$APPSTRING
);
$VERSION = "0.0.5";
$APPSTRING = "Wiaflos Accounting - %s v$VERSION, Copyright (c) 2006-2007 LinuxRulz";
1;
# vim: ts=4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment