summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-03-24 14:21:08 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-03-24 14:21:08 (GMT)
commit20f753dec4fa15abc9e7bd685d6666a3ce2e20e7 (patch)
tree889d4f7b73fbf1b2ca9bc325026cca9014f6a023 /rhimport
parent35aa26e2a79aa7ece3346661233de40e0a494058 (diff)
added progress bar
git-svn-id: https://svn.helsinki.at/rhimport/trunk@25 7c65635b-ec39-4f67-a626-873dbafdd612
Diffstat (limited to 'rhimport')
-rwxr-xr-xrhimport55
1 files changed, 46 insertions, 9 deletions
diff --git a/rhimport b/rhimport
index 26cea0f..5f5dfa0 100755
--- a/rhimport
+++ b/rhimport
@@ -48,18 +48,20 @@ GetOptions ("help!" => \$HELP,
"keep-carts!" => \$KEEPCARTS,
"dropbox=s" => \$DROPBOX,
"list-allowed!" => \$LISTALLOWED,
- );
+ ) or die();
if($HELP) {
print << "EOF";
usage: $0 --file <audio or playlist file> --pool --keep-carts --dropbox <path to dropbox> --list-allowed
+When called with no file and/or no dropbox the GUI gets started to select the missing parameters
+
options:
- --file the media file or playlist to import
- --pool pool mode, import media files referneced by playlist
- --keep-carts in pool mode keep existing carts instead of clearing them before import
- --dropbox the path to the dropbox to use
- --list-allowed list allowed dropboxes and exit
+ -f | --file the media file or playlist to import
+ -p | --pool pool mode, import media files referneced by playlist
+ -k | --keep-carts in pool mode keep existing carts instead of clearing them before import
+ -d | --dropbox the path to the dropbox to use
+ -l | --list-allowed list allowed dropboxes and exit
EOF
exit;
@@ -133,6 +135,22 @@ sub toggle_mode_gui()
}
}
+my $gui_progress_cb = sub {
+ my ($elapsed, $max, $text) = @_;
+
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
+ }
+ my $progressbar = $guixml->get_widget('progressbar');
+ $progressbar->set_text("($elapsed/$max) $text");
+ $progressbar->set_fraction($elapsed/$max);
+ while (Gtk2->events_pending) {
+ Gtk2->main_iteration;
+ }
+ Gtk2::Gdk->flush;
+};
+
sub start_import_gui()
{
if(!$guixml) {
@@ -166,9 +184,13 @@ sub start_import_gui()
if($cb_clear_carts->get_active) {
rhimport::clear_carts($dbh, $group);
}
- $ret = rhimport::import_playlist($file, $dropbox);
+ $ret = rhimport::import_playlist($file, $dropbox, $gui_progress_cb);
} else {
- $ret = rhimport::import_single($file, $dropbox);
+ $ret = rhimport::import_single($file, $dropbox, $gui_progress_cb);
+ }
+
+ if($ret) {
+ $l_status->set_label("Fehler beim Importieren");
}
return $ret;
@@ -199,6 +221,21 @@ sub show_used_carts_gui()
# $usedcartswin->show;
}
+sub clear_status_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
+ }
+
+ my $l_status = $guixml->get_widget('l_status');
+ $l_status->set_label("");
+
+ my $progressbar = $guixml->get_widget('progressbar');
+ $progressbar->set_text("");
+ $progressbar->set_fraction(0);
+}
+
if(!$FILE || !$DROPBOX) {
Gtk2->init;
@@ -259,7 +296,7 @@ for my $href (@allowed_dbs) {
}
if($group eq '') {
- print "Dropbox not found or not allowed";
+ print "Dropbox not found or not allowed\n";
exit 1
}