/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1303 by persson, Sun Aug 26 09:29:52 2007 UTC revision 1328 by schoenebeck, Fri Sep 7 21:18:31 2007 UTC
# Line 257  MainWindow::MainWindow() Line 257  MainWindow::MainWindow()
257          sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received)          sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received)
258      );      );
259      dimreg_edit.signal_dimreg_changed().connect(      dimreg_edit.signal_dimreg_changed().connect(
260          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));
261      m_RegionChooser.signal_instrument_changed().connect(      m_RegionChooser.signal_instrument_changed().connect(
262          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
263      m_DimRegionChooser.signal_region_changed().connect(      m_DimRegionChooser.signal_region_changed().connect(
264          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
265      instrumentProps.signal_instrument_changed().connect(      instrumentProps.signal_instrument_changed().connect(
266          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
267    
268        dimreg_edit.signal_dimreg_to_be_changed().connect(
269            dimreg_to_be_changed_signal.make_slot());
270        dimreg_edit.signal_dimreg_changed().connect(
271            dimreg_changed_signal.make_slot());
272        dimreg_edit.signal_sample_ref_changed().connect(
273            sample_ref_changed_signal.make_slot());
274    
275        m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
276            sigc::hide(
277                sigc::bind(
278                    file_structure_to_be_changed_signal.make_slot(),
279                    sigc::ref(this->file)
280                )
281            )
282        );
283        m_RegionChooser.signal_instrument_struct_changed().connect(
284            sigc::hide(
285                sigc::bind(
286                    file_structure_changed_signal.make_slot(),
287                    sigc::ref(this->file)
288                )
289            )
290        );
291        m_RegionChooser.signal_region_to_be_changed().connect(
292            region_to_be_changed_signal.make_slot());
293        m_RegionChooser.signal_region_changed_signal().connect(
294            region_changed_signal.make_slot());
295    
296      file = 0;      file = 0;
297      file_is_changed = false;      file_is_changed = false;
298    
# Line 481  void MainWindow::load_instrument(gig::In Line 510  void MainWindow::load_instrument(gig::In
510          msg.run();          msg.run();
511          Gtk::Main::quit();          Gtk::Main::quit();
512      }      }
513        // clear all GUI elements
514        __clear();
515        // load the instrument
516      gig::File* pFile = (gig::File*) instr->GetParent();      gig::File* pFile = (gig::File*) instr->GetParent();
517      load_gig(pFile, 0 /*file name*/);      load_gig(pFile, 0 /*file name*/);
518      //TODO: automatically select the given instrument      //TODO: automatically select the given instrument
# Line 534  bool MainWindow::file_save() Line 566  bool MainWindow::file_save()
566      if (!file_has_name) return file_save_as();      if (!file_has_name) return file_save_as();
567    
568      std::cout << "Saving file\n" << std::flush;      std::cout << "Saving file\n" << std::flush;
569        file_structure_to_be_changed_signal.emit(this->file);
570      try {      try {
571          file->Save();          file->Save();
572          if (file_is_changed) {          if (file_is_changed) {
# Line 541  bool MainWindow::file_save() Line 574  bool MainWindow::file_save()
574              file_is_changed = false;              file_is_changed = false;
575          }          }
576      } catch (RIFF::Exception e) {      } catch (RIFF::Exception e) {
577            file_structure_changed_signal.emit(this->file);
578          Glib::ustring txt = "Could not save file: " + e.Message;          Glib::ustring txt = "Could not save file: " + e.Message;
579          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
580          msg.run();          msg.run();
# Line 548  bool MainWindow::file_save() Line 582  bool MainWindow::file_save()
582      }      }
583      std::cout << "Saving file done\n" << std::flush;      std::cout << "Saving file done\n" << std::flush;
584      __import_queued_samples();      __import_queued_samples();
585        file_structure_changed_signal.emit(this->file);
586      return true;      return true;
587  }  }
588    
# Line 580  bool MainWindow::file_save_as() Line 615  bool MainWindow::file_save_as()
615      dialog.set_current_name(Glib::filename_display_basename(filename));      dialog.set_current_name(Glib::filename_display_basename(filename));
616    
617      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
618            file_structure_to_be_changed_signal.emit(this->file);
619          try {          try {
620              std::string filename = dialog.get_filename();              std::string filename = dialog.get_filename();
621              if (!Glib::str_has_suffix(filename, ".gig")) {              if (!Glib::str_has_suffix(filename, ".gig")) {
# Line 593  bool MainWindow::file_save_as() Line 629  bool MainWindow::file_save_as()
629              file_has_name = true;              file_has_name = true;
630              file_is_changed = false;              file_is_changed = false;
631          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
632                file_structure_changed_signal.emit(this->file);
633              Glib::ustring txt = "Could not save file: " + e.Message;              Glib::ustring txt = "Could not save file: " + e.Message;
634              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
635              msg.run();              msg.run();
636              return false;              return false;
637          }          }
638          __import_queued_samples();          __import_queued_samples();
639            file_structure_changed_signal.emit(this->file);
640          return true;          return true;
641      }      }
642      return false;      return false;
# Line 1244  void MainWindow::on_action_remove_sample Line 1282  void MainWindow::on_action_remove_sample
1282                       pSample; pSample = group->GetNextSample()) {                       pSample; pSample = group->GetNextSample()) {
1283                      members.push_back(pSample);                      members.push_back(pSample);
1284                  }                  }
1285                    // notify everybody that we're going to remove these samples
1286                    samples_to_be_removed_signal.emit(members);
1287                  // delete the group in the .gig file including the                  // delete the group in the .gig file including the
1288                  // samples that belong to the group                  // samples that belong to the group
1289                  file->DeleteGroup(group);                  file->DeleteGroup(group);
1290                    // notify that we're done with removal
1291                    samples_removed_signal.emit();
1292                  // if sample(s) were just previously added, remove                  // if sample(s) were just previously added, remove
1293                  // them from the import queue                  // them from the import queue
1294                  for (std::list<gig::Sample*>::iterator member = members.begin();                  for (std::list<gig::Sample*>::iterator member = members.begin();
# Line 1263  void MainWindow::on_action_remove_sample Line 1305  void MainWindow::on_action_remove_sample
1305                  }                  }
1306                  file_changed();                  file_changed();
1307              } else if (sample) {              } else if (sample) {
1308                    // notify everybody that we're going to remove this sample
1309                    std::list<gig::Sample*> lsamples;
1310                    lsamples.push_back(sample);
1311                    samples_to_be_removed_signal.emit(lsamples);
1312                  // remove sample from the .gig file                  // remove sample from the .gig file
1313                  file->DeleteSample(sample);                  file->DeleteSample(sample);
1314                    // notify that we're done with removal
1315                    samples_removed_signal.emit();
1316                  // if sample was just previously added, remove it from                  // if sample was just previously added, remove it from
1317                  // the import queue                  // the import queue
1318                  for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();                  for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();
# Line 1282  void MainWindow::on_action_remove_sample Line 1330  void MainWindow::on_action_remove_sample
1330              // remove respective row(s) from samples tree view              // remove respective row(s) from samples tree view
1331              m_refSamplesTreeModel->erase(it);              m_refSamplesTreeModel->erase(it);
1332          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1333                // pretend we're done with removal (i.e. to avoid dead locks)
1334                samples_removed_signal.emit();
1335                // show error message
1336              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1337              msg.run();              msg.run();
1338          }          }
# Line 1328  void MainWindow::on_sample_label_drop_dr Line 1379  void MainWindow::on_sample_label_drop_dr
1379          // drop success          // drop success
1380          context->drop_reply(true, time);          context->drop_reply(true, time);
1381    
1382          // find the samplechannel dimension          //TODO: we should better move most of the following code to DimRegionEdit::set_sample()
1383    
1384            // notify everybody that we're going to alter the region
1385          gig::Region* region = m_RegionChooser.get_region();          gig::Region* region = m_RegionChooser.get_region();
1386            region_to_be_changed_signal.emit(region);
1387    
1388            // find the samplechannel dimension
1389          gig::dimension_def_t* stereo_dimension = 0;          gig::dimension_def_t* stereo_dimension = 0;
1390          for (int i = 0 ; i < region->Dimensions ; i++) {          for (int i = 0 ; i < region->Dimensions ; i++) {
1391              if (region->pDimensionDefinitions[i].dimension ==              if (region->pDimensionDefinitions[i].dimension ==
# Line 1363  void MainWindow::on_sample_label_drop_dr Line 1419  void MainWindow::on_sample_label_drop_dr
1419              for (int i = 0 ; i < region->DimensionRegions ; i++) {              for (int i = 0 ; i < region->DimensionRegions ; i++) {
1420                  gig::DimensionRegion* d = region->pDimensionRegions[i];                  gig::DimensionRegion* d = region->pDimensionRegions[i];
1421                  if (d->pSample && d->pSample->Channels != sample->Channels) {                  if (d->pSample && d->pSample->Channels != sample->Channels) {
1422                      d->pSample = 0;                      gig::Sample* oldref = d->pSample;
1423                        d->pSample = NULL;
1424                        sample_ref_changed_signal.emit(oldref, NULL);
1425                  }                  }
1426              }              }
1427          }          }
1428    
1429            // notify we're done with altering
1430            region_changed_signal.emit(region);
1431    
1432          return;          return;
1433      }      }
1434      // drop failed      // drop failed
# Line 1407  void MainWindow::instrument_name_changed Line 1468  void MainWindow::instrument_name_changed
1468          file_changed();          file_changed();
1469      }      }
1470  }  }
1471    
1472    sigc::signal<void, gig::File*> MainWindow::signal_file_structure_to_be_changed() {
1473        return file_structure_to_be_changed_signal;
1474    }
1475    
1476    sigc::signal<void, gig::File*> MainWindow::signal_file_structure_changed() {
1477        return file_structure_changed_signal;
1478    }
1479    
1480    sigc::signal<void, std::list<gig::Sample*> > MainWindow::signal_samples_to_be_removed() {
1481        return samples_to_be_removed_signal;
1482    }
1483    
1484    sigc::signal<void> MainWindow::signal_samples_removed() {
1485        return samples_removed_signal;
1486    }
1487    
1488    sigc::signal<void, gig::Region*> MainWindow::signal_region_to_be_changed() {
1489        return region_to_be_changed_signal;
1490    }
1491    
1492    sigc::signal<void, gig::Region*> MainWindow::signal_region_changed() {
1493        return region_changed_signal;
1494    }
1495    
1496    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> MainWindow::signal_sample_ref_changed() {
1497        return sample_ref_changed_signal;
1498    }
1499    
1500    sigc::signal<void, gig::DimensionRegion*> MainWindow::signal_dimreg_to_be_changed() {
1501        return dimreg_to_be_changed_signal;
1502    }
1503    
1504    sigc::signal<void, gig::DimensionRegion*> MainWindow::signal_dimreg_changed() {
1505        return dimreg_changed_signal;
1506    }

Legend:
Removed from v.1303  
changed lines
  Added in v.1328

  ViewVC Help
Powered by ViewVC