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), |
43 |
m_addFromSelectionButton.set_image( |
m_addFromSelectionButton.set_image( |
44 |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
*new Gtk::Image(Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON) |
45 |
); |
); |
46 |
|
m_buttonDuplicate.set_image( |
47 |
|
*new Gtk::Image(Gtk::Stock::COPY, Gtk::ICON_SIZE_BUTTON) |
48 |
|
); |
49 |
m_deleteButton.set_image( |
m_deleteButton.set_image( |
50 |
*new Gtk::Image(Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON) |
*new Gtk::Image(Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON) |
51 |
); |
); |
118 |
m_mainHBox.pack_start(m_rvbox, Gtk::PACK_SHRINK); |
m_mainHBox.pack_start(m_rvbox, Gtk::PACK_SHRINK); |
119 |
m_mainHBox.set_spacing(5), |
m_mainHBox.set_spacing(5), |
120 |
m_rvbox.set_spacing(5); |
m_rvbox.set_spacing(5); |
121 |
|
m_rvbox.pack_start(m_buttonDuplicate, Gtk::PACK_SHRINK); |
122 |
m_rvbox.pack_start(m_detailsButtonBox, Gtk::PACK_SHRINK); |
m_rvbox.pack_start(m_detailsButtonBox, Gtk::PACK_SHRINK); |
123 |
|
|
124 |
//m_textViewComment.set_left_margin(3); |
//m_textViewComment.set_left_margin(3); |
141 |
m_buttonBoxL.pack_start(m_inverseDeleteButton); |
m_buttonBoxL.pack_start(m_inverseDeleteButton); |
142 |
m_deleteButton.set_sensitive(false); |
m_deleteButton.set_sensitive(false); |
143 |
m_inverseDeleteButton.set_sensitive(false); |
m_inverseDeleteButton.set_sensitive(false); |
144 |
|
m_buttonDuplicate.set_sensitive(false); |
145 |
|
m_buttonUp.set_sensitive(false); |
146 |
|
m_buttonDown.set_sensitive(false); |
147 |
|
|
148 |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
149 |
m_buttonBox.pack_start(m_applyButton); |
m_buttonBox.pack_start(m_applyButton); |
188 |
sigc::mem_fun(*this, &MacrosSetup::onButtonEdit) |
sigc::mem_fun(*this, &MacrosSetup::onButtonEdit) |
189 |
); |
); |
190 |
|
|
191 |
|
m_buttonDuplicate.signal_clicked().connect( |
192 |
|
sigc::mem_fun(*this, &MacrosSetup::onButtonDuplicate) |
193 |
|
); |
194 |
|
|
195 |
m_textViewComment.get_buffer()->signal_changed().connect( |
m_textViewComment.get_buffer()->signal_changed().connect( |
196 |
sigc::mem_fun(*this, &MacrosSetup::onCommentTextViewChanged) |
sigc::mem_fun(*this, &MacrosSetup::onCommentTextViewChanged) |
197 |
); |
); |
316 |
moveByDir(+1); |
moveByDir(+1); |
317 |
} |
} |
318 |
|
|
319 |
|
void MacrosSetup::onButtonDuplicate() { |
320 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_treeViewMacros.get_selection(); |
321 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
322 |
|
duplicateRows(rows); |
323 |
|
} |
324 |
|
|
325 |
void MacrosSetup::onButtonEdit() { |
void MacrosSetup::onButtonEdit() { |
326 |
Serialization::Archive* macro = getSelectedMacro(); |
Serialization::Archive* macro = getSelectedMacro(); |
327 |
if (!macro) return; |
if (!macro) return; |
442 |
m_deleteButton.set_sensitive(bValidSelection); |
m_deleteButton.set_sensitive(bValidSelection); |
443 |
m_inverseDeleteButton.set_sensitive(bValidSelection); |
m_inverseDeleteButton.set_sensitive(bValidSelection); |
444 |
m_buttonEdit.set_sensitive(bValidSelection); |
m_buttonEdit.set_sensitive(bValidSelection); |
445 |
|
m_buttonDuplicate.set_sensitive(bValidSelection); |
446 |
|
m_buttonUp.set_sensitive(bValidSelection); |
447 |
|
m_buttonDown.set_sensitive(bValidSelection); |
448 |
|
|
449 |
// update comment text view |
// update comment text view |
450 |
std::string sComment; |
std::string sComment; |
523 |
deleteRows(rows); |
deleteRows(rows); |
524 |
} |
} |
525 |
|
|
526 |
|
void MacrosSetup::duplicateRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
527 |
|
if (!rows.empty()) m_modified = true; |
528 |
|
bool bError = false; |
529 |
|
for (int r = 0; r < rows.size(); ++r) { |
530 |
|
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
531 |
|
if (!it) continue; |
532 |
|
Gtk::TreeModel::Row row = *it; |
533 |
|
int index = row[m_treeModelMacros.m_col_index]; |
534 |
|
if (index < 0 || index >= m_macros.size()) continue; |
535 |
|
|
536 |
|
Serialization::Archive clone = m_macros[index]; |
537 |
|
if (!endsWith(clone.name(), "COPY", true)) { |
538 |
|
clone.setName( |
539 |
|
(clone.name().empty()) ? "Unnamed COPY" : (clone.name() + " COPY") |
540 |
|
); |
541 |
|
} |
542 |
|
try { |
543 |
|
// enforce re-encoding the abstract object model and resetting the |
544 |
|
// 'modified' state |
545 |
|
clone.rawData(); |
546 |
|
} catch (Serialization::Exception e) { |
547 |
|
bError = true; |
548 |
|
e.PrintMessage(); |
549 |
|
continue; |
550 |
|
} catch (...) { |
551 |
|
bError = true; |
552 |
|
std::cerr << "Unknown exception while cloning macro." << std::endl; |
553 |
|
continue; |
554 |
|
} |
555 |
|
// finally add new cloned macro |
556 |
|
m_macros.push_back(clone); |
557 |
|
} |
558 |
|
reloadTreeView(); |
559 |
|
if (bError) { |
560 |
|
Glib::ustring txt = _("At least one of the macros could not be cloned due to an error (check console output)."); |
561 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
562 |
|
msg.run(); |
563 |
|
} |
564 |
|
} |
565 |
|
|
566 |
void MacrosSetup::deleteRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
void MacrosSetup::deleteRows(const std::vector<Gtk::TreeModel::Path>& rows) { |
567 |
m_modified = !rows.empty(); |
if (!rows.empty()) m_modified = true; |
568 |
std::set<int> macros; |
std::set<int> macros; |
569 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
570 |
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_treeStoreMacros->get_iter(rows[r]); |
617 |
); |
); |
618 |
m_addFromSelectionButton.set_sensitive(m_selectedDimRgn); |
m_addFromSelectionButton.set_sensitive(m_selectedDimRgn); |
619 |
m_buttonEdit.set_sensitive(bValidSelection); |
m_buttonEdit.set_sensitive(bValidSelection); |
620 |
|
m_buttonDuplicate.set_sensitive(bValidSelection); |
621 |
|
m_buttonUp.set_sensitive(bValidSelection); |
622 |
|
m_buttonDown.set_sensitive(bValidSelection); |
623 |
m_applyButton.set_sensitive(isModified()); |
m_applyButton.set_sensitive(isModified()); |
624 |
m_textViewComment.set_sensitive(bValidSelection); |
m_textViewComment.set_sensitive(bValidSelection); |
625 |
updateStatusBar(); |
updateStatusBar(); |