{
if(glk_data->interrupt_handler)
(*(glk_data->interrupt_handler))();
+ g_signal_emit_by_name(glk_data->self, "stopped");
g_thread_exit(NULL);
}
void
signal_abort()
{
- if(glk_data->abort_lock) {
+ if(glk_data && glk_data->abort_lock) {
g_mutex_lock(glk_data->abort_lock);
glk_data->abort_signalled = TRUE;
g_mutex_unlock(glk_data->abort_lock);
#include "chimara-glk.h"
#include "chimara-glk-private.h"
#include "glk.h"
+#include "abort.h"
#include "window.h"
#define CHIMARA_GLK_MIN_WIDTH 0
priv->self = self;
priv->interactive = TRUE;
priv->protect = FALSE;
+ priv->program = NULL;
priv->thread = NULL;
priv->event_queue = NULL;
priv->event_lock = NULL;
g_mutex_unlock(priv->abort_lock);
g_mutex_free(priv->abort_lock);
priv->abort_lock = NULL;
-
+
G_OBJECT_CLASS(chimara_glk_parent_class)->finalize(object);
}
static void
chimara_glk_stopped(ChimaraGlk *self)
{
- /* TODO: Add default signal handler implementation here */
+ ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(self);
+
+ /* Free the plugin */
+ if( priv->program && !g_module_close(priv->program) )
+ g_warning( "Error closing module: %s", g_module_error() );
}
static void
static gpointer
glk_enter(gpointer glk_main)
{
+ extern ChimaraGlkPrivate *glk_data;
+ g_signal_emit_by_name(glk_data->self, "started");
((glk_main_t)glk_main)();
+ g_signal_emit_by_name(glk_data->self, "stopped");
return NULL;
}
g_return_val_if_fail(glk || CHIMARA_IS_GLK(glk), FALSE);
g_return_val_if_fail(plugin, FALSE);
+ ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk);
+
/* Open the module to run */
- GModule *module;
glk_main_t glk_main;
g_assert( g_module_supported() );
- module = g_module_open(plugin, G_MODULE_BIND_LAZY);
+ priv->program = g_module_open(plugin, G_MODULE_BIND_LAZY);
- if(!module)
+ if(!priv->program)
{
g_warning( "Error opening module: %s", g_module_error() );
return FALSE;
}
- if( !g_module_symbol(module, "glk_main", (gpointer *) &glk_main) )
+ if( !g_module_symbol(priv->program, "glk_main", (gpointer *) &glk_main) )
{
g_warning( "Error finding glk_main(): %s", g_module_error() );
return FALSE;
}
-
- ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk);
+
extern ChimaraGlkPrivate *glk_data;
/* Set the thread's private data */
/* TODO: Do this with a GPrivate */
/* Run in a separate thread */
priv->thread = g_thread_create(glk_enter, glk_main, TRUE, error);
- /* Close module */
-/* if( !g_module_close(module) )
- {
- g_warning( "Error closing module: %s", g_module_error() );
- return FALSE;
- }*/
-
return !(priv->thread == NULL);
}
GtkWidget *window = NULL;
GtkWidget *glk = NULL;
+static void
+on_started(ChimaraGlk *glk)
+{
+ g_printerr("Started!\n");
+}
+
+static void
+on_stopped(ChimaraGlk *glk)
+{
+ g_printerr("Stopped!\n");
+}
+
static void
create_window(void)
{
gtk_builder_connect_signals(builder, NULL);
glk = chimara_glk_new();
+ g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL);
+ g_signal_connect(glk, "stopped", G_CALLBACK(on_stopped), NULL);
GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") );
if(vbox == NULL)