58 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
59 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
60 |
#include "gfx/builtinpix.h" |
#include "gfx/builtinpix.h" |
61 |
|
#include "MacroEditor.h" |
62 |
|
|
63 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
64 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
199 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
200 |
); |
); |
201 |
actionGroup->add( |
actionGroup->add( |
202 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
203 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
204 |
); |
); |
205 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
213 |
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
214 |
#endif |
#endif |
215 |
|
|
216 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
217 |
|
_("Copy selected dimension region")), |
218 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
219 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
220 |
|
|
221 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
222 |
|
_("Paste dimension region")), |
223 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
224 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
225 |
|
|
226 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
227 |
|
_("Adjust Clipboard Content")), |
228 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
229 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
230 |
|
|
231 |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
232 |
_("Select Previous Region")), |
_("Select Previous Region")), |
233 |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
284 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
285 |
|
|
286 |
|
|
287 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
288 |
toggle_action = |
toggle_action = |
289 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
290 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
442 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
443 |
" </menu>" |
" </menu>" |
444 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
445 |
|
" <menuitem action='CopyDimRgn'/>" |
446 |
|
" <menuitem action='AdjustClipboard'/>" |
447 |
|
" <menuitem action='PasteDimRgn'/>" |
448 |
|
" <separator/>" |
449 |
" <menuitem action='SelectPrevRegion'/>" |
" <menuitem action='SelectPrevRegion'/>" |
450 |
" <menuitem action='SelectNextRegion'/>" |
" <menuitem action='SelectNextRegion'/>" |
451 |
" <separator/>" |
" <separator/>" |
818 |
|
|
819 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
820 |
// (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) |
821 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
822 |
|
|
823 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
824 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
825 |
|
); |
826 |
|
updateClipboardPasteAvailable(); |
827 |
|
updateClipboardCopyAvailable(); |
828 |
} |
} |
829 |
|
|
830 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
896 |
} |
} |
897 |
} |
} |
898 |
|
|
899 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
900 |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
901 |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
902 |
m_DimRegionChooser.setModifyBothChannels(stereo); |
m_DimRegionChooser.setModifyBothChannels(stereo); |
903 |
|
|
904 |
|
updateClipboardCopyAvailable(); |
905 |
} |
} |
906 |
|
|
907 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
3693 |
m_DimRegionChooser.select_next_dimension(); |
m_DimRegionChooser.select_next_dimension(); |
3694 |
} |
} |
3695 |
|
|
3696 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3697 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3698 |
|
|
3699 |
|
void MainWindow::copy_selected_dimrgn() { |
3700 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3701 |
|
if (!pDimRgn) { |
3702 |
|
updateClipboardPasteAvailable(); |
3703 |
|
updateClipboardCopyAvailable(); |
3704 |
|
return; |
3705 |
|
} |
3706 |
|
|
3707 |
|
std::vector<Gtk::TargetEntry> targets; |
3708 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3709 |
|
|
3710 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3711 |
|
clipboard->set( |
3712 |
|
targets, |
3713 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3714 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3715 |
|
); |
3716 |
|
|
3717 |
|
m_serializationArchive.serialize(pDimRgn); |
3718 |
|
|
3719 |
|
updateClipboardPasteAvailable(); |
3720 |
|
} |
3721 |
|
|
3722 |
|
void MainWindow::paste_copied_dimrgn() { |
3723 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3724 |
|
clipboard->request_contents( |
3725 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3726 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3727 |
|
); |
3728 |
|
updateClipboardPasteAvailable(); |
3729 |
|
} |
3730 |
|
|
3731 |
|
void MainWindow::adjust_clipboard_content() { |
3732 |
|
MacroEditor* editor = new MacroEditor; |
3733 |
|
editor->setMacro(&m_serializationArchive); |
3734 |
|
editor->show(); |
3735 |
|
} |
3736 |
|
|
3737 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3738 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3739 |
|
clipboard->request_targets( |
3740 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3741 |
|
); |
3742 |
|
} |
3743 |
|
|
3744 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3745 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3746 |
|
static_cast<Gtk::MenuItem*>( |
3747 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3748 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3749 |
|
} |
3750 |
|
|
3751 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3752 |
|
updateClipboardPasteAvailable(); |
3753 |
|
} |
3754 |
|
|
3755 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3756 |
|
const std::string target = selection_data.get_target(); |
3757 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3758 |
|
selection_data.set( |
3759 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3760 |
|
&m_serializationArchive.rawData()[0], |
3761 |
|
m_serializationArchive.rawData().size() |
3762 |
|
); |
3763 |
|
} else { |
3764 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3765 |
|
} |
3766 |
|
} |
3767 |
|
|
3768 |
|
void MainWindow::on_clipboard_clear() { |
3769 |
|
m_serializationArchive.clear(); |
3770 |
|
updateClipboardPasteAvailable(); |
3771 |
|
updateClipboardCopyAvailable(); |
3772 |
|
} |
3773 |
|
|
3774 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3775 |
|
const std::string target = selection_data.get_target(); |
3776 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3777 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3778 |
|
if (!pDimRgn) return; |
3779 |
|
|
3780 |
|
Glib::ustring errorText; |
3781 |
|
try { |
3782 |
|
m_serializationArchive.decode( |
3783 |
|
selection_data.get_data(), selection_data.get_length() |
3784 |
|
); |
3785 |
|
|
3786 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3787 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3788 |
|
{ |
3789 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3790 |
|
|
3791 |
|
dimreg_to_be_changed_signal.emit(pDimRgn); |
3792 |
|
|
3793 |
|
m_serializationArchive.deserialize(pDimRgn); |
3794 |
|
|
3795 |
|
dimreg_changed_signal.emit(pDimRgn); |
3796 |
|
} |
3797 |
|
|
3798 |
|
//region_changed() |
3799 |
|
file_changed(); |
3800 |
|
dimreg_changed(); |
3801 |
|
|
3802 |
|
} catch (Serialization::Exception e) { |
3803 |
|
errorText = e.Message; |
3804 |
|
} catch (...) { |
3805 |
|
errorText = _("Unknown exception during deserialization decoding"); |
3806 |
|
} |
3807 |
|
if (!errorText.empty()) { |
3808 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3809 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3810 |
|
msg.run(); |
3811 |
|
} |
3812 |
|
} |
3813 |
|
} |
3814 |
|
|
3815 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
3816 |
|
const bool bDimensionRegionPasteIsPossible = |
3817 |
|
std::find(targets.begin(), targets.end(), |
3818 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
3819 |
|
|
3820 |
|
static_cast<Gtk::MenuItem*>( |
3821 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3822 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3823 |
|
|
3824 |
|
static_cast<Gtk::MenuItem*>( |
3825 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
3826 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3827 |
|
} |
3828 |
|
|
3829 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3830 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3831 |
} |
} |