From 8bb82a6b3881eb35b869ce33fd668696573fb2a2 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Mon, 18 Jun 2007 00:17:05 -0500 Subject: [PATCH] Do not subclass GtkSourceLanguage, use it directly --- moo/mooedit/gtksourceview/upstream/mangle.sh | 8 +- moo/mooedit/mooeditprefs.c | 2 +- moo/mooedit/mooeditprefspage.c | 4 +- moo/mooedit/moolang.c | 49 +------ moo/mooedit/moolangmgr.c | 4 +- moo/mooedit/moolangmgr.h | 4 +- moo/mooedit/moooutputfilterregex.c | 2 +- moo/mooedit/mootextview.c | 2 +- moo/moopython/pygtk/mooedit-pygtk.defs | 140 ++++++++----------- 9 files changed, 80 insertions(+), 135 deletions(-) diff --git a/moo/mooedit/gtksourceview/upstream/mangle.sh b/moo/mooedit/gtksourceview/upstream/mangle.sh index 18ab9e5a..d1854121 100644 --- a/moo/mooedit/gtksourceview/upstream/mangle.sh +++ b/moo/mooedit/gtksourceview/upstream/mangle.sh @@ -12,10 +12,10 @@ custom_cmd= echo "/* This file is autogenerated from $base */" case "$base" in - gtksourcelanguage.c) - echo '#include "mooedit/moolang.h"' - custom_cmd="-e s/g_object_new.*GTK_TYPE_SOURCE_LANGUAGE/g_object_new(MOO_TYPE_LANG/g" - ;; +# gtksourcelanguage.c) +# echo '#include "mooedit/moolang.h"' +# custom_cmd="-e s/g_object_new.*GTK_TYPE_SOURCE_LANGUAGE/g_object_new(MOO_TYPE_LANG/g" +# ;; gtksourcelanguage-parser-1.c) echo '#include "mooutils/moocompat.h"' ;; diff --git a/moo/mooedit/mooeditprefs.c b/moo/mooedit/mooeditprefs.c index 278b2a5c..91b6338e 100644 --- a/moo/mooedit/mooeditprefs.c +++ b/moo/mooedit/mooeditprefs.c @@ -195,7 +195,7 @@ _moo_edit_apply_prefs (MooEdit *edit) get_string (MOO_EDIT_PREFS_LINE_NUMBERS_FONT)); mgr = moo_editor_get_lang_mgr (edit->priv->editor); - scheme = _moo_lang_mgr_get_active_scheme (mgr); + scheme = moo_lang_mgr_get_active_scheme (mgr); if (scheme) moo_text_view_set_style_scheme (MOO_TEXT_VIEW (edit), scheme); diff --git a/moo/mooedit/mooeditprefspage.c b/moo/mooedit/mooeditprefspage.c index c58d25da..f716073f 100644 --- a/moo/mooedit/mooeditprefspage.c +++ b/moo/mooedit/mooeditprefspage.c @@ -118,7 +118,7 @@ scheme_combo_init (GtkComboBox *combo, GtkCellRenderer *cell; mgr = moo_editor_get_lang_mgr (editor); - list = _moo_lang_mgr_list_schemes (mgr); + list = moo_lang_mgr_list_schemes (mgr); g_return_if_fail (list != NULL); store = gtk_list_store_new (1, MOO_TYPE_TEXT_STYLE_SCHEME); @@ -171,7 +171,7 @@ prefs_page_init (MooPrefsDialogPage *page) editor = page_get_editor (page); mgr = moo_editor_get_lang_mgr (editor); - scheme = _moo_lang_mgr_get_active_scheme (mgr); + scheme = moo_lang_mgr_get_active_scheme (mgr); g_return_if_fail (scheme != NULL); scheme_combo = moo_glade_xml_get_widget (page->xml, "color_scheme_combo"); diff --git a/moo/mooedit/moolang.c b/moo/mooedit/moolang.c index d434f4e2..43caa2dc 100644 --- a/moo/mooedit/moolang.c +++ b/moo/mooedit/moolang.c @@ -25,52 +25,15 @@ #endif -struct _MooLangPrivate { - char *version; /* not NULL; "" by default */ - char *author; /* not NULL; "" by default */ - - char *brackets; - char *line_comment; - char *block_comment_start; - char *block_comment_end; - - guint hidden : 1; -}; - - -G_DEFINE_TYPE (MooLang, moo_lang, GTK_TYPE_SOURCE_LANGUAGE) - - -static void -moo_lang_init (MooLang *lang) +GType +moo_lang_get_type (void) { - lang->priv = G_TYPE_INSTANCE_GET_PRIVATE (lang, MOO_TYPE_LANG, MooLangPrivate); - lang->priv->version = g_strdup (""); - lang->priv->author = g_strdup (""); -} + static GType type; + if (G_UNLIKELY (!type)) + type = GTK_TYPE_SOURCE_LANGUAGE; -static void -moo_lang_finalize (GObject *object) -{ - MooLang *lang = MOO_LANG (object); - - g_free (lang->priv->version); - g_free (lang->priv->author); - g_free (lang->priv->brackets); - g_free (lang->priv->line_comment); - g_free (lang->priv->block_comment_start); - g_free (lang->priv->block_comment_end); - - G_OBJECT_CLASS (moo_lang_parent_class)->finalize (object); -} - - -static void -moo_lang_class_init (MooLangClass *klass) -{ - G_OBJECT_CLASS (klass)->finalize = moo_lang_finalize; - g_type_class_add_private (klass, sizeof (MooLangPrivate)); + return type; } diff --git a/moo/mooedit/moolangmgr.c b/moo/mooedit/moolangmgr.c index eb27e309..58d0b9b3 100644 --- a/moo/mooedit/moolangmgr.c +++ b/moo/mooedit/moolangmgr.c @@ -671,7 +671,7 @@ load_config (MooLangMgr *mgr) MooTextStyleScheme * -_moo_lang_mgr_get_active_scheme (MooLangMgr *mgr) +moo_lang_mgr_get_active_scheme (MooLangMgr *mgr) { g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL); @@ -713,7 +713,7 @@ prepend_scheme (G_GNUC_UNUSED const char *name, } GSList * -_moo_lang_mgr_list_schemes (MooLangMgr *mgr) +moo_lang_mgr_list_schemes (MooLangMgr *mgr) { GSList *list = NULL; diff --git a/moo/mooedit/moolangmgr.h b/moo/mooedit/moolangmgr.h index f0239249..d8d75e5b 100644 --- a/moo/mooedit/moolangmgr.h +++ b/moo/mooedit/moolangmgr.h @@ -45,11 +45,11 @@ GSList *moo_lang_mgr_get_sections (MooLangMgr *mgr); MooLang *_moo_lang_mgr_find_lang (MooLangMgr *mgr, const char *name); -MooTextStyleScheme *_moo_lang_mgr_get_active_scheme (MooLangMgr *mgr); +MooTextStyleScheme *moo_lang_mgr_get_active_scheme (MooLangMgr *mgr); void _moo_lang_mgr_set_active_scheme (MooLangMgr *mgr, const char *scheme_name); /* list must be freed, content unref'ed */ -GSList *_moo_lang_mgr_list_schemes (MooLangMgr *mgr); +GSList *moo_lang_mgr_list_schemes (MooLangMgr *mgr); /* list must be freed together with content */ GSList *_moo_lang_mgr_get_globs (MooLangMgr *mgr, diff --git a/moo/mooedit/moooutputfilterregex.c b/moo/mooedit/moooutputfilterregex.c index b5345abf..6be574a1 100644 --- a/moo/mooedit/moooutputfilterregex.c +++ b/moo/mooedit/moooutputfilterregex.c @@ -370,7 +370,7 @@ get_tag (MooLineView *view, tag = moo_line_view_create_tag (view, name, NULL); lang_mgr = moo_editor_get_lang_mgr (moo_editor_instance ()); - scheme = _moo_lang_mgr_get_active_scheme (lang_mgr); + scheme = moo_lang_mgr_get_active_scheme (lang_mgr); if (scheme) style = _moo_text_style_scheme_lookup_style (scheme, name); diff --git a/moo/mooedit/mootextview.c b/moo/mooedit/mootextview.c index d99a3276..eed4238b 100644 --- a/moo/mooedit/mootextview.c +++ b/moo/mooedit/mootextview.c @@ -2473,7 +2473,7 @@ moo_text_view_set_lang_by_id (MooTextView *view, mgr = moo_editor_get_lang_mgr (editor); lang = moo_lang_mgr_get_lang (mgr, lang_id); - scheme = _moo_lang_mgr_get_active_scheme (mgr); + scheme = moo_lang_mgr_get_active_scheme (mgr); moo_text_view_set_style_scheme (view, scheme); moo_text_view_set_lang (view, lang); diff --git a/moo/moopython/pygtk/mooedit-pygtk.defs b/moo/moopython/pygtk/mooedit-pygtk.defs index 4994029b..d3b82ad1 100644 --- a/moo/moopython/pygtk/mooedit-pygtk.defs +++ b/moo/moopython/pygtk/mooedit-pygtk.defs @@ -112,15 +112,12 @@ ; ) ; ) -;; (define-object TextStyleScheme -;; (in-module "Moo") -;; (parent "GObject") -;; (c-name "MooTextStyleScheme") -;; (gtype-id "MOO_TYPE_TEXT_STYLE_SCHEME") -;; (fields -;; '("char*" "name") -;; ) -;; ) +(define-object TextStyleScheme + (in-module "Moo") + (parent "GObject") + (c-name "MooTextStyleScheme") + (gtype-id "MOO_TYPE_TEXT_STYLE_SCHEME") +) (define-boxed TextStyle @@ -722,17 +719,17 @@ ) ) -; (define-method list_schemes -; (of-object "MooLangMgr") -; (c-name "moo_lang_mgr_list_schemes") -; (return-type "GSList*") -; ) +(define-method list_schemes + (of-object "MooLangMgr") + (c-name "moo_lang_mgr_list_schemes") + (return-type "object-slist") +) -; (define-method get_active_scheme -; (of-object "MooLangMgr") -; (c-name "moo_lang_mgr_get_active_scheme") -; (return-type "MooTextStyleScheme*") -; ) +(define-method get_active_scheme + (of-object "MooLangMgr") + (c-name "moo_lang_mgr_get_active_scheme") + (return-type "MooTextStyleScheme*") +) @@ -888,15 +885,6 @@ (return-type "gboolean") ) -; (define-method apply_scheme -; (of-object "MooTextBuffer") -; (c-name "moo_text_buffer_apply_scheme") -; (return-type "none") -; (parameters -; '("MooTextStyleScheme*" "scheme" (null-ok)) -; ) -; ) - (define-method add_line_mark (of-object "MooTextBuffer") (c-name "moo_text_buffer_add_line_mark") @@ -995,7 +983,7 @@ ) -;; From mootextstylescheme.h +; From mootextstylescheme.h ; (define-function moo_text_style_scheme_new_empty ; (c-name "moo_text_style_scheme_new_empty") @@ -1005,55 +993,49 @@ ; '("MooTextStyleScheme*" "base") ; ) ; ) - +; ; (define-function moo_text_style_scheme_new_default ; (c-name "moo_text_style_scheme_new_default") ; (return-type "MooTextStyleScheme*") ; ) -(define-method copy - (of-object "MooTextStyleScheme") - (c-name "moo_text_style_scheme_copy") - (return-type "MooTextStyleScheme*") -) +; (define-method copy +; (of-object "MooTextStyleScheme") +; (c-name "moo_text_style_scheme_copy") +; (return-type "MooTextStyleScheme*") +; ) -(define-method list_default - (of-object "MooTextStyleScheme") - (c-name "moo_text_style_scheme_list_default") - (return-type "GSList*") -) +; (define-method compose +; (of-object "MooTextStyleScheme") +; (c-name "moo_text_style_scheme_compose") +; (return-type "none") +; (parameters +; '("const-char*" "language_name" (null-ok)) +; '("const-char*" "style_name") +; '("const-MooTextStyle*" "style") +; ) +; ) -(define-method compose - (of-object "MooTextStyleScheme") - (c-name "moo_text_style_scheme_compose") - (return-type "none") - (parameters - '("const-char*" "language_name" (null-ok)) - '("const-char*" "style_name") - '("const-MooTextStyle*" "style") - ) -) - -(define-method set - (of-object "MooTextStyleScheme") - (c-name "moo_text_style_scheme_set") - (return-type "none") - (parameters - '("const-char*" "language_name" (null-ok)) - '("const-char*" "style_name") - '("const-MooTextStyle*" "style") - ) -) - -(define-method get - (of-object "MooTextStyleScheme") - (c-name "moo_text_style_scheme_get") - (return-type "const-MooTextStyle*") - (parameters - '("const-char*" "language_name" (null-ok)) - '("const-char*" "style_name") - ) -) +; (define-method set +; (of-object "MooTextStyleScheme") +; (c-name "moo_text_style_scheme_set") +; (return-type "none") +; (parameters +; '("const-char*" "language_name" (null-ok)) +; '("const-char*" "style_name") +; '("const-MooTextStyle*" "style") +; ) +; ) +; +; (define-method get +; (of-object "MooTextStyleScheme") +; (c-name "moo_text_style_scheme_get") +; (return-type "const-MooTextStyle*") +; (parameters +; '("const-char*" "language_name" (null-ok)) +; '("const-char*" "style_name") +; ) +; ) @@ -1204,14 +1186,14 @@ ) ) -; (define-method set_scheme -; (of-object "MooTextView") -; (c-name "moo_text_view_set_scheme") -; (return-type "none") -; (parameters -; '("MooTextStyleScheme*" "scheme") -; ) -; ) +(define-method set_style_scheme + (of-object "MooTextView") + (c-name "moo_text_view_set_style_scheme") + (return-type "none") + (parameters + '("MooTextStyleScheme*" "scheme" (null-ok)) + ) +) (define-method lookup_tag (of-object "MooTextView")