r1493@localhost: muntyan | 2005-12-24 01:12:28 -0600

Some win32 stuff
master
Yevgen Muntyan 2005-12-24 19:36:47 +00:00
parent cff99f3c3e
commit ed3e67396e
6 changed files with 89 additions and 10 deletions

View File

@ -49,12 +49,11 @@ mooedit_noinst_headers = \
$(mooedit)/mootextbtree.h \
$(mooedit)/mootextview-private.h
mooedit_unix_sources = $(mooedit)/moocmdview.c
mooedit_sources = \
$(mooedit_include_headers) \
$(mooedit_noinst_headers) \
$(mooedit)/gtksourceiter.c \
$(mooedit)/moocmdview.c \
$(mooedit)/mooedit.c \
$(mooedit)/mooeditconfig.c \
$(mooedit)/mooeditdialogs.c \
@ -125,4 +124,3 @@ $(mooedit)/mooeditsavemultiple-glade.h: $(mooedit_srcdir)/glade/mooeditsavemult.
moo_sources += $(mooedit_sources)
moo_built_sources += $(mooedit_built_sources)
moo_unix_sources += $(mooedit_unix_sources)

View File

@ -15,8 +15,11 @@
#include "mooedit/moocmdview.h"
#include "mooutils/moomarshals.h"
#include "mooutils/moocmd.h"
#ifndef __WIN32__
#include <sys/wait.h>
#include <unistd.h>
#endif /* !__WIN32__ */
struct _MooCmdViewPrivate {
@ -303,6 +306,7 @@ out:
}
#ifndef __WIN32__
static gboolean
moo_cmd_view_cmd_exit (MooCmdView *view,
int status)
@ -376,6 +380,29 @@ moo_cmd_view_cmd_exit (MooCmdView *view,
return FALSE;
}
#else /* __WIN32__ */
static gboolean
moo_cmd_view_cmd_exit (MooCmdView *view,
int status)
{
if (!status)
{
moo_line_view_write_line (MOO_LINE_VIEW (view),
"*** Done ***", -1,
view->priv->message_tag);
}
else
{
char *msg = g_strdup_printf ("*** Exited with status %d ***", status);
moo_line_view_write_line (MOO_LINE_VIEW (view),
msg, -1,
view->priv->error_tag);
g_free (msg);
}
return FALSE;
}
#endif /* __WIN32__ */
static gboolean

View File

@ -49,6 +49,7 @@ mooutils_sources = \
$(mooutils)/mooactiongroup.c \
$(mooutils)/moobigpaned.c \
$(mooutils)/mooclosure.c \
$(mooutils)/moocmd.c \
$(mooutils)/moocombo.c \
$(mooutils)/moocompat.c \
$(mooutils)/moocompat.h \
@ -88,9 +89,6 @@ mooutils_sources = \
$(mooutils)/stock-select-all-24.h \
$(mooutils)/stock-terminal-24.h
mooutils_unix_sources = \
$(mooutils)/moocmd.c
nodist_mooutils_sources = \
$(mooutils)/moomarshals.c \
$(mooutils)/moomarshals.h

View File

@ -14,8 +14,14 @@
#include "mooutils/moocmd.h"
#include "mooutils/moomarshals.h"
#ifndef __WIN32__
#include <sys/wait.h>
#include <unistd.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
struct _MooCmdPrivate {
@ -433,6 +439,7 @@ stderr_watch_removed (MooCmd *cmd)
}
#ifndef __WIN32__
static void
real_child_setup (gpointer user_data)
{
@ -446,6 +453,7 @@ real_child_setup (gpointer user_data)
if (data->child_setup)
data->child_setup (data->user_data);
}
#endif
static gboolean
@ -485,7 +493,11 @@ moo_cmd_run_command (MooCmd *cmd,
result = g_spawn_async_with_pipes (working_dir,
argv, envp,
flags | G_SPAWN_DO_NOT_REAP_CHILD,
#ifndef __WIN32__
real_child_setup, &data,
#else
NULL, NULL,
#endif
&cmd->priv->pid,
NULL, outp, errp, error);
@ -575,7 +587,11 @@ moo_cmd_cleanup (MooCmd *cmd)
if (cmd->priv->pid)
{
#ifndef __WIN32__
kill (-cmd->priv->pid, SIGHUP);
#else
TerminateProcess (cmd->priv->pid, 1);
#endif
g_spawn_close_pid (cmd->priv->pid);
cmd->priv->pid = 0;
}
@ -599,7 +615,11 @@ moo_cmd_abort_real (MooCmd *cmd)
g_return_val_if_fail (cmd->priv->pid != 0, TRUE);
#ifndef __WIN32__
kill (-cmd->priv->pid, SIGHUP);
#else
TerminateProcess (cmd->priv->pid, 1);
#endif
if (cmd->priv->stdout_watch)
{

View File

@ -1899,6 +1899,7 @@ render_icon_for_path (const char *path,
GtkIconSize size)
{
MooIconType icon = MOO_ICON_BLANK;
#ifndef __WIN32__
const char *mime_type = xdg_mime_type_unknown;
if (path)
@ -1910,6 +1911,9 @@ render_icon_for_path (const char *path,
icon = MOO_ICON_MIME;
}
}
#else
const char *mime_type = "application/octet-stream";
#endif
return _render_icon (icon, mime_type, 0, widget, size);
}
@ -2161,6 +2165,7 @@ static GdkPixbuf *_create_icon_for_mime_type (GtkIconTheme *icon_theme,
if (pixbuf)
return pixbuf;
#ifndef __WIN32__
parent_types = xdg_mime_list_mime_parents (mime_type);
if (parent_types && parent_types[0])
@ -2172,6 +2177,7 @@ static GdkPixbuf *_create_icon_for_mime_type (GtkIconTheme *icon_theme,
if (pixbuf)
return pixbuf;
#endif
g_message ("%s: could not find icon for mime type '%s'",
G_STRLOC, mime_type);

View File

@ -105,11 +105,43 @@ rm_fr (const char *path)
#endif /* __WIN32__ */
#ifdef __WIN32__
static gboolean
remove_dir_win32 (const char *path)
{
gboolean success;
guint pathlen;
char *freeme;
/* better fail than crash */
SHFILEOPSTRUCTA fileop = {
NULL, /* HWND hwnd; */
FO_DELETE, /* UINT wFunc; */
NULL, /* LPCTSTR pFrom; */
NULL, /* LPCTSTR pTo; */
FOF_SILENT, /* FILEOP_FLAGS fFlags; */
FALSE, /* BOOL fAnyOperationsAborted; */
NULL, /* LPVOID hNameMappings; */
NULL /* LPCTSTR lpszProgressTitle; */
};
pathlen = strlen (path);
freeme = g_new0 (char, pathlen + 2);
memcpy (freeme, path, pathlen);
fileop.pFrom = freeme;
success = SHFileOperationA (&fileop) == 0;
g_free (freeme);
return success;
}
#endif
gboolean
moo_rmdir (const char *path,
gboolean recursive)
{
g_return_val_if_fail (path != NULL, -1);
g_return_val_if_fail (path != NULL, FALSE);
if (!recursive)
{
@ -123,9 +155,7 @@ moo_rmdir (const char *path,
#ifndef __WIN32__
return rm_fr (path);
#else
/* XXX */
#warning "Implement me"
return FALSE;
return remove_dir_win32 (path);
#endif
}