From 8af1b296289e6b20b8c36aff5c719c05943f3d12 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Fri, 22 Nov 2013 23:11:41 +0100 Subject: Added AboutDialog TODO fix text and mail presentation and link --- AdminPanel/Shared.pm | 208 ++++++++++++++++++++++++++++++++++++++++++ modules/rpmdragora/rpmdragora | 25 ++++- 2 files changed, 230 insertions(+), 3 deletions(-) diff --git a/AdminPanel/Shared.pm b/AdminPanel/Shared.pm index 6f4f703..77f1d1b 100644 --- a/AdminPanel/Shared.pm +++ b/AdminPanel/Shared.pm @@ -32,6 +32,7 @@ our @EXPORT = qw(warningMsgBox infoMsgBox ask_YesOrNo ask_OkCancel + AboutDialog trim); sub warningMsgBox { @@ -144,6 +145,209 @@ sub ask_YesOrNo { return $retVal; } +sub AboutDialog { + my ($opts) = @_; + + # Credits dialog + sub Credits { + my ($opts) = @_; + + my $factory = yui::YUI::widgetFactory; + my $optional = yui::YUI::optionalWidgetFactory; + + my $licensedlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($licensedlg); + + # header + $factory->createHBox($layout); + my $hbox = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox); + $hbox = $factory->createHBox($align); + $factory->createHeading($hbox, N("Credits")); + + # Credits tab widget + if ($optional->hasDumbTab()) { + $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + my $dumptab = $optional->createDumbTab($align); + my $item = new yui::YItem(N("Written by")); + $item->setSelected(); + $dumptab->addItem( $item ); + $item->DISOWN(); + if (exists $opts->{documenters}) { + $item = new yui::YItem(N("Documented by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + if (exists $opts->{translator_credits}) { + $item = new yui::YItem(N("Translated by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + if (exists $opts->{artists}) { + $item = new yui::YItem(N("Artwork by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + my $vbox = $factory->createVBox($dumptab); + $align = $factory->createLeft($vbox); + $factory->createVSpacing($vbox, 1.0); + my $label = $factory->createRichText( $align, "***", 1); + $factory->createVSpacing($vbox, 1.0); + + # start value for first Item + $label->setValue($opts->{authors}) if exists $opts->{authors}; + + # Close button + $align = $factory->createRight($layout); + my $closeButton = $factory->createPushButton($align, N("Close")); + + # manage Credits dialog events + while(1) { + my $event = $licensedlg->waitForEvent(); + my $eventType = $event->eventType(); + + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + + if ($widget == $closeButton) { + last; + } + } + elsif ($event->item() ) { + # $eventType MenuEvent!!! + my $itemLabel = $event->item()->label(); + $itemLabel =~ s/&//; #remove shortcut from label + if ($itemLabel eq N("Written by")) { + $label->setValue($opts->{authors}) if exists $opts->{authors}; + } + elsif ($itemLabel eq N("Documented by")) { + $label->setValue($opts->{documenters}) if exists $opts->{documenters}; + } + elsif ($itemLabel eq N("Translated by")) { + $label->setValue($opts->{translator_credits}) if exists $opts->{translator_credits}; + } + elsif ($itemLabel eq N("Artwork by")) { + $label->setValue($opts->{artists}) if exists $opts->{artists}; + } + } + } + } + else { + print "No tab widgets available!\n"; + } + destroy $licensedlg; + } + + # License dialog + sub License { + my ($license) = @_; + + my $factory = yui::YUI::widgetFactory; + my $licensedlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($licensedlg); + + # header + $factory->createHBox($layout); + my $hbox = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox); + $hbox = $factory->createHBox($align); + $factory->createHeading($hbox, N("License")); + + # license + $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + $factory->createRichText( $align, $license, 1); + + $align = $factory->createRight($layout); + my $closeButton = $factory->createPushButton($align, N("Close")); + + $licensedlg->waitForEvent(); + + destroy $licensedlg; + } + + my $website = "http://www.mageia.org"; + my $website_label = "Mageia"; + my $factory = yui::YUI::widgetFactory; + my $aboutdlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($aboutdlg); + + # header + $factory->createHBox($layout); + my $hbox_iconbar = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox_iconbar); + $hbox_iconbar = $factory->createHBox($align); + $factory->createImage($hbox_iconbar, $opts->{logo}) if exists $opts->{logo}; + my $header = $opts->{name} . " " . $opts->{version}; + $factory->createHeading($hbox_iconbar, $header); + + # comments + my $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + $factory->createLabel( $align, $opts->{comments}, 0, 0) if exists $opts->{comments}; + + # copyright + $hbox = $factory->createHBox($layout); + $align = $factory->createHVCenter($hbox); + $factory->createLabel( $align, $opts->{copyright}, 0, 0) if exists $opts->{copyright}; + + # website / website_label + $hbox = $factory->createHBox($layout); + $align = $factory->createHVCenter($hbox); + $website = $opts->{website} if exists $opts->{website}; + $website_label = $opts->{website_label} if exists $opts->{website_label}; + my $webref = "". $website_label .""; + $factory->createRichText( $align, $webref); + + # Credits, License and Close buttons + $hbox = $factory->createHBox($layout); + $align = $factory->createLeft($hbox); + my $hbox1 = $factory->createHBox($align); + my $creditsButton = $factory->createPushButton($hbox1, N("Credits")); + my $licenseButton = $factory->createPushButton($hbox1, N("License")); + $factory->createHSpacing($hbox, 2.0); + $align = $factory->createRight($hbox); + my $closeButton = $factory->createPushButton($align, N("Close")); + + # AboutDialog Events + while(1) { + my $event = $aboutdlg->waitForEvent(); + my $eventType = $event->eventType(); + + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + + if($widget == $licenseButton) { + License($opts->{license}) if exists $opts->{license}; + } + elsif ($widget == $creditsButton) { + Credits($opts); + } + elsif ($widget == $closeButton) { + last; + } + } + elsif ($eventType == $yui::YEvent::MenuEvent) { + my $menuEvent = yui::YMGAWidgetFactory::getYMenuEvent($event); + #TODO check why is not working + run_program::raw({ detach => 1 }, 'www-browser', $menuEvent->id()); + } + } + + destroy $aboutdlg; +} + sub trim { my ($st) = shift; $st =~s /^\s+//g; @@ -172,6 +376,10 @@ sub trim { shows a message box for informations +=head2 AboutDialog + + shows an About Dialog box + =head2 ask_YesOrNo shows a dialog with two buttons (Yes/No) diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index 046c70d..bab4cd9 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -38,6 +38,7 @@ use AdminPanel::Rpmdragora::localization; use AdminPanel::Rpmdragora::init; use standalone; #- standalone must be loaded very first, for 'explanations', but after rpmdragora::init use AdminPanel::rpmdragora; +use AdminPanel::Shared; use AdminPanel::Rpmdragora::open_db; use AdminPanel::Rpmdragora::gui; use AdminPanel::Rpmdragora::rpmnew; @@ -1071,14 +1072,32 @@ sub run_treeview_dialog { else { ### any other events if ($event->item()) { - # print $event->item()->label() . "\n"; # items - if ($event->item()->label() eq $mnuItemExit->label()) { + my $itemLabel = $event->item()->label(); + #print "----- " . $itemLabel . "\n"; + if ($itemLabel eq $mnuItemExit->label()) { #menu File->Quit quit(); last; } - } + elsif ($itemLabel eq N("About")) { + my $license = formatAlaTeX(translate($::license)); + $license =~ s/\n/\n\n/sg; # nicer formatting + AboutDialog({ name => N("Rpmdragora"), + version => $Rpmdragora::init::version, + copyright => N("Copyright (C) %s by Mandriva", '2002-2009'), + license => $license, + comments => N("Rpmdragora is the Mageia package management tool."), + website => 'http://www.mageia.org', + website_label => N("Mageia"), + authors => 'Thierry Vignaud \nAngelo Naselli \nMatteo Pasotti ', + artists => 'Hélène Durosini ', + translator_credits => + #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith ") + N("_: Translator(s) name(s) & email(s)\n")} + ); + } + } } } -- cgit v1.2.1