From 31f268b173eb42b2b2ada15003e43669dcc26b97 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 19 Apr 2010 10:34:41 +0000 Subject: added message dialog at import end disabling buttons while importing diff --git a/rhimport b/rhimport index 8670f12..1ef55d3 100755 --- a/rhimport +++ b/rhimport @@ -220,12 +220,19 @@ sub start_import_gui() exit 2; } + my $b_apply = $guixml->get_widget('b_apply'); + my $b_close = $guixml->get_widget('b_close'); + $b_apply->set_sensitive(0); + $b_close->set_sensitive(0); + if(!rhimport::check_key_file()) { my $parent_window = $guixml->get_widget('appwin'); my $dialog = Gtk2::MessageDialog->new ($parent_window, 'destroy-with-parent', 'error', 'ok', "Es wurde kein Import Key gefunden."); $dialog->run; $dialog->destroy; + $b_apply->set_sensitive(1); + $b_close->set_sensitive(1); return 0; } @@ -239,6 +246,8 @@ sub start_import_gui() } else { $l_status->set_label("Keine Audio Datei ausgewählt!"); } + $b_apply->set_sensitive(1); + $b_close->set_sensitive(1); return 0; } $filechooser->unselect_all; @@ -255,18 +264,34 @@ sub start_import_gui() if($POOL) { my $cb_clear_carts = $guixml->get_widget('cb_clear_carts'); if($cb_clear_carts->get_active) { - rhimport::clear_carts($dbh, $group, $to_cart, $gui_progress_cb); + $log = rhimport::clear_carts($dbh, $group, $to_cart, $gui_progress_cb); } - ($ret, $log) = rhimport::import_playlist($file, $dropbox, $gui_progress_cb, $gui_error_cb); + my $import_log; + ($ret, $import_log) = rhimport::import_playlist($file, $dropbox, $gui_progress_cb, $gui_error_cb); + $log .= $import_log; } else { - rhimport::clear_carts($dbh, $group, $to_cart, $gui_progress_cb); - ($ret, $log) = rhimport::import_single($file, $dropbox, $gui_progress_cb, $gui_error_cb); + $log = rhimport::clear_carts($dbh, $group, $to_cart, $gui_progress_cb); + my $import_log; + ($ret, $import_log) = rhimport::import_single($file, $dropbox, $gui_progress_cb, $gui_error_cb); + $log .= $import_log; } + my $parent_window = $guixml->get_widget('appwin'); + my $dialog; if(!$ret) { $l_status->set_label("Fehler beim Importieren"); + $dialog = Gtk2::MessageDialog->new ($parent_window, 'destroy-with-parent', + 'error', 'ok', "Fehler beim Importieren."); + } else { + $l_status->set_label(""); + $dialog = Gtk2::MessageDialog->new ($parent_window, 'destroy-with-parent', + 'info', 'ok', "Der Import wurde erfolgreich abgeschlossen!"); } + $dialog->run; + $dialog->destroy; + $b_apply->set_sensitive(1); + $b_close->set_sensitive(1); return $ret; } @@ -405,13 +430,17 @@ my $ret; my $log; if($POOL) { if(!$KEEPCARTS) { - rhimport::clear_carts($dbh, $group, $to_cart); + $log = rhimport::clear_carts($dbh, $group, $to_cart); } - ($ret, $log) = rhimport::import_playlist($FILE, $DROPBOX, 0, $cl_error_cb); + my $import_log; + ($ret, $import_log) = rhimport::import_playlist($FILE, $DROPBOX, 0, $cl_error_cb); + $log .= $import_log; } else { - rhimport::clear_carts($dbh, $group, $to_cart); - ($ret, $log) = rhimport::import_single($FILE, $DROPBOX, 0); + $log = rhimport::clear_carts($dbh, $group, $to_cart); + my $import_log; + ($ret, $import_log) = rhimport::import_single($FILE, $DROPBOX, 0); + $log .= $import_log; } $dbh->disconnect(); diff --git a/rhimport.pm b/rhimport.pm index df67f74..948d675 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -117,7 +117,8 @@ sub clear_carts ($low_cart, $high_cart) = get_cart_range($dbh, $group); } - print "clearing Carts $low_cart - $high_cart\n"; + my $log = "clearing Carts $low_cart - $high_cart\n"; + print $log; my $cart = $low_cart; while($cart <= $high_cart) { $progress_cb->($cart - $low_cart, $high_cart + 1 - $low_cart, "deleting $cart") if($progress_cb); @@ -127,6 +128,7 @@ sub clear_carts $sth->execute(); while(my $cut_name = $sth->fetchrow_array()) { delete_file("/var/snd/$cut_name.wav"); + $log .= " - deleting file /var/snd/$cut_name.wav"; } $sth->finish(); @@ -142,6 +144,8 @@ sub clear_carts $cart++; } + + return $log; } sub import_playlist -- cgit v0.10.2