summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-05-04 11:03:33 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-05-04 11:03:33 (GMT)
commitf98747ecae5be274c3d31e02f3c1baa75a0fe371 (patch)
tree8a3469b4b565d9b0637a849f1ab7ead5461e2d3f
parentc12992811b919478b313a03b59edeb4f24b878a2 (diff)
proper handling of empty dropbox list
-rwxr-xr-xrhimport42
1 files changed, 30 insertions, 12 deletions
diff --git a/rhimport b/rhimport
index 8d70c9e..20a814f 100755
--- a/rhimport
+++ b/rhimport
@@ -136,6 +136,20 @@ sub set_mode_file_gui()
$filechooser->set_filter($filter);
}
+sub set_mode_disabled_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 2;
+ }
+
+ my @widgets = ('b_mode', 'cb_clear_carts', 'b_showcarts', 'b_apply', 'filechooser');
+ for my $w ( @widgets ) {
+ my $widget = $guixml->get_widget($w);
+ $widget->set_sensitive(0) if($widget);
+ }
+}
+
sub toggle_mode_gui()
{
if(!$guixml) {
@@ -144,7 +158,7 @@ sub toggle_mode_gui()
}
my $co_dropbox = $guixml->get_widget('co_dropbox');
- my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'};
+ my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'} if($allowed_dbs[$co_dropbox->get_active]);
my $response = 'no';
if(($to_cart == 0 && $POOL) ||
@@ -253,9 +267,9 @@ sub start_import_gui()
$filechooser->unselect_all;
my $co_dropbox = $guixml->get_widget('co_dropbox');
- my $dropbox = $allowed_dbs[$co_dropbox->get_active]->{'PATH'};
- my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'};
- my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'};
+ my $dropbox = $allowed_dbs[$co_dropbox->get_active]->{'PATH'} if ($allowed_dbs[$co_dropbox->get_active]);
+ my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'} if ($allowed_dbs[$co_dropbox->get_active]);
+ my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'} if($allowed_dbs[$co_dropbox->get_active]);
$l_status->set_label("importiere von $file");
@@ -312,7 +326,7 @@ sub show_used_carts_gui()
}
my $co_dropbox = $guixml->get_widget('co_dropbox');
- my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'};
+ my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'} if($allowed_dbs[$co_dropbox->get_active]);
my $l_status = $guixml->get_widget('l_status');
@@ -352,14 +366,18 @@ sub dropbox_updated_gui()
}
my $co_dropbox = $guixml->get_widget('co_dropbox');
- my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'};
- my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'};
- my ($low_cart, $high_cart) = rhimport::get_cart_range($dbh, $group);
-
- if($to_cart == 0) {
- set_mode_playlist_gui();
+ if($allowed_dbs[$co_dropbox->get_active]) {
+ my $to_cart = $allowed_dbs[$co_dropbox->get_active]->{'TO_CART'};
+ my $group = $allowed_dbs[$co_dropbox->get_active]->{'GROUP'};
+ my ($low_cart, $high_cart) = rhimport::get_cart_range($dbh, $group);
+
+ if($to_cart == 0) {
+ set_mode_playlist_gui();
+ } else {
+ set_mode_file_gui();
+ }
} else {
- set_mode_file_gui();
+ set_mode_disabled_gui();
}
}