22 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
23 |
#include "mainwindow.h" |
#include "mainwindow.h" |
24 |
|
|
25 |
#include <libintl.h> |
#include "global.h" |
|
#include <config.h> |
|
26 |
|
|
27 |
// the app has to work from a DLL as well, so we hard code argv |
// the app has to work from a DLL as well, so we hard code argv |
28 |
int argc = 1; |
int argc = 1; |
29 |
const char* argv_c[] = { "gigedit" }; |
const char* argv_c[] = { "gigedit" }; |
30 |
char** argv = const_cast<char**>(argv_c); |
char** argv = const_cast<char**>(argv_c); |
31 |
|
//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 |
32 |
|
Gtk::Main kit(argc, argv); |
33 |
|
|
34 |
static void __init_app() { |
static void __init_app() { |
35 |
setlocale(LC_ALL, ""); |
static bool process_initialized = false; |
36 |
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
if (!process_initialized) { |
37 |
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
std::cout << "Initializing 3rd party services needed by gigedit.\n" |
38 |
textdomain(GETTEXT_PACKAGE); |
<< std::flush; |
39 |
|
setlocale(LC_ALL, ""); |
40 |
|
|
41 |
|
#if HAVE_GETTEXT |
42 |
|
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
43 |
|
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
44 |
|
textdomain(GETTEXT_PACKAGE); |
45 |
|
#endif // HAVE_GETTEXT |
46 |
|
|
47 |
Glib::thread_init(); |
// make sure thread_init() is called once and ONLY once per process |
48 |
|
if (!Glib::thread_supported()) Glib::thread_init(); |
49 |
|
|
50 |
|
process_initialized = true; |
51 |
|
} |
52 |
|
} |
53 |
|
|
54 |
|
static void __connect_signals(GigEdit* gigedit, MainWindow* mainwindow) { |
55 |
|
// the signals of the "GigEdit" class are actually just proxies, that |
56 |
|
// is they simply forward the signals of the internal classes to the |
57 |
|
// outer world |
58 |
|
mainwindow->signal_file_structure_to_be_changed().connect( |
59 |
|
gigedit->signal_file_structure_to_be_changed().make_slot() |
60 |
|
); |
61 |
|
mainwindow->signal_file_structure_changed().connect( |
62 |
|
gigedit->signal_file_structure_changed().make_slot() |
63 |
|
); |
64 |
|
mainwindow->signal_samples_to_be_removed().connect( |
65 |
|
gigedit->signal_samples_to_be_removed().make_slot() |
66 |
|
); |
67 |
|
mainwindow->signal_samples_removed().connect( |
68 |
|
gigedit->signal_samples_removed().make_slot() |
69 |
|
); |
70 |
|
mainwindow->signal_region_to_be_changed().connect( |
71 |
|
gigedit->signal_region_to_be_changed().make_slot() |
72 |
|
); |
73 |
|
mainwindow->signal_region_changed().connect( |
74 |
|
gigedit->signal_region_changed().make_slot() |
75 |
|
); |
76 |
|
mainwindow->signal_dimreg_to_be_changed().connect( |
77 |
|
gigedit->signal_dimreg_to_be_changed().make_slot() |
78 |
|
); |
79 |
|
mainwindow->signal_dimreg_changed().connect( |
80 |
|
gigedit->signal_dimreg_changed().make_slot() |
81 |
|
); |
82 |
|
mainwindow->signal_sample_ref_changed().connect( |
83 |
|
gigedit->signal_sample_ref_changed().make_slot() |
84 |
|
); |
85 |
} |
} |
86 |
|
|
87 |
int GigEdit::run() { |
int GigEdit::run() { |
88 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
89 |
MainWindow window; |
MainWindow window; |
90 |
|
__connect_signals(this, &window); |
91 |
kit.run(window); |
kit.run(window); |
92 |
return 0; |
return 0; |
93 |
} |
} |
94 |
|
|
95 |
int GigEdit::run(const char* pFileName) { |
int GigEdit::run(const char* pFileName) { |
96 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
97 |
MainWindow window; |
MainWindow window; |
98 |
|
__connect_signals(this, &window); |
99 |
if (pFileName) window.load_file(pFileName); |
if (pFileName) window.load_file(pFileName); |
100 |
kit.run(window); |
kit.run(window); |
101 |
return 0; |
return 0; |
103 |
|
|
104 |
int GigEdit::run(gig::Instrument* pInstrument) { |
int GigEdit::run(gig::Instrument* pInstrument) { |
105 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
106 |
MainWindow window; |
MainWindow window; |
107 |
|
__connect_signals(this, &window); |
108 |
if (pInstrument) window.load_instrument(pInstrument); |
if (pInstrument) window.load_instrument(pInstrument); |
109 |
kit.run(window); |
kit.run(window); |
110 |
return 0; |
return 0; |
111 |
} |
} |
112 |
|
|
113 |
|
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() { |
114 |
|
return file_structure_to_be_changed_signal; |
115 |
|
} |
116 |
|
|
117 |
|
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_changed() { |
118 |
|
return file_structure_changed_signal; |
119 |
|
} |
120 |
|
|
121 |
|
sigc::signal<void, std::list<gig::Sample*> >& GigEdit::signal_samples_to_be_removed() { |
122 |
|
return samples_to_be_removed_signal; |
123 |
|
} |
124 |
|
|
125 |
|
sigc::signal<void>& GigEdit::signal_samples_removed() { |
126 |
|
return samples_removed_signal; |
127 |
|
} |
128 |
|
|
129 |
|
sigc::signal<void, gig::Region*>& GigEdit::signal_region_to_be_changed() { |
130 |
|
return region_to_be_changed_signal; |
131 |
|
} |
132 |
|
|
133 |
|
sigc::signal<void, gig::Region*>& GigEdit::signal_region_changed() { |
134 |
|
return region_changed_signal; |
135 |
|
} |
136 |
|
|
137 |
|
sigc::signal<void, gig::DimensionRegion*>& GigEdit::signal_dimreg_to_be_changed() { |
138 |
|
return dimreg_to_be_changed_signal; |
139 |
|
} |
140 |
|
|
141 |
|
sigc::signal<void, gig::DimensionRegion*>& GigEdit::signal_dimreg_changed() { |
142 |
|
return dimreg_changed_signal; |
143 |
|
} |
144 |
|
|
145 |
|
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& GigEdit::signal_sample_ref_changed() { |
146 |
|
return sample_ref_changed_signal; |
147 |
|
} |