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 */" echo "/* This file is autogenerated from $base */"
case "$base" in case "$base" in
gtksourcelanguage.c) # gtksourcelanguage.c)
echo '#include "mooedit/moolang.h"' # echo '#include "mooedit/moolang.h"'
custom_cmd="-e s/g_object_new.*GTK_TYPE_SOURCE_LANGUAGE/g_object_new(MOO_TYPE_LANG/g" # custom_cmd="-e s/g_object_new.*GTK_TYPE_SOURCE_LANGUAGE/g_object_new(MOO_TYPE_LANG/g"
;; # ;;
gtksourcelanguage-parser-1.c) gtksourcelanguage-parser-1.c)
echo '#include "mooutils/moocompat.h"' 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)); get_string (MOO_EDIT_PREFS_LINE_NUMBERS_FONT));
mgr = moo_editor_get_lang_mgr (edit->priv->editor); 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) if (scheme)
moo_text_view_set_style_scheme (MOO_TEXT_VIEW (edit), 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; GtkCellRenderer *cell;
mgr = moo_editor_get_lang_mgr (editor); 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); g_return_if_fail (list != NULL);
store = gtk_list_store_new (1, MOO_TYPE_TEXT_STYLE_SCHEME); 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); editor = page_get_editor (page);
mgr = moo_editor_get_lang_mgr (editor); 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); g_return_if_fail (scheme != NULL);
scheme_combo = moo_glade_xml_get_widget (page->xml, "color_scheme_combo"); scheme_combo = moo_glade_xml_get_widget (page->xml, "color_scheme_combo");

View File

@ -25,52 +25,15 @@
#endif #endif
struct _MooLangPrivate { GType
char *version; /* not NULL; "" by default */ moo_lang_get_type (void)
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)
{ {
lang->priv = G_TYPE_INSTANCE_GET_PRIVATE (lang, MOO_TYPE_LANG, MooLangPrivate); static GType type;
lang->priv->version = g_strdup ("");
lang->priv->author = g_strdup ("");
}
if (G_UNLIKELY (!type))
type = GTK_TYPE_SOURCE_LANGUAGE;
static void return type;
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));
} }

View File

@ -671,7 +671,7 @@ load_config (MooLangMgr *mgr)
MooTextStyleScheme * 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); g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
@ -713,7 +713,7 @@ prepend_scheme (G_GNUC_UNUSED const char *name,
} }
GSList * GSList *
_moo_lang_mgr_list_schemes (MooLangMgr *mgr) moo_lang_mgr_list_schemes (MooLangMgr *mgr)
{ {
GSList *list = NULL; 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, MooLang *_moo_lang_mgr_find_lang (MooLangMgr *mgr,
const char *name); 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, void _moo_lang_mgr_set_active_scheme (MooLangMgr *mgr,
const char *scheme_name); const char *scheme_name);
/* list must be freed, content unref'ed */ /* 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 */ /* list must be freed together with content */
GSList *_moo_lang_mgr_get_globs (MooLangMgr *mgr, 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); tag = moo_line_view_create_tag (view, name, NULL);
lang_mgr = moo_editor_get_lang_mgr (moo_editor_instance ()); 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) if (scheme)
style = _moo_text_style_scheme_lookup_style (scheme, name); 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); mgr = moo_editor_get_lang_mgr (editor);
lang = moo_lang_mgr_get_lang (mgr, lang_id); 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_style_scheme (view, scheme);
moo_text_view_set_lang (view, lang); moo_text_view_set_lang (view, lang);

View File

@ -112,15 +112,12 @@
; ) ; )
; ) ; )
;; (define-object TextStyleScheme (define-object TextStyleScheme
;; (in-module "Moo") (in-module "Moo")
;; (parent "GObject") (parent "GObject")
;; (c-name "MooTextStyleScheme") (c-name "MooTextStyleScheme")
;; (gtype-id "MOO_TYPE_TEXT_STYLE_SCHEME") (gtype-id "MOO_TYPE_TEXT_STYLE_SCHEME")
;; (fields )
;; '("char*" "name")
;; )
;; )
(define-boxed TextStyle (define-boxed TextStyle
@ -722,17 +719,17 @@
) )
) )
; (define-method list_schemes (define-method list_schemes
; (of-object "MooLangMgr") (of-object "MooLangMgr")
; (c-name "moo_lang_mgr_list_schemes") (c-name "moo_lang_mgr_list_schemes")
; (return-type "GSList*") (return-type "object-slist")
; ) )
; (define-method get_active_scheme (define-method get_active_scheme
; (of-object "MooLangMgr") (of-object "MooLangMgr")
; (c-name "moo_lang_mgr_get_active_scheme") (c-name "moo_lang_mgr_get_active_scheme")
; (return-type "MooTextStyleScheme*") (return-type "MooTextStyleScheme*")
; ) )
@ -888,15 +885,6 @@
(return-type "gboolean") (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 (define-method add_line_mark
(of-object "MooTextBuffer") (of-object "MooTextBuffer")
(c-name "moo_text_buffer_add_line_mark") (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 ; (define-function moo_text_style_scheme_new_empty
; (c-name "moo_text_style_scheme_new_empty") ; (c-name "moo_text_style_scheme_new_empty")
@ -1005,55 +993,49 @@
; '("MooTextStyleScheme*" "base") ; '("MooTextStyleScheme*" "base")
; ) ; )
; ) ; )
;
; (define-function moo_text_style_scheme_new_default ; (define-function moo_text_style_scheme_new_default
; (c-name "moo_text_style_scheme_new_default") ; (c-name "moo_text_style_scheme_new_default")
; (return-type "MooTextStyleScheme*") ; (return-type "MooTextStyleScheme*")
; ) ; )
(define-method copy ; (define-method copy
(of-object "MooTextStyleScheme") ; (of-object "MooTextStyleScheme")
(c-name "moo_text_style_scheme_copy") ; (c-name "moo_text_style_scheme_copy")
(return-type "MooTextStyleScheme*") ; (return-type "MooTextStyleScheme*")
) ; )
(define-method list_default ; (define-method compose
(of-object "MooTextStyleScheme") ; (of-object "MooTextStyleScheme")
(c-name "moo_text_style_scheme_list_default") ; (c-name "moo_text_style_scheme_compose")
(return-type "GSList*") ; (return-type "none")
) ; (parameters
; '("const-char*" "language_name" (null-ok))
; '("const-char*" "style_name")
; '("const-MooTextStyle*" "style")
; )
; )
(define-method compose ; (define-method set
(of-object "MooTextStyleScheme") ; (of-object "MooTextStyleScheme")
(c-name "moo_text_style_scheme_compose") ; (c-name "moo_text_style_scheme_set")
(return-type "none") ; (return-type "none")
(parameters ; (parameters
'("const-char*" "language_name" (null-ok)) ; '("const-char*" "language_name" (null-ok))
'("const-char*" "style_name") ; '("const-char*" "style_name")
'("const-MooTextStyle*" "style") ; '("const-MooTextStyle*" "style")
) ; )
) ; )
;
(define-method set ; (define-method get
(of-object "MooTextStyleScheme") ; (of-object "MooTextStyleScheme")
(c-name "moo_text_style_scheme_set") ; (c-name "moo_text_style_scheme_get")
(return-type "none") ; (return-type "const-MooTextStyle*")
(parameters ; (parameters
'("const-char*" "language_name" (null-ok)) ; '("const-char*" "language_name" (null-ok))
'("const-char*" "style_name") ; '("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 (define-method set_style_scheme
; (of-object "MooTextView") (of-object "MooTextView")
; (c-name "moo_text_view_set_scheme") (c-name "moo_text_view_set_style_scheme")
; (return-type "none") (return-type "none")
; (parameters (parameters
; '("MooTextStyleScheme*" "scheme") '("MooTextStyleScheme*" "scheme" (null-ok))
; ) )
; ) )
(define-method lookup_tag (define-method lookup_tag
(of-object "MooTextView") (of-object "MooTextView")