/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3151 by schoenebeck, Fri May 5 18:44:59 2017 UTC revision 3339 by schoenebeck, Sun Jul 30 18:57:35 2017 UTC
# Line 35  Line 35 
35  #include <gtkmm/aboutdialog.h>  #include <gtkmm/aboutdialog.h>
36  #include <gtkmm/filechooserdialog.h>  #include <gtkmm/filechooserdialog.h>
37  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
38    #include <gtkmm/stock.h>
39  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
40  #include <gtkmm/main.h>  #include <gtkmm/main.h>
41  #include <gtkmm/toggleaction.h>  #include <gtkmm/toggleaction.h>
42    #include <gtkmm/accelmap.h>
43  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
44  #include "wrapLabel.hh"  #include "wrapLabel.hh"
45  #endif  #endif
# Line 59  Line 61 
61  #include "../../gfx/status_detached.xpm"  #include "../../gfx/status_detached.xpm"
62  #include "gfx/builtinpix.h"  #include "gfx/builtinpix.h"
63  #include "MacroEditor.h"  #include "MacroEditor.h"
64    #include "MacrosSetup.h"
65    #if defined(__APPLE__)
66    # include "MacHelper.h"
67    #endif
68    
69    static const Gdk::ModifierType primaryModifierKey =
70        #if defined(__APPLE__)
71        Gdk::META_MASK; // Cmd key on Mac
72        #else
73        Gdk::CONTROL_MASK; // Ctrl key on all other OSs
74        #endif
75    
76  MainWindow::MainWindow() :  MainWindow::MainWindow() :
77      m_DimRegionChooser(*this),      m_DimRegionChooser(*this),
# Line 74  MainWindow::MainWindow() : Line 87  MainWindow::MainWindow() :
87  {  {
88      loadBuiltInPix();      loadBuiltInPix();
89    
90        this->file = NULL;
91    
92  //    set_border_width(5);  //    set_border_width(5);
93  //    set_default_size(400, 200);  
94        if (!Settings::singleton()->autoRestoreWindowDimension) {
95            set_default_size(800, 600);
96            set_position(Gtk::WIN_POS_CENTER);
97        }
98    
99      add(m_VBox);      add(m_VBox);
100    
# Line 154  MainWindow::MainWindow() : Line 173  MainWindow::MainWindow() :
173      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
174    
175      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
176      actionGroup->add(Gtk::Action::create("New", _("_New")),      actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),
                      Gtk::AccelKey("<control>n"),  
177                       sigc::mem_fun(                       sigc::mem_fun(
178                           *this, &MainWindow::on_action_file_new));                           *this, &MainWindow::on_action_file_new));
179      actionGroup->add(Gtk::Action::create("Open", _("_Open...")),      Glib::RefPtr<Gtk::Action> action =
180                       Gtk::AccelKey("<control>o"),          Gtk::Action::create("Open", Gtk::Stock::OPEN);
181        action->property_label() = action->property_label() + "...";
182        actionGroup->add(action,
183                       sigc::mem_fun(                       sigc::mem_fun(
184                           *this, &MainWindow::on_action_file_open));                           *this, &MainWindow::on_action_file_open));
185      actionGroup->add(Gtk::Action::create("Save", _("_Save")),      actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE),
                      Gtk::AccelKey("<control>s"),  
186                       sigc::mem_fun(                       sigc::mem_fun(
187                           *this, &MainWindow::on_action_file_save));                           *this, &MainWindow::on_action_file_save));
188      actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")),      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);
189        action->property_label() = action->property_label() + "...";
190        actionGroup->add(action,
191                       Gtk::AccelKey("<shift><control>s"),                       Gtk::AccelKey("<shift><control>s"),
192                       sigc::mem_fun(                       sigc::mem_fun(
193                           *this, &MainWindow::on_action_file_save_as));                           *this, &MainWindow::on_action_file_save_as));
194      actionGroup->add(Gtk::Action::create("Properties",      actionGroup->add(Gtk::Action::create("Properties",
195                                           _("_Properties")),                                           Gtk::Stock::PROPERTIES),
196                       sigc::mem_fun(                       sigc::mem_fun(
197                           *this, &MainWindow::on_action_file_properties));                           *this, &MainWindow::on_action_file_properties));
198      actionGroup->add(Gtk::Action::create("InstrProperties",      actionGroup->add(Gtk::Action::create("InstrProperties",
199                                           _("_Properties")),                                           Gtk::Stock::PROPERTIES),
200                       sigc::mem_fun(                       sigc::mem_fun(
201                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
202      actionGroup->add(Gtk::Action::create("MidiRules",      actionGroup->add(Gtk::Action::create("MidiRules",
# Line 186  MainWindow::MainWindow() : Line 207  MainWindow::MainWindow() :
207                                           _("_Script Slots...")),                                           _("_Script Slots...")),
208                       sigc::mem_fun(                       sigc::mem_fun(
209                           *this, &MainWindow::show_script_slots));                           *this, &MainWindow::show_script_slots));
210      actionGroup->add(Gtk::Action::create("Quit", _("_Quit")),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
                      Gtk::AccelKey("<control>q"),  
211                       sigc::mem_fun(                       sigc::mem_fun(
212                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
213      actionGroup->add(      actionGroup->add(
# Line 203  MainWindow::MainWindow() : Line 223  MainWindow::MainWindow() :
223          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
224      );      );
225      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));
226        actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script")));
227    
228      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
229    
# Line 228  MainWindow::MainWindow() : Line 249  MainWindow::MainWindow() :
249                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),
250                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));
251    
252        actionGroup->add(Gtk::Action::create("SelectPrevInstr",
253                                             _("Select Previous Instrument")),
254                         Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey),
255                         sigc::mem_fun(*this, &MainWindow::select_prev_instrument));
256    
257        actionGroup->add(Gtk::Action::create("SelectNextInstr",
258                                             _("Select Next Instrument")),
259                         Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey),
260                         sigc::mem_fun(*this, &MainWindow::select_next_instrument));
261    
262      actionGroup->add(Gtk::Action::create("SelectPrevRegion",      actionGroup->add(Gtk::Action::create("SelectPrevRegion",
263                                           _("Select Previous Region")),                                           _("Select Previous Region")),
264                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),
# Line 284  MainWindow::MainWindow() : Line 315  MainWindow::MainWindow() :
315      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
316    
317    
318        actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));
319    
320    
321      actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w")));      actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w")));
322      toggle_action =      toggle_action =
323          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));
# Line 311  MainWindow::MainWindow() : Line 345  MainWindow::MainWindow() :
345          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
346      );                      );                
347    
348      actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
349      actionGroup->add(Gtk::Action::create("About", _("_About")),      actionGroup->add(Gtk::Action::create("MenuHelp",
350                                             action->property_label()));
351        actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
352                       sigc::mem_fun(                       sigc::mem_fun(
353                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
354      actionGroup->add(      actionGroup->add(
# Line 324  MainWindow::MainWindow() : Line 360  MainWindow::MainWindow() :
360          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
361      );      );
362      actionGroup->add(      actionGroup->add(
363          Gtk::Action::create("RemoveInstrument", _("_Remove")),          Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),
364            Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),
365            sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
366        );
367        actionGroup->add(
368            Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
369          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
370      );      );
371    
# Line 371  MainWindow::MainWindow() : Line 412  MainWindow::MainWindow() :
412    
413      // sample right-click popup actions      // sample right-click popup actions
414      actionGroup->add(      actionGroup->add(
415          Gtk::Action::create("SampleProperties", _("_Properties")),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
416          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
417      );      );
418      actionGroup->add(      actionGroup->add(
# Line 383  MainWindow::MainWindow() : Line 424  MainWindow::MainWindow() :
424          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
425      );      );
426      actionGroup->add(      actionGroup->add(
427          Gtk::Action::create("RemoveSample", _("_Remove")),          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),
428          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
429      );      );
430      actionGroup->add(      actionGroup->add(
# Line 419  MainWindow::MainWindow() : Line 460  MainWindow::MainWindow() :
460          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
461      );      );
462      actionGroup->add(      actionGroup->add(
463          Gtk::Action::create("RemoveScript", _("_Remove")),          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),
464          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
465      );      );
466    
# Line 446  MainWindow::MainWindow() : Line 487  MainWindow::MainWindow() :
487          "      <menuitem action='AdjustClipboard'/>"          "      <menuitem action='AdjustClipboard'/>"
488          "      <menuitem action='PasteDimRgn'/>"          "      <menuitem action='PasteDimRgn'/>"
489          "      <separator/>"          "      <separator/>"
490            "      <menuitem action='SelectPrevInstr'/>"
491            "      <menuitem action='SelectNextInstr'/>"
492            "      <separator/>"
493          "      <menuitem action='SelectPrevRegion'/>"          "      <menuitem action='SelectPrevRegion'/>"
494          "      <menuitem action='SelectNextRegion'/>"          "      <menuitem action='SelectNextRegion'/>"
495          "      <separator/>"          "      <separator/>"
# Line 460  MainWindow::MainWindow() : Line 504  MainWindow::MainWindow() :
504          "      <menuitem action='CopySampleTune'/>"          "      <menuitem action='CopySampleTune'/>"
505          "      <menuitem action='CopySampleLoop'/>"          "      <menuitem action='CopySampleLoop'/>"
506          "    </menu>"          "    </menu>"
507            "    <menu action='MenuMacro'>"
508            "    </menu>"
509          "    <menu action='MenuSample'>"          "    <menu action='MenuSample'>"
510          "      <menuitem action='SampleProperties'/>"          "      <menuitem action='SampleProperties'/>"
511          "      <menuitem action='AddGroup'/>"          "      <menuitem action='AddGroup'/>"
# Line 478  MainWindow::MainWindow() : Line 524  MainWindow::MainWindow() :
524          "      <menuitem action='InstrProperties'/>"          "      <menuitem action='InstrProperties'/>"
525          "      <menuitem action='MidiRules'/>"          "      <menuitem action='MidiRules'/>"
526          "      <menuitem action='ScriptSlots'/>"          "      <menuitem action='ScriptSlots'/>"
527            "      <menu action='AssignScripts'/>"
528          "      <menuitem action='AddInstrument'/>"          "      <menuitem action='AddInstrument'/>"
529          "      <menuitem action='DupInstrument'/>"          "      <menuitem action='DupInstrument'/>"
530            "      <menuitem action='CombInstruments'/>"
531          "      <separator/>"          "      <separator/>"
532          "      <menuitem action='RemoveInstrument'/>"          "      <menuitem action='RemoveInstrument'/>"
533          "    </menu>"          "    </menu>"
# Line 516  MainWindow::MainWindow() : Line 564  MainWindow::MainWindow() :
564          "    <menuitem action='ScriptSlots'/>"          "    <menuitem action='ScriptSlots'/>"
565          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
566          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
567            "    <menuitem action='CombInstruments'/>"
568          "    <separator/>"          "    <separator/>"
569          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
570          "  </popup>"          "  </popup>"
# Line 610  MainWindow::MainWindow() : Line 659  MainWindow::MainWindow() :
659      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
660          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
661    
662        assign_scripts_menu = static_cast<Gtk::MenuItem*>(
663            uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu();
664    
665      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
666      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
667      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
# Line 643  MainWindow::MainWindow() : Line 695  MainWindow::MainWindow() :
695      // Add the TreeView's view columns:      // Add the TreeView's view columns:
696      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
697      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
698        m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts);
699      m_TreeView.set_headers_visible(true);      m_TreeView.set_headers_visible(true);
700            
701      // establish drag&drop within the instrument tree view, allowing to reorder      // establish drag&drop within the instrument tree view, allowing to reorder
# Line 825  MainWindow::MainWindow() : Line 878  MainWindow::MainWindow() :
878      );      );
879      updateClipboardPasteAvailable();      updateClipboardPasteAvailable();
880      updateClipboardCopyAvailable();      updateClipboardCopyAvailable();
881    
882        // setup macros and their keyboard accelerators
883        {
884            Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
885                uiManager->get_widget("/MenuBar/MenuMacro")
886            )->get_submenu();
887    
888            const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;
889            Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier);
890            Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier);
891            Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier);
892            Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier);
893            Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier);
894            Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier);
895            Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier);
896            Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier);
897            Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier);
898            Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);
899            Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);
900            Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);
901            Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);
902    
903            Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
904            menuMacro->set_accel_group(accelGroup);
905    
906            updateMacroMenu();
907        }
908    
909        // setup "Assign Scripts" keyboard accelerators
910        {
911            Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK);
912            Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK);
913            Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK);
914            Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK);
915            Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK);
916            Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK);
917            Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK);
918            Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK);
919            Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK);
920            Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);
921            Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);
922            Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);
923    
924            Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
925            assign_scripts_menu->set_accel_group(accelGroup);
926        }
927    
928        Glib::signal_idle().connect_once(
929            sigc::mem_fun(*this, &MainWindow::bringToFront),
930            200
931        );
932  }  }
933    
934  MainWindow::~MainWindow()  MainWindow::~MainWindow()
935  {  {
936  }  }
937    
938    void MainWindow::bringToFront() {
939        #if defined(__APPLE__)
940        macRaiseAppWindow();
941        #endif
942        raise();
943        present();
944    }
945    
946    void MainWindow::updateMacroMenu() {
947        Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
948            uiManager->get_widget("/MenuBar/MenuMacro")
949        )->get_submenu();
950    
951        // remove all entries from "Macro" menu
952        {
953            const std::vector<Gtk::Widget*> children = menuMacro->get_children();
954            for (int i = 0; i < children.size(); ++i) {
955                Gtk::Widget* child = children[i];
956                menuMacro->remove(*child);
957                delete child;
958            }
959        }
960    
961        // (re)load all macros from config file
962        try {
963            Settings::singleton()->loadMacros(m_macros);
964        } catch (Serialization::Exception e) {
965            std::cerr << "Exception while loading macros: " << e.Message << std::endl;
966        } catch (...) {
967            std::cerr << "Unknown exception while loading macros!" << std::endl;
968        }
969    
970        // add all configured macros as menu items to the "Macro" menu
971        for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) {
972            const Serialization::Archive& macro = m_macros[iMacro];
973            std::string name =
974                macro.name().empty() ?
975                    (std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name();
976            Gtk::MenuItem* item = new Gtk::MenuItem(name);
977            item->signal_activate().connect(
978                sigc::bind(
979                    sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro
980                )
981            );
982            menuMacro->append(*item);
983            item->set_accel_path("<Macros>/macro_" + ToString(iMacro));
984            Glib::ustring comment = macro.comment();
985            if (!comment.empty())
986                item->set_tooltip_text(comment);
987        }
988        // if there are no macros configured at all, then show a dummy entry instead
989        if (m_macros.empty()) {
990            Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros"));
991            item->set_sensitive(false);
992            menuMacro->append(*item);
993        }
994    
995        // add separator line to menu
996        menuMacro->append(*new Gtk::SeparatorMenuItem);
997    
998        {
999            Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ..."));
1000            item->signal_activate().connect(
1001                sigc::mem_fun(*this, &MainWindow::setupMacros)
1002            );
1003            menuMacro->append(*item);
1004            item->set_accel_path("<Macros>/SetupMacros");
1005        }
1006    
1007        menuMacro->show_all_children();
1008    }
1009    
1010    void MainWindow::onMacroSelected(int iMacro) {
1011        printf("onMacroSelected(%d)\n", iMacro);
1012        if (iMacro < 0 || iMacro >= m_macros.size()) return;
1013        Glib::ustring errorText;
1014        try {
1015            applyMacro(m_macros[iMacro]);
1016        } catch (Serialization::Exception e) {
1017            errorText = e.Message;
1018        } catch (...) {
1019            errorText = _("Unknown exception while applying macro");
1020        }
1021        if (!errorText.empty()) {
1022            Glib::ustring txt = _("Applying macro failed:\n") + errorText;
1023            Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1024            msg.run();
1025        }
1026    }
1027    
1028    void MainWindow::setupMacros() {
1029        MacrosSetup* setup = new MacrosSetup();
1030        gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion();
1031        setup->setMacros(m_macros, &m_serializationArchive, pDimRgn);
1032        setup->signal_macros_changed().connect(
1033            sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged)
1034        );
1035        setup->show();
1036    }
1037    
1038    void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) {
1039        m_macros = macros;
1040        Settings::singleton()->saveMacros(m_macros);
1041        updateMacroMenu();
1042    }
1043    
1044  bool MainWindow::on_delete_event(GdkEventAny* event)  bool MainWindow::on_delete_event(GdkEventAny* event)
1045  {  {
1046      return !file_is_shared && file_is_changed && !close_confirmation_dialog();      return !file_is_shared && file_is_changed && !close_confirmation_dialog();
# Line 931  void MainWindow::on_sel_change() Line 1141  void MainWindow::on_sel_change()
1141          }          }
1142      }      }
1143    
1144        updateScriptListOfMenu();
1145    
1146      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
1147    
1148      if (Settings::singleton()->syncSamplerInstrumentSelection) {      if (Settings::singleton()->syncSamplerInstrumentSelection) {
# Line 1061  void Saver::thread_function() Line 1273  void Saver::thread_function()
1273                  // save the file as separate temporary file first,                  // save the file as separate temporary file first,
1274                  // then move the saved file over the old file                  // then move the saved file over the old file
1275                  // (may result in performance speedup during save)                  // (may result in performance speedup during save)
1276                  String tmpname = filename + ".TMP";                  gig::String tmpname = filename + ".TMP";
1277                  gig->Save(tmpname, &progress);                  gig->Save(tmpname, &progress);
1278                  #if defined(WIN32)                  #if defined(WIN32)
1279                  if (!DeleteFile(filename.c_str())) {                  if (!DeleteFile(filename.c_str())) {
# Line 1069  void Saver::thread_function() Line 1281  void Saver::thread_function()
1281                  }                  }
1282                  #else // POSIX ...                  #else // POSIX ...
1283                  if (unlink(filename.c_str())) {                  if (unlink(filename.c_str())) {
1284                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));
1285                  }                  }
1286                  #endif                  #endif
1287                  if (rename(tmpname.c_str(), filename.c_str())) {                  if (rename(tmpname.c_str(), filename.c_str())) {
1288                      #if defined(WIN32)                      #if defined(WIN32)
1289                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
1290                      #else                      #else
1291                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));
1292                      #endif                      #endif
1293                  }                  }
1294              }              }
# Line 1204  bool MainWindow::close_confirmation_dial Line 1416  bool MainWindow::close_confirmation_dial
1416      g_free(msg);      g_free(msg);
1417      dialog.set_secondary_text(_("If you close without saving, your changes will be lost."));      dialog.set_secondary_text(_("If you close without saving, your changes will be lost."));
1418      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
1419      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1420      dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);
1421      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
1422      int response = dialog.run();      int response = dialog.run();
1423      dialog.hide();      dialog.hide();
# Line 1236  bool MainWindow::leaving_shared_mode_dia Line 1448  bool MainWindow::leaving_shared_mode_dia
1448            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
1449            "load it."));            "load it."));
1450      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
1451      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1452      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
1453      int response = dialog.run();      int response = dialog.run();
1454      dialog.hide();      dialog.hide();
# Line 1250  void MainWindow::on_action_file_open() Line 1462  void MainWindow::on_action_file_open()
1462      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
1463    
1464      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
1465      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1466      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
1467      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1468  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
1469      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1446  void MainWindow::on_action_file_save_as( Line 1658  void MainWindow::on_action_file_save_as(
1658    
1659  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
1660  {  {
1661      Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
1662      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1663      dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
1664      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1665      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
1666    
# Line 1672  void MainWindow::on_action_help_about() Line 1884  void MainWindow::on_action_help_about()
1884      dialog.set_comments(sComment.c_str());      dialog.set_comments(sComment.c_str());
1885      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
1886      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
1887        dialog.set_position(Gtk::WIN_POS_CENTER);
1888      dialog.run();      dialog.run();
1889  }  }
1890    
# Line 1693  PropDialog::PropDialog() Line 1906  PropDialog::PropDialog()
1906        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
1907        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
1908        eSubject(_("Subject")),        eSubject(_("Subject")),
1909        quitButton(_("_Close"), true),        quitButton(Gtk::Stock::CLOSE),
1910        table(2, 1),        table(2, 1),
1911        m_file(NULL)        m_file(NULL)
1912  {  {
1913        if (!Settings::singleton()->autoRestoreWindowDimension) {
1914            set_default_size(470, 390);
1915            set_position(Gtk::WIN_POS_MOUSE);
1916        }
1917    
1918      set_title(_("File Properties"));      set_title(_("File Properties"));
1919      eName.set_width_chars(50);      eName.set_width_chars(50);
1920    
# Line 1816  void InstrumentProps::set_MIDIProgram(ui Line 2034  void InstrumentProps::set_MIDIProgram(ui
2034  }  }
2035    
2036  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
2037      quitButton(_("_Close"), true),      quitButton(Gtk::Stock::CLOSE),
2038      table(2,1),      table(2,1),
2039      eName(_("Name")),      eName(_("Name")),
2040      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1831  InstrumentProps::InstrumentProps() : Line 2049  InstrumentProps::InstrumentProps() :
2049      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2050      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high"))
2051  {  {
2052        if (!Settings::singleton()->autoRestoreWindowDimension) {
2053            //set_default_size(470, 390);
2054            set_position(Gtk::WIN_POS_MOUSE);
2055        }
2056    
2057      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2058    
2059      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
# Line 1955  void MainWindow::load_gig(gig::File* gig Line 2178  void MainWindow::load_gig(gig::File* gig
2178      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
2179           instrument = gig->GetNextInstrument(), ++index) {           instrument = gig->GetNextInstrument(), ++index) {
2180          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
2181            const int iScriptSlots = instrument->ScriptSlotCount();
2182    
2183          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
2184          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
2185          row[m_Columns.m_col_nr] = index;          row[m_Columns.m_col_nr] = index;
2186          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
2187          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
2188            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2189    
2190          add_instrument_to_menu(name);          add_instrument_to_menu(name);
2191      }      }
# Line 2099  void MainWindow::show_script_slots() { Line 2324  void MainWindow::show_script_slots() {
2324    
2325      ScriptSlots* window = new ScriptSlots;      ScriptSlots* window = new ScriptSlots;
2326      window->setInstrument(instrument);      window->setInstrument(instrument);
2327        window->signal_script_slots_changed().connect(
2328            sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified)
2329        );
2330      //window->reparent(*this);      //window->reparent(*this);
2331      window->show();      window->show();
2332  }  }
2333    
2334    void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) {
2335        if (!pInstrument) return;
2336        const int iScriptSlots = pInstrument->ScriptSlotCount();
2337    
2338        Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
2339        for (int i = 0; i < model->children().size(); ++i) {
2340            Gtk::TreeModel::Row row = model->children()[i];
2341            if (row[m_Columns.m_col_instr] != pInstrument) continue;
2342            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2343            break;
2344        }
2345    
2346        // causes the sampler to reload the instrument with the new script
2347        on_sel_change();
2348    }
2349    
2350    void MainWindow::assignScript(gig::Script* pScript) {
2351        if (!pScript) {
2352            printf("assignScript() : !script\n");
2353            return;
2354        }
2355        printf("assignScript('%s')\n", pScript->Name.c_str());
2356    
2357        gig::Instrument* pInstrument = get_instrument();
2358        if (!pInstrument) {
2359            printf("!instrument\n");
2360            return;
2361        }
2362    
2363        pInstrument->AddScriptSlot(pScript);
2364    
2365        onScriptSlotsModified(pInstrument);
2366    }
2367    
2368  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
2369      __refreshEntireGUI();      __refreshEntireGUI();
2370  }  }
# Line 2375  void MainWindow::on_script_treeview_butt Line 2637  void MainWindow::on_script_treeview_butt
2637      }      }
2638  }  }
2639    
2640    void MainWindow::updateScriptListOfMenu() {
2641        // remove all entries from "Assign Script" menu
2642        {
2643            const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children();
2644            for (int i = 0; i < children.size(); ++i) {
2645                Gtk::Widget* child = children[i];
2646                assign_scripts_menu->remove(*child);
2647                delete child;
2648            }
2649        }
2650    
2651        int iTotalScripts = 0;
2652    
2653        if (!file) goto noScripts;
2654    
2655        // add all configured macros as menu items to the "Macro" menu
2656        for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) {
2657            gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup);
2658            for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) {
2659                gig::Script* pScript = pGroup->GetScript(iScript);
2660                std::string name = pScript->Name;
2661    
2662                Gtk::MenuItem* item = new Gtk::MenuItem(name);
2663                item->signal_activate().connect(
2664                    sigc::bind(
2665                        sigc::mem_fun(*this, &MainWindow::assignScript), pScript
2666                    )
2667                );
2668                assign_scripts_menu->append(*item);
2669                item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts));
2670                //item->set_tooltip_text(comment);
2671            }
2672        }
2673    
2674        noScripts:
2675    
2676        // if there are no macros configured at all, then show a dummy entry instead
2677        if (!iTotalScripts) {
2678            Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts"));
2679            item->set_sensitive(false);
2680            assign_scripts_menu->append(*item);
2681        }
2682    
2683        assign_scripts_menu->show_all_children();
2684    }
2685    
2686  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(
2687      const Glib::ustring& name, int position) {      const Glib::ustring& name, int position) {
2688    
# Line 2417  void MainWindow::add_instrument(gig::Ins Line 2725  void MainWindow::add_instrument(gig::Ins
2725      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
2726      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
2727      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
2728        rowInstr[m_Columns.m_col_scripts] = "";
2729      instrument_name_connection.unblock();      instrument_name_connection.unblock();
2730    
2731      add_instrument_to_menu(name);      add_instrument_to_menu(name);
2732        select_instrument(instrument);
     m_TreeView.get_selection()->select(iterInstr);  
   
2733      file_changed();      file_changed();
2734  }  }
2735    
# Line 2705  void MainWindow::add_or_replace_sample(b Line 3012  void MainWindow::add_or_replace_sample(b
3012    
3013      // show 'browse for file' dialog      // show 'browse for file' dialog
3014      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
3015      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3016      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
3017      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample
3018    
3019      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 2906  void MainWindow::on_action_replace_all_s Line 3213  void MainWindow::on_action_replace_all_s
3213      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
3214      description.show();      description.show();
3215      entryArea.show_all();      entryArea.show_all();
3216      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3217      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
3218      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
3219      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 3394  void MainWindow::instrument_name_changed Line 3701  void MainWindow::instrument_name_changed
3701    
3702  void MainWindow::on_action_combine_instruments() {  void MainWindow::on_action_combine_instruments() {
3703      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);
3704    
3705        // take over selection from instruments list view for the combine dialog's
3706        // list view as pre-selection
3707        std::set<int> indeces;
3708        {
3709            Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
3710            std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3711            for (int r = 0; r < rows.size(); ++r) {
3712                Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
3713                if (it) {
3714                    Gtk::TreeModel::Row row = *it;
3715                    int index = row[m_Columns.m_col_nr];
3716                    indeces.insert(index);
3717                }
3718            }
3719        }
3720        d->setSelectedInstruments(indeces);
3721    
3722      d->show_all();      d->show_all();
     d->resize(500, 400);  
3723      d->run();      d->run();
3724      if (d->fileWasChanged()) {      if (d->fileWasChanged()) {
3725          // update GUI with new instrument just created          // update GUI with new instrument just created
# Line 3530  void MainWindow::on_action_merge_files() Line 3854  void MainWindow::on_action_merge_files()
3854      }      }
3855    
3856      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
3857      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3858      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
3859      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
3860  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
# Line 3657  void MainWindow::show_scripts_tab() { Line 3981  void MainWindow::show_scripts_tab() {
3981      m_TreeViewNotebook.set_current_page(2);      m_TreeViewNotebook.set_current_page(2);
3982  }  }
3983    
3984    void MainWindow::select_instrument_by_dir(int dir) {
3985        if (!file) return;
3986        gig::Instrument* pInstrument = get_instrument();
3987        if (!pInstrument) {
3988            select_instrument( file->GetInstrument(0) );
3989            return;
3990        }
3991        for (int i = 0; file->GetInstrument(i); ++i) {
3992            if (file->GetInstrument(i) == pInstrument) {
3993                select_instrument( file->GetInstrument(i + dir) );
3994                return;
3995            }
3996        }
3997    }
3998    
3999    void MainWindow::select_prev_instrument() {
4000        select_instrument_by_dir(-1);
4001    }
4002    
4003    void MainWindow::select_next_instrument() {
4004        select_instrument_by_dir(1);
4005    }
4006    
4007  void MainWindow::select_prev_region() {  void MainWindow::select_prev_region() {
4008      m_RegionChooser.select_prev_region();      m_RegionChooser.select_prev_region();
4009  }  }
# Line 3729  void MainWindow::paste_copied_dimrgn() { Line 4076  void MainWindow::paste_copied_dimrgn() {
4076  }  }
4077    
4078  void MainWindow::adjust_clipboard_content() {  void MainWindow::adjust_clipboard_content() {
4079      MacroEditor* editor = new MacroEditor;      MacroEditor* editor = new MacroEditor();
4080      editor->setMacro(&m_serializationArchive);      editor->setMacro(&m_serializationArchive, true);
4081      editor->show();      editor->show();
4082  }  }
4083    
# Line 3771  void MainWindow::on_clipboard_clear() { Line 4118  void MainWindow::on_clipboard_clear() {
4118      updateClipboardCopyAvailable();      updateClipboardCopyAvailable();
4119  }  }
4120    
4121    //NOTE: Might throw exception !!!
4122    void MainWindow::applyMacro(Serialization::Archive& macro) {
4123        gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion();
4124        if (!pDimRgn) return;
4125    
4126        for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin();
4127             itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)
4128        {
4129            gig::DimensionRegion* pDimRgn = *itDimReg;
4130            DimRegionChangeGuard(this, pDimRgn);
4131            macro.deserialize(pDimRgn);
4132        }
4133        //region_changed()
4134        file_changed();
4135        dimreg_changed();
4136    }
4137    
4138  void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) {  void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) {
4139      const std::string target = selection_data.get_target();      const std::string target = selection_data.get_target();
4140      if (target == CLIPBOARD_DIMENSIONREGION_TARGET) {      if (target == CLIPBOARD_DIMENSIONREGION_TARGET) {
         gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion();  
         if (!pDimRgn) return;  
   
4141          Glib::ustring errorText;          Glib::ustring errorText;
4142          try {          try {
4143              m_serializationArchive.decode(              m_serializationArchive.decode(
4144                  selection_data.get_data(), selection_data.get_length()                  selection_data.get_data(), selection_data.get_length()
4145              );              );
4146                applyMacro(m_serializationArchive);
             for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin();  
                  itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)  
             {  
                 gig::DimensionRegion* pDimRgn = *itDimReg;  
   
                 dimreg_to_be_changed_signal.emit(pDimRgn);  
   
                 m_serializationArchive.deserialize(pDimRgn);  
   
                 dimreg_changed_signal.emit(pDimRgn);  
             }  
   
             //region_changed()  
             file_changed();  
             dimreg_changed();  
   
4147          } catch (Serialization::Exception e) {          } catch (Serialization::Exception e) {
4148              errorText = e.Message;              errorText = e.Message;
4149          } catch (...) {          } catch (...) {
4150              errorText = _("Unknown exception during deserialization decoding");              errorText = _("Unknown exception while pasting DimensionRegion");
4151          }          }
4152          if (!errorText.empty()) {          if (!errorText.empty()) {
4153              Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText;              Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText;

Legend:
Removed from v.3151  
changed lines
  Added in v.3339

  ViewVC Help
Powered by ViewVC