[evolution/webkit-composer] Replace deprecated GLib symbols (as of GLib 2.34.x)



commit a73d9dfb671c04b5f655447319de3249755a35d6
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Jun 3 14:58:21 2013 +0200

    Replace deprecated GLib symbols (as of GLib 2.34.x)
    
    Backport of 
https://git.gnome.org/browse/evolution/commit/plugins/external-editor?id=704b78d23bf8d707707411608a3453250f2637a1

 plugins/external-editor/external-editor.c |   47 +++++++++++++++++-----------
 1 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index 0c73b47..2609748 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -52,7 +52,6 @@ static void   ee_editor_command_changed
                                                (GtkWidget *textbox);
 static void    ee_editor_immediate_launch_changed
                                                (GtkWidget *checkbox);
-static void    async_external_editor           (EMsgComposer *composer);
 static gboolean        editor_running                  (void);
 static gboolean        key_press_cb                    (GtkWidget *widget,
                                                 GdkEventKey *event,
@@ -290,9 +289,13 @@ get_caret_position (EEditorWidget *widget)
        return webkit_dom_range_get_start_offset (range, NULL) + range_count;
 }
 
-void
-async_external_editor (EMsgComposer *composer)
+static gboolean external_editor_running = FALSE;
+static GMutex external_editor_running_lock;
+
+static gpointer
+external_editor_thread (gpointer user_data)
 {
+       EMsgComposer *composer = user_data;
        gchar *filename = NULL;
        gint status = 0;
        GSettings *settings;
@@ -324,7 +327,8 @@ async_external_editor (EMsgComposer *composer)
 
                /* run_error_dialog also calls enable_composer */
                g_idle_add ((GSourceFunc) run_error_dialog, data);
-               return;
+
+               goto finished;
        }
 
        settings = g_settings_new ("org.gnome.evolution.plugin.external-editor");
@@ -380,7 +384,7 @@ async_external_editor (EMsgComposer *composer)
                g_free (filename);
                g_free (editor_cmd_line);
                g_free (editor_cmd);
-               return;
+               goto finished;
        }
        g_free (editor_cmd_line);
        g_free (editor_cmd);
@@ -392,7 +396,7 @@ async_external_editor (EMsgComposer *composer)
 #endif
                d (printf ("\n\nsome problem here with external editor\n\n"));
                g_idle_add ((GSourceFunc) enable_composer, composer);
-               return;
+               goto finished;
        } else {
                gchar *buf;
 
@@ -416,6 +420,13 @@ async_external_editor (EMsgComposer *composer)
                        g_free (filename);
                }
        }
+
+finished:
+       g_mutex_lock (&external_editor_running_lock);
+       external_editor_running = FALSE;
+       g_mutex_unlock (&external_editor_running_lock);
+
+       return NULL;
 }
 
 static void launch_editor (GtkAction *action, EMsgComposer *composer)
@@ -429,8 +440,13 @@ static void launch_editor (GtkAction *action, EMsgComposer *composer)
 
        disable_composer (composer);
 
-       editor_thread = g_thread_create (
-               (GThreadFunc) async_external_editor, composer, FALSE, NULL);
+       g_mutex_lock (&external_editor_running_lock);
+       external_editor_running = TRUE;
+       g_mutex_unlock (&external_editor_running_lock);
+
+       editor_thread = g_thread_new (
+               NULL, external_editor_thread, composer);
+       g_thread_unref (editor_thread);
 }
 
 static GtkActionEntry entries[] = {
@@ -474,21 +490,14 @@ key_press_cb (GtkWidget *widget,
        return TRUE;
 }
 
-static void
-editor_running_thread_func (GThread *thread,
-                            gpointer running)
-{
-       if (thread == editor_thread)
-               *(gboolean*)running = TRUE;
-}
-
-/* Racy? */
 static gboolean
 editor_running (void)
 {
-       gboolean running = FALSE;
+       gboolean running;
 
-       g_thread_foreach ((GFunc) editor_running_thread_func, &running);
+       g_mutex_lock (&external_editor_running_lock);
+       running = external_editor_running;
+       g_mutex_unlock (&external_editor_running_lock);
 
        return running;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]