21 |
m_buttonUp(Gtk::Stock::GO_UP), |
m_buttonUp(Gtk::Stock::GO_UP), |
22 |
m_buttonDown(Gtk::Stock::GO_DOWN), |
m_buttonDown(Gtk::Stock::GO_DOWN), |
23 |
m_buttonEdit(Gtk::Stock::EDIT), |
m_buttonEdit(Gtk::Stock::EDIT), |
24 |
|
m_buttonDuplicate(_("Duplicate")), |
25 |
m_statusLabel("", Gtk::ALIGN_START), |
m_statusLabel("", Gtk::ALIGN_START), |
26 |
m_labelComment(_("Comment"), Gtk::ALIGN_START), |
m_labelComment(_("Comment"), Gtk::ALIGN_START), |
27 |
m_deleteButton(" " + Glib::ustring(_("Delete")) + " " + UNICODE_PRIMARY_KEY_SYMBOL + UNICODE_ERASE_KEY_SYMBOL), |
m_deleteButton(" " + Glib::ustring(_("Delete")) + " " + UNICODE_PRIMARY_KEY_SYMBOL + UNICODE_ERASE_KEY_SYMBOL), |
35 |
|
|
36 |
set_title(_("Setup Macros")); |
set_title(_("Setup Macros")); |
37 |
|
|
38 |
set_default_size(680, 500); |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
39 |
|
set_default_size(680, 500); |
40 |
|
set_position(Gtk::WIN_POS_CENTER); |
41 |
|
} |
42 |
|
|
43 |
|
m_labelIntro.set_padding(10, 10); |
44 |
|
#if GTKMM_MAJOR_VERSION >= 3 |
45 |
|
m_labelIntro.set_line_wrap(); |
46 |
|
#endif |
47 |
|
m_labelIntro.set_text( |
48 |
|
_("A macro is a list of parameters and corresponding values which " |
49 |
|
"should be applied to the instrument editor when the macro is " |
50 |
|
"triggered by the user. A macro is triggered either by selecting " |
51 |
|
"the macro from the \"Macro\" menu, or by hitting the macro's " |
52 |
|
"respective keyboard accelerator (F1 to F12), or by applying a " |
53 |
|
"previously copied macro from the clipboard.") |
54 |
|
); |
55 |
|
m_vbox.pack_start(m_labelIntro, Gtk::PACK_SHRINK); |
56 |
|
|
57 |
m_addFromClipboardButton.set_image( |
m_addFromClipboardButton.set_image( |
58 |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
60 |
m_addFromSelectionButton.set_image( |
m_addFromSelectionButton.set_image( |
61 |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
62 |
); |
); |
63 |
|
m_buttonDuplicate.set_image( |
64 |
|
*new Gtk::Image(Gtk::Stock::COPY, Gtk::ICON_SIZE_BUTTON) |
65 |
|
); |
66 |
m_deleteButton.set_image( |
m_deleteButton.set_image( |
67 |
*new Gtk::Image(Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON) |
*new Gtk::Image(Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON) |
68 |
); |
); |
71 |
); |
); |
72 |
m_addFromClipboardButton.set_tooltip_text(_("Create a new macro from the content currently available on the clipboard.")); |
m_addFromClipboardButton.set_tooltip_text(_("Create a new macro from the content currently available on the clipboard.")); |
73 |
m_addFromSelectionButton.set_tooltip_text(_("Create a new macro from the currently selected dimension region's parameters currently shown on the main window.")); |
m_addFromSelectionButton.set_tooltip_text(_("Create a new macro from the currently selected dimension region's parameters currently shown on the main window.")); |
74 |
|
m_buttonDuplicate.set_tooltip_text(_("Duplicate the selected macro(s). The new macro(s) will be appended to the end of the list.")); |
75 |
|
m_buttonUp.set_tooltip_text( |
76 |
|
_("Move the selected macro up in the list, which changes its order of " |
77 |
|
"appearance in the main window's \"Macro\" menu and changes to which " |
78 |
|
"keyboard accelerator key (F1 to F12) the macro is assigned to.")); |
79 |
|
m_buttonDown.set_tooltip_text( |
80 |
|
_("Move the selected macro down in the list, which changes its order of " |
81 |
|
"appearance in the main window's \"Macro\" menu and changes to which " |
82 |
|
"keyboard accelerator key (F1 to F12) the macro is assigned to.")); |
83 |
|
m_buttonEdit.set_tooltip_text(_("Open the Macro Editor for the selected macro.")); |
84 |
|
m_deleteButton.set_tooltip_text(_("Delete the selected macros.")); |
85 |
|
m_inverseDeleteButton.set_tooltip_text(_("Delete all macros except the selected ones.")); |
86 |
m_addHBox.pack_start(m_addFromClipboardButton, Gtk::PACK_EXPAND_WIDGET/*, 15*/); |
m_addHBox.pack_start(m_addFromClipboardButton, Gtk::PACK_EXPAND_WIDGET/*, 15*/); |
87 |
m_addHBox.pack_start(m_addFromSelectionButton, Gtk::PACK_EXPAND_WIDGET/*, 15*/); |
m_addHBox.pack_start(m_addFromSelectionButton, Gtk::PACK_EXPAND_WIDGET/*, 15*/); |
88 |
m_vbox.pack_start(m_addHBox, Gtk::PACK_SHRINK); |
m_vbox.pack_start(m_addHBox, Gtk::PACK_SHRINK); |
147 |
m_mainHBox.pack_start(m_rvbox, Gtk::PACK_SHRINK); |
m_mainHBox.pack_start(m_rvbox, Gtk::PACK_SHRINK); |
148 |
m_mainHBox.set_spacing(5), |
m_mainHBox.set_spacing(5), |
149 |
m_rvbox.set_spacing(5); |
m_rvbox.set_spacing(5); |
150 |
|
m_rvbox.pack_start(m_buttonDuplicate, Gtk::PACK_SHRINK); |
151 |
m_rvbox.pack_start(m_detailsButtonBox, Gtk::PACK_SHRINK); |
m_rvbox.pack_start(m_detailsButtonBox, Gtk::PACK_SHRINK); |
152 |
|
|
153 |
//m_textViewComment.set_left_margin(3); |
//m_textViewComment.set_left_margin(3); |
154 |
//m_textViewComment.set_right_margin(3); |
//m_textViewComment.set_right_margin(3); |
155 |
m_textViewComment.set_indent(2); |
m_textViewComment.set_indent(2); |
156 |
|
m_textViewComment.set_tooltip_text( |
157 |
|
_("Write arbitrary comments for the selected macro which help you to " |
158 |
|
"remember the purpose of your macro. The comment will be shown as " |
159 |
|
"tooltip in the main window's \"Macro\" menu for example.") |
160 |
|
); |
161 |
m_scrolledWindowComment.add(m_textViewComment); |
m_scrolledWindowComment.add(m_textViewComment); |
162 |
m_scrolledWindowComment.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_scrolledWindowComment.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
163 |
m_labelComment.set_markup( |
m_labelComment.set_markup( |
175 |
m_buttonBoxL.pack_start(m_inverseDeleteButton); |
m_buttonBoxL.pack_start(m_inverseDeleteButton); |
176 |
m_deleteButton.set_sensitive(false); |
m_deleteButton.set_sensitive(false); |
177 |
m_inverseDeleteButton.set_sensitive(false); |
m_inverseDeleteButton.set_sensitive(false); |
178 |
|
m_buttonDuplicate.set_sensitive(false); |
179 |
|
m_buttonUp.set_sensitive(false); |
180 |
|
m_buttonDown.set_sensitive(false); |
181 |
|
|
182 |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
183 |
m_buttonBox.pack_start(m_applyButton); |
m_buttonBox.pack_start(m_applyButton); |
222 |
sigc::mem_fun(*this, &MacrosSetup::onButtonEdit) |
sigc::mem_fun(*this, &MacrosSetup::onButtonEdit) |
223 |
); |
); |
224 |
|
|
225 |
|
m_buttonDuplicate.signal_clicked().connect( |
226 |
|
sigc::mem_fun(*this, &MacrosSetup::onButtonDuplicate) |
227 |
|
); |
228 |
|
|
229 |
m_textViewComment.get_buffer()->signal_changed().connect( |
m_textViewComment.get_buffer()->signal_changed().connect( |
230 |
sigc::mem_fun(*this, &MacrosSetup::onCommentTextViewChanged) |
sigc::mem_fun(*this, &MacrosSetup::onCommentTextViewChanged) |
231 |
); |
); |
350 |
moveByDir(+1); |
moveByDir(+1); |
351 |
} |
} |
352 |
|
|
353 |
|
void MacrosSetup::onButtonDuplicate() { |
354 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_treeViewMacros.get_selection(); |
355 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
356 |
|
duplicateRows(rows); |
357 |
|
} |
358 |
|
|
359 |
void MacrosSetup::onButtonEdit() { |
void MacrosSetup::onButtonEdit() { |
360 |
Serialization::Archive* macro = getSelectedMacro(); |
Serialization::Archive* macro = getSelectedMacro(); |
361 |
if (!macro) return; |
if (!macro) return; |
457 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
458 |
row[m_treeModelMacros.m_col_key] = indexToAccKey(iMacro); |
row[m_treeModelMacros.m_col_key] = indexToAccKey(iMacro); |
459 |
row[m_treeModelMacros.m_col_name] = macro.name().empty() ? _("Unnamed Macro") : gig_to_utf8(macro.name()); |
row[m_treeModelMacros.m_col_name] = macro.name().empty() ? _("Unnamed Macro") : gig_to_utf8(macro.name()); |
460 |
row[m_treeModelMacros.m_col_comment] = macro.comment().empty() ? _("No comment assigned yet.") : gig_to_utf8(macro.comment()); |
row[m_treeModelMacros.m_col_comment] = macro.comment().empty() ? _("No comment assigned to this macro yet.") : gig_to_utf8(macro.comment()); |
461 |
row[m_treeModelMacros.m_col_created] = humanShortStr(macro.dateTimeCreated()); |
row[m_treeModelMacros.m_col_created] = humanShortStr(macro.dateTimeCreated()); |
462 |
row[m_treeModelMacros.m_col_modified] = humanShortStr(macro.dateTimeModified()); |
row[m_treeModelMacros.m_col_modified] = humanShortStr(macro.dateTimeModified()); |
463 |
row[m_treeModelMacros.m_col_index] = iMacro; |
row[m_treeModelMacros.m_col_index] = iMacro; |
476 |
m_deleteButton.set_sensitive(bValidSelection); |
m_deleteButton.set_sensitive(bValidSelection); |
477 |
m_inverseDeleteButton.set_sensitive(bValidSelection); |
m_inverseDeleteButton.set_sensitive(bValidSelection); |
478 |
m_buttonEdit.set_sensitive(bValidSelection); |
m_buttonEdit.set_sensitive(bValidSelection); |
479 |
|
m_buttonDuplicate.set_sensitive(bValidSelection); |
480 |
|
m_buttonUp.set_sensitive(bValidSelection); |
481 |
|
m_buttonDown.set_sensitive(bValidSelection); |
482 |
|
|
483 |
// update comment text view |
// update comment text view |
484 |
std::string sComment; |
std::string sComment; |
557 |
deleteRows(rows); |
deleteRows(rows); |
558 |
} |
} |
559 |
|
|
560 |
|
void MacrosSetup::duplicateRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
561 |
|
if (!rows.empty()) m_modified = true; |
562 |
|
bool bError = false; |
563 |
|
for (int r = 0; r < rows.size(); ++r) { |
564 |
|
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
565 |
|
if (!it) continue; |
566 |
|
Gtk::TreeModel::Row row = *it; |
567 |
|
int index = row[m_treeModelMacros.m_col_index]; |
568 |
|
if (index < 0 || index >= m_macros.size()) continue; |
569 |
|
|
570 |
|
Serialization::Archive clone = m_macros[index]; |
571 |
|
if (!endsWith(clone.name(), "COPY", true)) { |
572 |
|
clone.setName( |
573 |
|
(clone.name().empty()) ? "Unnamed COPY" : (clone.name() + " COPY") |
574 |
|
); |
575 |
|
} |
576 |
|
try { |
577 |
|
// enforce re-encoding the abstract object model and resetting the |
578 |
|
// 'modified' state |
579 |
|
clone.rawData(); |
580 |
|
} catch (Serialization::Exception e) { |
581 |
|
bError = true; |
582 |
|
e.PrintMessage(); |
583 |
|
continue; |
584 |
|
} catch (...) { |
585 |
|
bError = true; |
586 |
|
std::cerr << "Unknown exception while cloning macro." << std::endl; |
587 |
|
continue; |
588 |
|
} |
589 |
|
// finally add new cloned macro |
590 |
|
m_macros.push_back(clone); |
591 |
|
} |
592 |
|
reloadTreeView(); |
593 |
|
if (bError) { |
594 |
|
Glib::ustring txt = _("At least one of the macros could not be cloned due to an error (check console output)."); |
595 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
596 |
|
msg.run(); |
597 |
|
} |
598 |
|
} |
599 |
|
|
600 |
void MacrosSetup::deleteRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
void MacrosSetup::deleteRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
601 |
m_modified = !rows.empty(); |
if (!rows.empty()) m_modified = true; |
602 |
std::set<int> macros; |
std::set<int> macros; |
603 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
604 |
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
651 |
); |
); |
652 |
m_addFromSelectionButton.set_sensitive(m_selectedDimRgn); |
m_addFromSelectionButton.set_sensitive(m_selectedDimRgn); |
653 |
m_buttonEdit.set_sensitive(bValidSelection); |
m_buttonEdit.set_sensitive(bValidSelection); |
654 |
|
m_buttonDuplicate.set_sensitive(bValidSelection); |
655 |
|
m_buttonUp.set_sensitive(bValidSelection); |
656 |
|
m_buttonDown.set_sensitive(bValidSelection); |
657 |
m_applyButton.set_sensitive(isModified()); |
m_applyButton.set_sensitive(isModified()); |
658 |
m_textViewComment.set_sensitive(bValidSelection); |
m_textViewComment.set_sensitive(bValidSelection); |
659 |
updateStatusBar(); |
updateStatusBar(); |