33 |
#endif |
#endif |
34 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
35 |
#include <glibmm/main.h> |
#include <glibmm/main.h> |
36 |
|
#include <glibmm/miscutils.h> |
37 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
38 |
|
|
39 |
|
#ifdef WIN32 |
40 |
|
#include <gtkmm/icontheme.h> |
41 |
|
#endif |
42 |
|
|
43 |
#if defined(__APPLE__) |
#if defined(__APPLE__) |
44 |
# include <CoreFoundation/CoreFoundation.h> |
# include <CoreFoundation/CoreFoundation.h> |
45 |
# include "MacHelper.h" |
# include "MacHelper.h" |
52 |
#ifdef __APPLE__ |
#ifdef __APPLE__ |
53 |
#include <dlfcn.h> |
#include <dlfcn.h> |
54 |
#include <glibmm/fileutils.h> |
#include <glibmm/fileutils.h> |
|
#include <glibmm/miscutils.h> |
|
55 |
#endif |
#endif |
56 |
|
|
57 |
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments below in this file for details) |
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments below in this file for details) |
127 |
|
|
128 |
#ifdef WIN32 |
#ifdef WIN32 |
129 |
HINSTANCE gigedit_dll_handle = 0; |
HINSTANCE gigedit_dll_handle = 0; |
130 |
|
std::string gigedit_datadir; |
131 |
|
bool gigedit_installdir_is_parent = false; |
132 |
#endif |
#endif |
133 |
|
|
134 |
#ifdef __APPLE__ |
#ifdef __APPLE__ |
182 |
".local/share").c_str(), 0777); |
".local/share").c_str(), 0777); |
183 |
#endif // __APPLE__ |
#endif // __APPLE__ |
184 |
|
|
185 |
//FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler? |
#ifdef WIN32 |
186 |
#if (HAVE_GETTEXT || defined(__APPLE__)) |
// Find the data directory: the linuxsampler installer puts |
187 |
|
// the binaries in sub directories "32" and "64", so the share |
188 |
|
// directory is located in the parent of the directory of the |
189 |
|
// binaries. |
190 |
|
|
191 |
#ifdef WIN32 |
#if GLIB_CHECK_VERSION(2, 16, 0) |
|
#if GLIB_CHECK_VERSION(2, 16, 0) |
|
192 |
gchar* root = |
gchar* root = |
193 |
g_win32_get_package_installation_directory_of_module(gigedit_dll_handle); |
g_win32_get_package_installation_directory_of_module(gigedit_dll_handle); |
194 |
#else |
#else |
195 |
gchar* root = |
gchar* root = |
196 |
g_win32_get_package_installation_directory(NULL, NULL); |
g_win32_get_package_installation_directory(NULL, NULL); |
197 |
#endif |
#endif |
198 |
gchar* temp = g_build_filename(root, "/share/locale", NULL); |
std::string installdir(root); |
199 |
g_free(root); |
g_free(root); |
200 |
gchar* localedir = g_win32_locale_filename_from_utf8(temp); |
std::string basename = Glib::path_get_basename(installdir); |
201 |
g_free(temp); |
if (basename == "32" || basename == "64") { |
202 |
|
installdir = Glib::path_get_dirname(installdir); |
203 |
|
gigedit_installdir_is_parent = true; |
204 |
|
} |
205 |
|
gigedit_datadir = Glib::build_filename(installdir, "share"); |
206 |
|
|
207 |
|
// the file dialogs need glib-2.0/schemas/gschemas.compiled |
208 |
|
if (gigedit_installdir_is_parent) { |
209 |
|
Glib::setenv("GSETTINGS_SCHEMA_DIR", |
210 |
|
Glib::build_filename(gigedit_datadir, |
211 |
|
"glib-2.0/schemas")); |
212 |
|
} |
213 |
|
#endif |
214 |
|
|
215 |
|
//FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler? |
216 |
|
#if (HAVE_GETTEXT || defined(__APPLE__)) |
217 |
|
#ifdef WIN32 |
218 |
|
std::string temp = Glib::build_filename(gigedit_datadir, "locale"); |
219 |
|
gchar* localedir = g_win32_locale_filename_from_utf8(temp.c_str()); |
220 |
bindtextdomain(GETTEXT_PACKAGE, localedir); |
bindtextdomain(GETTEXT_PACKAGE, localedir); |
221 |
g_free(localedir); |
g_free(localedir); |
222 |
#elif !defined(__APPLE__) |
#elif !defined(__APPLE__) |
234 |
} |
} |
235 |
} |
} |
236 |
|
|
237 |
|
void init_app_after_gtk_init() { |
238 |
|
//FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler? |
239 |
|
#if (/*HAVE_GETTEXT &&*/ defined(__APPLE__)) |
240 |
|
// Gtk::Main binds the gtk locale to a possible non-existent |
241 |
|
// directory. If we have bundled gtk locale files, we rebind here, |
242 |
|
// after the Gtk::Main constructor. |
243 |
|
if (!gigedit_localedir.empty()) { |
244 |
|
bindtextdomain("gtk20", gigedit_localedir.c_str()); |
245 |
|
} |
246 |
|
#endif |
247 |
|
|
248 |
|
#ifdef WIN32 |
249 |
|
if (gigedit_installdir_is_parent) { |
250 |
|
std::string icon_dir = Glib::build_filename(gigedit_datadir, "icons"); |
251 |
|
Gtk::IconTheme::get_default()->append_search_path(icon_dir); |
252 |
|
} |
253 |
|
#endif |
254 |
|
} |
255 |
|
|
256 |
void connect_signals(GigEdit* gigedit, MainWindow* mainwindow) { |
void connect_signals(GigEdit* gigedit, MainWindow* mainwindow) { |
257 |
// the signals of the "GigEdit" class are actually just proxies, that |
// the signals of the "GigEdit" class are actually just proxies, that |
258 |
// is they simply forward the signals of the internal classes to the |
// is they simply forward the signals of the internal classes to the |
314 |
init_app(); |
init_app(); |
315 |
|
|
316 |
Gtk::Main kit(argc, argv); |
Gtk::Main kit(argc, argv); |
317 |
|
init_app_after_gtk_init(); |
|
//FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler? |
|
|
#if (/*HAVE_GETTEXT &&*/ defined(__APPLE__)) |
|
|
// Gtk::Main binds the gtk locale to a possible non-existent |
|
|
// directory. If we have bundled gtk locale files, we rebind here, |
|
|
// after the Gtk::Main constructor. |
|
|
if (!gigedit_localedir.empty()) { |
|
|
bindtextdomain("gtk20", gigedit_localedir.c_str()); |
|
|
} |
|
|
#endif |
|
318 |
|
|
319 |
MainWindow window; |
MainWindow window; |
320 |
connect_signals(this, &window); |
connect_signals(this, &window); |
436 |
const char* argv_c[] = { "gigedit" }; |
const char* argv_c[] = { "gigedit" }; |
437 |
char** argv = const_cast<char**>(argv_c); |
char** argv = const_cast<char**>(argv_c); |
438 |
Gtk::Main main_loop(argc, argv); |
Gtk::Main main_loop(argc, argv); |
439 |
//FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler? |
init_app_after_gtk_init(); |
|
#if (/*HAVE_GETTEXT &&*/ defined(__APPLE__)) |
|
|
if (!gigedit_localedir.empty()) { |
|
|
bindtextdomain("gtk20", gigedit_localedir.c_str()); |
|
|
} |
|
|
#endif |
|
440 |
|
|
441 |
dispatcher = new Glib::Dispatcher(); |
dispatcher = new Glib::Dispatcher(); |
442 |
dispatcher->connect(sigc::ptr_fun(&GigEditState::open_window_static)); |
dispatcher->connect(sigc::ptr_fun(&GigEditState::open_window_static)); |