aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-02 08:20:34 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-02 08:20:34 +0000
commit8a007108e4ae652ff4138aaa48220caae53b3b93 (patch)
tree00d05f1a305320e173650409e64e17c0148b5acc
parentd0f57192d01dfd8c510bbf7ec81caacea5b58fc8 (diff)
src/compose.c: fixed for win32.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@706 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog4
-rw-r--r--ChangeLog.ja4
-rw-r--r--src/compose.c39
3 files changed, 38 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2decd239..97bfa307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2005-11-02
+ * src/compose.c: fixed for win32.
+
+2005-11-02
+
* src/compose.[ch]: reimplemented external editor with GSpawn and
GChildWatch.
* libsylph/utils.c: execute_async(): fixed wrong argument type.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 73d75423..150a85da 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,9 @@
2005-11-02
+ * src/compose.c: win32 用の修正。
+
+2005-11-02
+
* src/compose.[ch]: 外部エディタを GSpawn と GChildWatch で再実装。
* libsylph/utils.c: execute_async(): 引数の型が誤っていたのを修正。
diff --git a/src/compose.c b/src/compose.c
index 306cea4d..bb58dd47 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -73,6 +73,9 @@
#endif
#include <signal.h>
#include <errno.h>
+#ifdef G_OS_WIN32
+# include <windows.h>
+#endif
#include "main.h"
#include "mainwindow.h"
@@ -4355,7 +4358,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
compose->sig_tag = sig_tag;
compose->exteditor_file = NULL;
- compose->exteditor_pid = -1;
+ compose->exteditor_pid = 0;
compose->exteditor_tag = 0;
compose_select_account(compose, account, TRUE);
@@ -5126,6 +5129,13 @@ static void compose_exec_ext_editor(Compose *compose)
g_free(tmp);
return;
}
+#ifdef G_OS_WIN32
+ if (canonicalize_file_replace(tmp) < 0) {
+ g_warning("Coundn't write to file: %s\n", tmp);
+ g_free(tmp);
+ return;
+ }
+#endif
compose_set_ext_editor_sensitive(compose, FALSE);
@@ -5161,14 +5171,22 @@ static void compose_exec_ext_editor(Compose *compose)
static gboolean compose_ext_editor_kill(Compose *compose)
{
-#ifdef G_OS_UNIX
+#ifdef G_OS_WIN32
+ DWORD exitcode;
+#endif
gint ret;
- g_return_val_if_fail(compose->exteditor_pid != 1, TRUE);
+ g_return_val_if_fail(compose->exteditor_pid != 0, TRUE);
+
+#ifdef G_OS_WIN32
+ ret = GetExitCodeProcess(compose->exteditor_pid, &exitcode);
+ if (ret && exitcode == STILL_ACTIVE) {
+#else
ret = kill(compose->exteditor_pid, 0);
if (ret == 0 || (ret == -1 && EPERM == errno)) {
+#endif
AlertValue val;
gchar *msg;
@@ -5182,24 +5200,27 @@ static gboolean compose_ext_editor_kill(Compose *compose)
g_free(msg);
if (val == G_ALERTDEFAULT) {
+#ifdef G_OS_WIN32
+ if (TerminateProcess(compose->exteditor_pid, 1) == 0)
+ g_warning("TerminateProcess() failed: %d\n",
+ GetLastError());
+#else
if (kill(compose->exteditor_pid, SIGTERM) < 0)
perror("kill");
+#endif
g_message("Terminated process group id: %d",
compose->exteditor_pid);
g_message("Temporary file: %s",
compose->exteditor_file);
- while (compose->exteditor_pid != -1)
+ while (compose->exteditor_pid != 0)
gtk_main_iteration();
} else
return FALSE;
}
return TRUE;
-#else
- return FALSE;
-#endif
}
static void compose_ext_editor_child_exit(GPid pid, gint status, gpointer data)
@@ -5234,7 +5255,7 @@ static void compose_ext_editor_child_exit(GPid pid, gint status, gpointer data)
g_free(compose->exteditor_file);
compose->exteditor_file = NULL;
- compose->exteditor_pid = -1;
+ compose->exteditor_pid = 0;
compose->exteditor_tag = 0;
}
@@ -5685,7 +5706,7 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
Compose *compose = (Compose *)data;
AlertValue val;
- if (compose->exteditor_pid != -1) {
+ if (compose->exteditor_pid != 0) {
if (!compose_ext_editor_kill(compose))
return;
}