summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-02-22 22:27:52 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-02-22 22:27:52 (GMT)
commitcd12fd737768df244344bfa198838b2feff10377 (patch)
tree79eb6d52cdcab1e45a96a52d9c5393869bcc5f4f
parent88f86102d9bf801c410a7043937891edaabc1f6d (diff)
changed to pool/nopool setup
no concat anymore git-svn-id: https://svn.helsinki.at/rhimport/trunk@19 7c65635b-ec39-4f67-a626-873dbafdd612
-rw-r--r--gui_callbacks.pm7
-rwxr-xr-xrhimport82
-rw-r--r--rhimport.glade55
-rw-r--r--rhimport.pm17
4 files changed, 107 insertions, 54 deletions
diff --git a/gui_callbacks.pm b/gui_callbacks.pm
index 05b6adf..dd2291d 100644
--- a/gui_callbacks.pm
+++ b/gui_callbacks.pm
@@ -32,6 +32,13 @@ sub on_exit
Gtk2->main_quit;
}
+sub on_cb_pool_toggled
+{
+ my ($widget, $data) = @_;
+
+ ::change_pool_gui();
+}
+
sub on_b_apply_clicked
{
my ($widget, $data) = @_;
diff --git a/rhimport b/rhimport
index 94b367e..82823f6 100755
--- a/rhimport
+++ b/rhimport
@@ -36,25 +36,25 @@ my $DBUSER = "rivendellro";
my $DBPW = "lldrivenro";
my $DB = "rivendell";
my $HELP = 0;
-my $M3U = "";
-my $DONTCONCAT = 0;
+my $FILE = "";
+my $POOL = 0;
my $DROPBOX = "";
my $LISTALLOWED = 0;
GetOptions ("help!" => \$HELP,
- "m3u=s" => \$M3U,
- "dont-concat!" => \$DONTCONCAT,
+ "file=s" => \$FILE,
+ "pool!" => \$POOL,
"dropbox=s" => \$DROPBOX,
"list-allowed!" => \$LISTALLOWED,
);
if($HELP) {
print << "EOF";
-usage: $0 --m3u <playlist file> --dont-concat
+usage: $0 --file <audio or playlist file> --pool --dropbox <path to dropbox> --list-allowed
options:
- --m3u the playlist file to import
- --dont-concat dont concat the audio files, import as seperate files
+ --file the media file or playlist to import
+ --pool pool mode, import media files referneced by playlist
--dropbox the path to the dropbox to use
--list-allowed list allowed dropboxes and exit
@@ -62,8 +62,6 @@ EOF
exit;
}
-my $CONCAT = 0;
-$CONCAT = 1 unless $DONTCONCAT;
my $user = $ENV{'USER'};
$user or die "Username not found in environment";
@@ -97,7 +95,7 @@ if($LISTALLOWED) {
my $guixml;
-if(!$M3U && !$DROPBOX) {
+if(!$FILE && !$DROPBOX) {
Gtk2->init;
$guixml = Gtk2::GladeXML->new('rhimport.glade');
@@ -116,11 +114,6 @@ if(!$M3U && !$DROPBOX) {
$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";
$appwin->resize(800,600);
@@ -131,6 +124,30 @@ if(!$M3U && !$DROPBOX) {
exit 0;
}
+sub change_pool_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
+ }
+
+ my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ my $filechooser = $guixml->get_widget('filechooser');
+
+ my $cb_pool = $guixml->get_widget('cb_pool');
+ if($cb_pool->get_active) {
+ $l_file_playlist->set_label("<b>Playlist</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*.m3u");
+ $filechooser->set_filter($filter);
+ } else {
+ $l_file_playlist->set_label("<b>File</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*");
+ $filechooser->set_filter($filter);
+ }
+}
+
sub start_import_gui()
{
if(!$guixml) {
@@ -141,8 +158,8 @@ sub start_import_gui()
my $l_status = $guixml->get_widget('l_status');
my $filechooser = $guixml->get_widget('filechooser');
- my $m3u = $filechooser->get_filename;
- if(!$m3u || -d $m3u) {
+ my $file = $filechooser->get_filename;
+ if(!$file || -d $file) {
$l_status->set_label("No Playlist selected!");
return 0;
}
@@ -151,28 +168,35 @@ sub start_import_gui()
my $co_dropbox = $guixml->get_widget('co_dropbox');
my $dropbox = $co_dropbox->get_active_text;
- my $cb_concat = $guixml->get_widget('cb_concat');
- my $concat = 1;
- $concat = 0 unless $cb_concat->get_active;
+ $l_status->set_label("importing from $file");
- $l_status->set_label("importing from $m3u");
-
- rhimport::start_import($m3u, $dropbox, $concat);
+ my $cb_pool = $guixml->get_widget('cb_pool');
+ my $ret;
+ if($cb_pool->get_active) {
+ $ret = rhimport::import_playlist($file, $dropbox);
+ } else {
+ $ret = rhimport::import_file($file, $dropbox);
+ }
- return 0;
+ return $ret;
}
###########################################
## command line mode
-(-e "$M3U") or die "file '$M3U' not found";
-if($CONCAT) {
- print "Will import $M3U (concatenated), with user $user\n\n";
+(-e "$FILE") or die "file '$FILE' not found";
+if($POOL) {
+ print "Will import from playlist $FILE, with user $user\n\n";
} else {
- print "Will import $M3U (seperate files), with user $user\n\n";
+ print "Will import $FILE, with user $user\n\n";
}
-my $ret = rhimport::start_import($M3U, $DROPBOX, $CONCAT);
+my $ret;
+if($POOL) {
+ $ret = rhimport::import_playlist($FILE, $DROPBOX);
+} else {
+ $ret = rhimport::import_file($FILE, $DROPBOX);
+}
# $dbh->disconnect();
exit $ret;
diff --git a/rhimport.glade b/rhimport.glade
index 16e83bc..a4d6503 100644
--- a/rhimport.glade
+++ b/rhimport.glade
@@ -28,20 +28,22 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
- <widget class="GtkLabel" id="l_dropbox">
+ <widget class="GtkHSeparator" id="hseparator">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="label">&lt;b&gt;Dropbox&lt;/b&gt;</property>
- <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkComboBox" id="co_dropbox">
+ <widget class="GtkLabel" id="l_dropbox">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label">&lt;b&gt;Dropbox&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -49,11 +51,8 @@
</packing>
</child>
<child>
- <widget class="GtkLabel" id="l_playlist">
+ <widget class="GtkComboBox" id="co_dropbox">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="label">&lt;b&gt;Playlist&lt;/b&gt;</property>
- <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -61,25 +60,26 @@
</packing>
</child>
<child>
- <widget class="GtkFileChooserWidget" id="filechooser">
+ <widget class="GtkCheckButton" id="cb_pool">
+ <property name="label" translatable="yes">Musik Pool</property>
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="use_preview_label">False</property>
- <property name="preview_widget_active">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0.46000000834465027</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_cb_pool_toggled"/>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="cb_concat">
- <property name="label" translatable="yes">Musikdateien zusammenf&#xFC;gen</property>
+ <widget class="GtkLabel" id="l_file_playlist">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="xalign">0.46000000834465027</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
+ <property name="sensitive">False</property>
+ <property name="label">&lt;b&gt;File&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -87,13 +87,24 @@
</packing>
</child>
<child>
+ <widget class="GtkFileChooserWidget" id="filechooser">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="preview_widget_active">False</property>
+ <property name="use_preview_label">False</property>
+ </widget>
+ <packing>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="sensitive">False</property>
</widget>
<packing>
<property name="expand">False</property>
- <property name="position">5</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
@@ -140,7 +151,7 @@
</widget>
<packing>
<property name="expand">False</property>
- <property name="position">6</property>
+ <property name="position">7</property>
</packing>
</child>
</widget>
diff --git a/rhimport.pm b/rhimport.pm
index 064a8ad..512652b 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -25,11 +25,22 @@ use strict;
package rhimport;
-sub start_import
+sub import_playlist
{
- my ($m3u, $dropbox, $concat) = @_;
+ my ($playlist, $dropbox) = @_;
+
+ print "Starting import from playlist $playlist to $dropbox\n";
+
+
+ return 0;
+}
+
+sub import_file
+{
+ my ($file, $dropbox) = @_;
+
+ print "Starting import from $file to $dropbox\n";
- print "Starting import from $m3u($concat) to $dropbox\n";
return 0;
}