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 |
*/ |
*/ |
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); |
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 |
|
|
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, |
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; |
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 |
{ |
{ |
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; |
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]; |
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 |
|
|