#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);
use common;
use standalone;

# i18n: IMPORTANT: to get correct namespace (drakconf instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakoo' }
use ugtk2 qw(:all);

my $file = "$ENV{HOME}/.oofficerc";

my %config;

eval { %config = getVarsFromSh($file) };




my %l10n = (
            calc => {
                     title => N("Use OpenOffice.org Calc or the Microsoft® Excel file format?"),
                     text =>
                     #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
                     N("OpenOffice.org Calc can save your documents in the Microsoft® Excel file format or in its own file format. If you frequently have to send documents to people who use Microsoft® Excel, it is a good idea to choose to save your documents using the Microsoft® Excel file format by default.


Be warned that the Microsoft® Excel file format is not fully supported. You could lose some document formatting."),
                     
                     buttons => [
                                 N("Use the Microsoft® Excel file format"),
                                 N("Use the OpenOffice.org Calc file format"),
                                ],
                    },
            
            impress => 
            {
             title => N("Use OpenOffice.org Impress or the Microsoft® PowerPoint file format?"),
             text =>
             #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
             N("OpenOffice.org Impress can save your documents in the Microsoft® PowerPoint file format or in its own file format. If you frequently have to send documents to people who use Microsoft® PowerPoint, it is a good idea to choose to save your documents using the Microsoft® PowerPoint file format by default.


Be warned that the Microsoft® PowerPoint file format is not fully supported. You could lose some document formatting."),

             buttons => [
                         N("Use the Microsoft® PowerPoint file format"),
                         N("Use the OpenOffice.org Impress file format"),
                        ],
            },

            writer =>
            {
             title => N("Use OpenOffice.org Writer or the Microsoft® Word file format?"),
             text =>
             #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
              N("OpenOffice.org Writer can save your documents in the Microsoft® Word file format or in its own file format. If you frequently have to send documents to people who use Microsoft® Word, it is a good idea to choose to save your documents using the Microsoft® Word file format by default.


Be warned that the Microsoft® Word file format is not fully supported. You could lose some document formatting."),

             buttons => [
                         N("Use the Microsoft® Word file format"),
                         N("Use the OpenOffice.org Writer file format"),
                        ],
            },
           );

my %entries =
  (
   writer => "DOC_DEFAULTS_WRITER",
   calc => "DOC_DEFAULTS_CALC",
   impress => "DOC_DEFAULTS_IMPRESS",
  );
#    = MS|NATIVE

my $program = $ARGV[0];

my $icon = $ugtk2::wm_icon = (glob_("/usr/share/pixmaps/ooo-${program}2*.png"))[0];


if (!$program) {
    err_dialog(N("Error"), N("No action was requested"));
    exit(1);
}

if (!member($program, qw(calc impress writer))) {
    err_dialog(N("Error"), N("The \"%s\" program is unknown", $program));
    exit(1);
}


my $w = ugtk2->new(N("OpenOffice.org wizard"));
$w->{window}->set_size_request(-1, -1);


my @size = (500, -1);

$w->{window}->set_resizable(0);

gtkadd($w->{window},
       gtkpack_(Gtk2::VBox->new,
                1, gtkpack_(Gtk2::HBox->new,
                            0, gtkpack_(gtkset_border_width(Gtk2::VBox->new, 20),
					0, gtkcreate_img($icon),
					),
                            1, gtkpack_(gtkset_border_width(Gtk2::VBox->new, 10),
                                        0, gtkset_markup(gtkset_size_request(Gtk2::WrappedLabel->new, @size),
                                                         qq(<span weight="bold">) . formatAlaTeX($l10n{$program}{title}) . "</span>\n"),
                                        1, gtkset_size_request(Gtk2::WrappedLabel->new(formatAlaTeX($l10n{$program}{text})), @size),
                                       ),
                           ),
                0, gtkpack_(create_hbox('edge'),
                            0, gtksignal_connect(gtkadd(Gtk2::Button->new_with_label($l10n{$program}{buttons}[0])),
                                                 clicked => sub {
                                                     $config{$entries{$program}} = "MS";
                                                     Gtk2->main_quit;
                                                 }),
                            0, gtksignal_connect(my $default = gtkadd(Gtk2::Button->new, 
                                                                      gtkset_markup(Gtk2::Label->new,
                                                                                    #'<span weight="bold">' .
                                                                                    $l10n{$program}{buttons}[1]
                                                                                    # . '</span>'
                                                                                   ),
                                                                     ),

                                                 clicked => sub {
                                                     $config{$entries{$program}} = "NATIVE";
                                                     Gtk2->main_quit;
                                                 }),
                           ),
               ),
      );

$default->set_use_underline(1);
$default->grab_focus;

$w->{window}->show_all;
$w->main;
      
setVarsInSh($file, \%config);
              
