[gnome-builder] beautifier plugin: move self Builder config to gresource



commit 1f32d21c9c53c025151915788d0c2599db470826
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Sun Jan 7 22:12:26 2018 +0100

    beautifier plugin: move self Builder config to gresource

 src/plugins/beautifier/gb-beautifier-config.c      |   51 +++++++++++++-------
 src/plugins/beautifier/gb-beautifier.gresource.xml |    6 ++
 .../plugins/beautifier/self}/c/config.ini          |    0
 .../plugins/beautifier/self}/c/gb-clang-format.cfg |    0
 .../plugins/beautifier/self}/c/gb-uncrustify.cfg   |    0
 .../plugins/beautifier/self}/global.ini            |    0
 6 files changed, 40 insertions(+), 17 deletions(-)
---
diff --git a/src/plugins/beautifier/gb-beautifier-config.c b/src/plugins/beautifier/gb-beautifier-config.c
index 4312efb..af7112d 100644
--- a/src/plugins/beautifier/gb-beautifier-config.c
+++ b/src/plugins/beautifier/gb-beautifier-config.c
@@ -556,12 +556,14 @@ get_entries_worker (GTask        *task,
 {
   GbBeautifierEditorAddin *self = (GbBeautifierEditorAddin *)source_object;
   IdeContext *context;
+  IdeProject *project;
   IdeVcs *vcs;
   GArray *entries;
   GArray *map = NULL;
+  const gchar *project_name;
   g_autofree gchar *project_config_path = NULL;
   g_autofree gchar *user_config_path = NULL;
-  g_autofree gchar *configdir = NULL;
+  gchar *configdir;
   GbBeautifierEntriesResult *result;
   gboolean has_default = FALSE;
   gboolean ret_has_default = FALSE;
@@ -587,23 +589,37 @@ get_entries_worker (GTask        *task,
     g_array_free (map, TRUE);
 
   /* Project wide config */
-  if (NULL != (context = self->context) &&
-      NULL != (vcs = ide_context_get_vcs (context)))
+  if (NULL != (context = self->context))
     {
-      GFile *workdir;
-      g_autofree gchar *workdir_path = NULL;
-
-      workdir = ide_vcs_get_working_directory (vcs);
-      workdir_path = g_file_get_path (workdir);
-      project_config_path = g_build_filename (workdir_path,
-                                              ".beautifier",
-                                              NULL);
-      map = gb_beautifier_config_get_map (self, project_config_path);
-      add_entries_from_base_path (self, project_config_path, entries, map, &ret_has_default);
-      has_default |= ret_has_default;
-
-      if (map != NULL)
-        g_array_free (map, TRUE);
+      if (NULL != (project = ide_context_get_project (context)))
+        {
+          project_name = ide_project_get_name (project);
+          if (dzl_str_equal0 (project_name, "Builder"))
+            {
+              configdir = g_strdup ("resource:///org/gnome/builder/plugins/beautifier_plugin/self/");
+              map = gb_beautifier_config_get_map (self, configdir);
+              add_entries_from_base_path (self, configdir, entries, map, &ret_has_default);
+              has_default |= ret_has_default;
+              g_clear_pointer (&configdir, g_free);
+            }
+          else if (NULL != (vcs = ide_context_get_vcs (context)))
+            {
+              GFile *workdir;
+              g_autofree gchar *workdir_path = NULL;
+
+              workdir = ide_vcs_get_working_directory (vcs);
+              workdir_path = g_file_get_path (workdir);
+              project_config_path = g_build_filename (workdir_path,
+                                                      ".beautifier",
+                                                      NULL);
+              map = gb_beautifier_config_get_map (self, project_config_path);
+              add_entries_from_base_path (self, project_config_path, entries, map, &ret_has_default);
+              has_default |= ret_has_default;
+
+              if (map != NULL)
+                g_array_free (map, TRUE);
+            }
+        }
     }
 
   /* System wide config */
@@ -611,6 +627,7 @@ get_entries_worker (GTask        *task,
 
   map = gb_beautifier_config_get_map (self, configdir);
   add_entries_from_base_path (self, configdir, entries, map, &ret_has_default);
+  g_clear_pointer (&configdir, g_free);
   has_default |= ret_has_default;
 
   if (map != NULL)
diff --git a/src/plugins/beautifier/gb-beautifier.gresource.xml 
b/src/plugins/beautifier/gb-beautifier.gresource.xml
index 4346389..c520285 100644
--- a/src/plugins/beautifier/gb-beautifier.gresource.xml
+++ b/src/plugins/beautifier/gb-beautifier.gresource.xml
@@ -26,6 +26,12 @@
     <file>config/xml/config.ini</file>
   </gresource>
   <gresource prefix="/org/gnome/builder/plugins/beautifier_plugin">
+    <file>self/global.ini</file>
+    <file>self/c/config.ini</file>
+    <file>self/c/gb-clang-format.cfg</file>
+    <file>self/c/gb-uncrustify.cfg</file>
+  </gresource>
+  <gresource prefix="/org/gnome/builder/plugins/beautifier_plugin">
     <file>internal/align_makefile.py</file>
   </gresource>
 </gresources>
diff --git a/.beautifier/c/config.ini b/src/plugins/beautifier/self/c/config.ini
similarity index 100%
rename from .beautifier/c/config.ini
rename to src/plugins/beautifier/self/c/config.ini
diff --git a/.beautifier/c/gb-clang-format.cfg b/src/plugins/beautifier/self/c/gb-clang-format.cfg
similarity index 100%
rename from .beautifier/c/gb-clang-format.cfg
rename to src/plugins/beautifier/self/c/gb-clang-format.cfg
diff --git a/.beautifier/c/gb-uncrustify.cfg b/src/plugins/beautifier/self/c/gb-uncrustify.cfg
similarity index 100%
rename from .beautifier/c/gb-uncrustify.cfg
rename to src/plugins/beautifier/self/c/gb-uncrustify.cfg
diff --git a/.beautifier/global.ini b/src/plugins/beautifier/self/global.ini
similarity index 100%
rename from .beautifier/global.ini
rename to src/plugins/beautifier/self/global.ini


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]