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

Contents of /gigedit/trunk/src/gigedit/gigedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1339 - (show annotations) (download)
Mon Sep 10 19:56:26 2007 UTC (16 years, 6 months ago) by schoenebeck
File size: 4768 byte(s)
* bugfix: signals triggered before and after sensible modifications didn't
  ever make it to the outer world (i.e. to LinuxSampler)

1 /*
2 * Copyright (C) 2007 Andreas Persson
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "gigedit.h"
21
22 #include <gtkmm/main.h>
23 #include "mainwindow.h"
24
25 #include <libintl.h>
26 #include <config.h>
27
28 // the app has to work from a DLL as well, so we hard code argv
29 int argc = 1;
30 const char* argv_c[] = { "gigedit" };
31 char** argv = const_cast<char**>(argv_c);
32 //FIXME: Gtk only allows to instantiate one Gtk::Main object per process, so this might crash other Gtk applications, i.e. launched as plugins by LinuxSampler
33 Gtk::Main kit(argc, argv);
34
35 static void __init_app() {
36 static bool process_initialized = false;
37 if (!process_initialized) {
38 std::cout << "Initializing 3rd party services needed by gigedit.\n"
39 << std::flush;
40 setlocale(LC_ALL, "");
41 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
42 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
43 textdomain(GETTEXT_PACKAGE);
44 // make sure thread_init() is called once and ONLY once per process
45 if (!Glib::thread_supported()) Glib::thread_init();
46
47 process_initialized = true;
48 }
49 }
50
51 static void __connect_signals(GigEdit* gigedit, MainWindow* mainwindow) {
52 // the signals of the "GigEdit" class are actually just proxies, that
53 // is they simply forward the signals of the internal classes to the
54 // outer world
55 mainwindow->signal_file_structure_to_be_changed().connect(
56 gigedit->signal_file_structure_to_be_changed().make_slot()
57 );
58 mainwindow->signal_file_structure_changed().connect(
59 gigedit->signal_file_structure_changed().make_slot()
60 );
61 mainwindow->signal_samples_to_be_removed().connect(
62 gigedit->signal_samples_to_be_removed().make_slot()
63 );
64 mainwindow->signal_samples_removed().connect(
65 gigedit->signal_samples_removed().make_slot()
66 );
67 mainwindow->signal_region_to_be_changed().connect(
68 gigedit->signal_region_to_be_changed().make_slot()
69 );
70 mainwindow->signal_region_changed().connect(
71 gigedit->signal_region_changed().make_slot()
72 );
73 mainwindow->signal_dimreg_to_be_changed().connect(
74 gigedit->signal_dimreg_to_be_changed().make_slot()
75 );
76 mainwindow->signal_dimreg_changed().connect(
77 gigedit->signal_dimreg_changed().make_slot()
78 );
79 mainwindow->signal_sample_ref_changed().connect(
80 gigedit->signal_sample_ref_changed().make_slot()
81 );
82 }
83
84 int GigEdit::run() {
85 __init_app();
86 MainWindow window;
87 __connect_signals(this, &window);
88 kit.run(window);
89 return 0;
90 }
91
92 int GigEdit::run(const char* pFileName) {
93 __init_app();
94 MainWindow window;
95 __connect_signals(this, &window);
96 if (pFileName) window.load_file(pFileName);
97 kit.run(window);
98 return 0;
99 }
100
101 int GigEdit::run(gig::Instrument* pInstrument) {
102 __init_app();
103 MainWindow window;
104 __connect_signals(this, &window);
105 if (pInstrument) window.load_instrument(pInstrument);
106 kit.run(window);
107 return 0;
108 }
109
110 sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() {
111 return file_structure_to_be_changed_signal;
112 }
113
114 sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_changed() {
115 return file_structure_changed_signal;
116 }
117
118 sigc::signal<void, std::list<gig::Sample*> >& GigEdit::signal_samples_to_be_removed() {
119 return samples_to_be_removed_signal;
120 }
121
122 sigc::signal<void>& GigEdit::signal_samples_removed() {
123 return samples_removed_signal;
124 }
125
126 sigc::signal<void, gig::Region*>& GigEdit::signal_region_to_be_changed() {
127 return region_to_be_changed_signal;
128 }
129
130 sigc::signal<void, gig::Region*>& GigEdit::signal_region_changed() {
131 return region_changed_signal;
132 }
133
134 sigc::signal<void, gig::DimensionRegion*>& GigEdit::signal_dimreg_to_be_changed() {
135 return dimreg_to_be_changed_signal;
136 }
137
138 sigc::signal<void, gig::DimensionRegion*>& GigEdit::signal_dimreg_changed() {
139 return dimreg_changed_signal;
140 }
141
142 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& GigEdit::signal_sample_ref_changed() {
143 return sample_ref_changed_signal;
144 }

  ViewVC Help
Powered by ViewVC