Changeset 1169 in ProjectBuilder


Ignore:
Timestamp:
Jan 30, 2011, 8:13:29 PM (10 years ago)
Author:
Bruno Cornec
Message:
  • Adds support for CD choice in CDDBeditor
File:
1 edited

Legend:

Unmodified
Added
Removed
  • projects/CDDBeditor/devel/CDDBeditor/bin/CDDBeditor

    r1004 r1169  
    169169my $dev_label = Newt::Label("Device: ");
    170170my $proxy_label = Newt::Label("Proxy: ");
    171 my $user_label = Newt::Label("Multi CD: ");
    172171
    173172my $wait_label = Newt::Label("Please wait while searching ...");
     
    188187$ce_config{"HTTP_PROXY"}=$ENV{http_proxy} if $ENV{http_proxy};
    189188$ce_config{"input"}=0;
     189$ce_config{"multi"}=1;
    190190$ce_config{"PROTO_VERSION"} = 6;
    191191$ce_config{"DOMAIN"} = "musique-ancienne.org";
     
    217217my $dev_entry = Newt::Entry($width, $flag, $ce_config{"CD_DEVICE"});
    218218my $user_group;
    219 if ($ce_config{input} == 0 ) {
    220     $user_group = Newt::HRadiogroup('FALSE', 'TRUE');
    221 } else {
    222     $user_group = Newt::HRadiogroup('TRUE', 'FALSE');
    223 }
    224219my $quit_button = Newt::Button("Quit");
    225220$quit_button->Tag("Quit");
     
    250245$flage = NEWT_ANCHOR_LEFT;
    251246$ce_panel->Add(1, 4, $dev_entry, $flage);
    252 $flage = NEWT_ANCHOR_RIGHT;
    253 $ce_panel->Add(0, 5, $user_label, $flage);
    254247$flage = NEWT_ANCHOR_LEFT;
    255 $ce_panel->Add(1, 5, $user_group, $flage);
    256248$ce_panel->Add(0, 6, $empty_label);
    257249$ce_panel->Add(0, 7, $next_button);
     
    271263$ce_config{"CDDB_MODE"}=$ce_cddb_mode{$mode_group->Get()};
    272264$ce_config{"CD_DEVICE"}=$dev_entry->Get();
    273 $ce_config{"input"}=$user_group->Get();
    274265
    275266# Components
     
    280271
    281272my $firsttime = 1;
     273my @cecd;
    282274my $ce_cd;
    283275my $artist_entry;
     
    303295    # CDDB query if first time
    304296    if ($firsttime == 1) {
    305         my %ce_cd = get_cddb(\%ce_config);
    306         $ce_cd = \%ce_cd if (defined %ce_cd);
     297        @cecd = get_cddb(\%ce_config);
     298        # by default use first one
     299        $ce_cd = @cecd[0] if (defined @cecd[0]);
    307300    }
    308301    $firsttime = 0;
    309302
    310     #print Dumper($ce_cd)."\n";
    311     #exit 0;
     303    my @vradio;
     304    my $ind = 0;
     305    foreach my $entry (@cecd) {
     306        push @vradio,sprintf "%02d (%s - %d tracks) - %s",$ind,$entry->{cat},$entry->{tno},$entry->{title};
     307        $ind++;
     308    }
     309
     310    if ($ind gt 1) {
     311        # We have multiple entries chose the right one
     312        # Second panel for configuration parameters
     313        Newt::Cls();
     314        Newt::DrawRootText(ce_center_string($ce_title), 1, $ce_title);
     315        Newt::PushHelpLine($ce_help);
     316        Newt::Refresh();
     317
     318        my $user_group = Newt::VRadiogroup(@vradio);
     319        my $quit_button = Newt::Button("Quit");
     320        $quit_button->Tag("Quit");
     321        my $next_button = Newt::Button("Next");
     322        $next_button->Tag("Next");
     323       
     324        my $ce_panel = Newt::Panel(2, 20, "CD chooser");
     325        $flage = NEWT_ANCHOR_LEFT;
     326        $ce_panel->Add(0, 5, $user_group, $flage);
     327        $ce_panel->Add(0, 10, $empty_label);
     328        $ce_panel->Add(0, 11, $next_button);
     329        $ce_panel->Add(1, 11, $quit_button);
     330       
     331        Newt::Refresh();
     332        my ($reason, $data) = $ce_panel->Run();
     333
     334        Newt::Cls();
     335        exit 0 if ($data->Tag() eq "Quit");
     336       
     337        $ind=$user_group->Get();
     338    }
     339    # Point now to the right CD
     340    $ce_cd = @cecd[$ind-1];
     341
    312342    if (not defined $ce_cd->{title}) {
    313343        # Get the disc id first
Note: See TracChangeset for help on using the changeset viewer.