summaryrefslogtreecommitdiff
path: root/rhimport.pl
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-02-20 22:37:38 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-02-20 22:37:38 (GMT)
commit9b61ccddc84789af2656a9827fb65648506bc650 (patch)
tree0ab16e018b535dab5c31ee1354271be68029ff4a /rhimport.pl
parent279ed0997adda2200d0fd2d62229e8885b17bdb7 (diff)
added dropbox parameter
gui has now same capability as command line
Diffstat (limited to 'rhimport.pl')
-rwxr-xr-xrhimport.pl59
1 files changed, 47 insertions, 12 deletions
diff --git a/rhimport.pl b/rhimport.pl
index c5ef194..f477ee5 100755
--- a/rhimport.pl
+++ b/rhimport.pl
@@ -23,6 +23,8 @@
use strict;
+use rhimport_tools;
+
use Getopt::Long;
use DBI;
use Gtk2;
@@ -35,11 +37,13 @@ my $DB = "rivendell";
my $HELP = 0;
my $M3U = "";
my $DONTCONCAT = 0;
+my $DROPBOX = "";
my $LISTALLOWED = 0;
GetOptions ("help!" => \$HELP,
"m3u=s" => \$M3U,
"dont-concat!" => \$DONTCONCAT,
+ "dropbox=s" => \$DROPBOX,
"list-allowed!" => \$LISTALLOWED,
);
@@ -56,6 +60,8 @@ EOF
exit;
}
+my $CONCAT = 0;
+$CONCAT = 1 unless $DONTCONCAT;
my $user = $ENV{'USER'};
$user or die "Username not found in environment";
@@ -87,24 +93,31 @@ if($LISTALLOWED) {
###########################################
## GUI mode
-if(!$M3U) {
+my $guixml;
+
+if(!$M3U && !$DROPBOX) {
Gtk2->init;
- my $guixml = Gtk2::GladeXML->new('rhimport.glade');
+ $guixml = Gtk2::GladeXML->new('rhimport.glade');
$guixml or die "can't load glade xml file";
require gui_callbacks;
$guixml->signal_autoconnect_from_package('gui_callbacks');
- my $model = Gtk2::ListStore->new ('Glib::String');
+ my $model = Gtk2::ListStore->new('Glib::String');
for my $href ( @allowed_dbs ) {
$model->set ($model->append, 0, $href->{'PATH'});
}
- my $combo_db = $guixml->get_widget('co_dropbox');
- $combo_db->set_model($model);
+ my $co_dropbox = $guixml->get_widget('co_dropbox');
+ $co_dropbox->set_model($model);
my $renderer = Gtk2::CellRendererText->new;
- $combo_db->pack_start ($renderer, 1);
- $combo_db->add_attribute ($renderer, text => 0);
- $combo_db->set_active(0);
+ $co_dropbox->pack_start($renderer, 1);
+ $co_dropbox->add_attribute($renderer, text => 0);
+ $co_dropbox->set_active(0);
+
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*.m3u");
+ my $filechooser = $guixml->get_widget('filechooser');
+ $filechooser->set_filter($filter);
my $appwin = $guixml->get_widget('appwin');
$appwin or die "can't find Main Window";
@@ -115,15 +128,37 @@ if(!$M3U) {
exit 0;
}
+sub start_import_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
+ }
+
+ my $co_dropbox = $guixml->get_widget('co_dropbox');
+ my $dropbox = $co_dropbox->get_active_text;
+
+ my $filechooser = $guixml->get_widget('filechooser');
+ my $m3u = $filechooser->get_filename;
+
+ my $cb_concat = $guixml->get_widget('cb_concat');
+ my $concat = 1;
+ $concat = 0 unless $cb_concat->get_active;
+
+ rhimport::start_import($m3u, $dropbox, $concat);
+}
+
###########################################
## command line mode
(-e "$M3U") or die "file '$M3U' not found";
-if($DONTCONCAT) {
- print "Will import $M3U (seperate files), with user $user\n\n";
-} else {
+if($CONCAT) {
print "Will import $M3U (concatenated), with user $user\n\n";
+} else {
+ print "Will import $M3U (seperate files), with user $user\n\n";
}
+my $ret = rhimport::start_import($M3U, $DROPBOX, $CONCAT);
+
# $dbh->disconnect();
-exit 0;
+exit $ret;