#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <locale.h>
+#include <time.h>
+#include <inttypes.h>
#include "window.h"
#include "main.h"
+#include "settings.h"
#include <ucx/buffer.h>
#include <ucx/utils.h>
static XtAppContext app;
static Display *display;
+static Widget toplevel_window;
static String fallback[] = {
"*renderTable: rt",
NULL
};
-int main(int argc, char** argv) {
+static String langProc(Display *dp, String xnl, XtPointer closure) {
+ setlocale(LC_ALL, xnl);
+ setlocale(LC_NUMERIC, "C");
+ return setlocale(LC_ALL, NULL);
+}
+
+int main(int argc, char** argv) {
// disable stdout buffering, because the netbeans's internal terminal
// has a bug on freebsd and doesn't flush the output after a newline
setvbuf(stdout, NULL, _IONBF, 0);
-
+
+ // initialize toolkit
XtToolkitInitialize();
- XtSetLanguageProc(NULL, NULL, NULL);
+ XtSetLanguageProc(NULL, langProc, NULL);
app = XtCreateApplicationContext();
XtAppSetFallbackResources(app, fallback);
-
+
display = XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv);
+ // load settings
+ if(load_settings()) {
+ return 1;
+ }
+
MainWindow *window = WindowCreate(display);
+ toplevel_window = window->window;
+
+ // random numbers only used for creating tmp dirs
+ srand(time(NULL));
WindowShow(window);
XtAppMainLoop(app);
void ApplicationExit(void) {
XtAppSetExitFlag(app);
}
+
+void AppAddTimeOut(unsigned long interval, XtTimerCallbackProc proc, XtPointer data) {
+ XtAppAddTimeOut(app, interval, proc, data);
+
+ if(!toplevel_window) return;
+
+ // send a dummy X11 event, because the event loop may be waiting
+ // and the timeout proc is only called when an event is processed
+ XClientMessageEvent event;
+ memset(&event, 0, sizeof(XClientMessageEvent));
+ event.type = ClientMessage;
+ event.window = XtWindow(toplevel_window);
+ event.format = 32;
+ XSendEvent(display, XtWindow(toplevel_window), 0, 0, (XEvent*)&event);
+ XFlush(display);
+}