Gonna have python plugins

master
Yevgen Muntyan 2005-11-05 15:32:04 +00:00
parent df9801f498
commit e7680a218d
9 changed files with 145 additions and 222 deletions

View File

@ -46,6 +46,8 @@
/* moo-pygtk.c */
void initmoo (void);
/* mooplugin-python.c */
gboolean _moo_python_plugin_init (void);
static MooApp *moo_app_instance = NULL;
@ -895,6 +897,7 @@ static void start_python (G_GNUC_UNUSED MooApp *app)
app->priv->argv);
#ifdef MOO_USE_PYGTK
initmoo ();
_moo_python_plugin_init ();
#endif
}
else

View File

@ -22,6 +22,7 @@
description__,author__,version__) \
\
static MooPluginParams plugin_name__##_plugin_params = { \
TRUE, \
TRUE \
}; \
\

View File

@ -863,6 +863,14 @@ moo_plugin_init_builtin (void)
}
static gboolean
moo_plugin_visible (MooPlugin *plugin)
{
g_return_val_if_fail (MOO_IS_PLUGIN (plugin), FALSE);
return plugin->info->params->visible ? TRUE : FALSE;
}
/***************************************************************************/
/* Preferences dialog
*/
@ -1003,12 +1011,16 @@ prefs_init (MooPrefsDialog *dialog,
{
GtkTreeIter iter;
MooPlugin *plugin = l->data;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_ENABLED, moo_plugin_enabled (plugin),
COLUMN_PLUGIN_ID, moo_plugin_id (plugin),
COLUMN_PLUGIN_NAME, moo_plugin_name (plugin),
-1);
if (moo_plugin_visible (plugin))
{
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_ENABLED, moo_plugin_enabled (plugin),
COLUMN_PLUGIN_ID, moo_plugin_id (plugin),
COLUMN_PLUGIN_NAME, moo_plugin_name (plugin),
-1);
}
}
selection_changed (gtk_tree_view_get_selection (treeview), page);

View File

@ -20,7 +20,7 @@
G_BEGIN_DECLS
#define MOO_PLUGIN_PREFS_ROOT "Plugins"
#define MOO_PLUGIN_CURRENT_VERSION 13
#define MOO_PLUGIN_CURRENT_VERSION 14
#define MOO_PLUGIN_DIR_BASENAME "plugins"
@ -83,6 +83,7 @@ typedef void (*MooDocPluginDestroyFunc) (MooDocPlugin *doc_plugin);
struct _MooPluginParams
{
gboolean enabled;
gboolean visible;
};
struct _MooPluginPrefsParams

View File

@ -98,7 +98,7 @@ $(moopython)/mooapp-pygtk.c: $(moopython)/mooapp-pygtk.defs $(moopython)/mooapp-
$(moopython_srcdir)/mooapp-pygtk.defs > $(moopython)/mooapp-pygtk.c
if MOO_USE_PYTHON
if MOO_USE_PYGTK
moo_sources += $(moopython_sources)
moo_built_sources += $(moopython_bulit_sources)
moo_nodist_sources += $(nodist_moopython_sources)
@ -106,3 +106,12 @@ moo_cleanfiles += $(moopython_cleanfiles)
endif
moo_extra_dist += $(moopython_extra_dist)
###########################################################################
# Python plugin
if MOO_USE_PYGTK
moo_sources += $(moopython)/mooplugin-python.c
endif
moo_extra_dist += $(moopython)/mooplugin-python.c

View File

@ -28,13 +28,6 @@
(gtype-id "MOO_TYPE_LANG_MGR")
)
(define-object Plugin
(in-module "Moo")
(parent "GObject")
(c-name "MooPlugin")
(gtype-id "MOO_TYPE_PLUGIN")
)
(define-object TextBuffer
(in-module "Moo")
(parent "GtkTextBuffer")
@ -1291,211 +1284,6 @@
;; From ../mooedit/mooplugin.h
(define-function moo_plugin_get_type
(c-name "moo_plugin_get_type")
(return-type "GType")
)
(define-function moo_window_plugin_get_type
(c-name "moo_window_plugin_get_type")
(return-type "GType")
)
(define-function moo_plugin_register
(c-name "moo_plugin_register")
(return-type "gboolean")
(parameters
'("GType" "type")
)
)
(define-method initialized
(of-object "MooPlugin")
(c-name "moo_plugin_initialized")
(return-type "gboolean")
)
(define-method enabled
(of-object "MooPlugin")
(c-name "moo_plugin_enabled")
(return-type "gboolean")
)
(define-method set_enabled
(of-object "MooPlugin")
(c-name "moo_plugin_set_enabled")
(return-type "gboolean")
(parameters
'("gboolean" "enabled")
)
)
(define-function moo_plugin_get
(c-name "moo_plugin_get")
(return-type "MooPlugin*")
(parameters
'("GType" "type")
)
)
(define-function moo_plugin_registered
(c-name "moo_plugin_registered")
(return-type "gboolean")
(parameters
'("GType" "type")
)
)
(define-function moo_plugin_lookup
(c-name "moo_plugin_lookup")
(return-type "gpointer")
(parameters
'("const-char*" "plugin_id")
)
)
(define-function moo_list_plugins
(c-name "moo_list_plugins")
(return-type "GSList*")
)
(define-method id
(of-object "MooPlugin")
(c-name "moo_plugin_id")
(return-type "const-char*")
)
(define-method name
(of-object "MooPlugin")
(c-name "moo_plugin_name")
(return-type "const-char*")
)
(define-method description
(of-object "MooPlugin")
(c-name "moo_plugin_description")
(return-type "const-char*")
)
(define-method author
(of-object "MooPlugin")
(c-name "moo_plugin_author")
(return-type "const-char*")
)
(define-method version
(of-object "MooPlugin")
(c-name "moo_plugin_version")
(return-type "const-char*")
)
(define-function moo_window_plugin_lookup
(c-name "moo_window_plugin_lookup")
(return-type "gpointer")
(parameters
'("const-char*" "plugin_id")
'("MooEditWindow*" "window")
)
)
(define-function moo_plugin_read_dir
(c-name "moo_plugin_read_dir")
(return-type "none")
(parameters
'("const-char*" "dir")
)
)
(define-function moo_plugin_init_builtin
(c-name "moo_plugin_init_builtin")
(return-type "none")
)
;; From ../mooedit/mootextbuffer.h
(define-function moo_text_buffer_get_type
(c-name "moo_text_buffer_get_type")
(return-type "GType")
)
(define-function moo_text_buffer_new
(c-name "moo_text_buffer_new")
(is-constructor-of "MooTextBuffer")
(return-type "GtkTextBuffer*")
(parameters
'("GtkTextTagTable*" "table")
)
)
(define-method set_lang
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_set_lang")
(return-type "none")
(parameters
'("MooLang*" "lang")
)
)
(define-method get_lang
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_get_lang")
(return-type "MooLang*")
)
(define-method set_bracket_match_style
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_set_bracket_match_style")
(return-type "none")
(parameters
'("const-MooTextStyle*" "style")
)
)
(define-method set_bracket_mismatch_style
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_set_bracket_mismatch_style")
(return-type "none")
(parameters
'("const-MooTextStyle*" "style")
)
)
(define-method set_brackets
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_set_brackets")
(return-type "none")
(parameters
'("const-char*" "brackets")
)
)
(define-method set_check_brackets
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_set_check_brackets")
(return-type "none")
(parameters
'("gboolean" "check")
)
)
(define-method has_text
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_has_text")
(return-type "gboolean")
)
(define-method has_selection
(of-object "MooTextBuffer")
(c-name "moo_text_buffer_has_selection")
(return-type "gboolean")
)
;; From ../mooedit/mootextiter.h
(define-function moo_text_iter_find_matching_bracket

View File

@ -3,7 +3,10 @@ headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include "moo.h"
#include "mooedit/mooeditor.h"
#include "mooedit/mooeditsearch.h"
#include "mooedit/mootextbuffer.h"
#include "mooedit/moocmdview.h"
void moo_edit_add_constants (PyObject *module, const gchar *strip_prefix);
void moo_edit_register_classes (PyObject *d);

View File

@ -0,0 +1,92 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
*
* moofind.c
*
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef MOO_VERSION
#define MOO_VERSION NULL
#endif
#include "mooedit/mooplugin-macro.h"
#define PYTHON_PLUGIN_ID "python"
gboolean _moo_python_plugin_init (void);
typedef struct {
MooPlugin parent;
} PythonPlugin;
static gboolean
python_plugin_init (G_GNUC_UNUSED PythonPlugin *plugin)
{
return TRUE;
}
static void
python_plugin_deinit (G_GNUC_UNUSED PythonPlugin *plugin)
{
}
static void
python_plugin_attach_win (G_GNUC_UNUSED PythonPlugin *plugin,
G_GNUC_UNUSED MooEditWindow *window)
{
}
static void
python_plugin_detach_win (G_GNUC_UNUSED PythonPlugin *plugin,
G_GNUC_UNUSED MooEditWindow *window)
{
}
static void
python_plugin_attach_doc (G_GNUC_UNUSED PythonPlugin *plugin,
G_GNUC_UNUSED MooEdit *doc,
G_GNUC_UNUSED MooEditWindow *window)
{
}
static void
python_plugin_detach_doc (G_GNUC_UNUSED PythonPlugin *plugin,
G_GNUC_UNUSED MooEdit *doc,
G_GNUC_UNUSED MooEditWindow *window)
{
}
MOO_PLUGIN_DEFINE_INFO (python, PYTHON_PLUGIN_ID,
"Python", "A snake",
"Yevgen Muntyan <muntyan@tamu.edu>",
MOO_VERSION);
MOO_PLUGIN_DEFINE_FULL (Python, python,
python_plugin_init, python_plugin_deinit,
python_plugin_attach_win, python_plugin_detach_win,
python_plugin_attach_doc, python_plugin_detach_doc,
NULL, 0, 0);
gboolean
_moo_python_plugin_init (void)
{
python_plugin_params.visible = FALSE;
return moo_plugin_register (python_plugin_get_type ());
}

View File

@ -3,7 +3,21 @@ headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include "moo.h"
#include "mooutils/moobigpaned.h"
#include "mooutils/moocombo.h"
#include "mooutils/moofiltermgr.h"
#include "mooutils/moofilewatch.h"
#include "mooutils/moohistorylist.h"
#include "mooutils/moomenumgr.h"
#include "mooutils/moouixml.h"
#include "mooutils/moodialogs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/moowindow.h"
#include "mooutils/mooprefsdialog.h"
#include "mooutils/moohistoryentry.h"
#include "mooutils/mooprefs.h"
#include "mooutils/moonotebook.h"
#include "mooutils/mooentry.h"
void moo_utils_register_classes (PyObject *dict);