summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
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
}