Fixed config stuff
This commit is contained in:
parent
baaa1abfeb
commit
fbbbfba439
@ -1311,7 +1311,6 @@ _moo_edit_set_file (MooEdit *edit,
|
||||
edit->priv->norm_name = _moo_file_get_normalized_name (file);
|
||||
edit->priv->display_filename = moo_file_get_display_name (file);
|
||||
edit->priv->display_basename = moo_file_get_display_basename (file);
|
||||
// _moo_edit_normalize_filename_for_comparison (_moo_normalize_file_path (edit->priv->filename));
|
||||
}
|
||||
|
||||
if (!encoding)
|
||||
@ -1319,8 +1318,9 @@ _moo_edit_set_file (MooEdit *edit,
|
||||
else
|
||||
moo_edit_set_encoding (edit, encoding);
|
||||
|
||||
g_signal_emit_by_name (edit, "filename-changed", edit->priv->filename, NULL);
|
||||
g_signal_emit_by_name (edit, "filename-changed", NULL);
|
||||
_moo_edit_status_changed (edit);
|
||||
_moo_edit_queue_recheck_config (edit);
|
||||
|
||||
moo_file_free (tmp);
|
||||
|
||||
|
@ -75,9 +75,9 @@ extern guint *_moo_edit_settings;
|
||||
|
||||
void _moo_edit_update_global_config (void);
|
||||
void _moo_edit_init_config (void);
|
||||
void _moo_edit_update_lang_config (void);
|
||||
|
||||
void _moo_edit_apply_prefs (MooEdit *edit);
|
||||
void _moo_edit_queue_recheck_config_all (void);
|
||||
void _moo_edit_queue_recheck_config (MooEdit *edit);
|
||||
|
||||
void _moo_edit_closed (MooEdit *edit);
|
||||
|
||||
|
@ -28,6 +28,7 @@ struct MooEditPrivate {
|
||||
|
||||
gulong modified_changed_handler_id;
|
||||
guint apply_config_idle;
|
||||
gboolean in_recheck_config;
|
||||
|
||||
/***********************************************************************/
|
||||
/* Document
|
||||
@ -60,6 +61,7 @@ struct MooEditPrivate {
|
||||
};
|
||||
|
||||
void _moo_edit_remove_untitled (MooEdit *doc);
|
||||
void _moo_edit_apply_prefs (MooEdit *doc);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -45,47 +45,38 @@
|
||||
MOO_DEFINE_OBJECT_ARRAY (MooEdit, moo_edit)
|
||||
|
||||
MooEditList *_moo_edit_instances = NULL;
|
||||
static guint moo_edit_apply_config_all_idle;
|
||||
|
||||
static GObject *moo_edit_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_param);
|
||||
static void moo_edit_finalize (GObject *object);
|
||||
static void moo_edit_dispose (GObject *object);
|
||||
static GObject *moo_edit_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_param);
|
||||
static void moo_edit_finalize (GObject *object);
|
||||
static void moo_edit_dispose (GObject *object);
|
||||
|
||||
static void moo_edit_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void moo_edit_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void moo_edit_filename_changed (MooEdit *edit,
|
||||
const char *new_filename);
|
||||
|
||||
static void config_changed (MooEdit *edit,
|
||||
static void moo_edit_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void moo_edit_config_notify (MooEdit *edit,
|
||||
guint var_id,
|
||||
static void moo_edit_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void _moo_edit_freeze_config_notify (MooEdit *edit);
|
||||
static void _moo_edit_thaw_config_notify (MooEdit *edit);
|
||||
static void _moo_edit_update_config_from_global (MooEdit *edit);
|
||||
|
||||
static void config_changed (MooEdit *edit);
|
||||
static void update_config_from_mode_lines (MooEdit *doc);
|
||||
static void moo_edit_recheck_config (MooEdit *doc);
|
||||
|
||||
static void modified_changed_cb (GtkTextBuffer *buffer,
|
||||
MooEdit *edit);
|
||||
|
||||
static MooLang *moo_edit_get_lang (MooEdit *doc);
|
||||
|
||||
|
||||
enum {
|
||||
DOC_STATUS_CHANGED,
|
||||
FILENAME_CHANGED,
|
||||
COMMENT,
|
||||
UNCOMMENT,
|
||||
CONFIG_NOTIFY,
|
||||
SAVE_BEFORE,
|
||||
SAVE_AFTER,
|
||||
BOOKMARKS_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -97,6 +88,7 @@ enum {
|
||||
PROP_ENABLE_BOOKMARKS,
|
||||
PROP_HAS_COMMENTS,
|
||||
PROP_LINE_END_TYPE,
|
||||
PROP_LANG,
|
||||
PROP_ENCODING
|
||||
};
|
||||
|
||||
@ -114,57 +106,32 @@ moo_edit_class_init (MooEditClass *klass)
|
||||
gobject_class->finalize = moo_edit_finalize;
|
||||
gobject_class->dispose = moo_edit_dispose;
|
||||
|
||||
klass->filename_changed = moo_edit_filename_changed;
|
||||
klass->config_notify = moo_edit_config_notify;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (MooEditPrivate));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_EDITOR,
|
||||
g_param_spec_object ("editor",
|
||||
"editor",
|
||||
"editor",
|
||||
MOO_TYPE_EDITOR,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
|
||||
g_object_class_install_property (gobject_class, PROP_EDITOR,
|
||||
g_param_spec_object ("editor", "editor", "editor",
|
||||
MOO_TYPE_EDITOR, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ENABLE_BOOKMARKS,
|
||||
g_param_spec_boolean ("enable-bookmarks",
|
||||
"enable-bookmarks",
|
||||
"enable-bookmarks",
|
||||
TRUE,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_BOOKMARKS,
|
||||
g_param_spec_boolean ("enable-bookmarks", "enable-bookmarks", "enable-bookmarks",
|
||||
TRUE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_HAS_COMMENTS,
|
||||
g_param_spec_boolean ("has-comments",
|
||||
"has-comments",
|
||||
"has-comments",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property (gobject_class, PROP_HAS_COMMENTS,
|
||||
g_param_spec_boolean ("has-comments", "has-comments", "has-comments",
|
||||
FALSE, G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_LINE_END_TYPE,
|
||||
g_param_spec_enum ("line-end-type", "line-end-type", "line-end-type",
|
||||
MOO_TYPE_LINE_END_TYPE, MOO_LE_NONE,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ENCODING,
|
||||
g_param_spec_string ("encoding",
|
||||
"encoding",
|
||||
"encoding",
|
||||
NULL,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_class, PROP_ENCODING,
|
||||
g_param_spec_string ("encoding", "encoding", "encoding",
|
||||
NULL, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
signals[CONFIG_NOTIFY] =
|
||||
g_signal_new ("config-notify",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
(GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED),
|
||||
G_STRUCT_OFFSET (MooEditClass, config_notify),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__UINT_POINTER,
|
||||
G_TYPE_NONE, 2,
|
||||
G_TYPE_UINT, G_TYPE_POINTER);
|
||||
g_object_class_install_property (gobject_class, PROP_LANG,
|
||||
g_param_spec_object ("lang", "lang", "lang",
|
||||
MOO_TYPE_LANG, G_PARAM_READABLE));
|
||||
|
||||
signals[DOC_STATUS_CHANGED] =
|
||||
g_signal_new ("doc-status-changed",
|
||||
@ -181,27 +148,8 @@ moo_edit_class_init (MooEditClass *klass)
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (MooEditClass, filename_changed),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__STRING,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
|
||||
|
||||
signals[COMMENT] =
|
||||
_moo_signal_new_cb ("comment",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
(GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
||||
G_CALLBACK (_moo_edit_comment),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[UNCOMMENT] =
|
||||
_moo_signal_new_cb ("uncomment",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
(GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
||||
G_CALLBACK (_moo_edit_uncomment),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[SAVE_BEFORE] =
|
||||
g_signal_new ("save-before",
|
||||
@ -221,15 +169,6 @@ moo_edit_class_init (MooEditClass *klass)
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[BOOKMARKS_CHANGED] =
|
||||
g_signal_new ("bookmarks-changed",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (MooEditClass, bookmarks_changed),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
_moo_edit_init_config ();
|
||||
_moo_edit_class_init_actions (klass);
|
||||
}
|
||||
@ -242,7 +181,8 @@ moo_edit_init (MooEdit *edit)
|
||||
|
||||
edit->config = moo_edit_config_new ();
|
||||
g_signal_connect_swapped (edit->config, "notify",
|
||||
G_CALLBACK (config_changed), edit);
|
||||
G_CALLBACK (config_changed),
|
||||
edit);
|
||||
|
||||
edit->priv->actions = moo_action_collection_new ("MooEdit", "MooEdit");
|
||||
|
||||
@ -250,7 +190,7 @@ moo_edit_init (MooEdit *edit)
|
||||
}
|
||||
|
||||
|
||||
static GObject*
|
||||
static GObject *
|
||||
moo_edit_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_param)
|
||||
@ -573,6 +513,10 @@ moo_edit_get_property (GObject *object,
|
||||
g_value_set_string (value, edit->priv->encoding);
|
||||
break;
|
||||
|
||||
case PROP_LANG:
|
||||
g_value_set_object (value, moo_edit_get_lang (edit));
|
||||
break;
|
||||
|
||||
case PROP_LINE_END_TYPE:
|
||||
g_value_set_enum (value, edit->priv->line_end_type);
|
||||
break;
|
||||
@ -904,7 +848,7 @@ try_mode_string (MooEdit *edit,
|
||||
}
|
||||
|
||||
static void
|
||||
try_mode_strings (MooEdit *edit)
|
||||
update_config_from_mode_lines (MooEdit *edit)
|
||||
{
|
||||
GtkTextBuffer *buffer = moo_edit_get_buffer (edit);
|
||||
GtkTextIter start, end;
|
||||
@ -960,21 +904,11 @@ try_mode_strings (MooEdit *edit)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
config_changed (MooEdit *edit,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
guint id = moo_edit_config_get_setting_id (pspec);
|
||||
GQuark detail = g_quark_from_string (pspec->name);
|
||||
g_return_if_fail (id != 0);
|
||||
g_signal_emit (edit, signals[CONFIG_NOTIFY], detail, id, pspec);
|
||||
}
|
||||
|
||||
|
||||
static MooLang *
|
||||
moo_edit_get_lang (MooEdit *doc)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (doc), NULL);
|
||||
moo_assert (!doc->priv->in_recheck_config);
|
||||
return moo_text_view_get_lang (MOO_TEXT_VIEW (moo_edit_get_view (doc)));
|
||||
}
|
||||
|
||||
@ -984,156 +918,164 @@ moo_edit_get_lang (MooEdit *doc)
|
||||
* Returns: id of language currently used in the document. If no language
|
||||
* is used, then string "none" is returned.
|
||||
*/
|
||||
const char *
|
||||
char *
|
||||
moo_edit_get_lang_id (MooEdit *doc)
|
||||
{
|
||||
return _moo_lang_id (moo_edit_get_lang (doc));
|
||||
}
|
||||
MooLang *lang = NULL;
|
||||
|
||||
static void
|
||||
moo_edit_set_lang (MooEdit *edit,
|
||||
MooLang *lang)
|
||||
{
|
||||
MooLang *old_lang;
|
||||
moo_return_val_if_fail (MOO_IS_EDIT (doc), NULL);
|
||||
|
||||
old_lang = moo_edit_get_lang (edit);
|
||||
|
||||
if (old_lang != lang)
|
||||
if (!doc->priv->in_recheck_config)
|
||||
{
|
||||
moo_text_view_set_lang (MOO_TEXT_VIEW (moo_edit_get_view (edit)), 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");
|
||||
lang = moo_edit_get_lang (doc);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *lang_id = moo_edit_config_get_string (doc->config, "lang");
|
||||
lang = lang_id ? _moo_lang_mgr_find_lang (moo_lang_mgr_default (), lang_id) : NULL;
|
||||
}
|
||||
|
||||
return g_strdup (_moo_lang_id (lang));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_edit_apply_lang_config (MooEdit *edit)
|
||||
{
|
||||
const char *lang_id = moo_edit_config_get_string (edit->config, "lang");
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
moo_edit_apply_config (MooEdit *edit)
|
||||
{
|
||||
moo_edit_apply_lang_config (edit);
|
||||
_moo_edit_view_apply_config (moo_edit_get_view (edit));
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
do_apply_config (MooEdit *edit)
|
||||
{
|
||||
edit->priv->apply_config_idle = 0;
|
||||
moo_edit_apply_config (edit);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
moo_edit_queue_apply_config (MooEdit *edit)
|
||||
{
|
||||
if (!edit->priv->apply_config_idle)
|
||||
edit->priv->apply_config_idle =
|
||||
moo_idle_add_full (G_PRIORITY_HIGH,
|
||||
(GSourceFunc) do_apply_config,
|
||||
edit, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_edit_config_notify (MooEdit *edit,
|
||||
guint var_id,
|
||||
G_GNUC_UNUSED GParamSpec *pspec)
|
||||
{
|
||||
if (var_id == _moo_edit_settings[MOO_EDIT_SETTING_LANG])
|
||||
moo_edit_apply_lang_config (edit);
|
||||
else
|
||||
moo_edit_queue_apply_config (edit);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_moo_edit_update_config_from_global (MooEdit *edit)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (edit));
|
||||
/* XXX */
|
||||
moo_edit_config_unset_by_source (edit->config,
|
||||
MOO_EDIT_CONFIG_SOURCE_AUTO);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_moo_edit_update_lang_config (void)
|
||||
moo_edit_apply_config_all_in_idle (void)
|
||||
{
|
||||
MooEditList *l;
|
||||
|
||||
moo_edit_apply_config_all_idle = 0;
|
||||
|
||||
for (l = _moo_edit_instances; l != NULL; l = l->next)
|
||||
{
|
||||
MooEdit *edit = l->data;
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (), edit->config,
|
||||
moo_edit_get_lang_id (edit));
|
||||
}
|
||||
moo_edit_recheck_config (l->data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_moo_edit_queue_recheck_config_all (void)
|
||||
{
|
||||
if (!moo_edit_apply_config_all_idle)
|
||||
moo_edit_apply_config_all_idle =
|
||||
moo_idle_add ((GSourceFunc) moo_edit_apply_config_all_in_idle, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_edit_filename_changed (MooEdit *edit,
|
||||
const char *filename)
|
||||
update_lang_config_from_lang_globs (MooEdit *doc)
|
||||
{
|
||||
gboolean lang_changed = FALSE;
|
||||
MooLang *lang = NULL, *old_lang = NULL;
|
||||
const char *lang_id = NULL;
|
||||
char *filter_config = NULL;
|
||||
|
||||
old_lang = moo_edit_get_lang (edit);
|
||||
|
||||
_moo_edit_freeze_config_notify (edit);
|
||||
|
||||
moo_edit_config_unset_by_source (edit->config, MOO_EDIT_CONFIG_SOURCE_FILE);
|
||||
_moo_edit_update_config_from_global (edit);
|
||||
|
||||
if (filename)
|
||||
if (doc->priv->file)
|
||||
{
|
||||
MooLangMgr *mgr = moo_lang_mgr_default ();
|
||||
lang = moo_lang_mgr_get_lang_for_file (mgr, filename);
|
||||
MooLang *lang = moo_lang_mgr_get_lang_for_file (mgr, doc->priv->file);
|
||||
lang_id = lang ? _moo_lang_id (lang) : NULL;
|
||||
}
|
||||
|
||||
moo_edit_config_set (edit->config, MOO_EDIT_CONFIG_SOURCE_FILENAME,
|
||||
"lang", lang_id, "indent", (void*) NULL, (char*) NULL);
|
||||
moo_edit_config_set (doc->config, MOO_EDIT_CONFIG_SOURCE_FILENAME,
|
||||
"lang", lang_id, (char*) NULL);
|
||||
}
|
||||
|
||||
filter_config = _moo_edit_filter_settings_get_for_doc (edit);
|
||||
static void
|
||||
update_config_from_filter_settings (MooEdit *doc)
|
||||
{
|
||||
char *filter_config = NULL;
|
||||
|
||||
filter_config = _moo_edit_filter_settings_get_for_doc (doc);
|
||||
|
||||
if (filter_config)
|
||||
moo_edit_config_parse (edit->config, filter_config,
|
||||
moo_edit_config_parse (doc->config, filter_config,
|
||||
MOO_EDIT_CONFIG_SOURCE_FILENAME);
|
||||
|
||||
try_mode_strings (edit);
|
||||
g_free (filter_config);
|
||||
}
|
||||
|
||||
lang_id = moo_edit_config_get_string (edit->config, "lang");
|
||||
static void
|
||||
update_config_from_lang (MooEdit *doc)
|
||||
{
|
||||
char *lang_id = moo_edit_get_lang_id (doc);
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (), doc->config, lang_id);
|
||||
g_free (lang_id);
|
||||
}
|
||||
|
||||
if (!lang_id)
|
||||
lang_id = MOO_LANG_NONE;
|
||||
static void
|
||||
moo_edit_apply_config (MooEdit *doc)
|
||||
{
|
||||
const char *lang_id = moo_edit_config_get_string (doc->config, "lang");
|
||||
MooLangMgr *mgr = moo_lang_mgr_default ();
|
||||
MooLang *lang = lang_id ? _moo_lang_mgr_find_lang (mgr, lang_id) : NULL;
|
||||
moo_text_view_set_lang (MOO_TEXT_VIEW (moo_edit_get_view (doc)), lang);
|
||||
g_object_notify (G_OBJECT (doc), "has-comments");
|
||||
g_object_notify (G_OBJECT (doc), "lang");
|
||||
_moo_edit_view_apply_config (moo_edit_get_view (doc));
|
||||
}
|
||||
|
||||
lang_changed = strcmp (lang_id, _moo_lang_id (old_lang)) != 0;
|
||||
static void
|
||||
moo_edit_recheck_config (MooEdit *doc)
|
||||
{
|
||||
moo_return_if_fail (!doc->priv->in_recheck_config);
|
||||
|
||||
if (!lang_changed)
|
||||
if (doc->priv->apply_config_idle)
|
||||
{
|
||||
_moo_lang_mgr_update_config (moo_lang_mgr_default (),
|
||||
edit->config,
|
||||
_moo_lang_id (lang));
|
||||
_moo_edit_update_config_from_global (edit);
|
||||
g_source_remove (doc->priv->apply_config_idle);
|
||||
doc->priv->apply_config_idle = 0;
|
||||
}
|
||||
|
||||
_moo_edit_thaw_config_notify (edit);
|
||||
g_object_freeze_notify (G_OBJECT (doc));
|
||||
g_object_freeze_notify (G_OBJECT (moo_edit_get_view (doc)));
|
||||
doc->priv->in_recheck_config = TRUE;
|
||||
|
||||
g_free (filter_config);
|
||||
// this resets settings from global config
|
||||
moo_edit_config_unset_by_source (doc->config, MOO_EDIT_CONFIG_SOURCE_FILE);
|
||||
|
||||
// First global settings
|
||||
_moo_edit_apply_prefs (doc);
|
||||
|
||||
// then language from globs
|
||||
update_lang_config_from_lang_globs (doc);
|
||||
|
||||
// then settings from mode lines, these may change lang
|
||||
update_config_from_mode_lines (doc);
|
||||
|
||||
// then filter settings, these also may change lang
|
||||
update_config_from_filter_settings (doc);
|
||||
|
||||
// update config for lang
|
||||
update_config_from_lang (doc);
|
||||
|
||||
// finally apply config
|
||||
moo_edit_apply_config (doc);
|
||||
|
||||
doc->priv->in_recheck_config = FALSE;
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (moo_edit_get_view (doc)));
|
||||
g_object_thaw_notify (G_OBJECT (doc));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
moo_edit_recheck_config_in_idle (MooEdit *edit)
|
||||
{
|
||||
edit->priv->apply_config_idle = 0;
|
||||
moo_edit_recheck_config (edit);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_moo_edit_queue_recheck_config (MooEdit *doc)
|
||||
{
|
||||
moo_return_if_fail (!doc->priv->in_recheck_config);
|
||||
if (!doc->priv->apply_config_idle)
|
||||
doc->priv->apply_config_idle =
|
||||
moo_idle_add_full (G_PRIORITY_HIGH,
|
||||
(GSourceFunc) moo_edit_recheck_config_in_idle,
|
||||
doc, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
config_changed (MooEdit *doc)
|
||||
{
|
||||
if (!doc->priv->in_recheck_config)
|
||||
_moo_edit_queue_recheck_config (doc);
|
||||
}
|
||||
|
||||
|
||||
@ -1211,21 +1153,6 @@ moo_edit_save_copy (MooEdit *doc,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_moo_edit_freeze_config_notify (MooEdit *edit)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (edit));
|
||||
g_object_freeze_notify (G_OBJECT (edit->config));
|
||||
}
|
||||
|
||||
static void
|
||||
_moo_edit_thaw_config_notify (MooEdit *edit)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (edit));
|
||||
g_object_thaw_notify (G_OBJECT (edit->config));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Comment/uncomment
|
||||
*/
|
||||
|
@ -53,14 +53,7 @@ struct MooEditClass
|
||||
are changed. for use in editor to adjust title bar, etc. */
|
||||
void (* doc_status_changed) (MooEdit *edit);
|
||||
|
||||
void (* filename_changed) (MooEdit *edit,
|
||||
const char *new_filename);
|
||||
|
||||
void (* bookmarks_changed) (MooEdit *edit);
|
||||
|
||||
void (* config_notify) (MooEdit *edit,
|
||||
guint var_id,
|
||||
GParamSpec *pspec);
|
||||
void (* filename_changed) (MooEdit *edit);
|
||||
|
||||
void (* save_before) (MooEdit *edit);
|
||||
void (* save_after) (MooEdit *edit);
|
||||
@ -87,7 +80,7 @@ const char *moo_edit_get_encoding (MooEdit *edit);
|
||||
void moo_edit_set_encoding (MooEdit *edit,
|
||||
const char *encoding);
|
||||
|
||||
const char *moo_edit_get_lang_id (MooEdit *edit);
|
||||
char *moo_edit_get_lang_id (MooEdit *edit);
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define MOO_LE_DEFAULT MOO_LE_WIN32
|
||||
|
@ -55,9 +55,8 @@ moo_edit_bookmark_init (MooEditBookmark *bk)
|
||||
|
||||
|
||||
static void
|
||||
bookmarks_changed (MooEdit *edit)
|
||||
bookmarks_changed (G_GNUC_UNUSED MooEdit *edit)
|
||||
{
|
||||
g_signal_emit_by_name (edit, "bookmarks-changed");
|
||||
}
|
||||
|
||||
|
||||
@ -271,7 +270,7 @@ moo_edit_add_bookmark (MooEdit *edit,
|
||||
g_return_if_fail (line < get_line_count (edit));
|
||||
g_return_if_fail (moo_edit_get_bookmark_at_line (edit, line) == NULL);
|
||||
|
||||
g_object_set (edit, "show-line-marks", TRUE, (char*) 0);
|
||||
g_object_set (moo_edit_get_view (edit), "show-line-marks", TRUE, (char*) 0);
|
||||
|
||||
bk = MOO_EDIT_BOOKMARK (g_object_new (MOO_TYPE_EDIT_BOOKMARK, "background", get_bookmark_color (edit), (char*) 0));
|
||||
moo_text_buffer_add_line_mark (get_moo_buffer (edit), MOO_LINE_MARK (bk), line);
|
||||
|
@ -293,15 +293,20 @@ static gboolean
|
||||
moo_edit_filter_check_langs (GSList *langs,
|
||||
MooEdit *doc)
|
||||
{
|
||||
const char *lang_id = moo_edit_get_lang_id (doc);
|
||||
char *lang_id = moo_edit_get_lang_id (doc);
|
||||
|
||||
while (lang_id && langs)
|
||||
{
|
||||
if (strcmp (langs->data, lang_id) == 0)
|
||||
{
|
||||
g_free (lang_id);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
langs = langs->next;
|
||||
}
|
||||
|
||||
g_free (lang_id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ void _moo_editor_move_doc (MooEditor *editor,
|
||||
MooFileWatch *_moo_editor_get_file_watch (MooEditor *editor);
|
||||
|
||||
void _moo_editor_apply_prefs (MooEditor *editor);
|
||||
void _moo_editor_queue_apply_prefs (MooEditor *editor);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -45,8 +45,6 @@ struct MooEditorPrivate {
|
||||
GType doc_type;
|
||||
|
||||
MooLangMgr *lang_mgr;
|
||||
|
||||
guint prefs_idle;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -403,9 +403,6 @@ moo_editor_finalize (GObject *object)
|
||||
moo_edit_window_array_free (editor->priv->windows);
|
||||
moo_edit_array_free (editor->priv->windowless);
|
||||
|
||||
if (editor->priv->prefs_idle)
|
||||
g_source_remove (editor->priv->prefs_idle);
|
||||
|
||||
G_OBJECT_CLASS (moo_editor_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -769,8 +766,6 @@ moo_editor_add_doc (MooEditor *editor,
|
||||
{
|
||||
if (!window)
|
||||
moo_edit_array_append (editor->priv->windowless, doc);
|
||||
|
||||
_moo_edit_apply_prefs (doc);
|
||||
}
|
||||
|
||||
|
||||
@ -2783,52 +2778,23 @@ moo_editor_set_doc_type (MooEditor *editor,
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_editor_apply_prefs_in_idle (MooEditor *editor)
|
||||
{
|
||||
editor->priv->prefs_idle = 0;
|
||||
_moo_editor_apply_prefs (editor);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_moo_editor_queue_apply_prefs (MooEditor *editor)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDITOR (editor));
|
||||
if (!editor->priv->prefs_idle)
|
||||
editor->priv->prefs_idle =
|
||||
moo_idle_add_full (G_PRIORITY_HIGH,
|
||||
(GSourceFunc) moo_editor_apply_prefs_in_idle,
|
||||
editor, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_moo_editor_apply_prefs (MooEditor *editor)
|
||||
{
|
||||
MooEditArray *docs;
|
||||
gboolean backups;
|
||||
const char *color_scheme;
|
||||
|
||||
if (editor->priv->prefs_idle)
|
||||
{
|
||||
g_source_remove (editor->priv->prefs_idle);
|
||||
editor->priv->prefs_idle = 0;
|
||||
}
|
||||
|
||||
_moo_edit_window_update_title ();
|
||||
_moo_edit_window_set_use_tabs ();
|
||||
|
||||
_moo_edit_update_global_config ();
|
||||
_moo_edit_queue_recheck_config_all ();
|
||||
|
||||
color_scheme = moo_prefs_get_string (moo_edit_setting (MOO_EDIT_PREFS_COLOR_SCHEME));
|
||||
|
||||
if (color_scheme)
|
||||
_moo_lang_mgr_set_active_scheme (editor->priv->lang_mgr, color_scheme);
|
||||
|
||||
docs = moo_editor_get_docs (editor);
|
||||
moo_edit_array_foreach (docs, (MooEditArrayForeach) _moo_edit_apply_prefs, NULL);
|
||||
moo_edit_array_free (docs);
|
||||
|
||||
backups = moo_prefs_get_bool (moo_edit_setting (MOO_EDIT_PREFS_MAKE_BACKUPS));
|
||||
|
||||
g_object_set (editor,
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/mooedit-impl.h"
|
||||
#include "mooedit/mooedit-private.h"
|
||||
#include "mooedit/mooedit-fileops.h"
|
||||
#include "mooedit/mootextview-private.h"
|
||||
#include "mooedit/mooedit-enums.h"
|
||||
|
@ -115,7 +115,7 @@ prefs_page_new (MooEditor *editor,
|
||||
init_ui, init, apply);
|
||||
|
||||
g_signal_connect_swapped (prefs_page, "apply",
|
||||
G_CALLBACK (_moo_editor_queue_apply_prefs),
|
||||
G_CALLBACK (_moo_editor_apply_prefs),
|
||||
editor);
|
||||
|
||||
return prefs_page;
|
||||
@ -816,7 +816,7 @@ prefs_page_apply_lang_prefs (MooPrefsPage *page)
|
||||
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 ();
|
||||
_moo_edit_queue_recheck_config_all ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,11 +151,10 @@ static void set_title_format_from_prefs (MooEditWindow *window);
|
||||
|
||||
static void proxy_boolean_property (MooEditWindow *window,
|
||||
GParamSpec *prop,
|
||||
MooEditView *view);
|
||||
MooEdit *doc);
|
||||
static void edit_changed (MooEditWindow *window,
|
||||
MooEdit *doc);
|
||||
static void edit_filename_changed (MooEditWindow *window,
|
||||
const char *filename,
|
||||
MooEdit *doc);
|
||||
static void edit_encoding_changed (MooEditWindow *window,
|
||||
GParamSpec *pspec,
|
||||
@ -164,7 +163,6 @@ static void edit_line_end_changed (MooEditWindow *window,
|
||||
GParamSpec *pspec,
|
||||
MooEdit *doc);
|
||||
static void edit_lang_changed (MooEditWindow *window,
|
||||
guint var_id,
|
||||
GParamSpec *pspec,
|
||||
MooEdit *doc);
|
||||
static void view_overwrite_changed (MooEditWindow *window,
|
||||
@ -1842,20 +1840,23 @@ notebook_populate_popup (MooNotebook *notebook,
|
||||
GtkMenu *menu,
|
||||
MooEditWindow *window)
|
||||
{
|
||||
MooEdit *edit;
|
||||
MooEdit *doc;
|
||||
MooEditView *view;
|
||||
GtkWidget *item;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), TRUE);
|
||||
g_return_val_if_fail (window->priv->notebook == notebook, TRUE);
|
||||
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (child), TRUE);
|
||||
|
||||
edit = MOO_EDIT (gtk_bin_get_child (GTK_BIN (child)));
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), TRUE);
|
||||
view = MOO_EDIT_VIEW (gtk_bin_get_child (GTK_BIN (child)));
|
||||
g_return_val_if_fail (MOO_IS_EDIT_VIEW (view), TRUE);
|
||||
|
||||
doc = moo_edit_view_get_doc (view);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Close");
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", edit);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", doc);
|
||||
g_signal_connect (item, "activate",
|
||||
G_CALLBACK (close_activated),
|
||||
window);
|
||||
@ -1865,7 +1866,7 @@ notebook_populate_popup (MooNotebook *notebook,
|
||||
item = gtk_menu_item_new_with_label ("Close All Others");
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", edit);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", doc);
|
||||
g_signal_connect (item, "activate",
|
||||
G_CALLBACK (close_others_activated),
|
||||
window);
|
||||
@ -1881,7 +1882,7 @@ notebook_populate_popup (MooNotebook *notebook,
|
||||
item = gtk_menu_item_new_with_label ("Detach");
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", edit);
|
||||
g_object_set_data (G_OBJECT (item), "moo-edit", doc);
|
||||
g_signal_connect (item, "activate",
|
||||
G_CALLBACK (detach_activated),
|
||||
window);
|
||||
@ -2116,7 +2117,6 @@ update_doc_view_actions (MooEditWindow *window)
|
||||
|
||||
static void
|
||||
edit_filename_changed (MooEditWindow *window,
|
||||
G_GNUC_UNUSED const char *filename,
|
||||
MooEdit *doc)
|
||||
{
|
||||
edit_changed (window, doc);
|
||||
@ -2125,11 +2125,11 @@ edit_filename_changed (MooEditWindow *window,
|
||||
|
||||
|
||||
static void
|
||||
proxy_boolean_property (MooEditWindow *window,
|
||||
GParamSpec *prop,
|
||||
MooEditView *view)
|
||||
proxy_boolean_property (MooEditWindow *window,
|
||||
GParamSpec *prop,
|
||||
MooEdit *doc)
|
||||
{
|
||||
if (view == ACTIVE_VIEW (window))
|
||||
if (doc == ACTIVE_DOC (window))
|
||||
g_object_notify (G_OBJECT (window), prop->name);
|
||||
}
|
||||
|
||||
@ -2386,9 +2386,9 @@ _moo_edit_window_insert_doc (MooEditWindow *window,
|
||||
G_CALLBACK (view_show_line_numbers_changed), window);
|
||||
g_signal_connect_swapped (edit, "filename_changed",
|
||||
G_CALLBACK (edit_filename_changed), window);
|
||||
g_signal_connect_swapped (view, "notify::has-comments",
|
||||
g_signal_connect_swapped (edit, "notify::has-comments",
|
||||
G_CALLBACK (proxy_boolean_property), window);
|
||||
g_signal_connect_swapped (edit, "config-notify::lang",
|
||||
g_signal_connect_swapped (edit, "notify::lang",
|
||||
G_CALLBACK (edit_lang_changed), window);
|
||||
g_signal_connect_swapped (view, "cursor-moved",
|
||||
G_CALLBACK (view_cursor_moved), window);
|
||||
@ -2431,7 +2431,7 @@ _moo_edit_window_remove_doc (MooEditWindow *window,
|
||||
|
||||
g_signal_handlers_disconnect_by_func (doc, (gpointer) edit_changed, window);
|
||||
g_signal_handlers_disconnect_by_func (doc, (gpointer) edit_filename_changed, window);
|
||||
g_signal_handlers_disconnect_by_func (view, (gpointer) proxy_boolean_property, window);
|
||||
g_signal_handlers_disconnect_by_func (doc, (gpointer) proxy_boolean_property, window);
|
||||
g_signal_handlers_disconnect_by_func (view, (gpointer) view_cursor_moved, window);
|
||||
g_signal_handlers_disconnect_by_func (doc, (gpointer) edit_lang_changed, window);
|
||||
g_signal_handlers_disconnect_by_func (view, (gpointer) view_overwrite_changed, window);
|
||||
@ -3250,7 +3250,6 @@ update_lang_menu (MooEditWindow *window)
|
||||
|
||||
static void
|
||||
edit_lang_changed (MooEditWindow *window,
|
||||
G_GNUC_UNUSED guint var_id,
|
||||
G_GNUC_UNUSED GParamSpec *pspec,
|
||||
MooEdit *doc)
|
||||
{
|
||||
|
@ -82,13 +82,15 @@ moo_indenter_make_space (MooIndenter *indenter,
|
||||
guint start)
|
||||
{
|
||||
guint tabs, spaces, delta;
|
||||
guint tab_width = indenter->tab_width;
|
||||
guint tab_width;
|
||||
char *string;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_INDENTER (indenter), NULL);
|
||||
|
||||
sync_settings (indenter);
|
||||
|
||||
tab_width = indenter->tab_width;
|
||||
|
||||
if (!len)
|
||||
return NULL;
|
||||
|
||||
@ -349,12 +351,15 @@ moo_indenter_tab (MooIndenter *indenter,
|
||||
{
|
||||
GtkTextIter insert, start;
|
||||
int offset, new_offset, white_space;
|
||||
guint tab_width = indenter->tab_width;
|
||||
guint indent = indenter->indent;
|
||||
guint tab_width;
|
||||
guint indent;
|
||||
char *text = NULL;
|
||||
|
||||
sync_settings (indenter);
|
||||
|
||||
tab_width = indenter->tab_width;
|
||||
indent = indenter->indent;
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &insert, gtk_text_buffer_get_insert (buffer));
|
||||
|
||||
start = insert;
|
||||
|
@ -258,7 +258,7 @@ get_lang_by_extension (MooLangMgr *mgr,
|
||||
const char *filename)
|
||||
{
|
||||
MooLang *lang = NULL;
|
||||
char *basename, *utf8_basename;
|
||||
char *basename;
|
||||
GSList *langs, *l;
|
||||
gboolean found = FALSE;
|
||||
|
||||
@ -266,11 +266,8 @@ get_lang_by_extension (MooLangMgr *mgr,
|
||||
|
||||
read_langs (mgr);
|
||||
|
||||
/* TODO: is this right? */
|
||||
basename = g_path_get_basename (filename);
|
||||
moo_return_val_if_fail (basename != NULL, NULL);
|
||||
utf8_basename = g_filename_display_name (basename);
|
||||
moo_return_val_if_fail (utf8_basename != NULL, NULL);
|
||||
|
||||
langs = moo_lang_mgr_get_available_langs (mgr);
|
||||
|
||||
@ -283,7 +280,7 @@ get_lang_by_extension (MooLangMgr *mgr,
|
||||
|
||||
for (g = globs; !found && g != NULL; g = g->next)
|
||||
{
|
||||
if (_moo_glob_match_simple ((char*) g->data, utf8_basename))
|
||||
if (_moo_glob_match_simple ((char*) g->data, basename))
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
@ -298,7 +295,6 @@ get_lang_by_extension (MooLangMgr *mgr,
|
||||
|
||||
g_slist_foreach (langs, (GFunc) g_object_unref, NULL);
|
||||
g_slist_free (langs);
|
||||
g_free (utf8_basename);
|
||||
g_free (basename);
|
||||
return lang;
|
||||
}
|
||||
@ -309,7 +305,7 @@ lang_mgr_get_lang_for_bak_filename (MooLangMgr *mgr,
|
||||
const char *filename)
|
||||
{
|
||||
MooLang *lang = NULL;
|
||||
char *utf8_name, *utf8_base = NULL;
|
||||
char *base = NULL;
|
||||
int len;
|
||||
guint i;
|
||||
|
||||
@ -317,32 +313,23 @@ lang_mgr_get_lang_for_bak_filename (MooLangMgr *mgr,
|
||||
|
||||
read_langs (mgr);
|
||||
|
||||
utf8_name = g_filename_display_name (filename);
|
||||
len = strlen (utf8_name);
|
||||
len = strlen (filename);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (bak_globs); ++i)
|
||||
{
|
||||
int ext_len = strlen (bak_globs[i]) - 1;
|
||||
|
||||
if (len > ext_len && _moo_glob_match_simple (bak_globs[i], utf8_name))
|
||||
if (len > ext_len && _moo_glob_match_simple (bak_globs[i], filename))
|
||||
{
|
||||
utf8_base = g_strndup (utf8_name, len - ext_len);
|
||||
base = g_strndup (filename, len - ext_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (utf8_base)
|
||||
{
|
||||
char *base = g_filename_from_utf8 (utf8_base, -1, NULL, NULL, NULL);
|
||||
if (base)
|
||||
lang = get_lang_for_filename (mgr, base);
|
||||
|
||||
if (base)
|
||||
lang = get_lang_for_filename (mgr, base);
|
||||
|
||||
g_free (base);
|
||||
g_free (utf8_base);
|
||||
}
|
||||
|
||||
g_free (utf8_name);
|
||||
g_free (base);
|
||||
return lang;
|
||||
}
|
||||
|
||||
@ -352,7 +339,7 @@ filename_blacklisted (MooLangMgr *mgr,
|
||||
const char *filename)
|
||||
{
|
||||
/* XXX bak files */
|
||||
char *basename, *utf8_basename;
|
||||
char *basename;
|
||||
gboolean result = FALSE;
|
||||
LangInfo *info;
|
||||
GSList *l;
|
||||
@ -361,17 +348,14 @@ filename_blacklisted (MooLangMgr *mgr,
|
||||
|
||||
basename = g_path_get_basename (filename);
|
||||
moo_return_val_if_fail (basename != NULL, FALSE);
|
||||
utf8_basename = g_filename_display_name (basename);
|
||||
moo_return_val_if_fail (utf8_basename != NULL, FALSE);
|
||||
|
||||
info = get_lang_info (mgr, MOO_LANG_NONE, FALSE);
|
||||
|
||||
if (info)
|
||||
for (l = info->globs; !result && l != NULL; l = l->next)
|
||||
if (_moo_glob_match_simple ((char*) l->data, utf8_basename))
|
||||
if (_moo_glob_match_simple ((char*) l->data, basename))
|
||||
result = TRUE;
|
||||
|
||||
g_free (utf8_basename);
|
||||
g_free (basename);
|
||||
return result;
|
||||
}
|
||||
@ -387,28 +371,31 @@ file_blacklisted (MooLangMgr *mgr,
|
||||
|
||||
MooLang *
|
||||
moo_lang_mgr_get_lang_for_file (MooLangMgr *mgr,
|
||||
const char *filename)
|
||||
GFile *file)
|
||||
{
|
||||
MooLang *lang = NULL;
|
||||
const char *mime_type;
|
||||
char *filename;
|
||||
|
||||
moo_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
moo_return_val_if_fail (filename != NULL, NULL);
|
||||
moo_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
|
||||
read_langs (mgr);
|
||||
|
||||
filename = g_file_get_parse_name (file);
|
||||
|
||||
if (file_blacklisted (mgr, filename))
|
||||
return NULL;
|
||||
goto out;
|
||||
|
||||
lang = get_lang_by_extension (mgr, filename);
|
||||
|
||||
if (lang)
|
||||
return lang;
|
||||
goto out;
|
||||
|
||||
lang = lang_mgr_get_lang_for_bak_filename (mgr, filename);
|
||||
|
||||
if (lang)
|
||||
return lang;
|
||||
goto out;
|
||||
|
||||
mime_type = moo_get_mime_type_for_file (filename, NULL);
|
||||
|
||||
@ -416,9 +403,11 @@ moo_lang_mgr_get_lang_for_file (MooLangMgr *mgr,
|
||||
lang = get_lang_for_mime_type (mgr, mime_type);
|
||||
|
||||
if (lang)
|
||||
return lang;
|
||||
goto out;
|
||||
|
||||
return NULL;
|
||||
out:
|
||||
g_free (filename);
|
||||
return lang;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ MooLangMgr *moo_lang_mgr_default (void);
|
||||
MooLang *moo_lang_mgr_get_lang (MooLangMgr *mgr,
|
||||
const char *lang_id);
|
||||
MooLang *moo_lang_mgr_get_lang_for_file (MooLangMgr *mgr,
|
||||
const char *filename);
|
||||
GFile *file);
|
||||
|
||||
/* list must be freed, content unref'ed */
|
||||
GSList *moo_lang_mgr_get_available_langs (MooLangMgr *mgr);
|
||||
|
@ -310,6 +310,9 @@ _moo_ctags_language_find_for_name (const char *lang_name)
|
||||
{
|
||||
static GHashTable *langs_hash;
|
||||
|
||||
if (!lang_name)
|
||||
return NULL;
|
||||
|
||||
if (!langs_hash)
|
||||
{
|
||||
/* default fields option is --fields=afksS */
|
||||
@ -370,7 +373,8 @@ moo_ctags_doc_plugin_update (MooCtagsDocPlugin *plugin)
|
||||
if (filename)
|
||||
{
|
||||
GSList *list = NULL;
|
||||
MooCtagsLanguage *ctags_lang = _moo_ctags_language_find_for_name (moo_edit_get_lang_id (doc));
|
||||
char *lang_id = moo_edit_get_lang_id (doc);
|
||||
MooCtagsLanguage *ctags_lang = _moo_ctags_language_find_for_name (lang_id);
|
||||
|
||||
if (ctags_lang && (list = moo_ctags_parse_file (filename, ctags_lang->opts)))
|
||||
process_entries (plugin, list, ctags_lang);
|
||||
@ -379,6 +383,7 @@ moo_ctags_doc_plugin_update (MooCtagsDocPlugin *plugin)
|
||||
|
||||
g_slist_foreach (list, (GFunc) _moo_ctags_entry_unref, NULL);
|
||||
g_slist_free (list);
|
||||
g_free (lang_id);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user