522 |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
523 |
); |
); |
524 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
525 |
|
"MoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
526 |
|
); |
527 |
|
m_actionGroup->add_action( |
528 |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
529 |
); |
); |
530 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
546 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
547 |
); |
); |
548 |
actionGroup->add( |
actionGroup->add( |
549 |
|
Gtk::Action::create("MoveInstrument", _("Move _Instrument To ...")), |
550 |
|
Gtk::AccelKey(GDK_KEY_i, primaryModifierKey), |
551 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
552 |
|
); |
553 |
|
actionGroup->add( |
554 |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
555 |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
556 |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
906 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
907 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
908 |
" </item>" |
" </item>" |
909 |
|
" <item id='MoveInstrument'>" |
910 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
911 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
912 |
|
" </item>" |
913 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
914 |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
915 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1039 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
1040 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
1041 |
" </item>" |
" </item>" |
1042 |
|
" <item id='MoveInstrument'>" |
1043 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
1044 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
1045 |
|
" </item>" |
1046 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
1047 |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
1048 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1181 |
" <menu action='AssignScripts'/>" |
" <menu action='AssignScripts'/>" |
1182 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1183 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1184 |
|
" <menuitem action='MoveInstrument'/>" |
1185 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1186 |
" <separator/>" |
" <separator/>" |
1187 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1221 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
1222 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1223 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1224 |
|
" <menuitem action='MoveInstrument'/>" |
1225 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1226 |
" <separator/>" |
" <separator/>" |
1227 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
3939 |
} |
} |
3940 |
#endif |
#endif |
3941 |
|
|
3942 |
|
void MainWindow::on_action_move_instr() { |
3943 |
|
gig::Instrument* instr = get_instrument(); |
3944 |
|
if (!instr) return; |
3945 |
|
|
3946 |
|
int currentIndex = getIndexOf(instr); |
3947 |
|
|
3948 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
3949 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3950 |
|
Gtk::Adjustment adjustment( |
3951 |
|
currentIndex, |
3952 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3953 |
|
); |
3954 |
|
Gtk::SpinButton spinBox(adjustment); |
3955 |
|
#else |
3956 |
|
Gtk::SpinButton spinBox( |
3957 |
|
Gtk::Adjustment::create( |
3958 |
|
currentIndex, |
3959 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3960 |
|
) |
3961 |
|
); |
3962 |
|
#endif |
3963 |
|
#if USE_GTKMM_BOX |
3964 |
|
dialog.get_content_area()->pack_start(spinBox); |
3965 |
|
#else |
3966 |
|
dialog.get_vbox()->pack_start(spinBox); |
3967 |
|
#endif |
3968 |
|
#if HAS_GTKMM_STOCK |
3969 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
3970 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
3971 |
|
#else |
3972 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
3973 |
|
dialog.add_button(_("_Cancel"), 1); |
3974 |
|
#endif |
3975 |
|
okButton->set_sensitive(false); |
3976 |
|
// show the dialog at a reasonable screen position |
3977 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
3978 |
|
// only enable the 'OK' button if entered new index is not instrument's |
3979 |
|
// current index already |
3980 |
|
spinBox.signal_value_changed().connect([&]{ |
3981 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
3982 |
|
}); |
3983 |
|
// usability acceleration: if user hits enter key on the text entry field |
3984 |
|
// then auto trigger the 'OK' button |
3985 |
|
spinBox.signal_activate().connect([&]{ |
3986 |
|
if (okButton->get_sensitive()) |
3987 |
|
okButton->clicked(); |
3988 |
|
}); |
3989 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3990 |
|
dialog.show_all_children(); |
3991 |
|
#endif |
3992 |
|
if (!dialog.run()) { // 'OK' selected ... |
3993 |
|
int newIndex = spinBox.get_value_as_int(); |
3994 |
|
printf("MOVE TO %d\n", newIndex); |
3995 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
3996 |
|
instr->MoveTo(dst); |
3997 |
|
__refreshEntireGUI(); |
3998 |
|
select_instrument(instr); |
3999 |
|
} |
4000 |
|
} |
4001 |
|
|
4002 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4003 |
if (!instrument) return; |
if (!instrument) return; |
4004 |
|
|