198 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
199 |
); |
); |
200 |
actionGroup->add( |
actionGroup->add( |
201 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
202 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
203 |
); |
); |
204 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
212 |
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
213 |
#endif |
#endif |
214 |
|
|
215 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
216 |
|
_("Copy selected dimension region")), |
217 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
218 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
219 |
|
|
220 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
221 |
|
_("Paste dimension region")), |
222 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
223 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
224 |
|
|
225 |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
226 |
_("Select Previous Region")), |
_("Select Previous Region")), |
227 |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
278 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
279 |
|
|
280 |
|
|
281 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
282 |
toggle_action = |
toggle_action = |
283 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
284 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
436 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
437 |
" </menu>" |
" </menu>" |
438 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
439 |
|
" <menuitem action='CopyDimRgn'/>" |
440 |
|
" <menuitem action='PasteDimRgn'/>" |
441 |
|
" <separator/>" |
442 |
" <menuitem action='SelectPrevRegion'/>" |
" <menuitem action='SelectPrevRegion'/>" |
443 |
" <menuitem action='SelectNextRegion'/>" |
" <menuitem action='SelectNextRegion'/>" |
444 |
" <separator/>" |
" <separator/>" |
811 |
|
|
812 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
813 |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
814 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
815 |
|
|
816 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
817 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
818 |
|
); |
819 |
|
updateClipboardPasteAvailable(); |
820 |
|
updateClipboardCopyAvailable(); |
821 |
} |
} |
822 |
|
|
823 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
892 |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
893 |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
894 |
m_DimRegionChooser.setModifyBothChannels(stereo); |
m_DimRegionChooser.setModifyBothChannels(stereo); |
895 |
|
|
896 |
|
updateClipboardCopyAvailable(); |
897 |
} |
} |
898 |
|
|
899 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
3685 |
m_DimRegionChooser.select_next_dimension(); |
m_DimRegionChooser.select_next_dimension(); |
3686 |
} |
} |
3687 |
|
|
3688 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3689 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3690 |
|
|
3691 |
|
void MainWindow::copy_selected_dimrgn() { |
3692 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3693 |
|
if (!pDimRgn) { |
3694 |
|
updateClipboardPasteAvailable(); |
3695 |
|
updateClipboardCopyAvailable(); |
3696 |
|
return; |
3697 |
|
} |
3698 |
|
|
3699 |
|
std::vector<Gtk::TargetEntry> targets; |
3700 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3701 |
|
|
3702 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3703 |
|
clipboard->set( |
3704 |
|
targets, |
3705 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3706 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3707 |
|
); |
3708 |
|
|
3709 |
|
m_serializationArchive.serialize(pDimRgn); |
3710 |
|
|
3711 |
|
updateClipboardPasteAvailable(); |
3712 |
|
} |
3713 |
|
|
3714 |
|
void MainWindow::paste_copied_dimrgn() { |
3715 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3716 |
|
clipboard->request_contents( |
3717 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3718 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3719 |
|
); |
3720 |
|
updateClipboardPasteAvailable(); |
3721 |
|
} |
3722 |
|
|
3723 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3724 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3725 |
|
clipboard->request_targets( |
3726 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3727 |
|
); |
3728 |
|
} |
3729 |
|
|
3730 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3731 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3732 |
|
static_cast<Gtk::MenuItem*>( |
3733 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3734 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3735 |
|
} |
3736 |
|
|
3737 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3738 |
|
updateClipboardPasteAvailable(); |
3739 |
|
} |
3740 |
|
|
3741 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3742 |
|
const std::string target = selection_data.get_target(); |
3743 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3744 |
|
selection_data.set( |
3745 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3746 |
|
&m_serializationArchive.rawData()[0], |
3747 |
|
m_serializationArchive.rawData().size() |
3748 |
|
); |
3749 |
|
} else { |
3750 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3751 |
|
} |
3752 |
|
} |
3753 |
|
|
3754 |
|
void MainWindow::on_clipboard_clear() { |
3755 |
|
m_serializationArchive.clear(); |
3756 |
|
updateClipboardPasteAvailable(); |
3757 |
|
updateClipboardCopyAvailable(); |
3758 |
|
} |
3759 |
|
|
3760 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3761 |
|
const std::string target = selection_data.get_target(); |
3762 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3763 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3764 |
|
if (!pDimRgn) return; |
3765 |
|
|
3766 |
|
Glib::ustring errorText; |
3767 |
|
try { |
3768 |
|
m_serializationArchive.decode( |
3769 |
|
selection_data.get_data(), selection_data.get_length() |
3770 |
|
); |
3771 |
|
|
3772 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3773 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3774 |
|
{ |
3775 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3776 |
|
|
3777 |
|
dimreg_to_be_changed_signal.emit(pDimRgn); |
3778 |
|
|
3779 |
|
m_serializationArchive.deserialize(pDimRgn); |
3780 |
|
|
3781 |
|
dimreg_changed_signal.emit(pDimRgn); |
3782 |
|
} |
3783 |
|
|
3784 |
|
//region_changed() |
3785 |
|
file_changed(); |
3786 |
|
dimreg_changed(); |
3787 |
|
|
3788 |
|
} catch (Serialization::Exception e) { |
3789 |
|
errorText = e.Message; |
3790 |
|
} catch (...) { |
3791 |
|
errorText = _("Unknown exception during deserialization decoding"); |
3792 |
|
} |
3793 |
|
if (!errorText.empty()) { |
3794 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3795 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3796 |
|
msg.run(); |
3797 |
|
} |
3798 |
|
} |
3799 |
|
} |
3800 |
|
|
3801 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
3802 |
|
const bool bDimensionRegionPasteIsPossible = |
3803 |
|
std::find(targets.begin(), targets.end(), |
3804 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
3805 |
|
|
3806 |
|
static_cast<Gtk::MenuItem*>( |
3807 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3808 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3809 |
|
} |
3810 |
|
|
3811 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3812 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3813 |
} |
} |