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

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

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

revision 3151 by schoenebeck, Fri May 5 18:44:59 2017 UTC revision 3299 by schoenebeck, Sun Jul 9 12:44:59 2017 UTC
# Line 5  Line 5 
5      GNU General Public License version 2.      GNU General Public License version 2.
6  */  */
7    
8    #include "global.h"
9  #include "CombineInstrumentsDialog.h"  #include "CombineInstrumentsDialog.h"
10    
11  // enable this for debug messages being printed while combining the instruments  // enable this for debug messages being printed while combining the instruments
12  #define DEBUG_COMBINE_INSTRUMENTS 0  #define DEBUG_COMBINE_INSTRUMENTS 0
13    
 #include "global.h"  
14  #include "compat.h"  #include "compat.h"
15    
16  #include <set>  #include <set>
# Line 20  Line 20 
20  #include <string.h>  #include <string.h>
21    
22  #include <glibmm/ustring.h>  #include <glibmm/ustring.h>
23    #include <gtkmm/stock.h>
24  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
25  #include <gtkmm/label.h>  #include <gtkmm/label.h>
26    
# Line 780  static void combineInstruments(std::vect Line 781  static void combineInstruments(std::vect
781  CombineInstrumentsDialog::CombineInstrumentsDialog(Gtk::Window& parent, gig::File* gig)  CombineInstrumentsDialog::CombineInstrumentsDialog(Gtk::Window& parent, gig::File* gig)
782      : ManagedDialog(_("Combine Instruments"), parent, true),      : ManagedDialog(_("Combine Instruments"), parent, true),
783        m_gig(gig), m_fileWasChanged(false), m_newCombinedInstrument(NULL),        m_gig(gig), m_fileWasChanged(false), m_newCombinedInstrument(NULL),
784        m_cancelButton(_("_Cancel"), true), m_OKButton(_("_OK"), true),        m_cancelButton(Gtk::Stock::CANCEL), m_OKButton(Gtk::Stock::OK),
785        m_descriptionLabel(), m_tableDimCombo(2, 2), m_comboDimType(),        m_descriptionLabel(), m_tableDimCombo(2, 2), m_comboDimType(),
786        m_labelDimType(Glib::ustring(_("Combine by Dimension:")) + "  ", Gtk::ALIGN_END)        m_labelDimType(Glib::ustring(_("Combine by Dimension:")) + "  ", Gtk::ALIGN_END)
787  {  {
788        if (!Settings::singleton()->autoRestoreWindowDimension) {
789            set_default_size(500, 600);
790            set_position(Gtk::WIN_POS_MOUSE);
791        }
792    
793      m_scrolledWindow.add(m_treeView);      m_scrolledWindow.add(m_treeView);
794      m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);      m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
795    
# Line 834  CombineInstrumentsDialog::CombineInstrum Line 840  CombineInstrumentsDialog::CombineInstrum
840          "Use SHIFT + left click or CTRL + left click to select the instruments "          "Use SHIFT + left click or CTRL + left click to select the instruments "
841          "you want to combine."          "you want to combine."
842      ));      ));
843      m_treeView.append_column("Instrument", m_columns.m_col_name);      m_treeView.append_column(_("Nr"), m_columns.m_col_index);
844      m_treeView.set_headers_visible(false);      m_treeView.append_column(_("Instrument"), m_columns.m_col_name);
845        m_treeView.set_headers_visible(true);
846      m_treeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);      m_treeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
847      m_treeView.get_selection()->signal_changed().connect(      m_treeView.get_selection()->signal_changed().connect(
848          sigc::mem_fun(*this, &CombineInstrumentsDialog::onSelectionChanged)          sigc::mem_fun(*this, &CombineInstrumentsDialog::onSelectionChanged)
# Line 860  CombineInstrumentsDialog::CombineInstrum Line 867  CombineInstrumentsDialog::CombineInstrum
867          Glib::ustring name(gig_to_utf8(instr->pInfo->Name));          Glib::ustring name(gig_to_utf8(instr->pInfo->Name));
868          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
869          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
870            row[m_columns.m_col_index] = i;
871          row[m_columns.m_col_name] = name;          row[m_columns.m_col_name] = name;
872          row[m_columns.m_col_instr] = instr;          row[m_columns.m_col_instr] = instr;
873      }      }
# Line 897  CombineInstrumentsDialog::CombineInstrum Line 905  CombineInstrumentsDialog::CombineInstrum
905      }      }
906  }  }
907    
908    void CombineInstrumentsDialog::setSelectedInstruments(const std::set<int>& instrumentIndeces) {
909        typedef Gtk::TreeModel::Children Children;
910        Children children = m_refTreeModel->children();
911        for (Children::iterator iter = children.begin();
912             iter != children.end(); ++iter)
913        {
914            Gtk::TreeModel::Row row = *iter;
915            int index = row[m_columns.m_col_index];
916            if (instrumentIndeces.count(index))
917                m_treeView.get_selection()->select(iter);
918        }
919    }
920    
921  void CombineInstrumentsDialog::combineSelectedInstruments() {  void CombineInstrumentsDialog::combineSelectedInstruments() {
922      std::vector<gig::Instrument*> instruments;      std::vector<gig::Instrument*> instruments;
923      std::vector<Gtk::TreeModel::Path> v = m_treeView.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> v = m_treeView.get_selection()->get_selected_rows();

Legend:
Removed from v.3151  
changed lines
  Added in v.3299

  ViewVC Help
Powered by ViewVC