summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-02-23 14:31:51 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-02-23 14:31:51 (GMT)
commitdf6aa6819f9ad30395682f7a257926beca0dfcf3 (patch)
treee5cf18dee01f5f96a5e74a559698172c96d4c520
parent0784f649410c1483886c0e4a0d805720fc408da9 (diff)
reenabled db stuff
moved to new gui with mode selector
-rw-r--r--gui_callbacks.pm6
-rwxr-xr-xrhimport135
-rw-r--r--rhimport.glade73
3 files changed, 137 insertions, 77 deletions
diff --git a/gui_callbacks.pm b/gui_callbacks.pm
index dd2291d..446094c 100644
--- a/gui_callbacks.pm
+++ b/gui_callbacks.pm
@@ -32,11 +32,11 @@ sub on_exit
Gtk2->main_quit;
}
-sub on_cb_pool_toggled
+sub on_b_mode_clicked
{
my ($widget, $data) = @_;
-
- ::change_pool_gui();
+
+ ::toggle_mode_gui();
}
sub on_b_apply_clicked
diff --git a/rhimport b/rhimport
index 82823f6..ee1f552 100755
--- a/rhimport
+++ b/rhimport
@@ -65,28 +65,25 @@ EOF
my $user = $ENV{'USER'};
$user or die "Username not found in environment";
-# my $dbh = DBI->connect( "DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr";
-# my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH from USER_PERMS, DROPBOXES where USER_PERMS.USER_NAME='$user' and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME;};
-# my $sth = $dbh->prepare($sql);
-# $sth->execute();
+my $dbh = DBI->connect( "DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr";
+my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH from USER_PERMS, DROPBOXES where USER_PERMS.USER_NAME='$user' and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME;};
+my $sth = $dbh->prepare($sql);
+$sth->execute();
my @allowed_dbs;
-push @allowed_dbs, { 'GROUP' => "groupa", 'PATH' => "/programm/dropboxA/" };
-push @allowed_dbs, { 'GROUP' => "groupb", 'PATH' => "/programm/dropboxB/" };
-push @allowed_dbs, { 'GROUP' => "groupc", 'PATH' => "/programm/dropboxC/" };
-# while(my ($group, $path) = $sth->fetchrow_array()) {
-# $path =~ s/\/\*$//;
-# my $perm = {};
-# $perm->{'GROUP'} = $group;
-# $perm->{'PATH'} = $path;
-# push @allowed_dbs, $perm;
-# }
-# $sth->finish();
+while(my ($group, $path) = $sth->fetchrow_array()) {
+ $path =~ s/\/\*$//;
+ my $perm = {};
+ $perm->{'GROUP'} = $group;
+ $perm->{'PATH'} = $path;
+ push @allowed_dbs, $perm;
+}
+$sth->finish();
if($LISTALLOWED) {
for my $href ( @allowed_dbs ) {
print "$href->{'PATH'}\n";
}
-# $dbh->disconnect();
+ $dbh->disconnect();
exit 0;
}
@@ -95,56 +92,48 @@ if($LISTALLOWED) {
my $guixml;
-if(!$FILE && !$DROPBOX) {
- Gtk2->init;
-
- $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');
- for my $href ( @allowed_dbs ) {
- $model->set ($model->append, 0, $href->{'PATH'});
+sub set_mode_playlist_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
}
- my $co_dropbox = $guixml->get_widget('co_dropbox');
- $co_dropbox->set_model($model);
- my $renderer = Gtk2::CellRendererText->new;
- $co_dropbox->pack_start($renderer, 1);
- $co_dropbox->add_attribute($renderer, text => 0);
- $co_dropbox->set_active(0);
-
- my $appwin = $guixml->get_widget('appwin');
- $appwin or die "can't find Main Window";
- $appwin->resize(800,600);
- $appwin->show;
- Gtk2->main;
-# $dbh->disconnect();
- exit 0;
+ $POOL = 1;
+ my $l_mode = $guixml->get_widget('l_mode');
+ $l_mode->set_label("<b>Musik Pool</b>");
+ my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ $l_file_playlist->set_label("<b>Playlist</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*.m3u");
+ my $filechooser = $guixml->get_widget('filechooser');
+ $filechooser->set_filter($filter);
}
-sub change_pool_gui()
+sub set_mode_file_gui()
{
if(!$guixml) {
print STDERR "no GUI definition found!\n";
exit 0;
}
-
+
+ $POOL = 0;
+ my $l_mode = $guixml->get_widget('l_mode');
+ $l_mode->set_label("<b>Sendung</b>");
my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ $l_file_playlist->set_label("<b>Datei</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*");
my $filechooser = $guixml->get_widget('filechooser');
+ $filechooser->set_filter($filter);
+}
- 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);
+sub toggle_mode_gui()
+{
+ if($POOL) {
+ set_mode_file_gui();
} else {
- $l_file_playlist->set_label("<b>File</b>");
- my $filter = Gtk2::FileFilter->new;
- $filter->add_pattern("*");
- $filechooser->set_filter($filter);
+ set_mode_playlist_gui();
}
}
@@ -170,9 +159,8 @@ sub start_import_gui()
$l_status->set_label("importing from $file");
- my $cb_pool = $guixml->get_widget('cb_pool');
my $ret;
- if($cb_pool->get_active) {
+ if($POOL) {
$ret = rhimport::import_playlist($file, $dropbox);
} else {
$ret = rhimport::import_file($file, $dropbox);
@@ -181,6 +169,41 @@ sub start_import_gui()
return $ret;
}
+if(!$FILE && !$DROPBOX) {
+ Gtk2->init;
+
+ $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');
+ for my $href ( @allowed_dbs ) {
+ $model->set ($model->append, 0, $href->{'PATH'});
+ }
+ my $co_dropbox = $guixml->get_widget('co_dropbox');
+ $co_dropbox->set_model($model);
+ my $renderer = Gtk2::CellRendererText->new;
+ $co_dropbox->pack_start($renderer, 1);
+ $co_dropbox->add_attribute($renderer, text => 0);
+ $co_dropbox->set_active(0);
+
+ if($POOL) {
+ set_mode_playlist_gui();
+ } else {
+ set_mode_file_gui();
+ }
+
+ my $appwin = $guixml->get_widget('appwin');
+ $appwin or die "can't find Main Window";
+ $appwin->resize(800,600);
+ $appwin->show;
+
+ Gtk2->main;
+ $dbh->disconnect();
+ exit 0;
+}
+
###########################################
## command line mode
@@ -198,5 +221,5 @@ if($POOL) {
$ret = rhimport::import_file($FILE, $DROPBOX);
}
-# $dbh->disconnect();
+$dbh->disconnect();
exit $ret;
diff --git a/rhimport.glade b/rhimport.glade
index a4d6503..00ed60e 100644
--- a/rhimport.glade
+++ b/rhimport.glade
@@ -28,31 +28,75 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
- <widget class="GtkHSeparator" id="hseparator">
+ <widget class="GtkHBox" id="hbox_mode">
<property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="l_dummy_l">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="b_mode">
+ <property name="label" translatable="yes">Modus</property>
+ <property name="width_request">130</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_b_mode_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="l_mode">
+ <property name="width_request">120</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Sendung&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="l_dummy_r">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
</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="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">1</property>
</packing>
</child>
<child>
- <widget class="GtkComboBox" id="co_dropbox">
+ <widget class="GtkLabel" id="l_dropbox">
<property name="visible">True</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>
@@ -60,14 +104,8 @@
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="cb_pool">
- <property name="label" translatable="yes">Musik Pool</property>
+ <widget class="GtkComboBox" id="co_dropbox">
<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="draw_indicator">True</property>
- <signal name="toggled" handler="on_cb_pool_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -77,8 +115,7 @@
<child>
<widget class="GtkLabel" id="l_file_playlist">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="label">&lt;b&gt;File&lt;/b&gt;</property>
+ <property name="label">&lt;b&gt;Datei&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
@@ -90,8 +127,8 @@
<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>
+ <property name="preview_widget_active">False</property>
</widget>
<packing>
<property name="position">5</property>
@@ -108,7 +145,7 @@
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox">
+ <widget class="GtkHBox" id="hbox_button">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="l_status">