Win32 fixes

master
Yevgen Muntyan 2006-04-20 14:13:42 -05:00
parent afbb146d9e
commit 90ef4e4f20
18 changed files with 127 additions and 71 deletions

10
makewin
View File

@ -24,9 +24,13 @@ do_cmd () {
copy_files () {
do_cmd cp $1/usr/local/bin/medit.exe $2/ && \
do_cmd cp -r $1/usr/local/share/moo/ui.xml.example $2/ui.xml && \
do_cmd cp -r $1/usr/local/share/moo/actions.cfg.example $2/actions.cfg && \
do_cmd cp -r $1/usr/local/share/moo/syntax $2/
do_cmd cp -r $1/usr/local/share/moo/ui.xml.example $2/ && \
do_cmd cp -r $1/usr/local/share/moo/actions.cfg.example $2/ && \
do_cmd cp -r $1/usr/local/share/moo/syntax $2/ && \
do_cmd cp -r $1/usr/local/share/moo/completion $2/ && \
do_cmd cp -r $1/usr/local/share/moo/plugins $2/ && \
do_cmd cp -r $1/usr/local/share/moo/tools.cfg $2/ && \
do_cmd cp -r $1/usr/local/share/moo/menu.cfg $2/
}
build () {

View File

@ -33,7 +33,7 @@
<kdevautoproject>
<general>
<activetarget>moo/libmoo.la</activetarget>
<useconfiguration>debug</useconfiguration>
<useconfiguration>optimized</useconfiguration>
</general>
<run>
<mainprogram>./medit</mainprogram>
@ -288,16 +288,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" name="GAP source" create="template" >
<type icon="source" ext="g" create="template" name="GAP source" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" name="C Source" create="template" >
<type icon="source_c" ext="c" create="template" name="C Source" >
<descr>A new empty C file.</descr>
</type>
</filetypes>

View File

@ -273,11 +273,24 @@ moo_cmd_view_run_command (MooCmdView *view,
moo_line_view_write_line (MOO_LINE_VIEW (view), cmd, -1,
view->priv->message_tag);
#ifdef __WIN32__
g_shell_parse_argv (cmd, NULL, &argv, &error);
if (error)
{
moo_line_view_write_line (MOO_LINE_VIEW (view),
error->message, -1,
view->priv->error_tag);
g_error_free (error);
goto out;
}
#else
argv = g_new (char*, 4);
argv[0] = g_strdup ("/bin/sh");
argv[1] = g_strdup ("-c");
argv[2] = g_strdup (cmd);
argv[3] = NULL;
#endif
view->priv->cmd = moo_cmd_new_full (working_dir, argv, NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,

View File

@ -274,8 +274,12 @@ moo_edit_setup_command (MooCommand *cmd,
doc = moo_edit_window_get_active_doc (window);
ctx = moo_edit_context_new (doc, window);
moo_command_set_context (cmd, ctx);
moo_command_set_py_dict (cmd, ctx->py_dict);
if (ctx->py_dict)
moo_command_set_py_dict (cmd, ctx->py_dict);
g_object_unref (ctx);
moo_edit_set_shell_vars (cmd, doc, window);

View File

@ -360,11 +360,28 @@ load_config_item (FileType type,
ActionData *data;
ActionOptions options;
GSList *langs;
const char *name, *label, *accel, *pos;
const char *name, *label, *accel, *pos, *os;
gpointer klass;
g_return_if_fail (item != NULL);
os = moo_config_item_get_value (item, "os");
if (os)
{
char *norm = g_ascii_strdown (os, -1);
#ifdef __WIN32__
if (!strcmp (norm, "unix"))
return;
#else
if (!strncmp (norm, "win", 3))
return;
#endif
g_free (norm);
}
name = moo_config_item_get_value (item, "action");
label = moo_config_item_get_value (item, "label");
accel = moo_config_item_get_value (item, "accel");

View File

@ -1,5 +1,6 @@
action: ShellCommand
label: _Shell Command
os: unix
cmd = HistoryEntry("", "ShellCommand");
if cmd then
Insert(Exec(cmd), "\n");

View File

@ -2,7 +2,16 @@
# moo/moopython/plugins/Makefile.incl
#
moo_extra_dist += \
moopython_pluginsdir = $(MOO_DATA_DIR)/plugins
moopython_plugins_libdir = $(MOO_DATA_DIR)/plugins/lib
moopython_plugins_DATA = \
$(moopython)/plugins/console.py \
$(moopython)/plugins/pyconsole.py \
$(moopython)/plugins/pystuff.py
moopython_plugins_lib_DATA = \
$(moopython)/plugins/pyconsole.py
moo_extra_dist += \
$(moopython_plugins_DATA) \
$(moopython_plugins_lib_DATA)

View File

@ -1,3 +1,4 @@
import os
import moo
import gtk
@ -63,4 +64,5 @@ class WinPlugin(object):
window.remove_pane(CONSOLE_PLUGIN_ID)
moo.edit.plugin_register(Plugin, WinPlugin)
if os.name == 'posix':
moo.edit.plugin_register(Plugin, WinPlugin)

View File

@ -17,6 +17,11 @@
# it creates the widget and 'starts' interactive session; see the end of
# this file. If start_script is not empty, it pastes it as it was entered from keyboard.
#
# Console may subclass a type other than gtk.TextView, to allow syntax highlighting and stuff,
# e.g.:
# console_type = pyconsole.ConsoleType(moo.edit.TextView)
# console = console_type(use_rlcompleter=False, start_script="import moo\nimport gtk\n")
#
# This widget is not a replacement for real terminal with python running
# inside: GtkTextView is not a terminal.
# The use case is: you have a python program, you create this widget,

View File

@ -2,10 +2,17 @@ import moo
import gtk
import pango
import re
import sys
import os
ActionInfo = moo.edit.Plugin.ActionInfo
UIInfo = moo.edit.Plugin.UIInfo
if os.name == 'nt':
PYTHON_COMMAND = "'" + sys.exec_prefix + "\\python.exe'"
else:
PYTHON_COMMAND = 'python'
SHOW_LOG_WINDOW = False
try:
@ -151,7 +158,7 @@ class Plugin(moo.edit.Plugin):
pane = self.ensure_output(window)
pane.output.clear()
window.paned.present_pane(pane)
pane.output.run_command("python '%s'" % doc.get_filename())
pane.output.run_command(PYTHON_COMMAND + " '%s'" % doc.get_filename())
def detach_win(self, window):
window.remove_pane(PLUGIN_ID)

View File

@ -1,4 +1,3 @@
/* kate: lang C; indent-width 4; space-indent on; strip on; */
%%
headers
#include <Python.h>
@ -7,9 +6,9 @@ headers
#include "mooedit/mooeditor.h"
#include "mooedit/mootextsearch.h"
#include "mooedit/mootextbuffer.h"
#include "mooedit/moocmdview.h"
#include "mooedit/mootextiter.h"
#include "mooedit/mooeditprefs.h"
#include "mooedit/moocmdview.h"
#include "moopython/mooplugin-python.h"
#include "moopython/moopython-utils.h"
#include "moopython/pygtk/moo-pygtk.h"
@ -31,11 +30,6 @@ import _moo_utils.UIXML as PyMooUIXML_Type
ignore-glob
*_get_type
%%
ignore-glob-win32
MOO_TYPE_CMD_VIEW
moo_cmd_view*
MooCmdView
%%
override moo_python_plugin_hook varargs
static PyObject *
_wrap_moo_python_plugin_hook (G_GNUC_UNUSED PyObject *self, PyObject *args)

View File

@ -470,7 +470,11 @@ run_shell (MooCommand *cmd)
g_critical ("%s: implement me", G_STRLOC);
cmd_line = expand_vars (cmd, cmd->string);
#ifdef __WIN32__
sh_command_line = g_strdup_printf ("sh -c '%s'", cmd_line);
#else
sh_command_line = g_strdup_printf ("cmd.exe '%s'", cmd_line);
#endif
g_signal_emit (cmd, signals[RUN_EXE], 0, sh_command_line, &result);
@ -593,7 +597,8 @@ moo_command_set_py_dict (MooCommand *cmd,
gpointer dict)
{
g_return_if_fail (MOO_IS_COMMAND (cmd));
g_return_if_fail (moo_python_running ());
g_return_if_fail (!dict || moo_python_running ());
g_return_if_fail (!cmd->py_dict || moo_python_running ());
if (cmd->py_dict != dict)
{

View File

@ -162,7 +162,7 @@ moo_position_window (GtkWidget *window,
{
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
#ifdef __WIN32__
g_signal_connect (window, "unmap", on_hide, NULL);
g_signal_connect (window, "unmap", G_CALLBACK (on_hide), NULL);
#endif
}

View File

@ -628,6 +628,7 @@ static gboolean get_stat_a_bit (MooFolder *folder)
}
#ifndef __WIN32__
inline static void
get_mime_type (MooFile *file,
const char *path)
@ -642,6 +643,7 @@ get_mime_type (MooFile *file,
else
g_message ("%s: oops", G_STRLOC);
}
#endif /* !__WIN32__ */
static gboolean get_icons_a_bit (MooFolder *folder)

View File

@ -80,9 +80,6 @@ static char *get_absolute_path_unix (MooFileSystem *fs,
static MooFolder *get_root_folder_win32 (MooFileSystem *fs,
MooFileFlags wanted);
static gboolean create_folder_win32 (MooFileSystem *fs,
const char *path,
GError **error);
static gboolean move_file_win32 (MooFileSystem *fs,
const char *old_path,
const char *new_path,
@ -799,34 +796,19 @@ static char *get_absolute_path_unix (G_GNUC_UNUSED MooFileSystem *fs,
*/
#ifdef __WIN32__
static MooFolder *get_root_folder_win32 (MooFileSystem *fs,
MooFileFlags wanted)
static MooFolder *
get_root_folder_win32 (MooFileSystem *fs,
MooFileFlags wanted)
{
MooFolder *folder;
folder = g_hash_table_lookup (fs->priv->folders, "");
if (folder)
{
g_object_ref (folder);
return folder;
}
// WIN32_XXX
g_hash_table_insert (fs->priv->folders,
g_strdup (""), g_object_ref (folder));
g_signal_connect (folder, "deleted",
G_CALLBACK (folder_deleted), fs);
return folder;
#warning "Implement me"
return moo_file_system_get_folder (fs, "c:\\", wanted, NULL);
}
static gboolean
move_file_win32 (MooFileSystem *fs,
const char *old_path,
const char *new_path,
move_file_win32 (G_GNUC_UNUSED MooFileSystem *fs,
G_GNUC_UNUSED const char *old_path,
G_GNUC_UNUSED const char *new_path,
GError **error)
{
#warning "Implement me"
@ -856,22 +838,28 @@ splitdrive (const char *fullpath,
static char *
normalize_path_win32 (MooFileSystem *fs,
normalize_path_win32 (G_GNUC_UNUSED MooFileSystem *fs,
const char *fullpath,
gboolean isdir,
GError **error)
G_GNUC_UNUSED GError **error)
{
char *drive, *path, *normpath;
guint slashes, i;
char **comps;
guint slashes;
g_return_val_if_fail (fullpath != NULL, NULL);
splitdrive (fullpath, &prefix, &path);
splitdrive (fullpath, &drive, &path);
g_strdelimit (path, "/", '\\');
for (slashes = 0; path[slashes] == '\\'; ++slashes) ;
if (drive && path[0] != '\\')
{
char *tmp = path;
path = g_strdup_printf ("\\%s", path);
g_free (tmp);
}
if (!drive)
{
char *tmp = path;
@ -879,18 +867,18 @@ normalize_path_win32 (MooFileSystem *fs,
path = g_strdup (tmp + slashes);
g_free (tmp);
}
else if (path[0] == '\\')
{
char *tmp;
tmp = drive;
drive = g_strdup_printf ("%s\\", drive);
g_free (tmp);
tmp = path;
path = g_strdup (path + slashes);
g_free (tmp);
}
// else if (path[0] == '\\')
// {
// char *tmp;
//
// tmp = drive;
// drive = g_strdup_printf ("%s\\", drive);
// g_free (tmp);
//
// tmp = path;
// path = g_strdup (path + slashes);
// g_free (tmp);
// }
normpath = normalize_path (path);
@ -983,7 +971,7 @@ success:
static char *
get_absolute_path_win32 (MooFileSystem *fs,
get_absolute_path_win32 (G_GNUC_UNUSED MooFileSystem *fs,
const char *short_name,
const char *current_dir)
{

View File

@ -27,6 +27,7 @@
#ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <io.h>
#endif
#ifdef HAVE_SYS_WAIT_H
@ -131,7 +132,6 @@ rm_r (const char *path,
GDir *dir;
GError *error_here = NULL;
const char *file;
char *file_path;
gboolean success = TRUE;
g_return_val_if_fail (path != NULL, FALSE);

View File

@ -444,13 +444,14 @@ gboolean
moo_window_is_hidden (GtkWindow *window)
{
HANDLE h;
WINDOWPLACEMENT info = {0};
WINDOWPLACEMENT info;
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
h = get_handle (window);
g_return_val_if_fail (h != NULL, FALSE);
memset (&info, 0, sizeof (info));
info.length = sizeof (WINDOWPLACEMENT);
if (!GetWindowPlacement (h, &info))

View File

@ -19,8 +19,12 @@ Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription
[Files]
Source: C:\medit\medit.exe; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\syntax\*; DestDir: {app}\syntax; Flags: ignoreversion recursesubdirs
Source: C:\medit\actions.cfg; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\ui.xml; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\completion\*; DestDir: {app}\completion; Flags: ignoreversion recursesubdirs
Source: C:\medit\plugins\*; DestDir: {app}\plugins; Flags: ignoreversion recursesubdirs
Source: C:\medit\actions.cfg.example; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\ui.xml.example; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\tools.cfg; DestDir: {app}; Flags: ignoreversion
Source: C:\medit\menu.cfg; DestDir: {app}; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]