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 |
|
33 |
static void __init_app() { |
34 |
setlocale(LC_ALL, ""); |
35 |
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
36 |
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
37 |
textdomain(GETTEXT_PACKAGE); |
38 |
|
39 |
Glib::thread_init(); |
40 |
} |
41 |
|
42 |
static void __connect_signals(GigEdit* gigedit, MainWindow* mainwindow) { |
43 |
// the signals of the "GigEdit" class are actually just proxies, that |
44 |
// is they simply forward the signals of the internal classes to the |
45 |
// outer world |
46 |
mainwindow->signal_file_structure_to_be_changed().connect( |
47 |
gigedit->signal_file_structure_to_be_changed().make_slot() |
48 |
); |
49 |
mainwindow->signal_file_structure_changed().connect( |
50 |
gigedit->signal_file_structure_changed().make_slot() |
51 |
); |
52 |
mainwindow->signal_samples_to_be_removed().connect( |
53 |
gigedit->signal_samples_to_be_removed().make_slot() |
54 |
); |
55 |
mainwindow->signal_samples_removed().connect( |
56 |
gigedit->signal_samples_removed().make_slot() |
57 |
); |
58 |
mainwindow->signal_region_to_be_changed().connect( |
59 |
gigedit->signal_region_to_be_changed().make_slot() |
60 |
); |
61 |
mainwindow->signal_region_changed().connect( |
62 |
gigedit->signal_region_changed().make_slot() |
63 |
); |
64 |
mainwindow->signal_dimreg_to_be_changed().connect( |
65 |
gigedit->signal_dimreg_to_be_changed().make_slot() |
66 |
); |
67 |
mainwindow->signal_dimreg_changed().connect( |
68 |
gigedit->signal_dimreg_changed().make_slot() |
69 |
); |
70 |
mainwindow->signal_sample_ref_changed().connect( |
71 |
gigedit->signal_sample_ref_changed().make_slot() |
72 |
); |
73 |
} |
74 |
|
75 |
int GigEdit::run() { |
76 |
__init_app(); |
77 |
Gtk::Main kit(argc, argv); |
78 |
MainWindow window; |
79 |
__connect_signals(this, &window); |
80 |
kit.run(window); |
81 |
return 0; |
82 |
} |
83 |
|
84 |
int GigEdit::run(const char* pFileName) { |
85 |
__init_app(); |
86 |
Gtk::Main kit(argc, argv); |
87 |
MainWindow window; |
88 |
__connect_signals(this, &window); |
89 |
if (pFileName) window.load_file(pFileName); |
90 |
kit.run(window); |
91 |
return 0; |
92 |
} |
93 |
|
94 |
int GigEdit::run(gig::Instrument* pInstrument) { |
95 |
__init_app(); |
96 |
Gtk::Main kit(argc, argv); |
97 |
MainWindow window; |
98 |
__connect_signals(this, &window); |
99 |
if (pInstrument) window.load_instrument(pInstrument); |
100 |
kit.run(window); |
101 |
return 0; |
102 |
} |
103 |
|
104 |
sigc::signal<void, gig::File*> GigEdit::signal_file_structure_to_be_changed() { |
105 |
return file_structure_to_be_changed_signal; |
106 |
} |
107 |
|
108 |
sigc::signal<void, gig::File*> GigEdit::signal_file_structure_changed() { |
109 |
return file_structure_changed_signal; |
110 |
} |
111 |
|
112 |
sigc::signal<void, std::list<gig::Sample*> > GigEdit::signal_samples_to_be_removed() { |
113 |
return samples_to_be_removed_signal; |
114 |
} |
115 |
|
116 |
sigc::signal<void> GigEdit::signal_samples_removed() { |
117 |
return samples_removed_signal; |
118 |
} |
119 |
|
120 |
sigc::signal<void, gig::Region*> GigEdit::signal_region_to_be_changed() { |
121 |
return region_to_be_changed_signal; |
122 |
} |
123 |
|
124 |
sigc::signal<void, gig::Region*> GigEdit::signal_region_changed() { |
125 |
return region_changed_signal; |
126 |
} |
127 |
|
128 |
sigc::signal<void, gig::DimensionRegion*> GigEdit::signal_dimreg_to_be_changed() { |
129 |
return dimreg_to_be_changed_signal; |
130 |
} |
131 |
|
132 |
sigc::signal<void, gig::DimensionRegion*> GigEdit::signal_dimreg_changed() { |
133 |
return dimreg_changed_signal; |
134 |
} |
135 |
|
136 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> GigEdit::signal_sample_ref_changed() { |
137 |
return sample_ref_changed_signal; |
138 |
} |