Removed globs from lang files
parent
8b6ecb7d68
commit
65ca899745
|
@ -6,12 +6,12 @@ mooedit_tools_DATA = context.cfg menu.cfg filters.cfg
|
|||
|
||||
dummy_targets = \
|
||||
moocommand-exe.o \
|
||||
moocommand-exe-private.o
|
||||
moocommand-exe-private.o \
|
||||
moolangmgr-private.o
|
||||
CLEANFILES = $(dummy_targets)
|
||||
moocommand-exe.o: moocommand-exe-unix.o
|
||||
echo stamp > $(@F)
|
||||
moocommand-exe-private.o: moocommand-exe-unix.o
|
||||
echo stamp > $(@F)
|
||||
moocommand-exe.o: moocommand-exe-unix.o ; echo stamp > $(@F)
|
||||
moocommand-exe-private.o: moocommand-exe-unix.o ; echo stamp > $(@F)
|
||||
moolangmgr-private.o: moolangmgr.o ; echo stamp > $(@F)
|
||||
|
||||
unix_sources = \
|
||||
moocommand-exe-unix.c
|
||||
|
|
|
@ -43,9 +43,7 @@ struct _GtkSourceLanguagePrivate
|
|||
gboolean hidden;
|
||||
|
||||
GSList *mime_types;
|
||||
GSList *globs;
|
||||
|
||||
gchar *brackets;
|
||||
gchar *line_comment;
|
||||
gchar *block_comment_start;
|
||||
gchar *block_comment_end;
|
||||
|
|
|
@ -166,12 +166,10 @@ gtk_source_language_finalize (GObject *object)
|
|||
g_free (lang->priv->section);
|
||||
g_free (lang->priv->id);
|
||||
slist_deep_free (lang->priv->mime_types);
|
||||
slist_deep_free (lang->priv->globs);
|
||||
g_hash_table_destroy (lang->priv->styles);
|
||||
g_free (lang->priv->line_comment);
|
||||
g_free (lang->priv->block_comment_start);
|
||||
g_free (lang->priv->block_comment_end);
|
||||
g_free (lang->priv->brackets);
|
||||
g_free (lang->priv);
|
||||
lang->priv = NULL;
|
||||
}
|
||||
|
@ -180,8 +178,8 @@ gtk_source_language_finalize (GObject *object)
|
|||
}
|
||||
|
||||
static GSList *
|
||||
parse_mime_types_or_globs (xmlTextReaderPtr reader,
|
||||
const char *attr_name)
|
||||
parse_mime_types (xmlTextReaderPtr reader,
|
||||
const char *attr_name)
|
||||
{
|
||||
xmlChar *attr;
|
||||
gchar **mtl;
|
||||
|
@ -219,19 +217,6 @@ string_to_bool (const gchar *string)
|
|||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
process_brackets_node (xmlTextReaderPtr reader,
|
||||
GtkSourceLanguage *language)
|
||||
{
|
||||
xmlNode *node;
|
||||
|
||||
node = xmlTextReaderCurrentNode (reader);
|
||||
g_return_if_fail (node != NULL);
|
||||
g_return_if_fail (node->children != NULL);
|
||||
|
||||
language->priv->brackets = g_strdup ((gchar*) node->children->content);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_attribute (xmlTextReaderPtr reader,
|
||||
const gchar *element,
|
||||
|
@ -255,11 +240,10 @@ get_attribute (xmlTextReaderPtr reader,
|
|||
}
|
||||
|
||||
static void
|
||||
process_brackets_and_comments (xmlTextReaderPtr reader,
|
||||
GtkSourceLanguage *language)
|
||||
process_and_comments (xmlTextReaderPtr reader,
|
||||
GtkSourceLanguage *language)
|
||||
{
|
||||
gint ret;
|
||||
gboolean brackets_done = FALSE;
|
||||
gboolean line_comment_done = FALSE;
|
||||
gboolean block_comment_done = FALSE;
|
||||
|
||||
|
@ -273,20 +257,7 @@ process_brackets_and_comments (xmlTextReaderPtr reader,
|
|||
|
||||
name = xmlTextReaderName (reader);
|
||||
|
||||
if (!xmlStrcmp (name, BAD_CAST "brackets"))
|
||||
{
|
||||
if (brackets_done)
|
||||
{
|
||||
g_warning ("duplicated %s element", name);
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
process_brackets_node (reader, language);
|
||||
brackets_done = TRUE;
|
||||
}
|
||||
}
|
||||
else if (!xmlStrcmp (name, BAD_CAST "line-comment"))
|
||||
if (!xmlStrcmp (name, BAD_CAST "line-comment"))
|
||||
{
|
||||
if (line_comment_done)
|
||||
{
|
||||
|
@ -322,7 +293,7 @@ process_brackets_and_comments (xmlTextReaderPtr reader,
|
|||
}
|
||||
}
|
||||
|
||||
if (brackets_done && line_comment_done && block_comment_done)
|
||||
if (line_comment_done && block_comment_done)
|
||||
ret = 0;
|
||||
|
||||
xmlFree (name);
|
||||
|
@ -440,11 +411,10 @@ process_language_node (xmlTextReaderPtr reader, const gchar *filename)
|
|||
|
||||
xmlFree (version);
|
||||
|
||||
lang->priv->mime_types = parse_mime_types_or_globs (reader, "mimetypes");
|
||||
lang->priv->globs = parse_mime_types_or_globs (reader, "globs");
|
||||
lang->priv->mime_types = parse_mime_types (reader, "mimetypes");
|
||||
|
||||
if (lang->priv->version == GTK_SOURCE_LANGUAGE_VERSION_2_0)
|
||||
process_brackets_and_comments (reader, lang);
|
||||
process_and_comments (reader, lang);
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
@ -527,23 +497,6 @@ gtk_source_language_get_mime_types (GtkSourceLanguage *language)
|
|||
return slist_deep_copy (language->priv->mime_types);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_source_language_get_globs:
|
||||
* @language: a #GtkSourceLanguage.
|
||||
*
|
||||
* Returns a list of globs for the given @language. After usage you should
|
||||
* free each element of the list as well as the list itself.
|
||||
*
|
||||
* Return value: a list of globs (strings).
|
||||
**/
|
||||
GSList *
|
||||
gtk_source_language_get_globs (GtkSourceLanguage *language)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (language), NULL);
|
||||
|
||||
return slist_deep_copy (language->priv->globs);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_source_language_get_languages_manager:
|
||||
* @language: a #GtkSourceLanguage.
|
||||
|
|
|
@ -64,8 +64,6 @@ gint gtk_source_language_get_version (GtkSourceLanguage *language);
|
|||
|
||||
/* Should free the list (and free each string in it also). */
|
||||
GSList *gtk_source_language_get_mime_types (GtkSourceLanguage *language);
|
||||
/* Should free the list (and free each string in it also). */
|
||||
GSList *gtk_source_language_get_globs (GtkSourceLanguage *language);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -452,55 +452,6 @@ gtk_source_languages_manager_get_language_for_mime_type (GtkSourceLanguagesManag
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_source_languages_manager_get_language_for_filename:
|
||||
* @lm: a #GtkSourceLanguagesManager.
|
||||
* @filename: a filename in glib filename encoding.
|
||||
*
|
||||
* Return value: a #GtkSourceLanguage, or %NULL if there is no language
|
||||
* with glob matching @filename.
|
||||
**/
|
||||
/* FIXME use xdgmimeglob */
|
||||
GtkSourceLanguage *
|
||||
gtk_source_languages_manager_get_language_for_filename (GtkSourceLanguagesManager *lm,
|
||||
const gchar *filename)
|
||||
{
|
||||
const GSList *languages;
|
||||
char *utf8_filename;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
|
||||
g_return_val_if_fail (utf8_filename != NULL, NULL);
|
||||
|
||||
languages = gtk_source_languages_manager_get_available_languages (lm);
|
||||
|
||||
while (languages != NULL)
|
||||
{
|
||||
GSList *globs, *tmp;
|
||||
GtkSourceLanguage *lang = languages->data;
|
||||
|
||||
tmp = globs = gtk_source_language_get_globs (lang);
|
||||
|
||||
while (tmp != NULL)
|
||||
{
|
||||
if (g_pattern_match_simple (tmp->data, utf8_filename))
|
||||
break;
|
||||
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
|
||||
slist_deep_free (globs);
|
||||
|
||||
if (tmp != NULL)
|
||||
return lang;
|
||||
|
||||
languages = g_slist_next (languages);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_source_languages_manager_get_language_by_id:
|
||||
* @lm: a #GtkSourceLanguagesManager.
|
||||
|
|
|
@ -67,9 +67,6 @@ GtkSourceLanguage *gtk_source_languages_manager_get_language_by_id (GtkSource
|
|||
GtkSourceLanguage *gtk_source_languages_manager_get_language_for_mime_type
|
||||
(GtkSourceLanguagesManager *lm,
|
||||
const gchar *mime_type);
|
||||
GtkSourceLanguage *gtk_source_languages_manager_get_language_for_filename
|
||||
(GtkSourceLanguagesManager *lm,
|
||||
const gchar *filename);
|
||||
|
||||
/* Property */
|
||||
const GSList *gtk_source_languages_manager_get_lang_files_dirs (GtkSourceLanguagesManager *lm);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="c" _name="C" version="2.0" _section="Sources"
|
||||
mimetypes="text/x-c;text/x-chdr;text/x-csrc"
|
||||
globs="*.c;*.h">
|
||||
mimetypes="text/x-c;text/x-chdr;text/x-csrc">
|
||||
<styles>
|
||||
<style id="comment" _name="Comment" map-to="def:comment"/>
|
||||
<style id="error" _name="Error" map-to="def:error"/>
|
||||
|
@ -225,7 +224,6 @@
|
|||
</context>
|
||||
</definitions>
|
||||
|
||||
<brackets>(){}[]</brackets>
|
||||
<line-comment start="//"/>
|
||||
<block-comment start="/*" end="*/"/>
|
||||
</language>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="changelog" _name="ChangeLog" version="2.0" _section="Others"
|
||||
mimetypes="text/x-changelog" globs="ChangeLog;ChangeLog.*">
|
||||
mimetypes="text/x-changelog">
|
||||
|
||||
<styles>
|
||||
<style id="date" name="Date" map-to="def:data-type"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# specified here.
|
||||
|
||||
langs="c.lang cpp.lang changelog.lang def.lang \
|
||||
html.lang javascript.lang latex.lang ms.lang \
|
||||
html.lang javascript.lang latex.lang \
|
||||
m4.lang makefile.lang xml.lang yacc.lang \
|
||||
sh.lang python.lang"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="cpp" _name="C++" version="2.0" _section="Sources"
|
||||
mimetypes="text/x-c++;text/x-cpp;text/x-c-header;text/x-c++src;text/x-c++hdr"
|
||||
globs="*.cc;*.hh;*.cpp;*.hpp;*.cxx;*.hxx;*.C">
|
||||
mimetypes="text/x-c++;text/x-cpp;text/x-c-header;text/x-c++src;text/x-c++hdr">
|
||||
<styles>
|
||||
<style id="common-defines" _name="Common defines" map-to="c:common-defines"/>
|
||||
</styles>
|
||||
|
@ -68,7 +67,6 @@
|
|||
</context>
|
||||
</definitions>
|
||||
|
||||
<brackets>(){}[]</brackets>
|
||||
<line-comment start="//"/>
|
||||
<block-comment start="/*" end="*/"/>
|
||||
</language>
|
||||
|
|
|
@ -27,15 +27,15 @@
|
|||
<define-regex id="never-match">$^</define-regex>
|
||||
|
||||
<define-regex id="decimal" extended="true">
|
||||
([1-9][0-9]* | 0)
|
||||
(?<![\w\.]) ([1-9][0-9]* | 0) (?![\w\.])
|
||||
</define-regex>
|
||||
<define-regex id="octal" extended="true">
|
||||
0 [0-7]+
|
||||
(?<![\w\.]) 0 [0-7]+ (?![\w\.])
|
||||
</define-regex>
|
||||
<define-regex id="hexadecimal" extended="true">
|
||||
0 [xX] [0-9a-fA-F]+
|
||||
(?<![\w\.]) 0 [xX] [0-9a-fA-F]+ (?![\w\.])
|
||||
</define-regex>
|
||||
<!-- FIXME: these one is broke, and is it useful at all? -->
|
||||
<!-- FIXME: these one is broken, and is it useful at all? -->
|
||||
<define-regex id="float" extended="true" case-insensitive="true">
|
||||
\b
|
||||
([0-9]+ e [-+]? [0-9]+ |
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="diff" _name="Diff" version="2.0" _section="Others"
|
||||
mimetypes="text/x-diff;text/x-patch" globs="*.diff;*.patch">
|
||||
mimetypes="text/x-diff;text/x-patch">
|
||||
|
||||
<styles>
|
||||
<style id="added-line" _name="Added line"/> <!--Others 2-->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="html" _name="HTML" version="2.0" _section="Markup"
|
||||
mimetypes="text/html" globs="*.htm;*.html">
|
||||
mimetypes="text/html">
|
||||
<styles>
|
||||
<style id="comment" _name="Comment"
|
||||
map-to="xml:comment"/>
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
<optional>
|
||||
<attribute name="mimetypes"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="globs"/>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<ref name="metadata"/>
|
||||
|
@ -58,11 +55,6 @@
|
|||
|
||||
<ref name="definitions" />
|
||||
|
||||
<optional>
|
||||
<element name="brackets">
|
||||
<text/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="line-comment">
|
||||
<attribute name="start"/>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="m4" _name="m4" _section="Scripts" version="2.0"
|
||||
mimetypes="application/x-m4" globs="*.m4;configure.in;configure.ac">
|
||||
<language id="m4" _name="m4" _section="Scripts" version="2.0" mimetypes="application/x-m4">
|
||||
<styles>
|
||||
<style id="m4-comment" name="m4-comment" map-to="sh:comment"/>
|
||||
</styles>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="makefile" _name="Makefile" version="2.0" _section="Sources"
|
||||
mimetypes="text/x-makefile" globs="Makefile*">
|
||||
mimetypes="text/x-makefile">
|
||||
<styles>
|
||||
<style id="variable" name="Variable" map-to="def:data-type"/>
|
||||
<style id="assignment-rhs" name="assignment-rhs"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="mooscript" name="MooScript" version="2.0" _section="Scripts"
|
||||
mimetypes="text/x-mooscript;application/x-mooscript" globs="*.ms">
|
||||
mimetypes="text/x-mooscript;application/x-mooscript">
|
||||
|
||||
<styles>
|
||||
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
|
||||
|
@ -48,7 +48,6 @@
|
|||
</context>
|
||||
</definitions>
|
||||
|
||||
<brackets>()[]{}</brackets>
|
||||
<line-comment start="#"/>
|
||||
|
||||
</language>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="python" _name="Python" version="2.0" _section="Scripts"
|
||||
mimetypes="text/x-python;application/x-python" globs="*.py">
|
||||
mimetypes="text/x-python;application/x-python">
|
||||
|
||||
<styles>
|
||||
<style id="special-variables" _name="Special variables" map-to="def:data-type"/>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="xml" _name="XML" version="2.0" _section="Markup"
|
||||
mimetypes="application/xml;text/xml;image/svg+xml,text/rdf"
|
||||
globs="*.xml;*.rdf;*.svg;*.rng;*.lang;*.xslt">
|
||||
mimetypes="application/xml;text/xml;image/svg+xml;text/rdf">
|
||||
<styles>
|
||||
<style id="comment" _name="Comment" map-to="def:comment"/>
|
||||
<style id="doctype" _name="DOCTYPE"/>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="yacc" _name="Yacc" _section="Others"
|
||||
version="2.0"
|
||||
mimetypes="text/x-yacc;text/x-bison"
|
||||
globs="*.yacc;*.y">
|
||||
mimetypes="text/x-yacc;text/x-bison">
|
||||
<styles>
|
||||
<style id="inline-c" _name="Inline C Code" map-to="def:keyword"/>
|
||||
<style id="grammar" _name="grammar" map-to="def:keyword"/>
|
||||
|
@ -54,7 +53,6 @@
|
|||
</context>
|
||||
</definitions>
|
||||
|
||||
<brackets>()[]</brackets>
|
||||
<line-comment start="//"/>
|
||||
<block-comment start="/*" end="*/"/>
|
||||
</language>
|
||||
|
|
|
@ -357,7 +357,7 @@ create_lang_model (MooEditor *editor)
|
|||
|
||||
gtk_tree_store_append (store, &iter, NULL);
|
||||
config = _moo_lang_mgr_get_config (mgr, MOO_LANG_NONE);
|
||||
ext = list_to_string (_moo_lang_mgr_get_extensions (mgr, NULL), TRUE);
|
||||
ext = list_to_string (_moo_lang_mgr_get_globs (mgr, NULL), TRUE);
|
||||
mime = list_to_string (_moo_lang_mgr_get_mime_types (mgr, NULL), TRUE);
|
||||
gtk_tree_store_set (store, &iter, COLUMN_ID, MOO_LANG_NONE,
|
||||
COLUMN_NAME, "None",
|
||||
|
@ -388,7 +388,7 @@ create_lang_model (MooEditor *editor)
|
|||
GtkTreeIter child;
|
||||
char *ext, *mime;
|
||||
|
||||
ext = list_to_string (_moo_lang_mgr_get_extensions (mgr, _moo_lang_id (lang)), TRUE);
|
||||
ext = list_to_string (_moo_lang_mgr_get_globs (mgr, _moo_lang_id (lang)), TRUE);
|
||||
mime = list_to_string (_moo_lang_mgr_get_mime_types (mgr, _moo_lang_id (lang)), TRUE);
|
||||
|
||||
config = _moo_lang_mgr_get_config (mgr, _moo_lang_id (lang));
|
||||
|
@ -679,7 +679,7 @@ apply_one_lang (GtkTreeModel *model,
|
|||
COLUMN_EXTENSIONS, &ext, -1);
|
||||
|
||||
_moo_lang_mgr_set_mime_types (mgr, id, mime);
|
||||
_moo_lang_mgr_set_extensions (mgr, id, ext);
|
||||
_moo_lang_mgr_set_globs (mgr, id, ext);
|
||||
_moo_lang_mgr_set_config (mgr, id, config);
|
||||
|
||||
if (lang)
|
||||
|
|
|
@ -193,7 +193,7 @@ const char *
|
|||
_moo_lang_get_brackets (MooLang *lang)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_LANG (lang), NULL);
|
||||
return GTK_SOURCE_LANGUAGE(lang)->priv->brackets;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ struct _MooLangMgr {
|
|||
GtkSourceLanguagesManager base;
|
||||
|
||||
GHashTable *langs;
|
||||
GHashTable *extensions;
|
||||
GHashTable *globs;
|
||||
GHashTable *mime_types;
|
||||
GHashTable *config;
|
||||
GHashTable *schemes;
|
||||
|
|
|
@ -57,8 +57,8 @@ moo_lang_mgr_init (MooLangMgr *mgr)
|
|||
|
||||
mgr->langs = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
mgr->extensions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
(GDestroyNotify) string_list_free);
|
||||
mgr->globs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
(GDestroyNotify) string_list_free);
|
||||
mgr->mime_types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
(GDestroyNotify) string_list_free);
|
||||
mgr->config = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
|
@ -87,12 +87,12 @@ moo_lang_mgr_dispose (GObject *object)
|
|||
{
|
||||
g_hash_table_destroy (mgr->langs);
|
||||
g_hash_table_destroy (mgr->config);
|
||||
g_hash_table_destroy (mgr->extensions);
|
||||
g_hash_table_destroy (mgr->globs);
|
||||
g_hash_table_destroy (mgr->mime_types);
|
||||
g_hash_table_destroy (mgr->schemes);
|
||||
mgr->langs = NULL;
|
||||
mgr->config = NULL;
|
||||
mgr->extensions = NULL;
|
||||
mgr->globs = NULL;
|
||||
mgr->mime_types = NULL;
|
||||
mgr->active_scheme = NULL;
|
||||
mgr->schemes = NULL;
|
||||
|
@ -134,7 +134,7 @@ string_list_copy (GSList *list)
|
|||
list = list->next;
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
return g_slist_reverse (copy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -190,12 +190,12 @@ get_lang_by_extension (MooLangMgr *mgr,
|
|||
|
||||
for (l = langs; !found && l != NULL; l = l->next)
|
||||
{
|
||||
GSList *g, *extensions;
|
||||
GSList *g, *globs;
|
||||
|
||||
lang = l->data;
|
||||
extensions = _moo_lang_mgr_get_extensions (mgr, _moo_lang_id (lang));
|
||||
globs = _moo_lang_mgr_get_globs (mgr, _moo_lang_id (lang));
|
||||
|
||||
for (g = extensions; !found && g != NULL; g = g->next)
|
||||
for (g = globs; !found && g != NULL; g = g->next)
|
||||
{
|
||||
if (g_pattern_match_simple ((char*) g->data, utf8_basename))
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ get_lang_by_extension (MooLangMgr *mgr,
|
|||
}
|
||||
}
|
||||
|
||||
string_list_free (extensions);
|
||||
string_list_free (globs);
|
||||
}
|
||||
|
||||
if (!found)
|
||||
|
@ -268,24 +268,24 @@ filename_blacklisted (MooLangMgr *mgr,
|
|||
/* XXX bak files */
|
||||
char *basename, *utf8_basename;
|
||||
gboolean result = FALSE;
|
||||
GSList *extensions;
|
||||
GSList *globs;
|
||||
|
||||
basename = g_path_get_basename (filename);
|
||||
g_return_val_if_fail (basename != NULL, FALSE);
|
||||
utf8_basename = g_filename_display_name (basename);
|
||||
g_return_val_if_fail (utf8_basename != NULL, FALSE);
|
||||
|
||||
extensions = g_hash_table_lookup (mgr->extensions, MOO_LANG_NONE);
|
||||
globs = g_hash_table_lookup (mgr->globs, MOO_LANG_NONE);
|
||||
|
||||
while (extensions)
|
||||
while (globs)
|
||||
{
|
||||
if (g_pattern_match_simple ((char*) extensions->data, utf8_basename))
|
||||
if (g_pattern_match_simple ((char*) globs->data, utf8_basename))
|
||||
{
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
extensions = extensions->next;
|
||||
globs = globs->next;
|
||||
}
|
||||
|
||||
g_free (utf8_basename);
|
||||
|
@ -529,7 +529,8 @@ load_lang_node (MooLangMgr *mgr,
|
|||
{
|
||||
const char *string = moo_markup_get_content (node);
|
||||
GSList *list = parse_string_list (string);
|
||||
g_hash_table_insert (mgr->extensions, g_strdup (lang_id), list);
|
||||
if (list)
|
||||
g_hash_table_insert (mgr->globs, g_strdup (lang_id), list);
|
||||
}
|
||||
else if (!strcmp (node->name, ELEMENT_MIME_TYPES))
|
||||
{
|
||||
|
@ -717,45 +718,21 @@ moo_lang_mgr_get_available_langs (MooLangMgr *mgr)
|
|||
}
|
||||
|
||||
|
||||
static GSList *
|
||||
get_string_list (MooLangMgr *mgr,
|
||||
const char *lang_id,
|
||||
GHashTable *hash,
|
||||
gpointer func)
|
||||
GSList *
|
||||
_moo_lang_mgr_get_globs (MooLangMgr *mgr,
|
||||
const char *lang_id)
|
||||
{
|
||||
char *id;
|
||||
MooLang *lang;
|
||||
GSList *extensions;
|
||||
gpointer orig_key;
|
||||
GSList *globs, *ret;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
|
||||
id = _moo_lang_id_from_name (lang_id);
|
||||
globs = g_hash_table_lookup (mgr->globs, id);
|
||||
ret = string_list_copy (globs);
|
||||
|
||||
if (g_hash_table_lookup_extended (hash, id, &orig_key, (gpointer*) &extensions))
|
||||
{
|
||||
g_free (id);
|
||||
return string_list_copy (extensions);
|
||||
}
|
||||
|
||||
lang = moo_lang_mgr_get_lang (mgr, id);
|
||||
g_free (id);
|
||||
|
||||
if (lang)
|
||||
{
|
||||
GSList *(*get_stuff) (GtkSourceLanguage*) = func;
|
||||
return get_stuff (GTK_SOURCE_LANGUAGE (lang));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
GSList *
|
||||
_moo_lang_mgr_get_extensions (MooLangMgr *mgr,
|
||||
const char *lang_id)
|
||||
{
|
||||
return get_string_list (mgr, lang_id, mgr->mime_types, gtk_source_language_get_globs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -763,7 +740,28 @@ GSList *
|
|||
_moo_lang_mgr_get_mime_types (MooLangMgr *mgr,
|
||||
const char *lang_id)
|
||||
{
|
||||
return get_string_list (mgr, lang_id, mgr->mime_types, gtk_source_language_get_mime_types);
|
||||
char *id;
|
||||
MooLang *lang;
|
||||
GSList *mime_types;
|
||||
gpointer orig_key;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
|
||||
id = _moo_lang_id_from_name (lang_id);
|
||||
|
||||
if (g_hash_table_lookup_extended (mgr->mime_types, id, &orig_key, (gpointer*) &mime_types))
|
||||
{
|
||||
g_free (id);
|
||||
return string_list_copy (mime_types);
|
||||
}
|
||||
|
||||
lang = moo_lang_mgr_get_lang (mgr, id);
|
||||
g_free (id);
|
||||
|
||||
if (lang)
|
||||
return gtk_source_language_get_mime_types (GTK_SOURCE_LANGUAGE (lang));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -832,13 +830,22 @@ _moo_lang_mgr_set_mime_types (MooLangMgr *mgr,
|
|||
|
||||
|
||||
void
|
||||
_moo_lang_mgr_set_extensions (MooLangMgr *mgr,
|
||||
const char *lang_id,
|
||||
const char *extensions)
|
||||
_moo_lang_mgr_set_globs (MooLangMgr *mgr,
|
||||
const char *lang_id,
|
||||
const char *globs)
|
||||
{
|
||||
GSList *list;
|
||||
char *id;
|
||||
|
||||
g_return_if_fail (MOO_IS_LANG_MGR (mgr));
|
||||
set_strings_list (mgr, lang_id, extensions, mgr->extensions,
|
||||
gtk_source_language_get_globs);
|
||||
|
||||
list = parse_string_list (globs);
|
||||
id = _moo_lang_id_from_name (lang_id);
|
||||
|
||||
if (list)
|
||||
g_hash_table_insert (mgr->globs, id, list);
|
||||
else
|
||||
g_free (id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -941,16 +948,16 @@ static void
|
|||
save_one_lang (MooMarkupNode *root,
|
||||
const char *lang_id,
|
||||
const char *config,
|
||||
GSList *extensions,
|
||||
gboolean save_extensions,
|
||||
GSList *globs,
|
||||
gboolean save_globs,
|
||||
GSList *mimetypes,
|
||||
gboolean save_mimetypes)
|
||||
{
|
||||
MooMarkupNode *lang_node = NULL;
|
||||
|
||||
if (save_extensions)
|
||||
if (save_globs)
|
||||
{
|
||||
char *string = list_to_string (extensions);
|
||||
char *string = list_to_string (globs);
|
||||
lang_node = create_lang_node (root, lang_node, lang_id);
|
||||
moo_markup_create_text_element (lang_node, ELEMENT_EXTENSIONS, string);
|
||||
g_free (string);
|
||||
|
@ -979,18 +986,17 @@ save_one (MooLangMgr *mgr,
|
|||
MooMarkupNode **root)
|
||||
{
|
||||
const char *config;
|
||||
GSList *extensions = NULL, *mimetypes = NULL;
|
||||
gboolean has_extensions, has_mimetypes;
|
||||
gpointer dummy;
|
||||
GSList *globs = NULL, *mimetypes = NULL;
|
||||
gboolean has_mimetypes;
|
||||
|
||||
id = lang ? _moo_lang_id (lang) : id;
|
||||
g_return_if_fail (id != NULL);
|
||||
|
||||
config = g_hash_table_lookup (mgr->config, id);
|
||||
has_extensions = g_hash_table_lookup_extended (mgr->extensions, id, &dummy, (gpointer*) &extensions);
|
||||
has_mimetypes = g_hash_table_lookup_extended (mgr->mime_types, id, &dummy, (gpointer*) &mimetypes);
|
||||
globs = g_hash_table_lookup (mgr->globs, id);
|
||||
has_mimetypes = g_hash_table_lookup_extended (mgr->mime_types, id, NULL, (gpointer*) &mimetypes);
|
||||
|
||||
if (!config && !has_extensions && !has_mimetypes)
|
||||
if (!config && !globs && !has_mimetypes)
|
||||
return;
|
||||
|
||||
if (!*root)
|
||||
|
@ -999,7 +1005,7 @@ save_one (MooLangMgr *mgr,
|
|||
g_return_if_fail (*root != NULL);
|
||||
|
||||
save_one_lang (*root, id, config,
|
||||
extensions, has_extensions,
|
||||
globs, globs != NULL,
|
||||
mimetypes, has_mimetypes);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void _moo_lang_mgr_set_active_scheme (MooLangMgr *mgr,
|
|||
GSList *_moo_lang_mgr_list_schemes (MooLangMgr *mgr);
|
||||
|
||||
/* list must be freed together with content */
|
||||
GSList *_moo_lang_mgr_get_extensions (MooLangMgr *mgr,
|
||||
GSList *_moo_lang_mgr_get_globs (MooLangMgr *mgr,
|
||||
const char *lang_id);
|
||||
/* list must be freed together with content */
|
||||
GSList *_moo_lang_mgr_get_mime_types (MooLangMgr *mgr,
|
||||
|
@ -57,9 +57,9 @@ GSList *_moo_lang_mgr_get_mime_types (MooLangMgr *mgr,
|
|||
void _moo_lang_mgr_set_mime_types (MooLangMgr *mgr,
|
||||
const char *lang_id,
|
||||
const char *mime);
|
||||
void _moo_lang_mgr_set_extensions (MooLangMgr *mgr,
|
||||
void _moo_lang_mgr_set_globs (MooLangMgr *mgr,
|
||||
const char *lang_id,
|
||||
const char *extensions);
|
||||
const char *globs);
|
||||
const char *_moo_lang_mgr_get_config (MooLangMgr *mgr,
|
||||
const char *lang_id);
|
||||
void _moo_lang_mgr_set_config (MooLangMgr *mgr,
|
||||
|
|
Loading…
Reference in New Issue