Implemented the 'waiting' signal on the ChimaraGlk widget to let listeners know when...
authorPhilip Chimento <philip.chimento@gmail.com>
Sun, 11 Oct 2009 22:18:31 +0000 (22:18 +0000)
committerPhilip Chimento <philip.chimento@gmail.com>
Sun, 11 Oct 2009 22:18:31 +0000 (22:18 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@142 ddfedd41-794f-dd11-ae45-00112f111e67

libchimara/chimara-glk.c
libchimara/chimara-glk.h
libchimara/event.c
tests/main.c

index 3f5c71b91030cf738f114d1480287e920f7a7666..da4419306b38f9539c42d2baca221086b44fc0c2 100644 (file)
@@ -59,6 +59,7 @@ enum {
 enum {
        STOPPED,
        STARTED,
+       WAITING,
        CHAR_INPUT,
        LINE_INPUT,
        TEXT_BUFFER_OUTPUT,
@@ -549,6 +550,12 @@ chimara_glk_started(ChimaraGlk *self)
        /* TODO: Add default signal handler implementation here */
 }
 
+static void
+chimara_glk_waiting(ChimaraGlk *self)
+{
+       /* TODO: Add default signal handler */
+}
+
 static void
 chimara_glk_char_input(ChimaraGlk *self, guint window_rock, guint keysym)
 {
@@ -591,6 +598,7 @@ chimara_glk_class_init(ChimaraGlkClass *klass)
     /* Signals */
     klass->stopped = chimara_glk_stopped;
     klass->started = chimara_glk_started;
+    klass->waiting = chimara_glk_waiting;
     klass->char_input = chimara_glk_char_input;
     klass->line_input = chimara_glk_line_input;
     klass->text_buffer_output = chimara_glk_text_buffer_output;
@@ -603,6 +611,7 @@ chimara_glk_class_init(ChimaraGlkClass *klass)
      */ 
     chimara_glk_signals[STOPPED] = g_signal_new("stopped", 
         G_OBJECT_CLASS_TYPE(klass), 0, 
+        /* FIXME: Should be G_SIGNAL_RUN_CLEANUP but that segfaults??! */
         G_STRUCT_OFFSET(ChimaraGlkClass, stopped), NULL, NULL,
                g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
        /**
@@ -613,9 +622,14 @@ chimara_glk_class_init(ChimaraGlkClass *klass)
         * the widget.
         */
        chimara_glk_signals[STARTED] = g_signal_new ("started",
-               G_OBJECT_CLASS_TYPE (klass), 0,
+               G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, started), NULL, NULL,
                g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+       
+       chimara_glk_signals[WAITING] = g_signal_new("waiting",
+               G_OBJECT_CLASS_TYPE(klass), 0,
+               G_STRUCT_OFFSET(ChimaraGlkClass, waiting), NULL, NULL,
+               g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
        chimara_glk_signals[CHAR_INPUT] = g_signal_new("char-input",
                G_OBJECT_CLASS_TYPE(klass), 0,
index 78ea8deae477e6b593f52d946a20a05f9972fd06..32725de98968334294eec85e63fdbb7463e6db2d 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef __CHIMARA_GLK_H__
 #define __CHIMARA_GLK_H__
 
-#include <glib-object.h>
+#include <glib.h>
 #include <gtk/gtk.h>
 #include <pango/pango.h>
 
@@ -32,6 +32,7 @@ typedef struct _ChimaraGlkClass {
        /* Signals */
        void(* stopped) (ChimaraGlk *self);
        void(* started) (ChimaraGlk *self);
+       void(* waiting) (ChimaraGlk *self);
        void(* char_input) (ChimaraGlk *self, guint32 window_rock, guint keysym);
        void(* line_input) (ChimaraGlk *self, guint32 window_rock, gchar *text);
        void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, gchar *text);
index ca5e21aac58a874dd7a28a1ebc968601e925deab..5da6dd8e5058c60f97dbcbfaad265167ee36c561 100644 (file)
@@ -70,6 +70,9 @@ glk_select(event_t *event)
 
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
        
+       /* Emit the "waiting" signal to let listeners know we are ready for input */
+       g_signal_emit_by_name(glk_data->self, "waiting");
+       
        g_mutex_lock(glk_data->event_lock);
 
        /* Wait for an event */
@@ -200,4 +203,4 @@ glk_select_poll(event_t *event)
 
        /* If an abort event was generated, the thread should have exited by now */
        g_assert(event->type != evtype_Abort);
-}
\ No newline at end of file
+}
index 9ed6158f2245e49593f63e87e820ec33a8cf463d..e73df826ca98c0a92f35970d58f6705870f76978 100644 (file)
@@ -62,6 +62,12 @@ on_stopped(ChimaraGlk *glk)
     g_printerr("Stopped!\n");
 }
 
+static void
+on_waiting(ChimaraGlk *glk)
+{
+       g_printerr("Waiting!\n");
+}
+
 static void
 on_char_input(ChimaraGlk *glk, guint32 window_rock, guint keysym)
 {
@@ -125,14 +131,13 @@ create_window(void)
                return;
        }
        
-       gtk_builder_connect_signals(builder, NULL);
-       
        glk = chimara_glk_new();
        g_object_set(glk, "border-width", 6, "spacing", 6, NULL);
        chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
        chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
        g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL);
        g_signal_connect(glk, "stopped", G_CALLBACK(on_stopped), NULL);
+       g_signal_connect(glk, "waiting", G_CALLBACK(on_waiting), NULL);
        g_signal_connect(glk, "char-input", G_CALLBACK(on_char_input), NULL);
        g_signal_connect(glk, "line-input", G_CALLBACK(on_line_input), NULL);
        g_signal_connect(glk, "text-buffer-output", G_CALLBACK(on_text_buffer_output), NULL);
@@ -151,6 +156,8 @@ create_window(void)
        gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
        gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
        gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
+       
+       gtk_builder_connect_signals(builder, NULL);
 }
 
 int