Install/write everything into medit-1 folders, not moo or medit
This commit is contained in:
parent
52f19f437f
commit
f9f564ba08
@ -42,6 +42,11 @@ AC_SUBST(MOO_EMAIL)
|
||||
AC_SUBST(MOO_DISPLAY_VERSION)
|
||||
AC_SUBST(MOO_COPYRIGHT)
|
||||
|
||||
MOO_INI_FILE_NAME="medit.ini"
|
||||
MOO_STATE_FILE_NAME="medit.state"
|
||||
MOO_SESSION_FILE_NAME="medit.session"
|
||||
MOO_PACKAGE_SUBDIR_NAME="medit-1"
|
||||
|
||||
GETTEXT_PACKAGE=moo
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[moo])
|
||||
@ -96,7 +101,6 @@ AC_DEFINE_UNQUOTED(MOO_MODULE_MINOR_VERSION,[$MOO_MODULE_MINOR_VERSION],[MOO_MOD
|
||||
|
||||
AC_DEFINE_UNQUOTED(MOO_EMAIL,["$MOO_EMAIL"],MOO_EMAIL)
|
||||
AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT,["$PACKAGE_BUGREPORT"],PACKAGE_BUGREPORT)
|
||||
AC_DEFINE_UNQUOTED(MOO_PACKAGE_NAME,["$MOO_PACKAGE_NAME"],MOO_PACKAGE_NAME)
|
||||
AC_DEFINE_UNQUOTED(MOO_COPYRIGHT,["$MOO_COPYRIGHT"],MOO_COPYRIGHT)
|
||||
|
||||
MOO_AC_CHECK_OS
|
||||
|
@ -159,29 +159,33 @@ fi
|
||||
# MOO_AC_SET_DIRS
|
||||
#
|
||||
AC_DEFUN_ONCE([MOO_AC_SET_DIRS],[
|
||||
if test "x$MOO_PACKAGE_NAME" = x; then
|
||||
MOO_PACKAGE_NAME=moo
|
||||
if test "x$MOO_PACKAGE_SUBDIR_NAME" = x; then
|
||||
AC_MSG_ERROR([MOO_PACKAGE_SUBDIR_NAME not set])
|
||||
fi
|
||||
|
||||
AC_SUBST(MOO_PACKAGE_NAME)
|
||||
AC_DEFINE_UNQUOTED([MOO_PACKAGE_NAME], "$MOO_PACKAGE_NAME", [package name])
|
||||
AC_SUBST(MOO_PACKAGE_SUBDIR_NAME)
|
||||
AC_DEFINE_UNQUOTED([MOO_PACKAGE_SUBDIR_NAME], "$MOO_PACKAGE_SUBDIR_NAME", [data goes into /usr/share/$MOO_PACKAGE_SUBDIR_NAME, etc.])
|
||||
|
||||
MOO_DATA_DIR="${datadir}/$MOO_PACKAGE_NAME"
|
||||
MOO_DATA_DIR="${datadir}/$MOO_PACKAGE_SUBDIR_NAME"
|
||||
AC_SUBST(MOO_DATA_DIR)
|
||||
|
||||
MOO_LIB_DIR="${libdir}/$MOO_PACKAGE_NAME"
|
||||
MOO_LIB_DIR="${libdir}/$MOO_PACKAGE_SUBDIR_NAME"
|
||||
AC_SUBST(MOO_LIB_DIR)
|
||||
|
||||
MOO_PLUGINS_DIR="${MOO_LIB_DIR}/plugins"
|
||||
AC_SUBST(MOO_PLUGINS_DIR)
|
||||
|
||||
MOO_DOC_DIR="${datadir}/doc/medit"
|
||||
MOO_DOC_DIR="${datadir}/doc/$MOO_PACKAGE_SUBDIR_NAME"
|
||||
AC_SUBST(MOO_DOC_DIR)
|
||||
MOO_HELP_DIR="${MOO_DOC_DIR}/help"
|
||||
AC_SUBST(MOO_HELP_DIR)
|
||||
|
||||
MOO_TEXT_LANG_FILES_DIR="${MOO_DATA_DIR}/language-specs"
|
||||
AC_SUBST(MOO_TEXT_LANG_FILES_DIR)
|
||||
|
||||
AC_DEFINE_UNQUOTED([MOO_INI_FILE_NAME], "$MOO_INI_FILE_NAME", [medit.ini])
|
||||
AC_DEFINE_UNQUOTED([MOO_STATE_FILE_NAME], "$MOO_STATE_FILE_NAME", [medit.state])
|
||||
AC_DEFINE_UNQUOTED([MOO_SESSION_FILE_NAME], "$MOO_SESSION_FILE_NAME", [medit.session])
|
||||
])
|
||||
|
||||
##############################################################################
|
||||
|
@ -40,7 +40,7 @@ static struct MeditOpts {
|
||||
int use_session;
|
||||
int pid;
|
||||
gboolean new_app;
|
||||
const char *app_name;
|
||||
const char *instance_name;
|
||||
gboolean new_window;
|
||||
gboolean new_tab;
|
||||
gboolean reload;
|
||||
@ -125,7 +125,7 @@ static GOptionEntry medit_options[] = {
|
||||
{ "pid", 0, 0, G_OPTION_ARG_INT, &medit_opts.pid,
|
||||
/* help message for command line option --pid=PID */ N_("Use existing instance with process id PID"),
|
||||
/* "PID" part in "--pid=PID" */ N_("PID") },
|
||||
{ "app-name", 0, 0, G_OPTION_ARG_STRING, (gpointer) &medit_opts.app_name,
|
||||
{ "app-name", 0, 0, G_OPTION_ARG_STRING, (gpointer) &medit_opts.instance_name,
|
||||
/* help message for command line option --app-name=NAME */ N_("Set instance name to NAME if it's not already running"),
|
||||
/* "NAME" part in "--app-name=NAME" */ N_("NAME") },
|
||||
{ "new-window", 'w', 0, G_OPTION_ARG_NONE, &medit_opts.new_window,
|
||||
@ -172,7 +172,7 @@ post_parse_func (void)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (medit_opts.pid > 0 && medit_opts.app_name)
|
||||
if (medit_opts.pid > 0 && medit_opts.instance_name)
|
||||
{
|
||||
/* error message for wrong commmand line */
|
||||
g_printerr (_("%s and %s options may not be used simultaneously\n"),
|
||||
@ -526,10 +526,6 @@ medit_main (int argc, char *argv[])
|
||||
|
||||
ctx = parse_args (argc, argv);
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,8,0)
|
||||
g_set_prgname ("medit");
|
||||
#endif
|
||||
|
||||
stamp = get_time_stamp ();
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
@ -547,7 +543,7 @@ medit_main (int argc, char *argv[])
|
||||
if (medit_opts.new_app || medit_opts.project_mode)
|
||||
new_instance = TRUE;
|
||||
|
||||
run_input = !medit_opts.new_app || medit_opts.app_name ||
|
||||
run_input = !medit_opts.new_app || medit_opts.instance_name ||
|
||||
medit_opts.use_session == 1 || medit_opts.project_mode;
|
||||
|
||||
if (medit_opts.pid > 0)
|
||||
@ -555,8 +551,8 @@ medit_main (int argc, char *argv[])
|
||||
sprintf (pid_buf, "%d", medit_opts.pid);
|
||||
name = pid_buf;
|
||||
}
|
||||
else if (medit_opts.app_name)
|
||||
name = medit_opts.app_name;
|
||||
else if (medit_opts.instance_name)
|
||||
name = medit_opts.instance_name;
|
||||
else if (!medit_opts.new_app)
|
||||
name = g_getenv ("MEDIT_PID");
|
||||
|
||||
@ -580,14 +576,14 @@ medit_main (int argc, char *argv[])
|
||||
if (moo_app_send_files (files, n_files, stamp, name))
|
||||
exit (0);
|
||||
|
||||
if (!medit_opts.app_name)
|
||||
if (!medit_opts.instance_name)
|
||||
{
|
||||
g_printerr ("Could not send files to instance '%s'\n", name);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!new_instance && !medit_opts.app_name &&
|
||||
if (!new_instance && !medit_opts.instance_name &&
|
||||
moo_app_send_files (files, n_files, stamp, NULL))
|
||||
{
|
||||
notify_startup_complete ();
|
||||
@ -611,7 +607,7 @@ medit_main (int argc, char *argv[])
|
||||
app = MOO_APP (g_object_new (medit_app_get_type (),
|
||||
"run-input", run_input,
|
||||
"use-session", medit_opts.use_session,
|
||||
"instance-name", medit_opts.app_name,
|
||||
"instance-name", medit_opts.instance_name,
|
||||
(const char*) NULL));
|
||||
|
||||
if (!moo_app_init (app))
|
||||
|
@ -21,7 +21,6 @@ add_tests (void)
|
||||
#endif
|
||||
|
||||
moo_test_lua ();
|
||||
moo_test_mooedit_lua_api ();
|
||||
|
||||
moo_test_key_file ();
|
||||
moo_test_editor ();
|
||||
|
@ -67,13 +67,6 @@
|
||||
|
||||
#define SESSION_VERSION "1.0"
|
||||
|
||||
#ifndef __WIN32__
|
||||
#define TMPL_RC_FILE "%src"
|
||||
#else
|
||||
#define TMPL_RC_FILE "%s.ini"
|
||||
#endif
|
||||
#define TMPL_STATE_FILE "%s.state"
|
||||
|
||||
static struct {
|
||||
MooApp *instance;
|
||||
gboolean atexit_installed;
|
||||
@ -570,8 +563,6 @@ moo_app_init_editor (MooApp *app)
|
||||
will get editor's xml */
|
||||
moo_editor_set_ui_xml (app->priv->editor,
|
||||
moo_app_get_ui_xml (app));
|
||||
moo_editor_set_app_name (app->priv->editor,
|
||||
MOO_APP_SHORT_NAME);
|
||||
|
||||
init_plugins (app);
|
||||
}
|
||||
@ -582,17 +573,16 @@ static void
|
||||
moo_app_init_ui (MooApp *app)
|
||||
{
|
||||
MooUiXml *xml = NULL;
|
||||
char **files;
|
||||
guint n_files, i;
|
||||
char **files, **p;
|
||||
|
||||
files = moo_get_data_files (MOO_UI_XML_FILE, MOO_DATA_SHARE, &n_files);
|
||||
files = moo_get_data_files (MOO_UI_XML_FILE);
|
||||
|
||||
for (i = 0; i < n_files; ++i)
|
||||
for (p = files; p && *p; ++p)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GMappedFile *file;
|
||||
|
||||
file = g_mapped_file_new (files[i], FALSE, &error);
|
||||
file = g_mapped_file_new (*p, FALSE, &error);
|
||||
|
||||
if (file)
|
||||
{
|
||||
@ -606,7 +596,7 @@ moo_app_init_ui (MooApp *app)
|
||||
|
||||
if (error->domain != G_FILE_ERROR || error->code != G_FILE_ERROR_NOENT)
|
||||
{
|
||||
g_warning ("%s: could not open file '%s'", G_STRLOC, files[i]);
|
||||
g_warning ("%s: could not open file '%s'", G_STRLOC, *p);
|
||||
g_warning ("%s: %s", G_STRLOC, error->message);
|
||||
}
|
||||
|
||||
@ -668,6 +658,7 @@ moo_app_init_real (MooApp *app)
|
||||
gdk_set_program_class (MOO_APP_FULL_NAME);
|
||||
gtk_window_set_default_icon_name (MOO_APP_SHORT_NAME);
|
||||
|
||||
moo_set_display_app_name (MOO_APP_SHORT_NAME);
|
||||
_moo_set_app_instance_name (app->priv->instance_name);
|
||||
|
||||
moo_app_load_prefs (app);
|
||||
@ -1122,12 +1113,10 @@ moo_app_load_session (MooApp *app)
|
||||
if (!app->priv->session_file)
|
||||
{
|
||||
if (app->priv->instance_name)
|
||||
app->priv->session_file = g_strdup_printf ("%s.session.%s",
|
||||
g_get_prgname (),
|
||||
app->priv->session_file = g_strdup_printf (MOO_SESSION_FILE_NAME ".%s",
|
||||
app->priv->instance_name);
|
||||
else
|
||||
app->priv->session_file = g_strdup_printf ("%s.session",
|
||||
g_get_prgname ());
|
||||
app->priv->session_file = g_strdup (MOO_SESSION_FILE_NAME);
|
||||
}
|
||||
|
||||
session_file = moo_get_user_cache_file (app->priv->session_file);
|
||||
@ -1387,164 +1376,16 @@ moo_app_create_prefs_dialog (MooApp *app)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
try_move_user_data_dir (const char *old_dir,
|
||||
const char *new_dir)
|
||||
{
|
||||
if (!g_file_test (new_dir, G_FILE_TEST_EXISTS) &&
|
||||
g_file_test (old_dir, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_message ("Moving directory '%s' to '%s'", old_dir, new_dir);
|
||||
|
||||
if (!_moo_rename_file (old_dir, new_dir, &error))
|
||||
{
|
||||
g_critical ("%s: %s", G_STRLOC, error->message);
|
||||
moo_set_user_data_dir (old_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __WIN32__
|
||||
static void
|
||||
move_rc_files (MooApp *app)
|
||||
{
|
||||
char *old_dir;
|
||||
char *new_dir;
|
||||
char *cache_dir;
|
||||
|
||||
old_dir = g_strdup_printf ("%s/.%s", g_get_home_dir (), g_get_prgname ());
|
||||
new_dir = g_strdup_printf ("%s/%s", g_get_user_data_dir (), g_get_prgname ());
|
||||
cache_dir = g_strdup_printf ("%s/%s", g_get_user_cache_dir (), g_get_prgname ());
|
||||
|
||||
/* do not be too clever here, there are way too many possible errors */
|
||||
|
||||
try_move_user_data_dir (old_dir, new_dir);
|
||||
|
||||
{
|
||||
char *new_file;
|
||||
char *old_file;
|
||||
|
||||
new_file = g_strdup_printf ("%s/" TMPL_RC_FILE, g_get_user_config_dir (), g_get_prgname ());
|
||||
old_file = g_strdup_printf ("%s/." TMPL_RC_FILE, g_get_home_dir (), g_get_prgname ());
|
||||
|
||||
if (!g_file_test (new_file, G_FILE_TEST_EXISTS) &&
|
||||
g_file_test (old_file, G_FILE_TEST_EXISTS) &&
|
||||
_moo_rename (old_file, new_file) != 0)
|
||||
{
|
||||
app->priv->rc_files[MOO_PREFS_RC] = old_file;
|
||||
old_file = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
app->priv->rc_files[MOO_PREFS_RC] = new_file;
|
||||
new_file = NULL;
|
||||
|
||||
if (!g_file_test (g_get_user_config_dir (), G_FILE_TEST_EXISTS))
|
||||
_moo_mkdir_with_parents (g_get_user_config_dir ());
|
||||
}
|
||||
|
||||
g_free (old_file);
|
||||
g_free (new_file);
|
||||
}
|
||||
|
||||
if (!g_file_test (cache_dir, G_FILE_TEST_EXISTS))
|
||||
_moo_mkdir_with_parents (cache_dir);
|
||||
|
||||
{
|
||||
const char *new_file;
|
||||
char *old_file = g_strdup_printf ("%s/." TMPL_STATE_FILE, g_get_home_dir (), g_get_prgname ());
|
||||
|
||||
if (app->priv->instance_name)
|
||||
app->priv->rc_files[MOO_PREFS_STATE] =
|
||||
g_strdup_printf ("%s/" TMPL_STATE_FILE ".%s",
|
||||
cache_dir,
|
||||
g_get_prgname (),
|
||||
app->priv->instance_name);
|
||||
else
|
||||
app->priv->rc_files[MOO_PREFS_STATE] =
|
||||
g_strdup_printf ("%s/" TMPL_STATE_FILE,
|
||||
cache_dir,
|
||||
g_get_prgname ());
|
||||
|
||||
new_file = app->priv->rc_files[MOO_PREFS_STATE];
|
||||
|
||||
if (!g_file_test (new_file, G_FILE_TEST_EXISTS) &&
|
||||
g_file_test (old_file, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
_moo_rename (old_file, new_file);
|
||||
}
|
||||
|
||||
g_free (old_file);
|
||||
}
|
||||
|
||||
g_free (cache_dir);
|
||||
g_free (new_dir);
|
||||
g_free (old_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
static void
|
||||
move_user_data_dir (void)
|
||||
{
|
||||
char *old_dir = g_build_filename (g_get_home_dir (), g_get_prgname (), NULL);
|
||||
char *new_dir = moo_get_user_data_dir ();
|
||||
try_move_user_data_dir (old_dir, new_dir);
|
||||
g_free (new_dir);
|
||||
g_free (old_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
static char **
|
||||
get_rc_files (void)
|
||||
{
|
||||
char *prefix;
|
||||
char *var;
|
||||
const char *value;
|
||||
char **files = NULL;
|
||||
|
||||
prefix = g_ascii_strup (g_get_prgname (), -1);
|
||||
var = g_strdup_printf ("%s_RC_FILES", prefix);
|
||||
value = g_getenv (var);
|
||||
|
||||
if (value && value[0])
|
||||
{
|
||||
files = g_strsplit (value, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmpl = g_strdup_printf (TMPL_RC_FILE, g_get_prgname ());
|
||||
files = moo_get_data_files (tmpl, MOO_DATA_SHARE, NULL);
|
||||
g_free (tmpl);
|
||||
}
|
||||
|
||||
g_free (var);
|
||||
g_free (prefix);
|
||||
return files;
|
||||
}
|
||||
|
||||
static void
|
||||
moo_app_load_prefs (MooApp *app)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char **sys_files;
|
||||
|
||||
#ifndef __WIN32__
|
||||
move_rc_files (app);
|
||||
#else
|
||||
app->priv->rc_files[MOO_PREFS_RC] =
|
||||
g_strdup_printf ("%s\\" TMPL_RC_FILE, g_get_user_config_dir (), g_get_prgname ());
|
||||
app->priv->rc_files[MOO_PREFS_STATE] =
|
||||
g_strdup_printf ("%s\\" TMPL_STATE_FILE, g_get_user_config_dir (), g_get_prgname ());
|
||||
#endif
|
||||
app->priv->rc_files[MOO_PREFS_RC] = moo_get_user_data_file (MOO_INI_FILE_NAME);
|
||||
app->priv->rc_files[MOO_PREFS_STATE] = moo_get_user_cache_file (MOO_STATE_FILE_NAME);
|
||||
|
||||
#ifdef __WIN32__
|
||||
move_user_data_dir ();
|
||||
#endif
|
||||
|
||||
sys_files = get_rc_files ();
|
||||
sys_files = moo_get_sys_data_files (MOO_INI_FILE_NAME);
|
||||
|
||||
if (!moo_prefs_load (sys_files,
|
||||
app->priv->rc_files[MOO_PREFS_RC],
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void moo_test_mooedit_lua_api (void);
|
||||
void moo_test_key_file (void);
|
||||
void moo_test_editor (void);
|
||||
|
||||
|
@ -61,7 +61,6 @@ typedef enum {
|
||||
struct MooEditorPrivate {
|
||||
DocList *windowless;
|
||||
WindowList *windows;
|
||||
char *app_name;
|
||||
MooUiXml *doc_ui_xml;
|
||||
MooUiXml *ui_xml;
|
||||
MdHistoryMgr *history;
|
||||
@ -369,8 +368,6 @@ moo_editor_finalize (GObject *object)
|
||||
{
|
||||
MooEditor *editor = MOO_EDITOR (object);
|
||||
|
||||
g_free (editor->priv->app_name);
|
||||
|
||||
if (editor->priv->ui_xml)
|
||||
g_object_unref (editor->priv->ui_xml);
|
||||
if (editor->priv->history)
|
||||
@ -564,27 +561,6 @@ file_info_list_free (GSList *list)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_editor_set_app_name (MooEditor *editor,
|
||||
const char *name)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDITOR (editor));
|
||||
MOO_ASSIGN_STRING (editor->priv->app_name, name);
|
||||
_moo_edit_window_update_title ();
|
||||
}
|
||||
|
||||
const char *
|
||||
moo_editor_get_app_name (MooEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
|
||||
if (!editor->priv->app_name)
|
||||
return g_get_prgname ();
|
||||
else
|
||||
return editor->priv->app_name;
|
||||
}
|
||||
|
||||
|
||||
MooUiXml *
|
||||
moo_editor_get_ui_xml (MooEditor *editor)
|
||||
{
|
||||
|
@ -121,10 +121,6 @@ gboolean moo_editor_close_all (MooEditor *editor,
|
||||
gboolean ask_confirm,
|
||||
gboolean leave_one);
|
||||
|
||||
void moo_editor_set_app_name (MooEditor *editor,
|
||||
const char *name);
|
||||
const char *moo_editor_get_app_name (MooEditor *editor);
|
||||
|
||||
MooUiXml *moo_editor_get_ui_xml (MooEditor *editor);
|
||||
void moo_editor_set_ui_xml (MooEditor *editor,
|
||||
MooUiXml *xml);
|
||||
|
@ -942,9 +942,8 @@ get_doc_status_string (MooEdit *doc)
|
||||
}
|
||||
|
||||
static char *
|
||||
parse_title_format (const char *format,
|
||||
MooEditWindow *window,
|
||||
MooEdit *doc)
|
||||
parse_title_format (const char *format,
|
||||
MooEdit *doc)
|
||||
{
|
||||
GString *str;
|
||||
|
||||
@ -965,7 +964,7 @@ parse_title_format (const char *format,
|
||||
switch (*format)
|
||||
{
|
||||
case 'a':
|
||||
g_string_append (str, moo_editor_get_app_name (window->priv->editor));
|
||||
g_string_append (str, moo_get_display_app_name ());
|
||||
break;
|
||||
case 'b':
|
||||
if (!doc)
|
||||
@ -1031,9 +1030,9 @@ update_window_title (MooEditWindow *window)
|
||||
doc = ACTIVE_DOC (window);
|
||||
|
||||
if (doc)
|
||||
title = parse_title_format (window->priv->title_format, window, doc);
|
||||
title = parse_title_format (window->priv->title_format, doc);
|
||||
else
|
||||
title = parse_title_format (window->priv->title_format_no_doc, window, NULL);
|
||||
title = parse_title_format (window->priv->title_format_no_doc, NULL);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), title);
|
||||
|
||||
|
@ -66,7 +66,6 @@ static void
|
||||
moo_lang_mgr_init (MooLangMgr *mgr)
|
||||
{
|
||||
char **dirs;
|
||||
guint n_dirs;
|
||||
|
||||
mgr->schemes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
|
||||
@ -76,7 +75,7 @@ moo_lang_mgr_init (MooLangMgr *mgr)
|
||||
g_free, g_free);
|
||||
|
||||
mgr->lang_mgr = gtk_source_language_manager_new ();
|
||||
dirs = moo_get_data_subdirs (LANGUAGE_DIR, MOO_DATA_SHARE, &n_dirs);
|
||||
dirs = moo_get_data_subdirs (LANGUAGE_DIR);
|
||||
g_object_set (mgr->lang_mgr, "search-path", dirs, NULL);
|
||||
mgr->style_mgr = gtk_source_style_scheme_manager_new ();
|
||||
gtk_source_style_scheme_manager_set_search_path (mgr->style_mgr, dirs);
|
||||
|
@ -913,7 +913,6 @@ void
|
||||
moo_plugin_read_dirs (void)
|
||||
{
|
||||
char **d, **dirs;
|
||||
guint n_dirs;
|
||||
|
||||
plugin_store_init ();
|
||||
|
||||
@ -922,8 +921,7 @@ moo_plugin_read_dirs (void)
|
||||
|
||||
plugin_store->dirs_read = TRUE;
|
||||
|
||||
dirs = moo_get_data_subdirs (MOO_PLUGIN_DIR_BASENAME,
|
||||
MOO_DATA_LIB, &n_dirs);
|
||||
dirs = moo_get_lib_subdirs (MOO_PLUGIN_DIR_BASENAME);
|
||||
g_strfreev (plugin_store->dirs);
|
||||
plugin_store->dirs = _moo_strv_reverse (dirs);
|
||||
|
||||
|
@ -77,12 +77,12 @@ EXTRA_DIST += \
|
||||
moolua/slnudata.c \
|
||||
moolua/slnunico.c
|
||||
|
||||
lua2dir = $(MOO_DATA_DIR)/lua2
|
||||
luadir = $(MOO_DATA_DIR)/lua
|
||||
EXTRA_DIST += moolua/pl
|
||||
install-data-local: install-lua-pl
|
||||
uninstall-local: uninstall-lua-pl
|
||||
install-lua-pl:
|
||||
$(MKDIR_P) $(DESTDIR)$(lua2dir)/pl
|
||||
cd $(srcdir) && $(INSTALL_DATA) moolua/pl/*.lua $(DESTDIR)$(lua2dir)/pl/
|
||||
$(MKDIR_P) $(DESTDIR)$(luadir)/pl
|
||||
cd $(srcdir) && $(INSTALL_DATA) moolua/pl/*.lua $(DESTDIR)$(luadir)/pl/
|
||||
uninstall-lua-pl:
|
||||
rm -f $(DESTDIR)$(lua2dir)/pl/*.lua
|
||||
rm -f $(DESTDIR)$(luadir)/pl/*.lua
|
||||
|
@ -102,9 +102,7 @@ moo_app_input_new (const char *name,
|
||||
{
|
||||
MooAppInput *ch;
|
||||
InputChannel *ich;
|
||||
const char *appname = g_get_prgname ();
|
||||
|
||||
g_return_val_if_fail (appname != NULL, FALSE);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
ch = moo_new0 (MooAppInput);
|
||||
@ -112,18 +110,18 @@ moo_app_input_new (const char *name,
|
||||
ch->callback = callback;
|
||||
ch->callback_data = callback_data;
|
||||
ch->pipes = NULL;
|
||||
ch->appname = g_strdup (appname);
|
||||
ch->appname = g_strdup (MOO_PACKAGE_SUBDIR_NAME);
|
||||
|
||||
if ((ich = input_channel_new (appname, _moo_get_pid_string (), FALSE)))
|
||||
if ((ich = input_channel_new (ch->appname, _moo_get_pid_string (), FALSE)))
|
||||
{
|
||||
ch->pipes = g_slist_prepend (ch->pipes, ich);
|
||||
ch->main_path = input_channel_get_path (ich);
|
||||
}
|
||||
|
||||
if (name && (ich = input_channel_new (appname, name, FALSE)))
|
||||
if (name && (ich = input_channel_new (ch->appname, name, FALSE)))
|
||||
ch->pipes = g_slist_prepend (ch->pipes, ich);
|
||||
|
||||
if (bind_default && (ich = input_channel_new (appname, MOO_APP_INPUT_NAME_DEFAULT, TRUE)))
|
||||
if (bind_default && (ich = input_channel_new (ch->appname, MOO_APP_INPUT_NAME_DEFAULT, TRUE)))
|
||||
ch->pipes = g_slist_prepend (ch->pipes, ich);
|
||||
|
||||
return ch;
|
||||
@ -387,14 +385,12 @@ _moo_app_input_send_msg (const char *name,
|
||||
GDir *pipe_dir = NULL;
|
||||
char *pipe_dir_name;
|
||||
gboolean success = FALSE;
|
||||
const char *appname = g_get_prgname ();
|
||||
|
||||
g_return_val_if_fail (appname != NULL, FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
moo_dmsg ("_moo_app_input_send_msg: sending data to %s", name ? name : "NONE");
|
||||
|
||||
pipe_dir_name = get_pipe_dir (appname);
|
||||
pipe_dir_name = get_pipe_dir (MOO_PACKAGE_SUBDIR_NAME);
|
||||
g_return_val_if_fail (pipe_dir_name != NULL, FALSE);
|
||||
|
||||
if (name)
|
||||
@ -1134,9 +1130,7 @@ _moo_app_input_send_msg (const char *name,
|
||||
char *pipe_name;
|
||||
HANDLE pipe_handle;
|
||||
gboolean result = FALSE;
|
||||
const char *appname = g_get_prgname ();
|
||||
|
||||
g_return_val_if_fail (appname != NULL, FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
@ -1148,7 +1142,7 @@ _moo_app_input_send_msg (const char *name,
|
||||
if (!name)
|
||||
name = "main";
|
||||
|
||||
pipe_name = get_pipe_name (appname, name);
|
||||
pipe_name = get_pipe_name (MOO_PACKAGE_SUBDIR_NAME, name);
|
||||
/* XXX unicode */
|
||||
pipe_handle = CreateFileA (pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
|
@ -180,7 +180,7 @@ find_help_dir (void)
|
||||
|
||||
for (p = dirs; p && *p; ++p)
|
||||
{
|
||||
char *d = g_build_filename (*p, "doc", g_get_prgname (), "help", NULL);
|
||||
char *d = g_build_filename (*p, "doc", MOO_PACKAGE_SUBDIR_NAME, "help", NULL);
|
||||
|
||||
if (try_help_dir (d))
|
||||
{
|
||||
|
@ -53,12 +53,12 @@
|
||||
|
||||
G_LOCK_DEFINE_STATIC (moo_user_data_dir);
|
||||
static char *moo_app_instance_name;
|
||||
static char *moo_display_app_name;
|
||||
static char *moo_user_data_dir;
|
||||
static char *moo_temp_dir;
|
||||
|
||||
static void moo_install_atexit (void);
|
||||
static void moo_remove_tempdir (void);
|
||||
static const char *moo_get_prgname (void);
|
||||
|
||||
|
||||
#ifdef __WIN32__
|
||||
@ -87,7 +87,7 @@ _moo_find_script (const char *name,
|
||||
{
|
||||
char **dirs, **p;
|
||||
|
||||
dirs = moo_get_data_subdirs ("scripts", MOO_DATA_SHARE, NULL);
|
||||
dirs = moo_get_data_subdirs ("scripts");
|
||||
|
||||
for (p = dirs; p && *p; ++p)
|
||||
{
|
||||
@ -1197,23 +1197,6 @@ _moo_get_pid_string (void)
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
moo_get_prgname (void)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = g_get_prgname ();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
g_critical ("%s: program name not set", G_STRLOC);
|
||||
name = "medit";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
moo_tempnam (void)
|
||||
{
|
||||
@ -1227,7 +1210,7 @@ moo_tempnam (void)
|
||||
char *dirname = NULL;
|
||||
const char *short_name;
|
||||
|
||||
short_name = moo_get_prgname ();
|
||||
short_name = MOO_PACKAGE_SUBDIR_NAME;
|
||||
|
||||
for (i = 0; i < 1000; ++i)
|
||||
{
|
||||
@ -1326,7 +1309,7 @@ moo_cleanup (void)
|
||||
char *
|
||||
moo_get_user_cache_dir (void)
|
||||
{
|
||||
return g_build_filename (g_get_user_cache_dir (), moo_get_prgname (), NULL);
|
||||
return g_build_filename (g_get_user_cache_dir (), MOO_PACKAGE_SUBDIR_NAME, NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
@ -1343,7 +1326,7 @@ moo_get_user_data_dir (void)
|
||||
#endif
|
||||
|
||||
moo_user_data_dir = g_build_filename (basedir,
|
||||
moo_get_prgname (),
|
||||
MOO_PACKAGE_SUBDIR_NAME,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@ -1381,6 +1364,20 @@ _moo_set_app_instance_name (const char *name)
|
||||
moo_app_instance_name = g_strdup (name);
|
||||
}
|
||||
|
||||
void
|
||||
moo_set_display_app_name (const char *name)
|
||||
{
|
||||
g_return_if_fail (name && *name);
|
||||
g_free (moo_display_app_name);
|
||||
moo_display_app_name = g_strdup (name);
|
||||
}
|
||||
|
||||
const char *
|
||||
moo_get_display_app_name (void)
|
||||
{
|
||||
return moo_display_app_name ? moo_display_app_name : g_get_prgname ();
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
moo_make_user_data_dir (const char *path)
|
||||
@ -1443,7 +1440,7 @@ add_dir_list_from_env (GPtrArray *list,
|
||||
|
||||
static char **
|
||||
moo_get_data_dirs_real (MooDataDirType type,
|
||||
char **add,
|
||||
gboolean include_user,
|
||||
guint *n_dirs)
|
||||
{
|
||||
static char **moo_data_dirs[2];
|
||||
@ -1454,9 +1451,6 @@ moo_get_data_dirs_real (MooDataDirType type,
|
||||
|
||||
G_LOCK (moo_data_dirs);
|
||||
|
||||
if (add && moo_data_dirs[type])
|
||||
g_critical ("moo_add_data_dirs() called too late, ignored");
|
||||
|
||||
if (!moo_data_dirs[type])
|
||||
{
|
||||
const char *env[2];
|
||||
@ -1473,9 +1467,6 @@ moo_get_data_dirs_real (MooDataDirType type,
|
||||
|
||||
g_ptr_array_add (all_dirs, moo_get_user_data_dir ());
|
||||
|
||||
while (add && *add)
|
||||
g_ptr_array_add (all_dirs, g_strdup (*add++));
|
||||
|
||||
/* environment variables override everything */
|
||||
if (env[0] || env[1])
|
||||
{
|
||||
@ -1494,7 +1485,7 @@ moo_get_data_dirs_real (MooDataDirType type,
|
||||
const char* const *p;
|
||||
|
||||
for (p = g_get_system_data_dirs (); p && *p; ++p)
|
||||
g_ptr_array_add (all_dirs, g_build_filename (*p, MOO_PACKAGE_NAME, NULL));
|
||||
g_ptr_array_add (all_dirs, g_build_filename (*p, MOO_PACKAGE_SUBDIR_NAME, NULL));
|
||||
|
||||
g_ptr_array_add (all_dirs, g_strdup (MOO_DATA_DIR));
|
||||
}
|
||||
@ -1543,23 +1534,33 @@ moo_get_data_dirs_real (MooDataDirType type,
|
||||
|
||||
G_UNLOCK (moo_data_dirs);
|
||||
|
||||
if (n_dirs)
|
||||
*n_dirs = n_data_dirs[type];
|
||||
|
||||
return g_strdupv (moo_data_dirs[type]);
|
||||
if (include_user)
|
||||
{
|
||||
if (n_dirs)
|
||||
*n_dirs = n_data_dirs[type];
|
||||
return g_strdupv (moo_data_dirs[type]);
|
||||
}
|
||||
else if (n_data_dirs[type] == 1)
|
||||
{
|
||||
if (n_dirs)
|
||||
*n_dirs = 0;
|
||||
return g_strdupv (moo_data_dirs[type] + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char **ret = g_strdupv (moo_data_dirs[type]);
|
||||
ret[n_data_dirs[type] - 1] = 0;
|
||||
if (n_dirs)
|
||||
*n_dirs = n_data_dirs[type] - 1;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
char **
|
||||
moo_get_data_dirs (MooDataDirType type,
|
||||
guint *n_dirs)
|
||||
{
|
||||
return moo_get_data_dirs_real (type, NULL, n_dirs);
|
||||
}
|
||||
|
||||
void
|
||||
moo_add_data_dirs (char **dirs)
|
||||
{
|
||||
g_strfreev (moo_get_data_dirs_real (MOO_DATA_SHARE, dirs, NULL));
|
||||
return moo_get_data_dirs_real (type, TRUE, n_dirs);
|
||||
}
|
||||
|
||||
|
||||
@ -1575,22 +1576,19 @@ moo_get_locale_dir (void)
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
moo_get_data_subdirs (const char *subdir,
|
||||
MooDataDirType type,
|
||||
guint *n_dirs_p)
|
||||
static char **
|
||||
moo_get_stuff_subdirs (const char *subdir,
|
||||
MooDataDirType type,
|
||||
gboolean include_user)
|
||||
{
|
||||
char **data_dirs, **dirs;
|
||||
guint n_dirs, i;
|
||||
|
||||
g_return_val_if_fail (subdir != NULL, NULL);
|
||||
|
||||
data_dirs = moo_get_data_dirs (type, &n_dirs);
|
||||
data_dirs = moo_get_data_dirs_real (type, include_user, &n_dirs);
|
||||
g_return_val_if_fail (data_dirs != NULL, NULL);
|
||||
|
||||
if (n_dirs_p)
|
||||
*n_dirs_p = n_dirs;
|
||||
|
||||
dirs = g_new0 (char*, n_dirs + 1);
|
||||
|
||||
for (i = 0; i < n_dirs; ++i)
|
||||
@ -1600,6 +1598,24 @@ moo_get_data_subdirs (const char *subdir,
|
||||
return dirs;
|
||||
}
|
||||
|
||||
char **
|
||||
moo_get_data_subdirs (const char *subdir)
|
||||
{
|
||||
return moo_get_stuff_subdirs (subdir, MOO_DATA_SHARE, TRUE);
|
||||
}
|
||||
|
||||
char **
|
||||
moo_get_sys_data_subdirs (const char *subdir)
|
||||
{
|
||||
return moo_get_stuff_subdirs (subdir, MOO_DATA_SHARE, FALSE);
|
||||
}
|
||||
|
||||
char **
|
||||
moo_get_lib_subdirs (const char *subdir)
|
||||
{
|
||||
return moo_get_stuff_subdirs (subdir, MOO_DATA_LIB, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
get_user_data_file (const char *basename,
|
||||
|
@ -69,8 +69,9 @@ typedef enum {
|
||||
|
||||
void _moo_set_app_instance_name (const char *name);
|
||||
void moo_set_user_data_dir (const char *path);
|
||||
void moo_set_display_app_name (const char *name);
|
||||
const char *moo_get_display_app_name (void);
|
||||
|
||||
/* ~/.appname */
|
||||
gboolean moo_make_user_data_dir (const char *path);
|
||||
char *moo_get_user_data_dir (void);
|
||||
char *moo_get_user_data_file (const char *basename);
|
||||
@ -93,13 +94,14 @@ gboolean moo_save_config_file (const char *filename,
|
||||
/* user data comes first; MOO_DATA_DIR comes last */
|
||||
/* $MOO_APP_DIR:$MOO_DATA_DIRS:$prefix/share/appname or
|
||||
$MOO_APP_DIR:$MOO_LIB_DIRS:$prefix/lib/appname */
|
||||
void moo_add_data_dirs (char **dirs);
|
||||
char **moo_get_data_dirs (MooDataDirType type,
|
||||
guint *n_dirs);
|
||||
char **moo_get_data_subdirs (const char *subdir,
|
||||
MooDataDirType type,
|
||||
guint *n_dirs);
|
||||
char **moo_get_data_subdirs (const char *subdir);
|
||||
char **moo_get_sys_data_subdirs (const char *subdir);
|
||||
char **moo_get_lib_subdirs (const char *subdir);
|
||||
|
||||
#define moo_get_data_files moo_get_data_subdirs
|
||||
#define moo_get_sys_data_files moo_get_sys_data_subdirs
|
||||
|
||||
char *moo_tempnam (void);
|
||||
void moo_cleanup (void);
|
||||
|
@ -148,7 +148,7 @@ _moo_win32_add_data_dirs (GPtrArray *list,
|
||||
{
|
||||
char *subdir;
|
||||
|
||||
subdir = g_strdup_printf ("%s\\" MOO_PACKAGE_NAME, prefix);
|
||||
subdir = g_strdup_printf ("%s\\" MOO_PACKAGE_SUBDIR_NAME, prefix);
|
||||
add_win32_data_dirs_for_dll (list, subdir, NULL);
|
||||
add_win32_data_dirs_for_dll (list, subdir, get_moo_dll_name ());
|
||||
|
||||
|
@ -10,40 +10,6 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Version:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="version">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow2">
|
||||
<property name="visible">True</property>
|
||||
@ -58,7 +24,7 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -1,19 +1,16 @@
|
||||
plugins_sources += \
|
||||
plugins/usertools/lua/moocommand-lua.cpp \
|
||||
plugins/usertools/lua/moocommand-lua.h \
|
||||
plugins/usertools/lua/mooedit-lua1.cpp \
|
||||
plugins/usertools/lua/mooedit-lua1.h \
|
||||
plugins/usertools/lua/mooedit-lua-api1.cpp
|
||||
plugins/usertools/lua/moocommand-lua.h
|
||||
|
||||
EXTRA_DIST += plugins/usertools/glade/mooedittools-lua.glade
|
||||
built_plugins_sources += mooedittools-lua-gxml.h
|
||||
|
||||
lua1dir = $(MOO_DATA_DIR)/lua
|
||||
lua1_DATA = plugins/usertools/lua/medit.lua
|
||||
EXTRA_DIST += plugins/usertools/lua/medit.lua
|
||||
# luadir = $(MOO_DATA_DIR)/lua
|
||||
# lua_DATA = plugins/usertools/lua/medit.lua
|
||||
# EXTRA_DIST += plugins/usertools/lua/medit.lua
|
||||
|
||||
EXTRA_DIST += plugins/usertools/lua/lua2-tool-setup.lua
|
||||
built_plugins_sources += lua2-tool-setup.h
|
||||
lua2-tool-setup.h: plugins/usertools/lua/lua2-tool-setup.lua $(top_srcdir)/tools/xml2h.py
|
||||
$(PYTHON) $(top_srcdir)/tools/xml2h.py $(srcdir)/plugins/usertools/lua/lua2-tool-setup.lua lua2-tool-setup.h.tmp LUA2_SETUP_CODE \
|
||||
&& mv lua2-tool-setup.h.tmp lua2-tool-setup.h
|
||||
EXTRA_DIST += plugins/usertools/lua/lua-tool-setup.lua
|
||||
built_plugins_sources += lua-tool-setup.h
|
||||
lua-tool-setup.h: plugins/usertools/lua/lua-tool-setup.lua $(top_srcdir)/tools/xml2h.py
|
||||
$(PYTHON) $(top_srcdir)/tools/xml2h.py $(srcdir)/plugins/usertools/lua/lua-tool-setup.lua lua-tool-setup.h.tmp LUA_SETUP_CODE \
|
||||
&& mv lua-tool-setup.h.tmp lua-tool-setup.h
|
||||
|
@ -1,48 +0,0 @@
|
||||
local base = _G
|
||||
local _medit = require("_medit")
|
||||
module("medit")
|
||||
|
||||
-- open file in the editor
|
||||
function open(filename)
|
||||
return _medit.open(filename)
|
||||
end
|
||||
|
||||
|
||||
local function parse_args(arg)
|
||||
if base.type(arg[1]) == 'table' then
|
||||
return {cmd_line=arg[1].cmd_line,
|
||||
working_dir=arg[1].working_dir,
|
||||
env=arg[1].env,
|
||||
input=arg[1].input}
|
||||
elseif base.type(arg[1]) == 'string' and
|
||||
base.type(arg[2]) == 'table'
|
||||
then
|
||||
return {cmd_line=arg[1],
|
||||
working_dir=arg[2].working_dir,
|
||||
env=arg[2].env,
|
||||
input=arg[2].input}
|
||||
else
|
||||
return {cmd_line=arg[1],
|
||||
working_dir=arg[2],
|
||||
env=arg[3],
|
||||
input=arg[4]}
|
||||
end
|
||||
end
|
||||
|
||||
-- run a command in an output pane
|
||||
function run_in_pane(...)
|
||||
local args = parse_args(arg)
|
||||
return _medit.run_in_pane(args.cmd_line, args.working_dir)
|
||||
end
|
||||
|
||||
-- run a command in background
|
||||
function run_async(...)
|
||||
local args = parse_args(arg)
|
||||
return _medit.run_async(args.cmd_line, args.working_dir)
|
||||
end
|
||||
|
||||
-- run a command
|
||||
function run_sync(...)
|
||||
local args = parse_args(arg)
|
||||
return _medit.run_async(args.cmd_line, args.working_dir, args.input)
|
||||
end
|
@ -15,8 +15,7 @@
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "moocommand-lua.h"
|
||||
#include "mooedit-lua1.h"
|
||||
#include "lua2-tool-setup.h"
|
||||
#include "lua-tool-setup.h"
|
||||
#include "mooscript/mooscript-lua.h"
|
||||
#include "mooedit/mooeditor.h"
|
||||
#include "mooedit/mootext-private.h"
|
||||
@ -28,23 +27,8 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
enum {
|
||||
KEY_VERSION,
|
||||
N_KEYS
|
||||
};
|
||||
|
||||
static const char *data_keys[N_KEYS+1] = {
|
||||
"version", NULL
|
||||
};
|
||||
|
||||
enum {
|
||||
MOO_COMMAND_LUA1,
|
||||
MOO_COMMAND_LUA2
|
||||
};
|
||||
|
||||
struct _MooCommandLuaPrivate {
|
||||
char *code;
|
||||
int version;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MooCommandLua, _moo_command_lua, MOO_TYPE_COMMAND)
|
||||
@ -53,8 +37,7 @@ typedef MooCommandFactory MooCommandFactoryLua;
|
||||
typedef MooCommandFactoryClass MooCommandFactoryLuaClass;
|
||||
MOO_DEFINE_TYPE_STATIC (MooCommandFactoryLua, _moo_command_factory_lua, MOO_TYPE_COMMAND_FACTORY)
|
||||
|
||||
static MooCommand *moo_command_lua_new (int version,
|
||||
const char *code,
|
||||
static MooCommand *moo_command_lua_new (const char *code,
|
||||
MooCommandOptions options);
|
||||
|
||||
|
||||
@ -63,89 +46,35 @@ add_path (lua_State *L, const char *dir)
|
||||
{
|
||||
char **dirs;
|
||||
|
||||
dirs = moo_get_data_subdirs (dir, MOO_DATA_SHARE, NULL);
|
||||
dirs = moo_get_data_subdirs (dir);
|
||||
lua_addpath (L, dirs, g_strv_length (dirs));
|
||||
|
||||
g_strfreev (dirs);
|
||||
}
|
||||
|
||||
static lua_State *
|
||||
create_lua1 (void)
|
||||
static void
|
||||
moo_command_lua_run (MooCommand *cmd_base,
|
||||
MooCommandContext *ctx)
|
||||
{
|
||||
MooCommandLua *cmd = MOO_COMMAND_LUA (cmd_base);
|
||||
GtkTextBuffer *buffer = NULL;
|
||||
lua_State *L;
|
||||
|
||||
g_return_if_fail (cmd->priv->code != NULL);
|
||||
|
||||
L = lua_open ();
|
||||
g_return_if_fail (L != NULL);
|
||||
|
||||
luaL_openlibs (L);
|
||||
_moo_edit_lua1_add_api (L);
|
||||
add_path (L, "lua");
|
||||
|
||||
return L;
|
||||
}
|
||||
|
||||
static void
|
||||
moo_command_lua1_run (MooCommandLua *cmd,
|
||||
MooCommandContext *ctx)
|
||||
{
|
||||
GtkTextBuffer *buffer = NULL;
|
||||
lua_State *L;
|
||||
|
||||
g_return_if_fail (cmd->priv->code != NULL);
|
||||
|
||||
L = create_lua1 ();
|
||||
g_return_if_fail (L != NULL);
|
||||
|
||||
if (luaL_loadstring (L, cmd->priv->code) != 0)
|
||||
{
|
||||
const char *msg = lua_tostring (L, -1);
|
||||
g_critical ("%s: %s", G_STRLOC, msg ? msg : "ERROR");
|
||||
lua_pop (L, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
_moo_edit_lua1_set_doc (L, GTK_TEXT_VIEW (moo_command_context_get_doc (ctx)));
|
||||
|
||||
if (moo_command_context_get_doc (ctx))
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moo_command_context_get_doc (ctx)));
|
||||
|
||||
if (buffer)
|
||||
gtk_text_buffer_begin_user_action (buffer);
|
||||
|
||||
if (lua_pcall (L, 0, 0, 0) != 0)
|
||||
{
|
||||
const char *msg = lua_tostring (L, -1);
|
||||
g_critical ("%s: %s", G_STRLOC, msg ? msg : "ERROR");
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
gtk_text_buffer_end_user_action (buffer);
|
||||
|
||||
_moo_edit_lua1_cleanup (L);
|
||||
lua_close (L);
|
||||
}
|
||||
|
||||
static void
|
||||
moo_command_lua2_run (MooCommandLua *cmd,
|
||||
MooCommandContext *ctx)
|
||||
{
|
||||
GtkTextBuffer *buffer = NULL;
|
||||
lua_State *L;
|
||||
|
||||
g_return_if_fail (cmd->priv->code != NULL);
|
||||
|
||||
L = lua_open ();
|
||||
g_return_if_fail (L != NULL);
|
||||
|
||||
luaL_openlibs (L);
|
||||
add_path (L, "lua2");
|
||||
|
||||
if (!mom::lua_setup (L))
|
||||
{
|
||||
lua_close (L);
|
||||
return;
|
||||
}
|
||||
|
||||
if (luaL_loadstring (L, LUA2_SETUP_CODE) != 0)
|
||||
if (luaL_loadstring (L, LUA_SETUP_CODE) != 0)
|
||||
{
|
||||
const char *msg = lua_tostring (L, -1);
|
||||
g_critical ("%s: %s", G_STRLOC, msg ? msg : "ERROR");
|
||||
@ -189,23 +118,6 @@ moo_command_lua2_run (MooCommandLua *cmd,
|
||||
lua_close (L);
|
||||
}
|
||||
|
||||
static void
|
||||
moo_command_lua_run (MooCommand *cmd_base,
|
||||
MooCommandContext *ctx)
|
||||
{
|
||||
MooCommandLua *cmd = MOO_COMMAND_LUA (cmd_base);
|
||||
|
||||
switch (cmd->priv->version)
|
||||
{
|
||||
case MOO_COMMAND_LUA1:
|
||||
moo_command_lua1_run (cmd, ctx);
|
||||
break;
|
||||
case MOO_COMMAND_LUA2:
|
||||
moo_command_lua2_run (cmd, ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_command_lua_dispose (GObject *object)
|
||||
@ -222,77 +134,24 @@ moo_command_lua_dispose (GObject *object)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
parse_version (const char *string,
|
||||
int *version)
|
||||
{
|
||||
*version = MOO_COMMAND_LUA1;
|
||||
|
||||
if (!string || !string[0])
|
||||
return TRUE;
|
||||
|
||||
if (!strcmp (string, "1"))
|
||||
*version = MOO_COMMAND_LUA1;
|
||||
else if (!strcmp (string, "2"))
|
||||
*version = MOO_COMMAND_LUA2;
|
||||
else
|
||||
{
|
||||
moo_warning ("unknown version type %s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static MooCommand *
|
||||
lua_factory_create_command (G_GNUC_UNUSED MooCommandFactory *factory,
|
||||
MooCommandData *data,
|
||||
const char *options)
|
||||
{
|
||||
MooCommand *cmd;
|
||||
int version = MOO_COMMAND_LUA1;
|
||||
const char *code;
|
||||
|
||||
if (!parse_version (moo_command_data_get (data, KEY_VERSION), &version))
|
||||
return NULL;
|
||||
|
||||
code = moo_command_data_get_code (data);
|
||||
g_return_val_if_fail (code && *code, NULL);
|
||||
|
||||
cmd = moo_command_lua_new (version, code, moo_command_options_parse (options));
|
||||
cmd = moo_command_lua_new (code, moo_command_options_parse (options));
|
||||
g_return_val_if_fail (cmd != NULL, NULL);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_combo (GtkComboBox *combo,
|
||||
const char **items,
|
||||
guint n_items)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkCellRenderer *cell;
|
||||
guint i;
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, "text", 0, (char*) NULL);
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
|
||||
for (i = 0; i < n_items; ++i)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, Q_(items[i]), -1);
|
||||
}
|
||||
|
||||
gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
|
||||
|
||||
g_object_unref (store);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
lua_factory_create_widget (G_GNUC_UNUSED MooCommandFactory *factory)
|
||||
{
|
||||
@ -303,9 +162,6 @@ lua_factory_create_widget (G_GNUC_UNUSED MooCommandFactory *factory)
|
||||
moo_text_view_set_font_from_string (xml->textview, "Monospace");
|
||||
moo_text_view_set_lang_by_id (xml->textview, "lua");
|
||||
|
||||
const char *version_names[] = { N_("1"), N_("2") };
|
||||
init_combo (xml->version, version_names, G_N_ELEMENTS (version_names));
|
||||
|
||||
return GTK_WIDGET (xml->LuaPage);
|
||||
}
|
||||
|
||||
@ -318,7 +174,6 @@ lua_factory_load_data (G_GNUC_UNUSED MooCommandFactory *factory,
|
||||
LuaPageXml *xml;
|
||||
GtkTextBuffer *buffer;
|
||||
const char *code;
|
||||
int version;
|
||||
|
||||
xml = lua_page_xml_get (page);
|
||||
g_return_if_fail (xml != NULL);
|
||||
@ -327,9 +182,6 @@ lua_factory_load_data (G_GNUC_UNUSED MooCommandFactory *factory,
|
||||
|
||||
code = moo_command_data_get_code (data);
|
||||
gtk_text_buffer_set_text (buffer, code ? code : "", -1);
|
||||
|
||||
parse_version (moo_command_data_get (data, KEY_VERSION), &version);
|
||||
gtk_combo_box_set_active (xml->version, version);
|
||||
}
|
||||
|
||||
|
||||
@ -342,8 +194,6 @@ lua_factory_save_data (G_GNUC_UNUSED MooCommandFactory *factory,
|
||||
const char *code;
|
||||
char *new_code;
|
||||
gboolean changed = FALSE;
|
||||
int version, old_version;
|
||||
const char *version_strings[] = { "1", "2" };
|
||||
|
||||
xml = lua_page_xml_get (page);
|
||||
g_return_val_if_fail (xml != NULL, FALSE);
|
||||
@ -357,15 +207,6 @@ lua_factory_save_data (G_GNUC_UNUSED MooCommandFactory *factory,
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
version = gtk_combo_box_get_active (xml->version);
|
||||
parse_version (moo_command_data_get (data, KEY_VERSION), &old_version);
|
||||
g_assert (0 <= version && version <= MOO_COMMAND_LUA2);
|
||||
if (version != old_version)
|
||||
{
|
||||
moo_command_data_set (data, KEY_VERSION, version_strings[version]);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
g_free (new_code);
|
||||
return changed;
|
||||
}
|
||||
@ -397,7 +238,7 @@ _moo_command_lua_class_init (MooCommandLuaClass *klass)
|
||||
g_type_class_add_private (klass, sizeof (MooCommandLuaPrivate));
|
||||
|
||||
factory = MOO_COMMAND_FACTORY (g_object_new (_moo_command_factory_lua_get_type (), (const char*) NULL));
|
||||
moo_command_factory_register ("lua", _("Lua script"), factory, (char**) data_keys, ".lua");
|
||||
moo_command_factory_register ("lua", _("Lua script"), factory, NULL, ".lua");
|
||||
g_object_unref (factory);
|
||||
}
|
||||
|
||||
@ -412,8 +253,7 @@ _moo_command_lua_init (MooCommandLua *cmd)
|
||||
|
||||
|
||||
static MooCommand *
|
||||
moo_command_lua_new (int version,
|
||||
const char *code,
|
||||
moo_command_lua_new (const char *code,
|
||||
MooCommandOptions options)
|
||||
{
|
||||
MooCommandLua *cmd;
|
||||
@ -422,7 +262,6 @@ moo_command_lua_new (int version,
|
||||
|
||||
cmd = MOO_COMMAND_LUA (g_object_new (MOO_TYPE_COMMAND_LUA, "options", options, (const char*) NULL));
|
||||
cmd->priv->code = g_strdup (code);
|
||||
cmd->priv->version = version;
|
||||
|
||||
return MOO_COMMAND (cmd);
|
||||
}
|
||||
|
@ -1,872 +0,0 @@
|
||||
/*
|
||||
* mooedit-lua-api1.c
|
||||
*
|
||||
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@sourceforge.net>
|
||||
*
|
||||
* This file is part of medit. medit is free software; you can
|
||||
* redistribute it and/or modify it under the terms of the
|
||||
* GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation; either version 2.1 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit-lua1.h"
|
||||
#include "mooedit/mooeditor.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/mootype-macros.h"
|
||||
#include <string.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* GObject
|
||||
*/
|
||||
|
||||
MOO_DEFINE_QUARK_STATIC (moo-lua-type, lua_type_quark)
|
||||
|
||||
#ifdef MOO_ENABLE_UNIT_TESTS
|
||||
static int object_count;
|
||||
#endif
|
||||
|
||||
static GObject **
|
||||
check_gobject (lua_State *L)
|
||||
{
|
||||
return (GObject**) luaL_checkudata (L, 1, "medit.GObject");
|
||||
}
|
||||
|
||||
static gpointer
|
||||
get_gobject (lua_State *L,
|
||||
int arg,
|
||||
GType type)
|
||||
{
|
||||
GObject **ptr = check_gobject (L);
|
||||
|
||||
if (!G_TYPE_CHECK_INSTANCE_TYPE (*ptr, type))
|
||||
luaL_error (L, "arg %d is not a %s", arg, g_type_name (type));
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#define GET_GOBJECT(L) G_OBJECT (get_gobject (L, 1, G_TYPE_OBJECT))
|
||||
|
||||
static int
|
||||
cfunc_GObject__gc (lua_State *L)
|
||||
{
|
||||
GObject **op = check_gobject (L);
|
||||
|
||||
if (*op)
|
||||
{
|
||||
g_object_unref (*op);
|
||||
*op = NULL;
|
||||
#ifdef MOO_ENABLE_UNIT_TESTS
|
||||
object_count -= 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cfunc_GObject__tostring (lua_State *L)
|
||||
{
|
||||
GObject *object;
|
||||
object = GET_GOBJECT (L);
|
||||
lua_pushfstring (L, "<%s at %p>",
|
||||
g_type_name (G_OBJECT_TYPE (object)),
|
||||
(gpointer) object);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
gvalue_from_lua (lua_State *L,
|
||||
int arg,
|
||||
GValue *val)
|
||||
{
|
||||
switch (G_TYPE_FUNDAMENTAL (val->g_type))
|
||||
{
|
||||
case G_TYPE_CHAR:
|
||||
g_value_set_char (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_UCHAR:
|
||||
g_value_set_uchar (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_BOOLEAN:
|
||||
g_value_set_boolean (val, lua_toboolean (L, arg));
|
||||
break;
|
||||
case G_TYPE_INT:
|
||||
g_value_set_int (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_UINT:
|
||||
g_value_set_uint (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_LONG:
|
||||
g_value_set_long (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_ULONG:
|
||||
g_value_set_ulong (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_INT64:
|
||||
g_value_set_int64 (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_UINT64:
|
||||
g_value_set_uint64 (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_ENUM:
|
||||
g_value_set_enum (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_FLAGS:
|
||||
g_value_set_flags (val, lua_tointeger (L, arg));
|
||||
break;
|
||||
case G_TYPE_FLOAT:
|
||||
g_value_set_float (val, lua_tonumber (L, arg));
|
||||
break;
|
||||
case G_TYPE_DOUBLE:
|
||||
g_value_set_double (val, lua_tonumber (L, arg));
|
||||
break;
|
||||
case G_TYPE_STRING:
|
||||
if (lua_isnil (L, arg))
|
||||
g_value_set_string (val, NULL);
|
||||
else
|
||||
g_value_set_string (val, lua_tostring (L, arg));
|
||||
break;
|
||||
case G_TYPE_OBJECT:
|
||||
if (lua_isnil (L, arg))
|
||||
g_value_set_object (val, NULL);
|
||||
else
|
||||
g_value_set_object (val, get_gobject (L, arg, G_TYPE_OBJECT));
|
||||
break;
|
||||
default:
|
||||
luaL_error (L, "unsupported value type '%s'",
|
||||
g_type_name (val->g_type));
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
gvalue_to_lua (lua_State *L,
|
||||
const GValue *val)
|
||||
{
|
||||
const char *s;
|
||||
GObject *o;
|
||||
|
||||
switch (G_TYPE_FUNDAMENTAL (val->g_type))
|
||||
{
|
||||
case G_TYPE_CHAR:
|
||||
lua_pushnumber (L, g_value_get_char (val));
|
||||
break;
|
||||
case G_TYPE_UCHAR:
|
||||
lua_pushnumber (L, g_value_get_uchar (val));
|
||||
break;
|
||||
case G_TYPE_BOOLEAN:
|
||||
lua_pushboolean (L, g_value_get_boolean (val));
|
||||
break;
|
||||
case G_TYPE_INT:
|
||||
lua_pushnumber (L, g_value_get_int (val));
|
||||
break;
|
||||
case G_TYPE_UINT:
|
||||
lua_pushnumber (L, g_value_get_uint (val));
|
||||
break;
|
||||
case G_TYPE_LONG:
|
||||
lua_pushnumber (L, g_value_get_long (val));
|
||||
break;
|
||||
case G_TYPE_ULONG:
|
||||
lua_pushnumber (L, g_value_get_ulong (val));
|
||||
break;
|
||||
case G_TYPE_INT64:
|
||||
lua_pushnumber (L, g_value_get_int64 (val));
|
||||
break;
|
||||
case G_TYPE_UINT64:
|
||||
lua_pushnumber (L, g_value_get_uint64 (val));
|
||||
break;
|
||||
case G_TYPE_ENUM:
|
||||
lua_pushnumber (L, g_value_get_enum (val));
|
||||
break;
|
||||
case G_TYPE_FLAGS:
|
||||
lua_pushnumber (L, g_value_get_flags (val));
|
||||
break;
|
||||
case G_TYPE_FLOAT:
|
||||
lua_pushnumber (L, g_value_get_float (val));
|
||||
break;
|
||||
case G_TYPE_DOUBLE:
|
||||
lua_pushnumber (L, g_value_get_double (val));
|
||||
break;
|
||||
case G_TYPE_STRING:
|
||||
if ((s = g_value_get_string (val)))
|
||||
lua_pushstring (L, s);
|
||||
else
|
||||
lua_pushnil (L);
|
||||
break;
|
||||
case G_TYPE_OBJECT:
|
||||
if ((o = G_OBJECT (g_value_get_object (val))))
|
||||
_moo_lua1_push_object (L, o);
|
||||
else
|
||||
lua_pushnil (L);
|
||||
break;
|
||||
default:
|
||||
luaL_error (L, "unsupported value type '%s'",
|
||||
g_type_name (val->g_type));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
cfunc_GObject_set_property (lua_State *L)
|
||||
{
|
||||
GObject *object;
|
||||
const char *propname;
|
||||
GParamSpec *pspec;
|
||||
GValue val = {0};
|
||||
|
||||
object = GET_GOBJECT (L);
|
||||
propname = luaL_checkstring (L, 2);
|
||||
luaL_checkany (L, 3);
|
||||
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), propname);
|
||||
if (!pspec)
|
||||
luaL_error (L, "no property named '%s' in object '<%s at %p>'",
|
||||
propname, g_type_name (G_OBJECT_TYPE (object)),
|
||||
(gpointer) object);
|
||||
|
||||
g_value_init (&val, pspec->value_type);
|
||||
gvalue_from_lua (L, 3, &val);
|
||||
g_object_set_property (object, propname, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cfunc_GObject_get_property (lua_State *L)
|
||||
{
|
||||
GObject *object;
|
||||
const char *propname;
|
||||
GParamSpec *pspec;
|
||||
GValue val = {0};
|
||||
int n_ret;
|
||||
|
||||
object = GET_GOBJECT (L);
|
||||
propname = luaL_checkstring (L, 2);
|
||||
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), propname);
|
||||
if (!pspec)
|
||||
luaL_error (L, "no property named '%s' in object '<%s at %p>'",
|
||||
propname, g_type_name (G_OBJECT_TYPE (object)),
|
||||
(gpointer) object);
|
||||
|
||||
g_value_init (&val, pspec->value_type);
|
||||
g_object_get_property (object, propname, &val);
|
||||
n_ret = gvalue_to_lua (L, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
return n_ret;
|
||||
}
|
||||
|
||||
static int
|
||||
cfunc_GObject__index (lua_State *L)
|
||||
{
|
||||
GObject *object;
|
||||
GType type;
|
||||
|
||||
object = GET_GOBJECT (L);
|
||||
luaL_checkany (L, 2);
|
||||
|
||||
for (type = G_OBJECT_TYPE (object); ; type = g_type_parent (type))
|
||||
{
|
||||
const luaL_Reg *meths;
|
||||
|
||||
if ((meths = (const luaL_Reg*) g_type_get_qdata (type, lua_type_quark ())))
|
||||
{
|
||||
char *tname;
|
||||
|
||||
tname = g_strdup_printf ("medit.%s", g_type_name (type));
|
||||
if (luaL_newmetatable (L, tname))
|
||||
luaL_register (L, NULL, meths);
|
||||
g_free (tname);
|
||||
|
||||
lua_pushvalue (L, 2);
|
||||
lua_rawget (L, -2);
|
||||
|
||||
if (!lua_isnil (L, -1))
|
||||
return 1;
|
||||
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
|
||||
if (type == G_TYPE_OBJECT)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg meths_GObject[] = {
|
||||
{ "__gc", cfunc_GObject__gc },
|
||||
{ "__tostring", cfunc_GObject__tostring },
|
||||
{ "__index", cfunc_GObject__index },
|
||||
{ "set_property", cfunc_GObject_set_property },
|
||||
{ "get_property", cfunc_GObject_get_property },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
#define METH_VOID_VOID(Typ,GET_OBJ,name,func) \
|
||||
static int \
|
||||
cfunc_##Typ##_##name (lua_State *L) \
|
||||
{ \
|
||||
func (GET_OBJ (L)); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define METH_LREG(Type,name) { #name, cfunc_##Type##_##name }
|
||||
#define METH(Type,name) static int cfunc_##Type##_##name (lua_State *L)
|
||||
|
||||
/********************************************************************/
|
||||
/* GtkWidget
|
||||
*/
|
||||
|
||||
#define GET_WIDGET(L) GTK_WIDGET (get_gobject (L, 1, GTK_TYPE_WIDGET))
|
||||
|
||||
// METH_VOID_VOID (GtkWidget, GET_WIDGET, hide, gtk_widget_hide)
|
||||
// METH_VOID_VOID (GtkWidget, GET_WIDGET, show, gtk_widget_show)
|
||||
|
||||
static const luaL_Reg meths_GtkWidget[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* GtkTextView
|
||||
*/
|
||||
|
||||
#define GET_TEXT_VIEW(L) GTK_TEXT_VIEW (get_gobject (L, 1, GTK_TYPE_TEXT_VIEW))
|
||||
#define GET_BUFFER(L) GtkTextBuffer *buffer = gtk_text_view_get_buffer (GET_TEXT_VIEW (L))
|
||||
|
||||
static void
|
||||
push_offset (lua_State *L,
|
||||
int c_offset)
|
||||
{
|
||||
lua_pushinteger (L, c_offset + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
push_iter_offset (lua_State *L,
|
||||
const GtkTextIter *iter)
|
||||
{
|
||||
push_offset (L, gtk_text_iter_get_offset (iter));
|
||||
}
|
||||
|
||||
static int
|
||||
check_offset (lua_State *L,
|
||||
int arg)
|
||||
{
|
||||
return luaL_checkinteger (L, arg) - 1;
|
||||
}
|
||||
|
||||
static int
|
||||
check_opt_offset (lua_State *L,
|
||||
int arg,
|
||||
int dflt)
|
||||
{
|
||||
return luaL_optinteger (L, arg, dflt + 1) - 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_cursor)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
push_iter_offset (L, &iter);
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_selection_bound)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
|
||||
gtk_text_buffer_get_selection_bound (buffer));
|
||||
push_iter_offset (L, &iter);
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_selection)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter start, end;
|
||||
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
|
||||
{
|
||||
push_iter_offset (L, &start);
|
||||
push_iter_offset (L, &end);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
METH (GtkTextView, set_cursor)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
int pos = check_offset (L, 2);
|
||||
GtkTextIter iter;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
gtk_text_buffer_place_cursor (buffer, &iter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, select_range)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
int sb_pos = check_offset (L, 2);
|
||||
int ins_pos = check_opt_offset (L, 3, -1);
|
||||
GtkTextIter sb, ins;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &sb, sb_pos);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &ins, ins_pos);
|
||||
gtk_text_buffer_select_range (buffer, &ins, &sb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, unselect)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
gtk_text_buffer_place_cursor (buffer, &iter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, scroll_to_cursor)
|
||||
{
|
||||
GtkTextView *textview = GET_TEXT_VIEW (L);
|
||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
|
||||
gtk_text_view_scroll_mark_onscreen (textview,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, delete_selection)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, delete_range)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
int start_pos = check_offset (L, 2);
|
||||
int end_pos = check_opt_offset (L, 3, -1);
|
||||
GtkTextIter start, end;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_pos);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos);
|
||||
gtk_text_buffer_delete (buffer, &start, &end);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_text)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
int start_pos = check_opt_offset (L, 2, 0);
|
||||
int end_pos = check_opt_offset (L, 3, -1);
|
||||
char *text;
|
||||
GtkTextIter start, end;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_pos);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos);
|
||||
text = gtk_text_buffer_get_slice (buffer, &start, &end, TRUE);
|
||||
lua_take_utf8string (L, text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_selected_text)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter start, end;
|
||||
|
||||
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
|
||||
{
|
||||
char *text = gtk_text_buffer_get_slice (buffer, &start, &end, TRUE);
|
||||
lua_take_utf8string (L, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil (L);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, replace_selection)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
const char *text = lua_check_utf8string (L, 2, NULL);
|
||||
GtkTextIter start, end;
|
||||
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
|
||||
gtk_text_buffer_delete (buffer, &start, &end);
|
||||
gtk_text_buffer_insert (buffer, &start, text, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, insert_text)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
const char *text;
|
||||
GtkTextIter iter;
|
||||
int pos;
|
||||
|
||||
text = lua_check_utf8string (L, 2, NULL);
|
||||
pos = check_opt_offset (L, 3, G_MININT);
|
||||
if (pos == G_MININT)
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
|
||||
else
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, text, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, set_text)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
size_t len;
|
||||
const char *text = lua_check_utf8string (L, 2, &len);
|
||||
gtk_text_buffer_set_text (buffer, text, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_char_count)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
lua_pushinteger (L, gtk_text_buffer_get_char_count (buffer));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_line_count)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
lua_pushinteger (L, gtk_text_buffer_get_line_count (buffer));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_pos_at_line)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter = {0};
|
||||
int line = check_offset (L, 2);
|
||||
gtk_text_buffer_get_iter_at_line (buffer, &iter, line);
|
||||
push_iter_offset (L, &iter);
|
||||
if (!gtk_text_iter_ends_line (&iter))
|
||||
gtk_text_iter_forward_to_line_end (&iter);
|
||||
push_iter_offset (L, &iter);
|
||||
gtk_text_iter_forward_line (&iter);
|
||||
push_iter_offset (L, &iter);
|
||||
return 3;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_line_at_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter = {0};
|
||||
int pos = check_offset (L, 2);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
push_offset (L, gtk_text_iter_get_line (&iter));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_line_at_cursor)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
push_offset (L, gtk_text_iter_get_line (&iter));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_line_text)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter start, end;
|
||||
char *text;
|
||||
int line = check_opt_offset (L, 2, G_MININT);
|
||||
if (line == G_MININT)
|
||||
{
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &start,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
gtk_text_iter_set_line_offset (&start, 0);
|
||||
}
|
||||
else
|
||||
gtk_text_buffer_get_iter_at_line (buffer, &start, line);
|
||||
end = start;
|
||||
if (!gtk_text_iter_ends_line (&end))
|
||||
gtk_text_iter_forward_to_line_end (&end);
|
||||
text = gtk_text_buffer_get_slice (buffer, &start, &end, TRUE);
|
||||
lua_pushstring (L, text);
|
||||
g_free (text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, next_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
int pos = check_offset (L, 2);
|
||||
gboolean ret;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
ret = gtk_text_iter_forward_cursor_position (&iter);
|
||||
push_iter_offset (L, &iter);
|
||||
lua_pushboolean (L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
METH (GtkTextView, prev_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
int pos = check_offset (L, 2);
|
||||
gboolean ret;
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
ret = gtk_text_iter_backward_cursor_position (&iter);
|
||||
push_iter_offset (L, &iter);
|
||||
lua_pushboolean (L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
METH (GtkTextView, get_end_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
push_offset (L, gtk_text_buffer_get_char_count (buffer));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, is_end_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
int pos = check_offset (L, 2);
|
||||
lua_pushboolean (L, pos == gtk_text_buffer_get_char_count (buffer));
|
||||
return 1;
|
||||
}
|
||||
|
||||
METH (GtkTextView, is_cursor_pos)
|
||||
{
|
||||
GET_BUFFER (L);
|
||||
GtkTextIter iter;
|
||||
int pos = check_offset (L, 2);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
|
||||
lua_pushboolean (L, gtk_text_iter_is_cursor_position (&iter));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg meths_GtkTextView[] = {
|
||||
METH_LREG (GtkTextView, get_cursor),
|
||||
METH_LREG (GtkTextView, get_selection_bound),
|
||||
METH_LREG (GtkTextView, get_selection),
|
||||
METH_LREG (GtkTextView, set_cursor),
|
||||
METH_LREG (GtkTextView, select_range),
|
||||
METH_LREG (GtkTextView, unselect),
|
||||
METH_LREG (GtkTextView, scroll_to_cursor),
|
||||
|
||||
METH_LREG (GtkTextView, next_pos),
|
||||
METH_LREG (GtkTextView, prev_pos),
|
||||
METH_LREG (GtkTextView, is_cursor_pos),
|
||||
METH_LREG (GtkTextView, is_end_pos),
|
||||
METH_LREG (GtkTextView, get_end_pos),
|
||||
|
||||
METH_LREG (GtkTextView, get_char_count),
|
||||
METH_LREG (GtkTextView, get_line_count),
|
||||
METH_LREG (GtkTextView, get_pos_at_line),
|
||||
METH_LREG (GtkTextView, get_line_at_pos),
|
||||
METH_LREG (GtkTextView, get_line_at_cursor),
|
||||
METH_LREG (GtkTextView, get_line_text),
|
||||
|
||||
METH_LREG (GtkTextView, delete_selection),
|
||||
METH_LREG (GtkTextView, delete_range),
|
||||
|
||||
METH_LREG (GtkTextView, get_text),
|
||||
METH_LREG (GtkTextView, get_selected_text),
|
||||
|
||||
METH_LREG (GtkTextView, replace_selection),
|
||||
METH_LREG (GtkTextView, insert_text),
|
||||
METH_LREG (GtkTextView, set_text),
|
||||
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* MooTextView
|
||||
*/
|
||||
|
||||
#define GET_MOO_TEXT_VIEW(L) MOO_TEXT_VIEW (get_gobject (L, 1, MOO_TYPE_TEXT_VIEW))
|
||||
|
||||
static const luaL_Reg meths_MooTextView[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* MooEdit
|
||||
*/
|
||||
|
||||
#define GET_MOO_EDIT(L) MOO_EDIT (get_gobject (L, 1, MOO_TYPE_EDIT))
|
||||
|
||||
static const luaL_Reg meths_MooEdit[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* MooEditor
|
||||
*/
|
||||
|
||||
#define GET_MOO_EDITOR(L) MOO_EDITOR (get_gobject (L, 1, MOO_TYPE_EDITOR))
|
||||
|
||||
static const luaL_Reg meths_MooEditor[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* External API
|
||||
*/
|
||||
|
||||
static void
|
||||
register_type (GType type,
|
||||
const luaL_Reg *meths)
|
||||
{
|
||||
if (meths && meths[0].name)
|
||||
g_type_set_qdata (type, lua_type_quark (), (gpointer) meths);
|
||||
}
|
||||
|
||||
static void
|
||||
init_types (void)
|
||||
{
|
||||
static gboolean been_here;
|
||||
|
||||
if (been_here)
|
||||
return;
|
||||
|
||||
been_here = TRUE;
|
||||
|
||||
register_type (G_TYPE_OBJECT, meths_GObject);
|
||||
register_type (GTK_TYPE_WIDGET, meths_GtkWidget);
|
||||
register_type (GTK_TYPE_TEXT_VIEW, meths_GtkTextView);
|
||||
register_type (MOO_TYPE_TEXT_VIEW, meths_MooTextView);
|
||||
register_type (MOO_TYPE_EDIT, meths_MooEdit);
|
||||
register_type (MOO_TYPE_EDITOR, meths_MooEditor);
|
||||
}
|
||||
|
||||
void
|
||||
_moo_lua1_push_object (lua_State *L,
|
||||
GObject *object)
|
||||
{
|
||||
GObject **object_ptr;
|
||||
|
||||
init_types ();
|
||||
|
||||
object_ptr = (GObject**) lua_newuserdata (L, sizeof (gpointer));
|
||||
MOO_OBJECT_REF_SINK (object);
|
||||
*object_ptr = object;
|
||||
#ifdef MOO_ENABLE_UNIT_TESTS
|
||||
object_count += 1;
|
||||
#endif
|
||||
|
||||
if (luaL_newmetatable (L, "medit.GObject"))
|
||||
luaL_register (L, NULL, meths_GObject);
|
||||
|
||||
lua_setmetatable (L, -2);
|
||||
}
|
||||
|
||||
#ifdef MOO_ENABLE_UNIT_TESTS
|
||||
|
||||
#include "moolua/moo-tests-lua.h"
|
||||
#include <mooedit/mooedit-tests.h>
|
||||
|
||||
static int
|
||||
cfunc_present_widget (lua_State *L)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = GET_WIDGET (L);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_size_request (window, 300, 300);
|
||||
gtk_container_add (GTK_CONTAINER (window), widget);
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cfunc_new_text_view (lua_State *L)
|
||||
{
|
||||
GtkWidget *textview = gtk_text_view_new ();
|
||||
_moo_lua1_push_object (L, G_OBJECT (textview));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_reg mooedittestlib[] = {
|
||||
{ "new_text_view", cfunc_new_text_view },
|
||||
{ "present", cfunc_present_widget },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
add_test_api (lua_State *L)
|
||||
{
|
||||
luaL_register (L, "mooedittest", mooedittestlib);
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
test_gtk_text_view (void)
|
||||
{
|
||||
TEST_ASSERT (object_count == 0);
|
||||
moo_test_run_lua_file ("textview.lua", add_test_api, NULL);
|
||||
TEST_ASSERT (object_count == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_gobject (void)
|
||||
{
|
||||
TEST_ASSERT (object_count == 0);
|
||||
moo_test_run_lua_file ("gobject.lua", add_test_api, NULL);
|
||||
TEST_ASSERT (object_count == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_moo_edit (void)
|
||||
{
|
||||
TEST_ASSERT (object_count == 0);
|
||||
moo_test_run_lua_file ("mooedit.lua", add_test_api, NULL);
|
||||
TEST_ASSERT (object_count == 0);
|
||||
}
|
||||
|
||||
void
|
||||
moo_test_mooedit_lua_api (void)
|
||||
{
|
||||
MooTestSuite *suite;
|
||||
|
||||
suite = moo_test_suite_new ("mooedit/mooedit-lua-api.c", NULL, NULL, NULL);
|
||||
|
||||
moo_test_suite_add_test (suite, "test of GObject",
|
||||
(MooTestFunc) test_gobject, NULL);
|
||||
moo_test_suite_add_test (suite, "test of GtkTextView",
|
||||
(MooTestFunc) test_gtk_text_view, NULL);
|
||||
moo_test_suite_add_test (suite, "test of the editor",
|
||||
(MooTestFunc) test_moo_edit, NULL);
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* mooedit-lua1.h
|
||||
*
|
||||
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@sourceforge.net>
|
||||
*
|
||||
* This file is part of medit. medit is free software; you can
|
||||
* redistribute it and/or modify it under the terms of the
|
||||
* GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation; either version 2.1 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MOO_EDIT_LUA1_H
|
||||
#define MOO_EDIT_LUA1_H
|
||||
|
||||
#include <mooedit/mooedit.h>
|
||||
#include <moolua/moolua.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
void _moo_edit_lua1_add_api (lua_State *L);
|
||||
|
||||
void _moo_edit_lua1_set_doc (lua_State *L,
|
||||
GtkTextView *doc);
|
||||
void _moo_edit_lua1_cleanup (lua_State *L);
|
||||
|
||||
void _moo_lua1_push_object (lua_State *L,
|
||||
GObject *object);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* MOO_EDIT_LUA1_H */
|
@ -1077,7 +1077,7 @@ _moo_command_filter_regex_load (void)
|
||||
{
|
||||
char **files, **p;
|
||||
|
||||
files = _moo_strv_reverse (moo_get_data_files (FILTERS_FILE, MOO_DATA_SHARE, NULL));
|
||||
files = _moo_strv_reverse (moo_get_data_files (FILTERS_FILE));
|
||||
|
||||
for (p = files; p && *p; ++p)
|
||||
parse_filter_file (*p);
|
||||
|
@ -185,11 +185,13 @@ find_user_tools_file (int type,
|
||||
*sys_files_p = NULL;
|
||||
*user_file_p = NULL;
|
||||
|
||||
files = _moo_strv_reverse (moo_get_data_files (FILENAMES[type], MOO_DATA_SHARE, &n_files));
|
||||
files = _moo_strv_reverse (moo_get_data_files (FILENAMES[type]));
|
||||
|
||||
if (!n_files)
|
||||
if (!files || !*files)
|
||||
return;
|
||||
|
||||
n_files = g_strv_length (files);
|
||||
|
||||
if (g_file_test (files[n_files - 1], G_FILE_TEST_EXISTS))
|
||||
*user_file_p = g_strdup (files[n_files - 1]);
|
||||
|
||||
@ -445,14 +447,13 @@ init_tools_environment (void)
|
||||
if (!done)
|
||||
{
|
||||
char **script_dirs;
|
||||
guint n_script_dirs;
|
||||
const char *old_path;
|
||||
char *new_path, *my_path;
|
||||
|
||||
done = TRUE;
|
||||
|
||||
script_dirs = moo_get_data_subdirs ("scripts", MOO_DATA_SHARE, &n_script_dirs);
|
||||
g_return_if_fail (n_script_dirs != 0);
|
||||
script_dirs = moo_get_data_subdirs ("scripts");
|
||||
g_return_if_fail (script_dirs != NULL);
|
||||
|
||||
old_path = g_getenv ("PATH");
|
||||
g_return_if_fail (old_path != NULL);
|
||||
@ -659,10 +660,8 @@ load_directories (MooUserToolType type,
|
||||
GHashTable *ids)
|
||||
{
|
||||
char **dirs, **p;
|
||||
guint n_dirs;
|
||||
|
||||
dirs = moo_get_data_subdirs (type == MOO_USER_TOOL_MENU ? "tools" : "tools-context",
|
||||
MOO_DATA_SHARE, &n_dirs);
|
||||
dirs = moo_get_data_subdirs (type == MOO_USER_TOOL_MENU ? "tools" : "tools-context");
|
||||
dirs = _moo_strv_reverse (dirs);
|
||||
|
||||
for (p = dirs; p && *p; ++p)
|
||||
|
Loading…
x
Reference in New Issue
Block a user