Use a global instance of MooLangMgr too
This commit is contained in:
parent
f4d41a8b42
commit
176528be2d
@ -45,6 +45,7 @@ syntax: regexp
|
||||
^moo/Makefile\.am
|
||||
^moo/mooedit/Makefile\.am
|
||||
^moo/mooedit/plugins/Makefile\.am
|
||||
^moo/moopython/Makefile\.am
|
||||
^moo/moofileview/Makefile\.am
|
||||
^moo/moolua/Makefile\.am
|
||||
^moo/mooapp/Makefile\.am
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooedit/mooeditfiltersettings.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include "marshals.h"
|
||||
#include "mooutils/mooi18n.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
@ -891,7 +892,7 @@ parse_emacs_mode_string (MooEdit *edit,
|
||||
|
||||
g_strstrip (string);
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
|
||||
if (_moo_lang_mgr_find_lang (mgr, string))
|
||||
set_emacs_var (edit, "mode", string);
|
||||
@ -1029,8 +1030,9 @@ moo_edit_set_lang (MooEdit *edit,
|
||||
if (old_lang != lang)
|
||||
{
|
||||
moo_text_view_set_lang (MOO_TEXT_VIEW (edit), lang);
|
||||
_moo_lang_mgr_update_config (moo_editor_get_lang_mgr (edit->priv->editor),
|
||||
edit->config, _moo_lang_id (lang));
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (),
|
||||
edit->config,
|
||||
_moo_lang_id (lang));
|
||||
_moo_edit_update_config_from_global (edit);
|
||||
g_object_notify (G_OBJECT (edit), "has-comments");
|
||||
}
|
||||
@ -1041,7 +1043,7 @@ static void
|
||||
moo_edit_apply_lang_config (MooEdit *edit)
|
||||
{
|
||||
const char *lang_id = moo_edit_config_get_string (edit->config, "lang");
|
||||
MooLangMgr *mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
MooLangMgr *mgr = moo_lang_mgr_default ();
|
||||
MooLang *lang = lang_id ? _moo_lang_mgr_find_lang (mgr, lang_id) : NULL;
|
||||
moo_edit_set_lang (edit, lang);
|
||||
}
|
||||
@ -1121,7 +1123,7 @@ _moo_edit_update_lang_config (void)
|
||||
for (l = _moo_edit_instances; l != NULL; l = l->next)
|
||||
{
|
||||
MooEdit *edit = l->data;
|
||||
_moo_lang_mgr_update_config (moo_editor_get_lang_mgr (edit->priv->editor), edit->config,
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (), edit->config,
|
||||
_moo_lang_id (moo_text_view_get_lang (MOO_TEXT_VIEW (edit))));
|
||||
}
|
||||
}
|
||||
@ -1145,7 +1147,7 @@ moo_edit_filename_changed (MooEdit *edit,
|
||||
|
||||
if (filename)
|
||||
{
|
||||
MooLangMgr *mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
MooLangMgr *mgr = moo_lang_mgr_default ();
|
||||
lang = moo_lang_mgr_get_lang_for_file (mgr, filename);
|
||||
lang_id = lang ? _moo_lang_id (lang) : NULL;
|
||||
filter_config = _moo_edit_filter_settings_get_for_file (filename);
|
||||
@ -1169,8 +1171,9 @@ moo_edit_filename_changed (MooEdit *edit,
|
||||
|
||||
if (!lang_changed)
|
||||
{
|
||||
_moo_lang_mgr_update_config (moo_editor_get_lang_mgr (edit->priv->editor),
|
||||
edit->config, _moo_lang_id (lang));
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (),
|
||||
edit->config,
|
||||
_moo_lang_id (lang));
|
||||
_moo_edit_update_config_from_global (edit);
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ moo_editor_init (MooEditor *editor)
|
||||
moo_ui_xml_add_ui_from_string (editor->priv->doc_ui_xml,
|
||||
mooedit_ui_xml, -1);
|
||||
|
||||
editor->priv->lang_mgr = moo_lang_mgr_new ();
|
||||
editor->priv->lang_mgr = g_object_ref (moo_lang_mgr_default ());
|
||||
g_signal_connect_swapped (editor->priv->lang_mgr, "loaded",
|
||||
G_CALLBACK (moo_editor_apply_prefs),
|
||||
editor);
|
||||
@ -2513,14 +2513,6 @@ moo_editor_get_doc (MooEditor *editor,
|
||||
}
|
||||
|
||||
|
||||
MooLangMgr*
|
||||
moo_editor_get_lang_mgr (MooEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
return editor->priv->lang_mgr;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_editor_set_window_type (MooEditor *editor,
|
||||
GType type)
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define MOO_EDITOR_H
|
||||
|
||||
#include <mooedit/mooeditwindow.h>
|
||||
#include <mooedit/moolangmgr.h>
|
||||
#include <mooutils/moouixml.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -129,8 +128,6 @@ MooUIXML *moo_editor_get_doc_ui_xml (MooEditor *editor);
|
||||
MooEditor *moo_edit_window_get_editor (MooEditWindow *window);
|
||||
MooEditor *moo_edit_get_editor (MooEdit *doc);
|
||||
|
||||
MooLangMgr *moo_editor_get_lang_mgr (MooEditor *editor);
|
||||
|
||||
void moo_editor_set_window_type (MooEditor *editor,
|
||||
GType type);
|
||||
void moo_editor_set_edit_type (MooEditor *editor,
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mooedit/mootextview-private.h"
|
||||
#include "mooedit/mooedit-enums.h"
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include "mooutils/mooencodings.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -218,7 +219,7 @@ _moo_edit_apply_prefs (MooEdit *edit)
|
||||
_moo_text_view_set_line_numbers_font (MOO_TEXT_VIEW (edit),
|
||||
get_string (MOO_EDIT_PREFS_LINE_NUMBERS_FONT));
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
scheme = moo_lang_mgr_get_active_scheme (mgr);
|
||||
|
||||
if (scheme)
|
||||
|
@ -43,8 +43,7 @@ static gboolean moo_edit_prefs_page_help (GtkWidget *widget);
|
||||
static void prefs_page_apply_lang_prefs (PrefsPage *page);
|
||||
static void apply_filter_settings (PrefsPage *page);
|
||||
|
||||
static void scheme_combo_init (GtkComboBox *combo,
|
||||
MooEditor *editor);
|
||||
static void scheme_combo_init (GtkComboBox *combo);
|
||||
static void scheme_combo_data_func (GtkCellLayout *layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
@ -62,7 +61,7 @@ static void lang_combo_init (GtkComboBox *combo,
|
||||
|
||||
static void filter_treeview_init (MooGladeXML *xml);
|
||||
|
||||
static GtkTreeModel *create_lang_model (MooEditor *editor);
|
||||
static GtkTreeModel *create_lang_model (void);
|
||||
|
||||
static void save_encoding_combo_init (MooGladeXML *xml);
|
||||
static void save_encoding_combo_apply (MooGladeXML *xml);
|
||||
@ -206,7 +205,7 @@ moo_edit_prefs_page_new (MooEditor *editor)
|
||||
gtk_container_add (GTK_CONTAINER (prefs_page), GTK_WIDGET (data->notebook));
|
||||
|
||||
data->editor = g_object_ref (editor);
|
||||
data->lang_mgr = g_object_ref (moo_editor_get_lang_mgr (editor));
|
||||
data->lang_mgr = g_object_ref (moo_lang_mgr_default ());
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (prefs_pages); i++)
|
||||
{
|
||||
@ -230,7 +229,7 @@ moo_edit_prefs_page_new (MooEditor *editor)
|
||||
gtk_label_new (_(info->label)));
|
||||
|
||||
page->editor = g_object_ref (editor);
|
||||
page->lang_mgr = g_object_ref (moo_editor_get_lang_mgr (editor));
|
||||
page->lang_mgr = g_object_ref (moo_lang_mgr_default ());
|
||||
|
||||
data->n_pages++;
|
||||
}
|
||||
@ -293,7 +292,7 @@ page_view_init (PrefsPage *page)
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
scheme_combo = moo_glade_xml_get_widget (page->page->xml, "color_scheme_combo");
|
||||
scheme_combo_init (scheme_combo, page->editor);
|
||||
scheme_combo_init (scheme_combo);
|
||||
|
||||
scheme_combo_set_scheme (scheme_combo, scheme);
|
||||
}
|
||||
@ -349,15 +348,14 @@ page_langs_apply (PrefsPage *page)
|
||||
|
||||
|
||||
static void
|
||||
scheme_combo_init (GtkComboBox *combo,
|
||||
MooEditor *editor)
|
||||
scheme_combo_init (GtkComboBox *combo)
|
||||
{
|
||||
GtkListStore *store;
|
||||
MooLangMgr *mgr;
|
||||
GSList *list, *l;
|
||||
GtkCellRenderer *cell;
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
list = moo_lang_mgr_list_schemes (mgr);
|
||||
g_return_if_fail (list != NULL);
|
||||
|
||||
@ -422,7 +420,7 @@ page_get_lang_model (PrefsPage *page)
|
||||
|
||||
if (!model)
|
||||
{
|
||||
model = create_lang_model (page->editor);
|
||||
model = create_lang_model ();
|
||||
g_object_set_data_full (G_OBJECT (page->master), "moo-lang-model",
|
||||
model, g_object_unref);
|
||||
}
|
||||
@ -581,7 +579,7 @@ lang_cmp (MooLang *lang1,
|
||||
}
|
||||
|
||||
static GtkTreeModel *
|
||||
create_lang_model (MooEditor *editor)
|
||||
create_lang_model (void)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
MooLangMgr *mgr;
|
||||
@ -590,7 +588,7 @@ create_lang_model (MooEditor *editor)
|
||||
const char *config;
|
||||
char *ext, *mime;
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
langs = g_slist_sort (moo_lang_mgr_get_available_langs (mgr), (GCompareFunc) lang_cmp);
|
||||
sections = moo_lang_mgr_get_sections (mgr);
|
||||
|
||||
@ -947,7 +945,7 @@ prefs_page_apply_lang_prefs (PrefsPage *page)
|
||||
model = page_get_lang_model (page);
|
||||
g_return_if_fail (model != NULL);
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (page->editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) apply_one_lang, mgr);
|
||||
_moo_lang_mgr_save_config (mgr);
|
||||
_moo_edit_update_lang_config ();
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "mooedit/moocmdview.h"
|
||||
#include "mooedit/mooeditaction.h"
|
||||
#include "mooedit/mooedit-bookmarks.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include "mooutils/moonotebook.h"
|
||||
#include "mooutils/moostock.h"
|
||||
#include "marshals.h"
|
||||
@ -3049,14 +3050,14 @@ lang_item_activated (MooEditWindow *window,
|
||||
|
||||
|
||||
static GtkAction*
|
||||
create_lang_action (MooEditWindow *window)
|
||||
create_lang_action (MooEditWindow *window)
|
||||
{
|
||||
GtkAction *action;
|
||||
MooMenuMgr *menu_mgr;
|
||||
MooLangMgr *lang_mgr;
|
||||
GSList *langs, *sections, *l;
|
||||
|
||||
lang_mgr = moo_editor_get_lang_mgr (window->priv->editor);
|
||||
lang_mgr = moo_lang_mgr_default ();
|
||||
|
||||
/* TODO display names, etc. */
|
||||
sections = moo_lang_mgr_get_sections (lang_mgr);
|
||||
|
@ -125,6 +125,15 @@ moo_lang_mgr_new (void)
|
||||
return g_object_new (MOO_TYPE_LANG_MGR, NULL);
|
||||
}
|
||||
|
||||
MooLangMgr *
|
||||
moo_lang_mgr_default (void)
|
||||
{
|
||||
static MooLangMgr *instance;
|
||||
if (!instance)
|
||||
instance = moo_lang_mgr_new ();
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
static LangInfo *
|
||||
lang_info_new (void)
|
||||
|
@ -30,6 +30,7 @@ typedef struct _MooLangMgr MooLangMgr;
|
||||
GType moo_lang_mgr_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooLangMgr *moo_lang_mgr_new (void);
|
||||
MooLangMgr *moo_lang_mgr_default (void);
|
||||
|
||||
MooLang *moo_lang_mgr_get_lang (MooLangMgr *mgr,
|
||||
const char *lang_id);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "mooedit/moocommand.h"
|
||||
#include "mooedit/mookeyfile.h"
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include "mooutils/mooutils-gobject.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/moomarkup.h"
|
||||
@ -375,7 +376,7 @@ get_tag (MooLineView *view,
|
||||
MooTextStyle *style = NULL;
|
||||
|
||||
tag = moo_line_view_create_tag (view, name, NULL);
|
||||
lang_mgr = moo_editor_get_lang_mgr (moo_editor_instance ());
|
||||
lang_mgr = moo_lang_mgr_default ();
|
||||
scheme = moo_lang_mgr_get_active_scheme (lang_mgr);
|
||||
|
||||
if (scheme)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mooedit/mooedit-enums.h"
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/mootextbox.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include "marshals.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/mooundo.h"
|
||||
@ -2740,7 +2741,7 @@ moo_text_view_set_lang_by_id (MooTextView *view,
|
||||
editor = moo_editor_instance ();
|
||||
g_return_if_fail (editor != NULL);
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
mgr = moo_lang_mgr_default ();
|
||||
lang = moo_lang_mgr_get_lang (mgr, lang_id);
|
||||
scheme = moo_lang_mgr_get_active_scheme (mgr);
|
||||
|
||||
|
@ -93,7 +93,7 @@ nodist_libmoopython_la_SOURCES = $(nodist_libmoopython_la_sources)
|
||||
libmoopython_la_LIBADD = $(PYTHON_LIBS) $(PYTHON_EXTRA_LIBS)
|
||||
libmoopython_la_LDFLAGS = $(PYTHON_LDFLAGS) $(PYTHON_EXTRA_LDFLAGS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
EXTRA_DIST += \
|
||||
moo-mod.c \
|
||||
moopython-mod.c \
|
||||
moopython-builtin.h \
|
@ -6,14 +6,13 @@ moopygtk_sources = \
|
||||
pygtk/mooutils-mod.h \
|
||||
pygtk/moo-mod.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
BUILT_SOURCES += \
|
||||
pygtk/mooapp-mod.h \
|
||||
pygtk/mooedit-mod.h \
|
||||
pygtk/mooutils-mod.h \
|
||||
pygtk/moo-mod.h
|
||||
|
||||
nodist_moopygtk_sources =
|
||||
CLEANFILES =
|
||||
|
||||
mooedit_defs_files = \
|
||||
pygtk/mooeditor.defs \
|
||||
@ -119,6 +118,11 @@ pygtk/%-mod.h: $(srcdir)/pygtk/%-mod.py $(PY2H)
|
||||
$(SHELL) $(PY2H) `echo $* | tr '[a-z]' '[A-Z]'`_PY $(srcdir)/pygtk/$*-mod.py > $@.tmp && \
|
||||
mv $@.tmp $@
|
||||
|
||||
UGLY_SUBDIRS += pygtk
|
||||
|
||||
mooeditor.lo mooplugin.lo moocommand.lo: mooedit-pygtk.lo ; @true
|
||||
moopaned.lo moofileview.lo: mooutils-pygtk.lo ; @true
|
||||
|
||||
# noinst_LTLIBRARIES += libmoopygtk.la
|
||||
#
|
||||
# libmoopygtk_la_SOURCES = $(moopygtk_sources)
|
||||
|
@ -634,6 +634,11 @@
|
||||
(return-type "MooLangMgr*")
|
||||
)
|
||||
|
||||
(define-function lang_mgr_default
|
||||
(c-name "moo_lang_mgr_default")
|
||||
(return-type "MooLangMgr*")
|
||||
)
|
||||
|
||||
(define-method get_available_langs
|
||||
(of-object "MooLangMgr")
|
||||
(c-name "moo_lang_mgr_get_available_langs")
|
||||
|
@ -248,12 +248,6 @@
|
||||
(return-type "MooEditor*")
|
||||
)
|
||||
|
||||
(define-method get_lang_mgr
|
||||
(of-object "MooEditor")
|
||||
(c-name "moo_editor_get_lang_mgr")
|
||||
(return-type "MooLangMgr*")
|
||||
)
|
||||
|
||||
(define-method set_window_type
|
||||
(of-object "MooEditor")
|
||||
(c-name "moo_editor_set_window_type")
|
||||
|
Loading…
x
Reference in New Issue
Block a user