29 |
int argc = 1; |
int argc = 1; |
30 |
const char* argv_c[] = { "gigedit" }; |
const char* argv_c[] = { "gigedit" }; |
31 |
char** argv = const_cast<char**>(argv_c); |
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() { |
static void __init_app() { |
36 |
setlocale(LC_ALL, ""); |
static bool process_initialized = false; |
37 |
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); |
if (!process_initialized) { |
38 |
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
std::cout << "Initializing 3rd party services needed by gigedit.\n" |
39 |
textdomain(GETTEXT_PACKAGE); |
<< 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 |
Glib::thread_init(); |
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() { |
int GigEdit::run() { |
85 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
86 |
MainWindow window; |
MainWindow window; |
87 |
|
__connect_signals(this, &window); |
88 |
kit.run(window); |
kit.run(window); |
89 |
return 0; |
return 0; |
90 |
} |
} |
91 |
|
|
92 |
int GigEdit::run(const char* pFileName) { |
int GigEdit::run(const char* pFileName) { |
93 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
94 |
MainWindow window; |
MainWindow window; |
95 |
|
__connect_signals(this, &window); |
96 |
if (pFileName) window.load_file(pFileName); |
if (pFileName) window.load_file(pFileName); |
97 |
kit.run(window); |
kit.run(window); |
98 |
return 0; |
return 0; |
100 |
|
|
101 |
int GigEdit::run(gig::Instrument* pInstrument) { |
int GigEdit::run(gig::Instrument* pInstrument) { |
102 |
__init_app(); |
__init_app(); |
|
Gtk::Main kit(argc, argv); |
|
103 |
MainWindow window; |
MainWindow window; |
104 |
|
__connect_signals(this, &window); |
105 |
if (pInstrument) window.load_instrument(pInstrument); |
if (pInstrument) window.load_instrument(pInstrument); |
106 |
kit.run(window); |
kit.run(window); |
107 |
return 0; |
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 |
|
} |