1 |
/* |
/* |
2 |
* Copyright (C) 2007 Andreas Persson |
* Copyright (C) 2007, 2008 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include "gigedit.h" |
#include "gigedit.h" |
21 |
|
|
22 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
23 |
|
#include <glibmm/main.h> |
24 |
#include "mainwindow.h" |
#include "mainwindow.h" |
25 |
|
|
26 |
#include "global.h" |
#include "global.h" |
40 |
GigEditState(GigEdit* parent) : parent(parent) { } |
GigEditState(GigEdit* parent) : parent(parent) { } |
41 |
void run(gig::Instrument* pInstrument); |
void run(gig::Instrument* pInstrument); |
42 |
|
|
43 |
|
MainWindow* window; |
44 |
|
|
45 |
private: |
private: |
46 |
|
|
47 |
// simple condition variable abstraction |
// simple condition variable abstraction |
74 |
Cond open; |
Cond open; |
75 |
Cond close; |
Cond close; |
76 |
gig::Instrument* instrument; |
gig::Instrument* instrument; |
|
MainWindow* window; |
|
77 |
|
|
78 |
void open_window(); |
void open_window(); |
79 |
void close_window(); |
void close_window(); |
87 |
setlocale(LC_ALL, ""); |
setlocale(LC_ALL, ""); |
88 |
|
|
89 |
#if HAVE_GETTEXT |
#if HAVE_GETTEXT |
90 |
|
|
91 |
|
#ifdef WIN32 |
92 |
|
#if GLIB_CHECK_VERSION(2, 16, 0) |
93 |
|
gchar* root = |
94 |
|
g_win32_get_package_installation_directory_of_module(NULL); |
95 |
|
#else |
96 |
|
gchar* root = |
97 |
|
g_win32_get_package_installation_directory(NULL, NULL); |
98 |
|
#endif |
99 |
|
gchar* temp = g_build_filename(root, "/share/locale", NULL); |
100 |
|
g_free(root); |
101 |
|
gchar* localedir = g_win32_locale_filename_from_utf8(temp); |
102 |
|
g_free(temp); |
103 |
|
bindtextdomain(GETTEXT_PACKAGE, localedir); |
104 |
|
g_free(localedir); |
105 |
|
#else |
106 |
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
107 |
|
#endif |
108 |
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
109 |
textdomain(GETTEXT_PACKAGE); |
textdomain(GETTEXT_PACKAGE); |
110 |
#endif // HAVE_GETTEXT |
#endif // HAVE_GETTEXT |
144 |
mainwindow->signal_dimreg_changed().connect( |
mainwindow->signal_dimreg_changed().connect( |
145 |
gigedit->signal_dimreg_changed().make_slot() |
gigedit->signal_dimreg_changed().make_slot() |
146 |
); |
); |
147 |
|
mainwindow->signal_sample_changed().connect( |
148 |
|
gigedit->signal_sample_changed().make_slot() |
149 |
|
); |
150 |
mainwindow->signal_sample_ref_changed().connect( |
mainwindow->signal_sample_ref_changed().connect( |
151 |
gigedit->signal_sample_ref_changed().make_slot() |
gigedit->signal_sample_ref_changed().make_slot() |
152 |
); |
); |
153 |
|
mainwindow->signal_keyboard_key_hit().connect( |
154 |
|
gigedit->signal_keyboard_key_hit().make_slot() |
155 |
|
); |
156 |
|
mainwindow->signal_keyboard_key_released().connect( |
157 |
|
gigedit->signal_keyboard_key_released().make_slot() |
158 |
|
); |
159 |
} |
} |
160 |
|
|
161 |
} |
} // namespace |
162 |
|
|
163 |
|
GigEdit::GigEdit() { |
164 |
|
state = NULL; |
165 |
|
} |
166 |
|
|
167 |
int GigEdit::run(int argc, char* argv[]) { |
int GigEdit::run(int argc, char* argv[]) { |
168 |
init_app(); |
init_app(); |
179 |
init_app(); |
init_app(); |
180 |
|
|
181 |
GigEditState state(this); |
GigEditState state(this); |
182 |
|
this->state = &state; |
183 |
state.run(pInstrument); |
state.run(pInstrument); |
184 |
|
this->state = NULL; |
185 |
return 0; |
return 0; |
186 |
} |
} |
187 |
|
|
188 |
|
void GigEdit::on_note_on_event(int key, int velocity) { |
189 |
|
if (!this->state) return; |
190 |
|
GigEditState* state = (GigEditState*) this->state; |
191 |
|
state->window->signal_note_on().emit(key, velocity); |
192 |
|
} |
193 |
|
|
194 |
|
void GigEdit::on_note_off_event(int key, int velocity) { |
195 |
|
if (!this->state) return; |
196 |
|
GigEditState* state = (GigEditState*) this->state; |
197 |
|
state->window->signal_note_off().emit(key, velocity); |
198 |
|
} |
199 |
|
|
200 |
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() { |
201 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
202 |
} |
} |
229 |
return dimreg_changed_signal; |
return dimreg_changed_signal; |
230 |
} |
} |
231 |
|
|
232 |
|
sigc::signal<void, gig::Sample*>& GigEdit::signal_sample_changed() { |
233 |
|
return sample_changed_signal; |
234 |
|
} |
235 |
|
|
236 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& GigEdit::signal_sample_ref_changed() { |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& GigEdit::signal_sample_ref_changed() { |
237 |
return sample_ref_changed_signal; |
return sample_ref_changed_signal; |
238 |
} |
} |
239 |
|
|
240 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_hit() { |
241 |
|
return keyboard_key_hit_signal; |
242 |
|
} |
243 |
|
|
244 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_released() { |
245 |
|
return keyboard_key_released_signal; |
246 |
|
} |
247 |
|
|
248 |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
249 |
Glib::Dispatcher* GigEditState::dispatcher = 0; |
Glib::Dispatcher* GigEditState::dispatcher = 0; |