GtkApp.cpp
1 |
#include <CtrlCore/CtrlCore.h> |
---|---|
2 |
|
3 |
#ifdef GUI_GTK
|
4 |
|
5 |
NAMESPACE_UPP |
6 |
|
7 |
#define LLOG(x) // DLOG(x) |
8 |
|
9 |
void _DBG_Ungrab(void) |
10 |
{ // This is a special nasty hack to make possible to ungrab mouse by debugger (see ide/Debuggers/PrettyPrinters.py)
|
11 |
gdk_pointer_ungrab(GDK_CURRENT_TIME); |
12 |
} |
13 |
|
14 |
void Ctrl::PanicMsgBox(const char *title, const char *text) |
15 |
{ |
16 |
LLOG("PanicMsgBox " << title << ": " << text); |
17 |
_DBG_Ungrab(); |
18 |
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
|
19 |
GTK_BUTTONS_CLOSE, "%s: %s", title, text);
|
20 |
gtk_dialog_run(GTK_DIALOG (dialog)); |
21 |
gtk_widget_destroy(dialog); |
22 |
__BREAK__; |
23 |
} |
24 |
|
25 |
void InitGtkApp(int argc, char **argv, const char **envptr) |
26 |
{ |
27 |
LLOG(rmsecs() << " InitGtkApp");
|
28 |
#ifdef _MULTITHREADED
|
29 |
#if GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 32 |
30 |
if(!g_thread_supported())
|
31 |
g_thread_init(NULL);
|
32 |
#endif
|
33 |
gdk_threads_set_lock_functions(EnterGuiMutex, LeaveGuiMutex); |
34 |
gdk_threads_init(); |
35 |
EnterGuiMutex(); |
36 |
#endif
|
37 |
gtk_init(&argc, &argv); |
38 |
Ctrl::GlobalBackBuffer(); |
39 |
Ctrl::ReSkin(); |
40 |
g_timeout_add(20, (GSourceFunc) Ctrl::TimeHandler, NULL); |
41 |
InstallPanicMessageBox(Ctrl::PanicMsgBox); |
42 |
gdk_window_add_filter(NULL, Ctrl::RootKeyFilter, NULL); |
43 |
} |
44 |
|
45 |
void ExitGtkApp()
|
46 |
{ |
47 |
#ifdef _MULTITHREADED
|
48 |
LeaveGuiMutex(); |
49 |
#endif
|
50 |
} |
51 |
|
52 |
END_UPP_NAMESPACE |
53 |
|
54 |
#endif
|