aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-gtk.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-22 22:41:50 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-22 22:41:50 +0200
commit730f801f1d75bc247c86f76345e71f9ea128a07d (patch)
treefdf51e89c6e6b023a8e0e0ab75d2cef0b1dd8f9f /src/interface-gtk.h
parent6f48745171ab3ef898b24d8da9732c4f309b08c7 (diff)
downloadsciteco-730f801f1d75bc247c86f76345e71f9ea128a07d.tar.gz
major GTK UI rewrite: use a separate execution thread
* the execution thread does not block the main thread (with the main loop). * therefore if SciTECO executes a long-running macro, the UI stays "responsive". * also this allows us to handle ^C interruptions. This is part of the solution to #4 for GTK+ UIs. * to speed up execution and avoid frequent UI redraws (now that we run concurrently, there are even more redraws), the view change is applied only after key presses. * also we freeze all UI updates on the view during SciTECO's key processing. * Closing the window, requests a graceful execution thread shut down. This may later be extended to allow programmable window close-behaviour using a special function key macro (e.g. mapped to the "Break" key).
Diffstat (limited to 'src/interface-gtk.h')
-rw-r--r--src/interface-gtk.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/interface-gtk.h b/src/interface-gtk.h
index 31deaf6..8150c8c 100644
--- a/src/interface-gtk.h
+++ b/src/interface-gtk.h
@@ -21,6 +21,8 @@
#include <stdarg.h>
#include <glib.h>
+
+#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <Scintilla.h>
@@ -60,7 +62,13 @@ public:
inline sptr_t
ssm_impl(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0)
{
- return scintilla_send_message(sci, iMessage, wParam, lParam);
+ sptr_t ret;
+
+ gdk_threads_enter();
+ ret = scintilla_send_message(sci, iMessage, wParam, lParam);
+ gdk_threads_leave();
+
+ return ret;
}
} ViewCurrent;
@@ -68,6 +76,8 @@ typedef class InterfaceGtk : public Interface<InterfaceGtk, ViewGtk> {
GtkWidget *window;
GtkWidget *vbox;
+ GtkWidget *event_box_widget;
+
gchar *info_current;
GtkWidget *info_widget;
@@ -78,15 +88,19 @@ typedef class InterfaceGtk : public Interface<InterfaceGtk, ViewGtk> {
GtkWidget *current_view_widget;
+ GAsyncQueue *event_queue;
+
public:
InterfaceGtk() : Interface(),
window(NULL),
vbox(NULL),
+ event_box_widget(NULL),
info_current(NULL), info_widget(NULL),
message_widget(NULL),
cmdline_widget(NULL),
popup_widget(NULL),
- current_view_widget(NULL) {}
+ current_view_widget(NULL),
+ event_queue(NULL) {}
~InterfaceGtk();
/* overrides Interface::get_options() */
@@ -122,24 +136,27 @@ public:
popup_show_impl(void)
{
/* FIXME: scroll through popup contents */
+ gdk_threads_enter();
gtk_widget_show(popup_widget);
+ gdk_threads_leave();
}
/* implementation of Interface::popup_is_shown() */
inline bool
popup_is_shown_impl(void)
{
- return gtk_widget_get_visible(popup_widget);
+ bool ret;
+
+ gdk_threads_enter();
+ ret = gtk_widget_get_visible(popup_widget);
+ gdk_threads_leave();
+
+ return ret;
}
/* implementation of Interface::popup_clear() */
void popup_clear_impl(void);
/* main entry point (implementation) */
- inline void
- event_loop_impl(void)
- {
- gtk_widget_show_all(window);
- gtk_main();
- }
+ void event_loop_impl(void);
/*
* FIXME: This is for internal use only and could be