#!/usr/bin/perl # Postfix # Copyright (C) 2003 Brian J. Murrell (brian@interlinx.bc.ca) # (based heavily on Damien's Netconfig) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # DrakX includes use lib qw(/usr/lib/libDrakX); use interactive; use common; use ugtk2 qw(:helpers :wrappers :create); # we include the Network Systemconf module use Libconf::System::Postfix; use Libconf::GUI::Gtk2 qw(:generators); # for debugging purpose use Data::Dumper; # we ask systemconf to give us the structure representing the global network config my $postfix = new Libconf::System::Postfix(); # we dump the content for debugging purpose print Data::Dumper->Dump([$postfix], ['postfix']) . "\n"; # we build the GUI # a window my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(delete_event => sub { ugtk2->exit(0) }); $window->set_position('center'); $window->set_title(N('postfix - Postfix main configuration')); # in the window, we add the widget generated by Libconf::GUI::Gtk2::generateWidget(), # an OK button that will save the modification in the network config files, # a Cancel button that will leave without saving. gtkadd($window, gtkpack_(Gtk2::VBox->new(0,10), 1, gtkshow(generateWidget($postfix)), 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'end'), gtksignal_connect(new Gtk2::Button(N("OK")), clicked => sub { save_exit(); }), gtksignal_connect(new Gtk2::Button(N("Cancel")), clicked => sub { cancel_exit(); }) ) ), ); # we make everything visible in the window $window->show_all(); #and we start the Gtk2 main loop. Gtk2->main; # After the user has clicked on one button, we dump the content of the sys_network structure for debugging purpose print Data::Dumper->Dump([$postfix], ['postfix']) . "\n"; #and we exit the program. ugtk2->exit(0); # the function called when the user clicks on the OK button sub save_exit { # we ask the $sys_network object to write itself back to the real config file # he knows everything about himself, so no need to give him any arg. # the file is rewritten, without loosing any information or comments. $postfix->writeconf(); # we exit the gtk2 main loop Gtk2->main_quit(); } # the function called when the user clicks on the Cancel button sub cancel_exit { # we exit the gtk2 main loop Gtk2->main_quit(); }