• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files

hvirtual/cinelerra/channeledit.C

Go to the documentation of this file.
00001 #include "batch.h"
00002 #include "bcprogressbox.h"
00003 #include "bcsignals.h"
00004 #include "channel.h"
00005 #include "channeldb.h"
00006 #include "channeledit.h"
00007 #include "channelpicker.h"
00008 #include "chantables.h"
00009 #include "clip.h"
00010 #include "condition.h"
00011 #include "language.h"
00012 #include "picture.h"
00013 #include "theme.h"
00014 #include "videodevice.h"
00015 #include <ctype.h>
00016 #include <string.h>
00017 #include <unistd.h>
00018 
00019 
00020 ChannelEditThread::ChannelEditThread(ChannelPicker *channel_picker,
00021         ChannelDB *channeldb)
00022  : Thread()
00023 {
00024         this->channel_picker = channel_picker;
00025         this->channeldb = channeldb;
00026         in_progress = 0;
00027         this->window = 0;
00028         new_channels = new ChannelDB;
00029         completion = new Condition(1, "ChannelEditThread::completion");
00030         scan_thread = 0;
00031 }
00032 ChannelEditThread::~ChannelEditThread()
00033 {
00034         channel_picker->get_subwindow()->unlock_window();
00035         delete scan_thread;
00036         channel_picker->get_subwindow()->lock_window("ChannelEditThread::~ChannelEditThread");
00037         delete new_channels;
00038         delete completion;
00039 }
00040 
00041 void ChannelEditThread::run()
00042 {
00043         int i;
00044 
00045         if(in_progress) 
00046         {
00047                 if(window)
00048                 {
00049                         window->lock_window("ChannelEditThread::run");
00050                         window->raise_window(1);
00051                         window->unlock_window();
00052                 }
00053                 return;
00054         }
00055         in_progress = 1;
00056         completion->lock("ChannelEditThread::run");
00057 
00058 // Copy master channel list to temporary.
00059         new_channels->copy_from(channel_picker->channeldb);
00060         current_channel = channel_picker->get_current_channel_number();
00061 //printf("ChannelEditThread::run 1 %d\n", current_channel);
00062 
00063 // Run the channel list window using the temporary list.
00064         ChannelEditWindow window(this, channel_picker);
00065         window.create_objects();
00066         this->window = &window;
00067         int result = window.run_window();
00068         this->window = 0;
00069 
00070         if(!result)
00071         {
00072 // Copy new channels to master list
00073                 channel_picker->channeldb->clear();
00074                 
00075                 channel_picker->channeldb->copy_from(new_channels);
00076                 channel_picker->update_channel_list();
00077 
00078         }
00079 
00080         channel_picker->handle_channel_edit(result);
00081 
00082         window.edit_thread->close_threads();
00083         window.picture_thread->close_threads();
00084 
00085         completion->unlock();
00086         in_progress = 0;
00087 
00088 }
00089 
00090 int ChannelEditThread::close_threads()
00091 {
00092         if(in_progress && window)
00093         {
00094                 window->edit_thread->close_threads();
00095                 window->picture_thread->close_threads();
00096                 window->set_done(1);
00097                 completion->lock("ChannelEditThread::close_threads");
00098                 completion->unlock();
00099         }
00100 }
00101 
00102 char *ChannelEditThread::value_to_freqtable(int value)
00103 {
00104         switch(value)
00105         {
00106                 case NTSC_BCAST:
00107                         return _("NTSC_BCAST");
00108                         break;
00109                 case NTSC_CABLE:
00110                         return _("NTSC_CABLE");
00111                         break;
00112                 case NTSC_HRC:
00113                         return _("NTSC_HRC");
00114                         break;
00115                 case NTSC_BCAST_JP:
00116                         return _("NTSC_BCAST_JP");
00117                         break;
00118                 case NTSC_CABLE_JP:
00119                         return _("NTSC_CABLE_JP");
00120                         break;
00121                 case PAL_AUSTRALIA:
00122                         return _("PAL_AUSTRALIA");
00123                         break;
00124                 case PAL_EUROPE:
00125                         return _("PAL_EUROPE");
00126                         break;
00127                 case PAL_E_EUROPE:
00128                         return _("PAL_E_EUROPE");
00129                         break;
00130                 case PAL_ITALY:
00131                         return _("PAL_ITALY");
00132                         break;
00133                 case PAL_IRELAND:
00134                         return _("PAL_IRELAND");
00135                         break;
00136                 case PAL_NEWZEALAND:
00137                         return _("PAL_NEWZEALAND");
00138                         break;
00139         }
00140 }
00141 
00142 char* ChannelEditThread::value_to_norm(int value)
00143 {
00144         switch(value)
00145         {
00146                 case NTSC:
00147                         return _("NTSC");
00148                         break;
00149                 case PAL:
00150                         return _("PAL");
00151                         break;
00152                 case SECAM:
00153                         return _("SECAM");
00154                         break;
00155         }
00156 }
00157 
00158 char* ChannelEditThread::value_to_input(int value)
00159 {
00160         if(channel_picker->get_video_inputs()->total > value)
00161                 return channel_picker->get_video_inputs()->values[value]->device_name;
00162         else
00163                 return _("None");
00164 }
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 ChannelEditWindow::ChannelEditWindow(ChannelEditThread *thread, 
00173         ChannelPicker *channel_picker)
00174  : BC_Window(PROGRAM_NAME ": Channels", 
00175         channel_picker->parent_window->get_abs_cursor_x(1) - 330, 
00176         channel_picker->parent_window->get_abs_cursor_y(1), 
00177         350, 
00178         400, 
00179         350, 
00180         400,
00181         0,
00182         0,
00183         1)
00184 {
00185         this->thread = thread;
00186         this->channel_picker = channel_picker;
00187         scan_confirm_thread = 0;
00188 }
00189 ChannelEditWindow::~ChannelEditWindow()
00190 {
00191         int i;
00192         for(i = 0; i < channel_list.total; i++)
00193         {
00194                 delete channel_list.values[i];
00195         }
00196         channel_list.remove_all();
00197         delete edit_thread;
00198         delete picture_thread;
00199         delete scan_confirm_thread;
00200 }
00201 
00202 int ChannelEditWindow::create_objects()
00203 {
00204         int x = 10, y = 10, i;
00205         char string[1024];
00206 
00207 // Create channel list
00208         for(i = 0; i < thread->new_channels->size(); i++)
00209         {
00210                 channel_list.append(new BC_ListBoxItem(thread->new_channels->get(i)->title));
00211         }
00212 
00213         add_subwindow(list_box = new ChannelEditList(this, x, y));
00214         x += 200;
00215         if(channel_picker->use_select())
00216         {
00217                 add_subwindow(new ChannelEditSelect(this, x, y));
00218                 y += 30;
00219         }
00220         add_subwindow(new ChannelEditAdd(this, x, y));
00221         y += 30;
00222         add_subwindow(new ChannelEdit(this, x, y));
00223         y += 30;
00224         add_subwindow(new ChannelEditMoveUp(this, x, y));
00225         y += 30;
00226         add_subwindow(new ChannelEditMoveDown(this, x, y));
00227         y += 30;
00228         add_subwindow(new ChannelEditSort(this, x, y));
00229         y += 30;
00230 
00231         Channel *channel_usage = channel_picker->get_channel_usage();
00232         if(channel_usage && channel_usage->has_scanning)
00233         {
00234                 add_subwindow(new ChannelEditScan(this, x, y));
00235                 y += 30;
00236         }
00237         add_subwindow(new ChannelEditDel(this, x, y));
00238         y += 30;
00239         add_subwindow(new ChannelEditPicture(this, x, y));
00240         y += 100;
00241         x = 10;
00242         add_subwindow(new BC_OKButton(this));
00243         x += 150;
00244         add_subwindow(new BC_CancelButton(this));
00245 
00246 
00247         edit_thread = new ChannelEditEditThread(this, 
00248                 channel_picker);
00249         picture_thread = new ChannelEditPictureThread(channel_picker, this);
00250         show_window();
00251         return 0;
00252 }
00253 
00254 int ChannelEditWindow::close_event()
00255 {
00256         set_done(0);
00257 }
00258 
00259 int ChannelEditWindow::add_channel()
00260 {
00261         Channel *new_channel;
00262         Channel *prev_channel = 0;
00263 
00264 // Create new channel
00265         new_channel = new Channel;
00266 
00267 // Reuse parameters from previous channel
00268         if(thread->new_channels->size()) 
00269         {
00270                 prev_channel = thread->new_channels->get(
00271                                 thread->new_channels->size() - 1);
00272                 new_channel->copy_settings(prev_channel);
00273         }
00274         else
00275 // Use default channel parameters
00276         if(channel_picker->get_master_channel())
00277         {
00278                 new_channel->copy_settings(channel_picker->get_master_channel());
00279         }
00280 
00281 // Copy device usage.  Need the same thing for playback.
00282         if(channel_picker->get_master_channel())
00283         {
00284                 new_channel->copy_usage(channel_picker->get_master_channel());
00285         }
00286 
00287 // Add to channel table
00288         channel_list.append(new BC_ListBoxItem(new_channel->title));
00289         thread->new_channels->append(new_channel);
00290         update_list();
00291 
00292 // Start common routing
00293         edit_thread->edit_channel(new_channel, 0);
00294         return 0;
00295 }
00296 
00297 int ChannelEditWindow::update_list()
00298 {
00299 // Create channel list
00300         channel_list.remove_all_objects();
00301         for(int i = 0; i < thread->new_channels->size(); i++)
00302         {
00303                 channel_list.append(
00304                         new BC_ListBoxItem(
00305                                 thread->new_channels->get(i)->title));
00306         }
00307 
00308         list_box->update(&channel_list, 0, 0, 1, list_box->get_yposition());
00309 }
00310 
00311 int ChannelEditWindow::update_list(Channel *channel)
00312 {
00313         int i;
00314         for(i = 0; i < thread->new_channels->size(); i++)
00315                 if(thread->new_channels->get(i) == channel) break;
00316 
00317         if(i < thread->new_channels->size())
00318         {
00319                 channel_list.values[i]->set_text(channel->title);
00320         }
00321 
00322         update_list();
00323 }
00324 
00325 
00326 int ChannelEditWindow::edit_channel()
00327 {
00328         if(list_box->get_selection_number(0, 0) > -1)
00329         {
00330                 thread->current_channel = list_box->get_selection_number(0, 0);
00331                 edit_thread->edit_channel(
00332                         thread->new_channels->get(
00333                                 list_box->get_selection_number(0, 0)), 
00334                         1);
00335         }
00336 }
00337 
00338 int ChannelEditWindow::edit_picture()
00339 {
00340         picture_thread->edit_picture();
00341 }
00342 
00343 void ChannelEditWindow::scan_confirm()
00344 {
00345         channel_picker->load_scan_defaults(&thread->scan_params);
00346         if(!scan_confirm_thread) scan_confirm_thread = new ConfirmScanThread(this);
00347         unlock_window();
00348         scan_confirm_thread->start();
00349         lock_window("ChannelEditWindow::scan_confirm");
00350 }
00351 
00352 void ChannelEditWindow::scan()
00353 {
00354         thread->new_channels->clear();
00355         update_list();
00356 
00357         if(!thread->scan_thread) thread->scan_thread = new ScanThread(thread);
00358         thread->scan_thread->start();
00359 }
00360 
00361 
00362 void ChannelEditWindow::sort()
00363 {
00364         int done = 0;
00365         while(!done)
00366         {
00367                 done = 1;
00368                 for(int i = 0; i < thread->new_channels->size() - 1; i++)
00369                 {
00370                         Channel *channel1 = thread->new_channels->get(i);
00371                         Channel *channel2 = thread->new_channels->get(i + 1);
00372                         int is_num = 1;
00373                         for(int j = 0; j < strlen(channel1->title); j++)
00374                                 if(!isdigit(channel1->title[j])) is_num = 0;
00375                         for(int j = 0; j < strlen(channel2->title); j++)
00376                                 if(!isdigit(channel2->title[j])) is_num = 0;
00377                         if(is_num && atoi(channel1->title) > atoi(channel2->title) ||
00378                                 !is_num && strcasecmp(channel2->title, channel1->title) < 0)
00379                         {
00380                                 thread->new_channels->set(i, channel2);
00381                                 thread->new_channels->set(i + 1, channel1);
00382                                 done = 0;
00383                         }
00384                 }
00385         }
00386         update_list();
00387 }
00388 
00389 
00390 int ChannelEditWindow::delete_channel(int number)
00391 {
00392         delete thread->new_channels->get(number);
00393         channel_list.remove_number(number);
00394         thread->new_channels->remove_number(number);
00395         update_list();
00396 }
00397 
00398 int ChannelEditWindow::delete_channel(Channel *channel)
00399 {
00400         int i;
00401         for(i = 0; i < thread->new_channels->size(); i++)
00402         {
00403                 if(thread->new_channels->get(i) == channel)
00404                 {
00405                         break;
00406                 }
00407         }
00408         if(i < thread->new_channels->size()) delete_channel(i);
00409         return 0;
00410 }
00411 
00412 int ChannelEditWindow::move_channel_up()
00413 {
00414         if(list_box->get_selection_number(0, 0) > -1)
00415         {
00416                 int number2 = list_box->get_selection_number(0, 0);
00417                 int number1 = number2 - 1;
00418                 Channel *temp;
00419                 BC_ListBoxItem *temp_text;
00420 
00421                 if(number1 < 0) number1 = thread->new_channels->size() - 1;
00422 
00423                 temp = thread->new_channels->get(number1);
00424                 thread->new_channels->set(number1, thread->new_channels->get(number2));
00425                 thread->new_channels->set(number2, temp);
00426 
00427                 temp_text = channel_list.values[number1];
00428                 channel_list.values[number1] = channel_list.values[number2];
00429                 channel_list.values[number2] = temp_text;
00430                 list_box->update(&channel_list, 
00431                         0, 
00432                         0, 
00433                         1, 
00434                         list_box->get_xposition(), 
00435                         list_box->get_yposition(), 
00436                         number1,
00437                         1);
00438         }
00439         return 0;
00440 }
00441 
00442 int ChannelEditWindow::move_channel_down()
00443 {
00444         if(list_box->get_selection_number(0, 0) > -1)
00445         {
00446                 int number2 = list_box->get_selection_number(0, 0);
00447                 int number1 = number2 + 1;
00448                 Channel *temp;
00449                 BC_ListBoxItem *temp_text;
00450 
00451                 if(number1 > thread->new_channels->size() - 1) number1 = 0;
00452 
00453                 temp = thread->new_channels->get(number1);
00454                 thread->new_channels->set(number1, thread->new_channels->get(number2));
00455                 thread->new_channels->set(number2, temp);
00456                 temp_text = channel_list.values[number1];
00457                 channel_list.values[number1] = channel_list.values[number2];
00458                 channel_list.values[number2] = temp_text;
00459                 list_box->update(&channel_list, 
00460                         0, 
00461                         0, 
00462                         1, 
00463                         list_box->get_xposition(), 
00464                         list_box->get_yposition(), 
00465                         number1,
00466                         1);
00467         }
00468         return 0;
00469 }
00470 
00471 int ChannelEditWindow::change_channel_from_list(int channel_number)
00472 {
00473         Channel *channel;
00474         if(channel_number > -1 && channel_number < thread->new_channels->size())
00475         {
00476                 thread->current_channel = channel_number;
00477                 channel_picker->set_channel(thread->new_channels->get(channel_number));
00478         }
00479 }
00480 
00481 ChannelEditSelect::ChannelEditSelect(ChannelEditWindow *window, int x, int y)
00482  : BC_GenericButton(x, y, _("Select"))
00483 {
00484 }
00485 ChannelEditSelect::~ChannelEditSelect()
00486 {
00487 }
00488 int ChannelEditSelect::handle_event()
00489 {
00490         window->change_channel_from_list(
00491                 window->list_box->get_selection_number(0, 0));
00492 }
00493 
00494 ChannelEditAdd::ChannelEditAdd(ChannelEditWindow *window, int x, int y)
00495  : BC_GenericButton(x, y, _("Add..."))
00496 {
00497         this->window = window;
00498 }
00499 ChannelEditAdd::~ChannelEditAdd()
00500 {
00501 }
00502 int ChannelEditAdd::handle_event()
00503 {
00504         window->add_channel();
00505 }
00506 
00507 ChannelEditList::ChannelEditList(ChannelEditWindow *window, int x, int y)
00508  : BC_ListBox(x, 
00509                         y, 
00510                         185, 
00511                         window->get_h() - BC_OKButton::calculate_h() - y - 10, 
00512                         LISTBOX_TEXT, 
00513                         &(window->channel_list))
00514 {
00515         this->window = window;
00516 }
00517 ChannelEditList::~ChannelEditList()
00518 {
00519 }
00520 int ChannelEditList::handle_event()
00521 {
00522         window->edit_channel();
00523 }
00524 
00525 ChannelEditMoveUp::ChannelEditMoveUp(ChannelEditWindow *window, int x, int y)
00526  : BC_GenericButton(x, y, _("Move up"))
00527 {
00528         this->window = window;
00529 }
00530 ChannelEditMoveUp::~ChannelEditMoveUp()
00531 {
00532 }
00533 int ChannelEditMoveUp::handle_event()
00534 {
00535         lock_window("ChannelEditMoveUp::handle_event");
00536         window->move_channel_up();
00537         unlock_window();
00538 }
00539 
00540 ChannelEditMoveDown::ChannelEditMoveDown(ChannelEditWindow *window, int x, int y)
00541  : BC_GenericButton(x, y, _("Move down"))
00542 {
00543         this->window = window;
00544 }
00545 ChannelEditMoveDown::~ChannelEditMoveDown()
00546 {
00547 }
00548 int ChannelEditMoveDown::handle_event()
00549 {
00550         lock_window("ChannelEditMoveDown::handle_event");
00551         window->move_channel_down();
00552         unlock_window();
00553 }
00554 
00555 ChannelEditSort::ChannelEditSort(ChannelEditWindow *window, int x, int y)
00556  : BC_GenericButton(x, y, _("Sort"))
00557 {
00558         this->window = window;
00559 }
00560 int ChannelEditSort::handle_event()
00561 {
00562         lock_window("ChannelEditSort::handle_event");
00563         window->sort();
00564         unlock_window();
00565 }
00566 
00567 ChannelEditScan::ChannelEditScan(ChannelEditWindow *window, int x, int y)
00568  : BC_GenericButton(x, y, _("Scan"))
00569 {
00570         this->window = window;
00571 }
00572 int ChannelEditScan::handle_event()
00573 {
00574         window->scan_confirm();
00575 }
00576 
00577 ChannelEditDel::ChannelEditDel(ChannelEditWindow *window, int x, int y)
00578  : BC_GenericButton(x, y, _("Delete"))
00579 {
00580         this->window = window;
00581 }
00582 ChannelEditDel::~ChannelEditDel()
00583 {
00584 }
00585 int ChannelEditDel::handle_event()
00586 {
00587         if(window->list_box->get_selection_number(0, 0) > -1) window->delete_channel(window->list_box->get_selection_number(0, 0));
00588 }
00589 
00590 ChannelEdit::ChannelEdit(ChannelEditWindow *window, int x, int y)
00591  : BC_GenericButton(x, y, _("Edit..."))
00592 {
00593         this->window = window;
00594 }
00595 ChannelEdit::~ChannelEdit()
00596 {
00597 }
00598 int ChannelEdit::handle_event()
00599 {
00600         window->edit_channel();
00601 }
00602 
00603 ChannelEditPicture::ChannelEditPicture(ChannelEditWindow *window, int x, int y)
00604  : BC_GenericButton(x, y, _("Picture..."))
00605 {
00606         this->window = window;
00607 }
00608 ChannelEditPicture::~ChannelEditPicture()
00609 {
00610 }
00611 int ChannelEditPicture::handle_event()
00612 {
00613         window->edit_picture();
00614 }
00615 
00616 
00617 
00618 
00619 
00620 
00621 
00622 
00623 
00624 
00625 
00626 
00627 // ========================= confirm overwrite by channel scannin
00628 
00629 
00630 ConfirmScan::ConfirmScan(ChannelEditWindow *gui, int x, int y)
00631  : BC_Window(PROGRAM_NAME ": Scan confirm",
00632         x,
00633         y,
00634         350,
00635         BC_OKButton::calculate_h() + 130,
00636         0,
00637         0,
00638         0,
00639         0,
00640         1)
00641 {
00642         this->gui = gui;
00643 }
00644 
00645 void ConfirmScan::create_objects()
00646 {
00647         int x = 10, y = 10;
00648         int y2 = 0, x2 = 0;
00649         BC_Title *title;
00650         add_subwindow(title = new BC_Title(x, y, _("Set parameters for channel scanning.")));
00651         y += title->get_h() + 10;
00652         y2 = y;
00653 
00654         add_subwindow(title = new BC_Title(x, y, _("Frequency table:")));
00655         x2 = title->get_w();
00656         y += BC_PopupMenu::calculate_h();
00657         add_subwindow(title = new BC_Title(x, y, _("Norm:")));
00658         x2 = MAX(x2, title->get_w());
00659         y += BC_PopupMenu::calculate_h();
00660         add_subwindow(title = new BC_Title(x, y, _("Input:")));
00661         x2 = MAX(x2, title->get_w());
00662         y += BC_PopupMenu::calculate_h();
00663         x2 += x + 5;
00664 
00665         y = y2;
00666         x = x2;
00667         ChannelEditEditFreqtable *table;
00668         add_subwindow(table = new ChannelEditEditFreqtable(x, 
00669                 y, 
00670                 0, 
00671                 gui->thread));
00672         table->add_items();
00673         y += table->get_h() + 10;
00674 
00675         ChannelEditEditNorm *norm;
00676         add_subwindow(norm = new ChannelEditEditNorm(x, 
00677                 y, 
00678                 0,
00679                 gui->thread));
00680         norm->add_items();
00681         y += norm->get_h() + 10;
00682 
00683         ChannelEditEditInput *input;
00684         add_subwindow(input = new ChannelEditEditInput(x, 
00685                 y, 
00686                 0, 
00687                 gui->thread));
00688         input->add_items();
00689 
00690 
00691         add_subwindow(new BC_OKButton(this));
00692         add_subwindow(new BC_CancelButton(this));
00693         show_window();
00694 }
00695 
00696 
00697 
00698 
00699 
00700 
00701 
00702 ConfirmScanThread::ConfirmScanThread(ChannelEditWindow *gui)
00703  : BC_DialogThread()
00704 {
00705         this->gui = gui;
00706 }
00707 
00708 void ConfirmScanThread::handle_done_event(int result)
00709 {
00710         gui->channel_picker->save_scan_defaults(&gui->thread->scan_params);
00711         if(!result)
00712         {
00713                 get_gui()->hide_window();
00714                 gui->lock_window("ConfirmScanThread::handle_done_event");
00715                 gui->scan();
00716                 gui->unlock_window();
00717         }
00718 }
00719 
00720 BC_Window* ConfirmScanThread::new_gui()
00721 {
00722         int x = gui->get_abs_cursor_x(1);
00723         int y = gui->get_abs_cursor_y(1);
00724         ConfirmScan *result = new ConfirmScan(gui, x, y);
00725         result->create_objects();
00726         return result;
00727 }
00728 
00729 
00730 
00731 
00732 
00733 
00734 ScanThread::ScanThread(ChannelEditThread *edit)
00735  : Thread(1, 0, 0)
00736 {
00737         this->edit = edit;
00738         interrupt = 0;
00739         progress = 0;
00740 }
00741 
00742 ScanThread::~ScanThread()
00743 {
00744         interrupt = 1;
00745         Thread::join();
00746 
00747         delete progress;
00748 }
00749 
00750 
00751 void ScanThread::start()
00752 {
00753 // Cancel previous job
00754         interrupt = 1;
00755         Thread::join();
00756         delete progress;
00757         interrupt = 0;
00758 
00759 
00760         progress = new BC_ProgressBox(
00761                 edit->channel_picker->parent_window->get_abs_cursor_x(1),
00762                 edit->channel_picker->parent_window->get_abs_cursor_y(1),
00763                 "Scanning", 
00764                 chanlists[edit->scan_params.freqtable].count);
00765         Thread::start();
00766 }
00767 
00768 void ScanThread::run()
00769 {
00770         for(int i = 0; 
00771                 i < chanlists[edit->scan_params.freqtable].count &&
00772                         !interrupt && 
00773                         !progress->is_cancelled();
00774                 i++)
00775         {
00776                 edit->scan_params.entry = i;
00777                 char string[BCTEXTLEN];
00778                 sprintf(edit->scan_params.title, 
00779                         "%s", 
00780                         chanlists[edit->scan_params.freqtable].list[i].name);
00781                 sprintf(string, 
00782                         "Scanning %s", 
00783                         edit->scan_params.title);
00784                 progress->update_title(string, 1);
00785                 progress->update(i, 1);
00786                 edit->channel_picker->set_channel(&edit->scan_params);
00787 
00788 
00789                 sleep(2);
00790 
00791             int got_signal = edit->channel_picker->has_signal();
00792                 if(got_signal)
00793                 {
00794                         Channel *new_channel = new Channel;
00795                         new_channel->copy_usage(&edit->scan_params);
00796                         new_channel->copy_settings(&edit->scan_params);
00797                         edit->window->lock_window("ScanThread::run");
00798                         edit->new_channels->append(new_channel);
00799                         edit->window->update_list();
00800                         edit->window->unlock_window();
00801                 }
00802         }
00803         delete progress;
00804         progress = 0;
00805 }
00806 
00807 
00808 
00809 
00810 
00811 
00812 
00813 // ================================= Edit a single channel
00814 
00815 
00816 
00817 ChannelEditEditThread::ChannelEditEditThread(ChannelEditWindow *window, 
00818         ChannelPicker *channel_picker)
00819  : Thread()
00820 {
00821         this->window = window;
00822         this->channel_picker = channel_picker;
00823         in_progress = 0;
00824         edit_window = 0;
00825         editing = 0;
00826         completion = new Condition(1, "ChannelEditEditThread::completion");
00827 }
00828 
00829 ChannelEditEditThread::~ChannelEditEditThread()
00830 {
00831         delete completion;
00832 }
00833 
00834 int ChannelEditEditThread::close_threads()
00835 {
00836         if(edit_window)
00837         {
00838                 edit_window->set_done(1);
00839                 completion->lock("ChannelEditEditThread::close_threads");
00840                 completion->unlock();
00841         }
00842 }
00843 
00844 int ChannelEditEditThread::edit_channel(Channel *channel, int editing)
00845 {
00846         if(in_progress) 
00847         {
00848                 edit_window->lock_window("ChannelEditEditThread::edit_channel");
00849                 edit_window->raise_window(1);
00850                 edit_window->unlock_window();
00851                 return 1;
00852         }
00853         in_progress = 1;
00854 
00855 // Copy the channel to edit into a temporary
00856         completion->lock("ChannelEditEditThread::edit_channel");
00857         this->editing = editing;
00858         this->output_channel = channel;
00859         new_channel.copy_settings(output_channel);
00860         new_channel.copy_usage(output_channel);
00861 
00862         if(editing && new_channel.title[0])
00863