From 9b61ccddc84789af2656a9827fb65648506bc650 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 20 Feb 2010 22:37:38 +0000 Subject: added dropbox parameter gui has now same capability as command line diff --git a/gui_callbacks.pm b/gui_callbacks.pm index 2817b65..5675000 100644 --- a/gui_callbacks.pm +++ b/gui_callbacks.pm @@ -25,9 +25,18 @@ use strict; package gui_callbacks; -sub on_exit() +sub on_exit { + my ($widget, $data) = @_; + Gtk2->main_quit; } +sub on_b_ok_clicked +{ + my ($widget, $data) = @_; + + ::start_import_gui(); +} + 1; diff --git a/rhimport.glade b/rhimport.glade index e573dcb..0e2c931 100644 --- a/rhimport.glade +++ b/rhimport.glade @@ -128,6 +128,7 @@ True True True + False 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; diff --git a/rhimport_tools.pm b/rhimport_tools.pm new file mode 100644 index 0000000..eda2d79 --- /dev/null +++ b/rhimport_tools.pm @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w +# +# +# rhdropbox +# +# Copyright (C) 2009 Christian Pointner +# +# This file is part of rhdropbox. +# +# rhdropbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# rhdropbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rhdropbox. If not, see . +# + +use strict; + +package rhimport; + +sub start_import +{ + my ($m3u, $dropbox, $concat) = @_; + + print "Starting import from $m3u($concat) to $dropbox\n"; + + return 0; +} + +1; -- cgit v0.10.2