From 7c5c216325e3124ba912207745b395e7313f0abd Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 4 May 2010 11:03:33 +0000 Subject: proper handling of empty dropbox list git-svn-id: https://svn.helsinki.at/rhimport/trunk@63 7c65635b-ec39-4f67-a626-873dbafdd612 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(); } } -- cgit v0.10.2