aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AdminPanel/Shared.pm208
-rwxr-xr-xmodules/rpmdragora/rpmdragora36
2 files changed, 236 insertions, 8 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 = "<a href=\"". $website ."\">". $website_label ."</a>";
+ $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 5494f89..f11c2f7 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;
@@ -51,7 +52,9 @@ use AdminPanel::Rpmdragora::widgets;
use feature 'state';
# OLD $ugtk2::wm_icon = get_icon('installremoverpm', "title-$MODE");
-my $wm_icon = "/usr/share/mcc/themes/default/installremoverpm.png";
+#TODO fix $wm_resource_path
+my $wm_resource_path="/usr/share/rpmdrake/icons";
+my $wm_icon = "$wm_resource_path"."/title-$MODE.png";
# Declarations
my $my_win;
@@ -374,10 +377,9 @@ sub run_treeview_dialog {
my $hbox_iconbar = $factory->createHBox($vbox);
$head_align_left = $factory->createLeft($hbox_iconbar);
$hbox_iconbar = $factory->createHBox($head_align_left);
- # TODO manage MODE for title and icon
- $factory->createImage($hbox_iconbar, "/usr/share/rpmdrake/icons/title-install.png");
- $factory->createHeading($hbox_iconbar, N("Software Management"));
-# Gtk2::Banner->new($ugtk2::wm_icon, $::MODE eq 'update' ? N("Software Packages Update") : N("Software Management"))
+ $factory->createImage($hbox_iconbar, $wm_icon);
+
+ $factory->createHeading($hbox_iconbar, $::MODE eq 'update' ? N("Software Packages Update") : N("Software Management"));
my $hbox_top = $factory->createHBox($vbox);
my $hbox_middle = $factory->createHBox($vbox);
@@ -1076,14 +1078,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 <vignaud@mandriva.com>\nAngelo Naselli <anaselli@linux.it>\nMatteo Pasotti <matteo.pasotti@gmail.com>',
+ artists => 'Hélène Durosini <ln@mandriva.com>',
+ translator_credits =>
+ #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
+ N("_: Translator(s) name(s) & email(s)\n")}
+ );
+ }
+ }
}
}