fixed #27
authorMarijn van Vliet <marijn.vanvliet@med.kuleuven.be>
Sun, 22 Nov 2009 14:52:12 +0000 (14:52 +0000)
committerMarijn van Vliet <marijn.vanvliet@med.kuleuven.be>
Sun, 22 Nov 2009 14:52:12 +0000 (14:52 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@176 ddfedd41-794f-dd11-ae45-00112f111e67

libchimara/abort.c
libchimara/chimara-glk.c
libchimara/chimara-glk.h
libchimara/style.c

index aa8ed732bddfe4eab579d2be9847196e0e907364..87e4dd18b7e61523bba5990fc355580553579ee3 100644 (file)
@@ -81,4 +81,7 @@ shutdown_glk(void)
        /* Unref the input queues */
        g_async_queue_unref(glk_data->char_input_queue);
        g_async_queue_unref(glk_data->line_input_queue);
+
+       printf("cleaning up...\n");
+       chimara_glk_reset(glk_data->self);
 }
index c9bb7cc25d97ae8d393e8bedd4c155b34cf6b568..1d981a5ce2445201d8b809a888952483ef6bda5f 100644 (file)
@@ -168,11 +168,10 @@ chimara_glk_get_property(GObject *object, guint prop_id, GValue *value, GParamSp
 }
 
 static void
-chimara_glk_finalize(GObject *object)
+chimara_glk_free_private_data(ChimaraGlk *self)
 {
-    ChimaraGlk *self = CHIMARA_GLK(object);
     ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(self);
-    
+
     /* Free the event queue */
     g_mutex_lock(priv->event_lock);
        g_queue_foreach(priv->event_queue, (GFunc)g_free, NULL);
@@ -201,18 +200,39 @@ chimara_glk_finalize(GObject *object)
        g_async_queue_unref(priv->char_input_queue);
        g_async_queue_unref(priv->line_input_queue);
        
-       /* Free private data */
+       /* Free styles */
        pango_font_description_free(priv->default_font_desc);
        pango_font_description_free(priv->monospace_font_desc);
+
        g_free(priv->current_dir);
        g_hash_table_destroy(priv->default_styles->text_buffer);
        g_hash_table_destroy(priv->default_styles->text_grid);
        g_hash_table_destroy(priv->current_styles->text_buffer);
        g_hash_table_destroy(priv->current_styles->text_grid);
+}
        
+static void
+chimara_glk_finalize(GObject *object)
+{
+    ChimaraGlk *self = CHIMARA_GLK(object);
+       chimara_glk_free_private_data(self);
+
     G_OBJECT_CLASS(chimara_glk_parent_class)->finalize(object);
 }
 
+/**
+ * chimara_glk_reset:
+ * Resets the widget back to it's origional state. IE: it resets all the private data.
+ * @param self: The ChimaraGLK widget to reset
+ */
+void
+chimara_glk_reset(ChimaraGlk *self)
+{
+       chimara_glk_free_private_data(self);
+       chimara_glk_init(self);
+}
+
+
 /* Internal function: Recursively get the Glk window tree's size request */
 static void
 request_recurse(winid_t win, GtkRequisition *requisition, guint spacing)
@@ -551,6 +571,7 @@ static void
 chimara_glk_stopped(ChimaraGlk *self)
 {
     CHIMARA_GLK_USE_PRIVATE(self, priv);
+       printf("stopped signal received\n");
     priv->running = FALSE;
 
     /* Free the plugin */
@@ -562,6 +583,7 @@ static void
 chimara_glk_started(ChimaraGlk *self)
 {
        CHIMARA_GLK_USE_PRIVATE(self, priv);
+       printf("started signal received\n");
        priv->running = TRUE;
 }
 
@@ -1072,8 +1094,17 @@ glk_enter(struct StartupData *startup)
        
        /* Run main function */
     g_signal_emit_by_name(startup->glk_data->self, "started");
+       /* FIXME: hack. should be done by the signal above but for some reason
+        * this doesn't work */
+       chimara_glk_started(startup->glk_data->self);
+
        (startup->glk_main)();
+
        g_signal_emit_by_name(startup->glk_data->self, "stopped");
+       /* FIXME: hack. should be done by the signal above but for some reason
+        * this doesn't work */
+       chimara_glk_stopped(startup->glk_data->self);
+
        g_slice_free(struct StartupData, startup);
        return NULL;
 }
@@ -1158,6 +1189,8 @@ chimara_glk_stop(ChimaraGlk *glk)
 {
     g_return_if_fail(glk || CHIMARA_IS_GLK(glk));
     CHIMARA_GLK_USE_PRIVATE(glk, priv);
+
+       printf("stopping (%d)...\n", priv->running);
     /* Don't do anything if not running a program */
     if(!priv->running)
        return;
index dfa669e3afa1b4f281712ec65a47876be89dfbd3..8713efe46ef2887c6ba4f2791bd5413d84d2d954 100644 (file)
@@ -96,6 +96,7 @@ void chimara_glk_wait(ChimaraGlk *glk);
 gboolean chimara_glk_get_running(ChimaraGlk *glk);
 void chimara_glk_feed_char_input(ChimaraGlk *glk, guint32 keycode);
 void chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text);
+void chimara_glk_reset(ChimaraGlk *self);
 
 G_END_DECLS
 
index e4169d6a6aa5ade98c58a7ec43dc04e8057c7eed..b7257036de6437a9d5593c053f72f879b0bd9174 100644 (file)
@@ -168,10 +168,10 @@ void
 style_init()
 {
        ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-       GHashTable *default_text_grid_styles = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
-       GHashTable *default_text_buffer_styles = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
-       GHashTable *current_text_grid_styles = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
-       GHashTable *current_text_buffer_styles = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+       GHashTable *default_text_grid_styles = g_hash_table_new(g_str_hash, g_str_equal);
+       GHashTable *default_text_buffer_styles = g_hash_table_new(g_str_hash, g_str_equal);
+       GHashTable *current_text_grid_styles = g_hash_table_new(g_str_hash, g_str_equal);
+       GHashTable *current_text_buffer_styles = g_hash_table_new(g_str_hash, g_str_equal);
        GtkTextTag *tag;
 
        /* Create the CSS file scanner */