Commit 3b3b1e53 authored by Paolo Maggi's avatar Paolo Maggi

Adapt to GtkSourceView API changes


svn path=/trunk/; revision=5855
parent 82608824
2007-08-27 Paolo Maggi <paolo@gnome.org>
* gedit/gedit-file-chooser-dialog.c (all_text_files_filter):
* gedit/gedit-language-manager.c
(gedit_language_manager_list_languages_sorted),
(gedit_language_manager_get_language_from_mime_type):
Adapt to GtkSourceView api changes.
2007-08-27 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-style-scheme-manager.[ch]: renamed and updated to
......
......@@ -152,6 +152,7 @@ filter_changed (GeditFileChooserDialog *dialog,
gedit_prefs_manager_set_active_file_filter (id);
}
/* FIXME: use globs too - Paolo (Aug. 27, 2007) */
static gboolean
all_text_files_filter (const GtkFileFilterInfo *filter_info,
gpointer data)
......@@ -162,19 +163,20 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
if (known_mime_types == NULL)
{
GtkSourceLanguageManager *lm;
GSList *languages;
GSList *l;
const gchar * const *languages;
lm = gedit_get_language_manager ();
languages = gtk_source_language_manager_list_languages (lm);
languages = gtk_source_language_manager_get_language_ids (lm);
for (l = languages; l != NULL; l = l->next)
while (*languages != NULL)
{
gchar **mime_types;
gint i;
GtkSourceLanguage *lang;
lang = l->data;
lang = gtk_source_language_manager_get_language (lm, *languages);
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), FALSE);
++languages;
mime_types = gtk_source_language_get_mime_types (lang);
if (mime_types == NULL)
......@@ -201,8 +203,6 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
g_strfreev (mime_types);
}
g_slist_free (languages);
/* known_mime_types always has "text/plain" as first item" */
known_mime_types = g_slist_prepend (known_mime_types, g_strdup ("text/plain"));
}
......
......@@ -49,37 +49,7 @@ gedit_get_language_manager (void)
return language_manager;
}
static GSList *
remove_hidden_languages (GSList *languages)
{
GSList *item;
GSList *prev;
GtkSourceLanguage *language;
prev = NULL;
item = languages;
while (item != NULL)
{
language = GTK_SOURCE_LANGUAGE(item->data);
if (gtk_source_language_get_hidden (language))
{
languages = g_slist_delete_link (languages, item);
/* Set item to start of the list if we removed the first
* language */
item = prev == NULL ? languages : prev->next;
}
else
{
prev = item;
item = item->next;
}
}
return languages;
}
static gint
language_compare (gconstpointer a, gconstpointer b)
......@@ -96,12 +66,21 @@ GSList *
gedit_language_manager_list_languages_sorted (GtkSourceLanguageManager *lm,
gboolean include_hidden)
{
GSList *languages;
GSList *languages = NULL;
const gchar * const *ids;
ids = gtk_source_language_manager_get_language_ids (lm);
while (*ids != NULL)
{
GtkSourceLanguage *lang;
languages = gtk_source_language_manager_list_languages (lm);
lang = gtk_source_language_manager_get_language (lm, *ids);
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), NULL);
++ids;
if (!include_hidden)
languages = remove_hidden_languages (languages);
if (include_hidden || !gtk_source_language_get_hidden (lang))
languages = g_slist_prepend (languages, lang);
}
return g_slist_sort (languages, (GCompareFunc)language_compare);
}
......@@ -159,8 +138,7 @@ GtkSourceLanguage *
gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm,
const gchar *mime_type)
{
GSList *languages;
GSList *l;
const gchar* const *languages;
GtkSourceLanguage *lang;
GtkSourceLanguage *parent = NULL;
......@@ -176,15 +154,17 @@ gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm
gedit_debug_message (DEBUG_DOCUMENT,
"Cache miss for %s", mime_type);
languages = gtk_source_language_manager_list_languages (lm);
languages = gtk_source_language_manager_get_language_ids (lm);
for (l = languages; l != NULL; l = l->next)
while (*languages != NULL)
{
gchar **mime_types;
gchar *found = NULL;
gint i;
lang = l->data;
lang = gtk_source_language_manager_get_language (lm, *languages);
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), NULL);
++languages;
mime_types = gtk_source_language_get_mime_types (lang);
if (mime_types == NULL)
......@@ -230,7 +210,6 @@ gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm
add_language_to_cache (lm, mime_type, lang);
g_strfreev (mime_types);
g_slist_free (languages);
return lang;
}
......@@ -238,8 +217,6 @@ gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm
g_strfreev (mime_types);
}
g_slist_free (languages);
if (parent != NULL)
add_language_to_cache (lm, mime_type, parent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment