aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/external-editor
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-06 23:20:46 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-06 23:21:37 +0800
commit704b78d23bf8d707707411608a3453250f2637a1 (patch)
tree6bea89936534973c9b467503d198245f5035bc77 /plugins/external-editor
parentb6fddaaa0efb8013c526f00926830b9cdcbe0d60 (diff)
downloadgsoc2013-evolution-704b78d23bf8d707707411608a3453250f2637a1.tar.gz
gsoc2013-evolution-704b78d23bf8d707707411608a3453250f2637a1.tar.zst
gsoc2013-evolution-704b78d23bf8d707707411608a3453250f2637a1.zip
Replace deprecated GLib symbols (as of GLib 2.34.x)
Diffstat (limited to 'plugins/external-editor')
-rw-r--r--plugins/external-editor/external-editor.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index cac0a63ed5..42cdb9f9ff 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -53,7 +53,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,
@@ -249,9 +248,13 @@ numlines (const gchar *text,
return lineno;
}
-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;
@@ -280,7 +283,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");
@@ -339,7 +343,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);
@@ -351,7 +355,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;
@@ -373,6 +377,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)
@@ -386,8 +397,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[] = {
@@ -431,21 +447,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;
}