Do not subclass GtkSourceLanguage, use it directly

This commit is contained in:
Yevgen Muntyan 2007-06-18 00:17:05 -05:00
parent e7db6b1099
commit 8bb82a6b38
9 changed files with 80 additions and 135 deletions

View File

@ -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"'
;;

View File

@ -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);

View File

@ -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");

View File

@ -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;
}

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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")