/[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 3409 by schoenebeck, Tue Jan 23 16:30:56 2018 UTC revision 3779 by schoenebeck, Fri May 29 21:37:07 2020 UTC
# Line 1  Line 1 
1  /*  /*
2      Copyright (c) 2014-2018 Christian Schoenebeck      Copyright (c) 2014-2020 Christian Schoenebeck
3        
4      This file is part of "gigedit" and released under the terms of the      This file is part of "gigedit" and released under the terms of the
5      GNU General Public License version 2.      GNU General Public License version 2.
6  */  */
# Line 941  CombineInstrumentsDialog::CombineInstrum Line 941  CombineInstrumentsDialog::CombineInstrum
941      }      }
942    
943      m_buttonBox.set_layout(Gtk::BUTTONBOX_END);      m_buttonBox.set_layout(Gtk::BUTTONBOX_END);
944  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
945      m_buttonBox.set_margin(5);      m_buttonBox.set_margin(5);
946  #else  #else
947      m_buttonBox.set_border_width(5);      m_buttonBox.set_border_width(5);
# Line 989  CombineInstrumentsDialog::CombineInstrum Line 989  CombineInstrumentsDialog::CombineInstrum
989    
990  void CombineInstrumentsDialog::on_order_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)  void CombineInstrumentsDialog::on_order_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
991  {  {
992        #if DEBUG_COMBINE_INSTRUMENTS
993      printf("Drag begin\n");      printf("Drag begin\n");
994        #endif
995      first_call_to_drag_data_get = true;      first_call_to_drag_data_get = true;
996  }  }
997    
998  void CombineInstrumentsDialog::on_order_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context,  void CombineInstrumentsDialog::on_order_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context,
999                                                         Gtk::SelectionData& selection_data, guint, guint)                                                         Gtk::SelectionData& selection_data, guint, guint)
1000  {  {
1001        #if DEBUG_COMBINE_INSTRUMENTS
1002      printf("Drag data get\n");      printf("Drag data get\n");
1003        #endif
1004      if (!first_call_to_drag_data_get) return;      if (!first_call_to_drag_data_get) return;
1005      first_call_to_drag_data_get = false;      first_call_to_drag_data_get = false;
1006    
# Line 1016  void CombineInstrumentsDialog::on_order_ Line 1020  void CombineInstrumentsDialog::on_order_
1020          printf("Drag data get: !src\n");          printf("Drag data get: !src\n");
1021          return;          return;
1022      }      }
1023        #if DEBUG_COMBINE_INSTRUMENTS
1024      printf("src=%ld\n", (size_t)src);      printf("src=%ld\n", (size_t)src);
1025        #endif
1026    
1027      // pass the source gig::Instrument as pointer      // pass the source gig::Instrument as pointer
1028      selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src,      selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src,
# Line 1027  void CombineInstrumentsDialog::on_order_ Line 1033  void CombineInstrumentsDialog::on_order_
1033      const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,      const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
1034      const Gtk::SelectionData& selection_data, guint, guint time)      const Gtk::SelectionData& selection_data, guint, guint time)
1035  {  {
1036        #if DEBUG_COMBINE_INSTRUMENTS
1037      printf("Drag data received\n");      printf("Drag data received\n");
1038      if (&selection_data == NULL) {      #endif
         printf("!selection_data\n");  
         return;  
     }  
1039      if (!selection_data.get_data()) {      if (!selection_data.get_data()) {
1040          printf("selection_data.get_data() == NULL\n");          printf("selection_data.get_data() == NULL\n");
1041          return;          return;
# Line 1042  void CombineInstrumentsDialog::on_order_ Line 1046  void CombineInstrumentsDialog::on_order_
1046          printf("!src\n");          printf("!src\n");
1047          return;          return;
1048      }      }
1049      printf("src=%d\n", src);      #if DEBUG_COMBINE_INSTRUMENTS
1050        printf("src=%ld\n", (size_t)src);
1051        #endif
1052    
1053      gig::Instrument* dst = NULL;      gig::Instrument* dst = NULL;
1054      {      {
# Line 1059  void CombineInstrumentsDialog::on_order_ Line 1065  void CombineInstrumentsDialog::on_order_
1065          return;          return;
1066      }      }
1067    
1068        #if DEBUG_COMBINE_INSTRUMENTS
1069      printf("dragdrop received src='%s' dst='%s'\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str());      printf("dragdrop received src='%s' dst='%s'\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str());
1070        #endif
1071    
1072      // swap the two items      // swap the two items
1073      typedef Gtk::TreeModel::Children Children;      typedef Gtk::TreeModel::Children Children;
# Line 1127  void CombineInstrumentsDialog::combineSe Line 1135  void CombineInstrumentsDialog::combineSe
1135              Glib::ustring name = row[m_orderColumns.m_col_name];              Glib::ustring name = row[m_orderColumns.m_col_name];
1136              gig::Instrument* instrument = row[m_orderColumns.m_col_instr];              gig::Instrument* instrument = row[m_orderColumns.m_col_instr];
1137              #if DEBUG_COMBINE_INSTRUMENTS              #if DEBUG_COMBINE_INSTRUMENTS
1138              printf("Selection %d. '%s' %p\n\n", (i+1), name.c_str(), instrument));              printf("Selection %d. '%s' %p\n\n", (i+1), name.c_str(), instrument);
1139              #endif              #endif
1140              instruments.push_back(instrument);              instruments.push_back(instrument);
1141          }          }
# Line 1196  void CombineInstrumentsDialog::onSelecti Line 1204  void CombineInstrumentsDialog::onSelecti
1204      {      {
1205          Children allOrdered = m_refOrderModel->children();          Children allOrdered = m_refOrderModel->children();
1206          for (Children::iterator itOrder = allOrdered.begin();          for (Children::iterator itOrder = allOrdered.begin();
1207               itOrder != allOrdered.end(); ++itOrder)               itOrder != allOrdered.end(); )
1208          {          {
1209              Gtk::TreeModel::Row rowOrder = *itOrder;              Gtk::TreeModel::Row rowOrder = *itOrder;
1210              gig::Instrument* instr = rowOrder[m_orderColumns.m_col_instr];              gig::Instrument* instr = rowOrder[m_orderColumns.m_col_instr];
# Line 1208  void CombineInstrumentsDialog::onSelecti Line 1216  void CombineInstrumentsDialog::onSelecti
1216              }              }
1217              goto removeOrderedItem;              goto removeOrderedItem;
1218          nextOrderedItem:          nextOrderedItem:
1219                ++itOrder;
1220              continue;              continue;
1221          removeOrderedItem:          removeOrderedItem:
1222              m_refOrderModel->erase(itOrder);              // postfix increment here to avoid iterator invalidation
1223                m_refOrderModel->erase(itOrder++);
1224          }          }
1225      }      }
1226    

Legend:
Removed from v.3409  
changed lines
  Added in v.3779

  ViewVC Help
Powered by ViewVC