[gnome-builder] snippets: merge c and chdr snippets together when reloading.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] snippets: merge c and chdr snippets together when reloading.
- Date: Tue, 9 Sep 2014 21:24:03 +0000 (UTC)
commit 02a9cfeb2cb13a147dfb229ca7042f73aa133a24
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 9 14:23:57 2014 -0700
snippets: merge c and chdr snippets together when reloading.
src/editor/gb-editor-tab.c | 20 +++++++++++++++++++-
src/editor/gb-source-snippets-manager.c | 3 ---
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 44cb734..a1a5401 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -389,7 +389,25 @@ gb_editor_tab_reload_snippets (GbEditorTab *tab,
if (language)
{
manager = gb_source_snippets_manager_get_default ();
- snippets = gb_source_snippets_manager_get_for_language (manager, language);
+
+ if (g_str_equal (gtk_source_language_get_id (language), "chdr"))
+ {
+ GtkSourceLanguageManager *lm;
+ GtkSourceLanguage *l;
+ GbSourceSnippets *other;
+
+ lm = gtk_source_language_manager_get_default ();
+ l = gtk_source_language_manager_get_language (lm, "c");
+ snippets = gb_source_snippets_manager_get_for_language (manager, l);
+ other = gb_source_snippets_manager_get_for_language (manager,
+ language);
+
+ gb_source_snippets_merge (snippets, other);
+ }
+ else
+ snippets = gb_source_snippets_manager_get_for_language (manager,
+ language);
+
}
g_object_set (priv->snippets_provider, "snippets", snippets, NULL);
diff --git a/src/editor/gb-source-snippets-manager.c b/src/editor/gb-source-snippets-manager.c
index 4f3fb86..e7afb04 100644
--- a/src/editor/gb-source-snippets-manager.c
+++ b/src/editor/gb-source-snippets-manager.c
@@ -150,9 +150,6 @@ gb_source_snippets_manager_get_for_language (GbSourceSnippetsManager *manager,
language_id = gtk_source_language_get_id (language);
snippets = g_hash_table_lookup (priv->by_language_id, language_id);
- if (!snippets && g_str_equal (language_id, "chdr"))
- snippets = g_hash_table_lookup (priv->by_language_id, "c");
-
return snippets;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]