[gnome-builder] beautifier plugin: move config files to gresource
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] beautifier plugin: move config files to gresource
- Date: Sun, 7 Jan 2018 21:20:21 +0000 (UTC)
commit 8cd0bcf3440c983f0d236ae04bf1502a0f5d8484
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sat Jan 6 00:47:59 2018 +0100
beautifier plugin: move config files to gresource
We can also now build the plugin as an embedded one
src/plugins/beautifier/beautifier.plugin | 1 +
.../data => config}/automake/config.ini | 0
.../data => config}/c-sharp/config.ini | 0
.../data => config}/c-sharp/mono.cfg | 0
.../data => config}/c/config.ini | 2 +-
.../data => config}/c/gnu-indent.cfg | 0
.../data/c/k&r.cfg => config/c/kr.cfg} | 0
.../data => config}/c/linux-kernel.cfg | 0
.../data => config}/d/config.ini | 0
.../{beautifier_plugin/data => config}/d/d.cfg | 2 -
.../{beautifier_plugin/data => config}/global.ini | 0
.../data => config}/html/config.ini | 0
.../data => config}/html/tidy-autoindent.cfg | 0
.../data => config}/html/tidy-indent.cfg | 0
.../data => config}/objc/config.ini | 0
.../data => config}/objc/objc.cfg | 0
.../data => config}/python/config.ini | 0
.../data => config}/xml/config.ini | 0
src/plugins/beautifier/gb-beautifier-config.c | 310 +++++++++++++++-----
src/plugins/beautifier/gb-beautifier-config.h | 28 ++-
.../beautifier/gb-beautifier-editor-addin.c | 55 +++-
src/plugins/beautifier/gb-beautifier-helper.c | 144 +++++++++-
src/plugins/beautifier/gb-beautifier-helper.h | 31 ++-
src/plugins/beautifier/gb-beautifier-plugin.c | 2 +-
src/plugins/beautifier/gb-beautifier-process.c | 83 ++----
src/plugins/beautifier/gb-beautifier.gresource.xml | 25 ++
.../internal/align_makefile.py | 0
src/plugins/beautifier/meson.build | 23 +--
28 files changed, 517 insertions(+), 189 deletions(-)
---
diff --git a/src/plugins/beautifier/beautifier.plugin b/src/plugins/beautifier/beautifier.plugin
index 9cc60c9..d30494d 100644
--- a/src/plugins/beautifier/beautifier.plugin
+++ b/src/plugins/beautifier/beautifier.plugin
@@ -6,3 +6,4 @@ Authors=Sébastien Lafargue <slafargue gnome org>
Copyright=Copyright © 2016 Sébastien Lafargue
Depends=editor
Builtin=true
+Embedded=gb_beautifier_register_types
diff --git a/src/plugins/beautifier/beautifier_plugin/data/automake/config.ini
b/src/plugins/beautifier/config/automake/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/automake/config.ini
rename to src/plugins/beautifier/config/automake/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c-sharp/config.ini
b/src/plugins/beautifier/config/c-sharp/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/c-sharp/config.ini
rename to src/plugins/beautifier/config/c-sharp/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c-sharp/mono.cfg
b/src/plugins/beautifier/config/c-sharp/mono.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/c-sharp/mono.cfg
rename to src/plugins/beautifier/config/c-sharp/mono.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c/config.ini
b/src/plugins/beautifier/config/c/config.ini
similarity index 95%
rename from src/plugins/beautifier/beautifier_plugin/data/c/config.ini
rename to src/plugins/beautifier/config/c/config.ini
index 6cea913..974044e 100644
--- a/src/plugins/beautifier/beautifier_plugin/data/c/config.ini
+++ b/src/plugins/beautifier/config/c/config.ini
@@ -13,7 +13,7 @@ name = Gnu identation
[k&r]
command-pattern = uncrustify -c @c@ -f @s@
-config = k&r.cfg
+config = kr.cfg
name = Kernighan and Ritchie
[linux-kernel]
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c/gnu-indent.cfg
b/src/plugins/beautifier/config/c/gnu-indent.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/c/gnu-indent.cfg
rename to src/plugins/beautifier/config/c/gnu-indent.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c/k&r.cfg b/src/plugins/beautifier/config/c/kr.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/c/k&r.cfg
rename to src/plugins/beautifier/config/c/kr.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/c/linux-kernel.cfg
b/src/plugins/beautifier/config/c/linux-kernel.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/c/linux-kernel.cfg
rename to src/plugins/beautifier/config/c/linux-kernel.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/d/config.ini
b/src/plugins/beautifier/config/d/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/d/config.ini
rename to src/plugins/beautifier/config/d/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/d/d.cfg b/src/plugins/beautifier/config/d/d.cfg
similarity index 99%
rename from src/plugins/beautifier/beautifier_plugin/data/d/d.cfg
rename to src/plugins/beautifier/config/d/d.cfg
index da8cb5d..61d02c2 100644
--- a/src/plugins/beautifier/beautifier_plugin/data/d/d.cfg
+++ b/src/plugins/beautifier/config/d/d.cfg
@@ -72,7 +72,6 @@ align_var_struct_span = 3
align_right_cmt_span = 3
align_pp_define_span = 3
align_pp_define_gap = 4
-align_number_left = TRUE
align_typedef_span = 5
align_typedef_gap = 3
@@ -80,4 +79,3 @@ align_typedef_gap = 3
eat_blanks_before_close_brace = TRUE
eat_blanks_after_open_brace = TRUE
-
diff --git a/src/plugins/beautifier/beautifier_plugin/data/global.ini
b/src/plugins/beautifier/config/global.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/global.ini
rename to src/plugins/beautifier/config/global.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/html/config.ini
b/src/plugins/beautifier/config/html/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/html/config.ini
rename to src/plugins/beautifier/config/html/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/html/tidy-autoindent.cfg
b/src/plugins/beautifier/config/html/tidy-autoindent.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/html/tidy-autoindent.cfg
rename to src/plugins/beautifier/config/html/tidy-autoindent.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/html/tidy-indent.cfg
b/src/plugins/beautifier/config/html/tidy-indent.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/html/tidy-indent.cfg
rename to src/plugins/beautifier/config/html/tidy-indent.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/objc/config.ini
b/src/plugins/beautifier/config/objc/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/objc/config.ini
rename to src/plugins/beautifier/config/objc/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/objc/objc.cfg
b/src/plugins/beautifier/config/objc/objc.cfg
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/objc/objc.cfg
rename to src/plugins/beautifier/config/objc/objc.cfg
diff --git a/src/plugins/beautifier/beautifier_plugin/data/python/config.ini
b/src/plugins/beautifier/config/python/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/python/config.ini
rename to src/plugins/beautifier/config/python/config.ini
diff --git a/src/plugins/beautifier/beautifier_plugin/data/xml/config.ini
b/src/plugins/beautifier/config/xml/config.ini
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/data/xml/config.ini
rename to src/plugins/beautifier/config/xml/config.ini
diff --git a/src/plugins/beautifier/gb-beautifier-config.c b/src/plugins/beautifier/gb-beautifier-config.c
index 4db490d..4312efb 100644
--- a/src/plugins/beautifier/gb-beautifier-config.c
+++ b/src/plugins/beautifier/gb-beautifier-config.c
@@ -19,26 +19,15 @@
#define G_LOG_DOMAIN "beautifier-config"
#include <string.h>
+
+#include <glib/gstdio.h>
#include <ide.h>
#include <libpeas/peas.h>
+#include "gb-beautifier-helper.h"
#include "gb-beautifier-private.h"
#include "gb-beautifier-config.h"
-static const gchar *
-get_datadir (void)
-{
- PeasEngine *engine;
- PeasPluginInfo *info;
- const gchar *datadir = NULL;
-
- engine = peas_engine_get_default ();
- if (NULL != (info = peas_engine_get_plugin_info (engine, "beautifier_plugin")))
- datadir = peas_plugin_info_get_data_dir (info);
-
- return datadir;
-}
-
static void
config_entry_clear_func (gpointer data)
{
@@ -46,15 +35,13 @@ config_entry_clear_func (gpointer data)
g_assert (entry != NULL);
- /* Some entries don't have a config file */
- if (entry->config_file != NULL)
- g_object_unref (entry->config_file);
+ g_clear_object (&entry->config_file);
g_free (entry->name);
g_free (entry->lang_id);
if (entry->command_args != NULL)
- g_ptr_array_unref (entry->command_args);
+ g_array_unref (entry->command_args);
}
static void
@@ -69,6 +56,16 @@ map_entry_clear_func (gpointer data)
g_free (entry->default_profile);
}
+static void
+command_arg_clear_func (gpointer data)
+{
+ GbBeautifierCommandArg *arg = (GbBeautifierCommandArg *)data;
+
+ g_assert (arg != NULL);
+
+ g_clear_pointer (&arg->str, g_free);
+}
+
static gboolean
gb_beautifier_config_check_duplicates (GbBeautifierEditorAddin *self,
GArray *entries,
@@ -120,6 +117,34 @@ gb_beautifier_map_check_duplicates (GbBeautifierEditorAddin *self,
return FALSE;
}
+gchar *
+copy_to_tmp_file (const gchar *source_path,
+ gboolean is_executable)
+{
+ g_autoptr (GFile) file = NULL;
+ g_autoptr (GFile) tmp_file = NULL;
+ g_autoptr (GError) error = NULL;
+ GFileIOStream *stream;
+ gchar *tmp_path;
+
+ file = g_file_new_for_uri (source_path);
+ if (NULL == (tmp_file = g_file_new_tmp ("gnome-builder-beautifier-XXXXXX.txt", &stream, &error)) ||
+ !g_io_stream_close (G_IO_STREAM (stream), NULL, &error) ||
+ !g_file_copy (file, tmp_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
+ {
+ g_warning ("beautifier plugin: error copying the gresource config file:%s",
+ error->message);
+
+ return NULL;
+ }
+
+ tmp_path = g_file_get_path (tmp_file);
+ if (is_executable)
+ g_chmod (tmp_path, 0777);
+
+ return tmp_path;
+}
+
static gboolean
add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
const gchar *base_path,
@@ -132,11 +157,13 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
{
g_autoptr(GKeyFile) key_file = NULL;
g_autofree gchar *ini_path = NULL;
+ g_autoptr(GFile) file = NULL;
g_auto(GStrv) profiles = NULL;
g_autofree gchar *default_profile = NULL;
- GbBeautifierConfigEntry entry;
+ g_autofree gchar *data = NULL;
+ g_autoptr (GError) error = NULL;
+ gsize data_len;
gsize nb_profiles;
- GError *error = NULL;
g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
g_assert (!dzl_str_empty0 (base_path));
@@ -147,15 +174,19 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
*has_default = FALSE;
key_file = g_key_file_new ();
ini_path = g_build_filename (base_path, real_lang_id, "config.ini", NULL);
+ if (g_str_has_prefix (ini_path, "resource://"))
+ file = g_file_new_for_uri (ini_path);
+ else
+ file = g_file_new_for_path (ini_path);
- if (!g_file_test (ini_path, G_FILE_TEST_EXISTS))
+ if (!g_file_load_contents (file, NULL, &data, &data_len, NULL, &error))
{
- g_debug ("%s doesn't exist", ini_path);
+ g_debug ("Can't read .ini file:%s", error->message);
return FALSE;
}
- if (!g_key_file_load_from_file (key_file, ini_path, G_KEY_FILE_NONE, &error))
- return FALSE;
+ if (!g_key_file_load_from_data (key_file, data, data_len, G_KEY_FILE_NONE, &error))
+ goto fail;
if (map_default != NULL)
default_profile = g_strdup (map_default);
@@ -171,11 +202,11 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
g_autofree gchar *config_path = NULL;
g_autoptr(GFile) config_file = NULL;
g_auto(GStrv) strv = NULL;
- const gchar *datadir;
+ GbBeautifierConfigEntry entry = {0};
gint argc;
gchar *profile;
- gboolean has_command;
- gboolean has_command_pattern;
+ gboolean has_command = FALSE;
+ gboolean has_command_pattern = FALSE;
profile = profiles [i];
if (0 == g_strcmp0 (profile, "global"))
@@ -201,19 +232,37 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
continue;
}
+ if (has_command && has_command_pattern)
+ {
+ g_warning ("beautifier plugin: both command and command-pattern keys found");
+ g_warning ("entry \"%s\" disabled", display_name);
+ continue;
+ }
+
if (NULL != (config_name = g_key_file_get_string (key_file, profile, "config", NULL)))
{
config_path = g_build_filename (base_path, real_lang_id, config_name, NULL);
- config_file = g_file_new_for_path (config_path);
- if (!g_file_query_exists (config_file, NULL))
+ if (g_str_has_prefix (config_path, "resource://"))
{
- g_warning ("beautifier plugin: \"%s\" does not exist", config_path);
- g_warning ("entry \"%s\" disabled", display_name);
- continue;
+ gchar *tmp_config_path = copy_to_tmp_file (config_path, FALSE);
+
+ g_free (config_path);
+ config_path = tmp_config_path;
+ config_file = g_file_new_for_path (config_path);
+ entry.is_config_file_temp = TRUE;
+ }
+ else
+ {
+ config_file = g_file_new_for_path (config_path);
+ if (!g_file_query_exists (config_file, NULL))
+ {
+ g_warning ("beautifier plugin: \"%s\" does not exist", config_path);
+ g_warning ("entry \"%s\" disabled", display_name);
+ continue;
+ }
}
}
- memset (&entry, 0, sizeof(GbBeautifierConfigEntry));
if (has_command)
{
command = g_key_file_get_string (key_file, profile, "command", NULL);
@@ -223,6 +272,10 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
{
g_warning ("beautifier plugin: command key out of possible values");
g_warning ("entry \"%s\" disabled", display_name);
+
+ if (entry.is_config_file_temp)
+ gb_beautifier_helper_remove_temp_for_file (config_file);
+
continue;
}
}
@@ -231,13 +284,14 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
command = g_key_file_get_string (key_file, profile, "command-pattern", NULL);
if (g_str_has_prefix (command, "[internal]"))
{
- datadir = get_datadir ();
- command_pattern = g_build_filename (datadir, "internal", command + 10, NULL);
+ command_pattern = g_build_filename
("resource:///org/gnome/builder/plugins/beautifier_plugin/internal/",
+ command + 10,
+ NULL);
}
else
command_pattern = g_strdup (command);
- if (g_strstr_len (command_pattern, -1, "@c@") == NULL && config_file != NULL)
+ if (g_strstr_len (command_pattern, -1, "@c@") != NULL && config_file == NULL)
{
g_warning ("beautifier plugin: @c@ in \"%s\" command-pattern key but no config file set",
profile);
@@ -247,38 +301,69 @@ add_entries_from_config_ini_file (GbBeautifierEditorAddin *self,
if (!g_shell_parse_argv (command_pattern, &argc, &strv, &error))
{
- g_warning ("beautifier plugin: \"%s\"", error->message);
- return FALSE;
+ if (entry.is_config_file_temp)
+ gb_beautifier_helper_remove_temp_for_file (config_file);
+
+ goto fail;
}
entry.command = GB_BEAUTIFIER_CONFIG_COMMAND_NONE;
- entry.command_args = g_ptr_array_new_with_free_func (g_free);
+ entry.command_args = g_array_new (FALSE, TRUE, sizeof (GbBeautifierCommandArg));
+ g_array_set_clear_func (entry.command_args, command_arg_clear_func);
+
for (gint j = 0; strv [j] != NULL; ++j)
- g_ptr_array_add (entry.command_args, g_strdup (strv [j]));
+ {
+ GbBeautifierCommandArg arg = {0};
+ gboolean is_executable = FALSE;
+
+ if (g_str_has_prefix (strv[j], "resource://"))
+ {
+ if (g_strstr_len (strv[j], -1, "internal"))
+ is_executable = TRUE;
+
+ if (NULL == (arg.str = copy_to_tmp_file (strv[j], is_executable)))
+ {
+ g_warning ("beautifier plugin: can't create tmp file for:%s", strv[j]);
+ g_warning ("entry \"%s\" disabled", display_name);
+
+ if (entry.is_config_file_temp)
+ gb_beautifier_helper_remove_temp_for_file (config_file);
+
+ gb_beautifier_helper_config_entry_remove_temp_files (&entry);
+ config_entry_clear_func (&entry);
+
+ continue;
+ }
- g_ptr_array_add (entry.command_args, NULL);
+ arg.is_temp = TRUE;
+ }
+ else
+ arg.str = g_strdup (strv [j]);
+
+ g_array_append_val (entry.command_args, arg);
+ }
}
- entry.name = g_steal_pointer (&display_name);
- entry.config_file = g_steal_pointer (&config_file);
- entry.lang_id = g_strdup (lang_id);
+ entry.name = g_steal_pointer (&display_name);
+ entry.config_file = g_steal_pointer (&config_file);
+ entry.lang_id = g_strdup (lang_id);
- if (0 == g_strcmp0 (default_profile, profile))
- {
- *has_default = entry.is_default = TRUE;
- g_clear_pointer (&default_profile, g_free);
- }
- else
- entry.is_default = FALSE;
+ if (0 == g_strcmp0 (default_profile, profile))
+ {
+ *has_default = entry.is_default = TRUE;
+ g_clear_pointer (&default_profile, g_free);
+ }
+ else
+ entry.is_default = FALSE;
- g_array_append_val (entries, entry);
+ g_array_append_val (entries, entry);
}
}
return TRUE;
fail:
- g_warning ("\"%s\"", error->message);
+ g_warning ("Beautifier plugin:\"%s\"", error->message);
return FALSE;
}
@@ -305,8 +390,8 @@ add_entries_from_base_path (GbBeautifierEditorAddin *self,
{
g_autoptr(GFileEnumerator) enumerator = NULL;
g_autoptr(GFile) parent_file = NULL;
+ g_autoptr (GError) error = NULL;
GFileInfo *child_info;
- GError *error = NULL;
gboolean ret = FALSE;
gboolean ret_has_default = FALSE;
@@ -316,7 +401,12 @@ add_entries_from_base_path (GbBeautifierEditorAddin *self,
g_assert (map != NULL);
*has_default = FALSE;
- parent_file = g_file_new_for_path (base_path);
+
+ if (g_str_has_prefix (base_path, "resource://"))
+ parent_file = g_file_new_for_uri (base_path);
+ else
+ parent_file = g_file_new_for_path (base_path);
+
if (NULL == (enumerator = g_file_enumerate_children (parent_file,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME","
G_FILE_ATTRIBUTE_STANDARD_TYPE,
@@ -384,27 +474,39 @@ gb_beautifier_config_get_map (GbBeautifierEditorAddin *self,
GArray *map;
g_autofree gchar *file_name = NULL;
g_autoptr(GKeyFile) key_file = NULL;
+ g_autoptr (GFile) file = NULL;
g_auto(GStrv) lang_ids = NULL;
+ g_autofree gchar *data = NULL;
+ g_autoptr (GError) error = NULL;
gsize nb_lang_ids;
- GError *error = NULL;
+ gsize data_len;
g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
g_assert (!dzl_str_empty0 (path));
map = g_array_new (TRUE, TRUE, sizeof (GbBeautifierMapEntry));
g_array_set_clear_func (map, map_entry_clear_func);
- file_name = g_build_filename (path,
- "global.ini",
- NULL);
+
+ file_name = g_build_filename (path, "global.ini", NULL);
+ if (g_str_has_prefix (file_name, "resource://"))
+ file = g_file_new_for_uri (file_name);
+ else
+ file = g_file_new_for_path (file_name);
key_file = g_key_file_new ();
- if (!g_file_test (file_name, G_FILE_TEST_EXISTS))
+ if (!g_file_query_exists (file, NULL))
{
g_debug ("%s doesn't exist", file_name);
return map;
}
- if (g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error) &&
+ if (!g_file_load_contents (file, NULL, &data, &data_len, NULL, NULL))
+ {
+ g_debug ("Can't read the resource file:%s", file_name);
+ return map;
+ }
+
+ if (g_key_file_load_from_data (key_file, data, data_len, G_KEY_FILE_NONE, &error) &&
NULL != (lang_ids = g_key_file_get_groups (key_file, &nb_lang_ids)))
{
for (guint i = 0; i < nb_lang_ids; ++i)
@@ -433,21 +535,41 @@ gb_beautifier_config_get_map (GbBeautifierEditorAddin *self,
return map;
}
-GArray *
-gb_beautifier_config_get_entries (GbBeautifierEditorAddin *self,
- gboolean *has_default)
+void
+gb_beautifier_entries_result_free (gpointer data)
+{
+ GbBeautifierEntriesResult *result = (GbBeautifierEntriesResult *)data;
+
+ g_return_if_fail (result != NULL);
+
+ if (result->entries != NULL)
+ g_array_unref (result->entries);
+
+ g_slice_free (GbBeautifierEntriesResult, result);
+}
+
+static void
+get_entries_worker (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
+ GbBeautifierEditorAddin *self = (GbBeautifierEditorAddin *)source_object;
IdeContext *context;
IdeVcs *vcs;
GArray *entries;
GArray *map = NULL;
g_autofree gchar *project_config_path = NULL;
g_autofree gchar *user_config_path = NULL;
- const gchar *datadir;
g_autofree gchar *configdir = NULL;
- gboolean ret_has_default;
+ GbBeautifierEntriesResult *result;
+ gboolean has_default = FALSE;
+ gboolean ret_has_default = FALSE;
+ //g_autoptr (GError) error = NULL;
g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (G_IS_TASK (task));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
entries = g_array_new (TRUE, TRUE, sizeof (GbBeautifierConfigEntry));
g_array_set_clear_func (entries, config_entry_clear_func);
@@ -459,7 +581,7 @@ gb_beautifier_config_get_entries (GbBeautifierEditorAddin *self,
NULL);
map = gb_beautifier_config_get_map (self, user_config_path);
add_entries_from_base_path (self, user_config_path, entries, map, &ret_has_default);
- *has_default |= ret_has_default;
+ has_default |= ret_has_default;
if (map != NULL)
g_array_free (map, TRUE);
@@ -478,24 +600,56 @@ gb_beautifier_config_get_entries (GbBeautifierEditorAddin *self,
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;
+ has_default |= ret_has_default;
if (map != NULL)
g_array_free (map, TRUE);
}
/* System wide config */
- if (NULL != (datadir = get_datadir ()))
- {
- configdir = g_build_filename (datadir, "data", NULL);
+ configdir = g_strdup ("resource:///org/gnome/builder/plugins/beautifier_plugin/config/");
- 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;
+ 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;
- if (map != NULL)
- g_array_free (map, TRUE);
- }
+ if (map != NULL)
+ g_array_free (map, TRUE);
+
+ result = g_slice_new0 (GbBeautifierEntriesResult);
+ result->entries = entries;
+ result->has_default = has_default;
+
+ g_task_return_pointer (task, result, NULL);
+ // g_task_return_error (task, error);
+}
+
+void
+gb_beautifier_config_get_entries_async (GbBeautifierEditorAddin *self,
+ gboolean *has_default,
+ GAsyncReadyCallback callback,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ g_assert (callback != NULL);
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gb_beautifier_config_get_entries_async);
+
+ g_task_run_in_thread (task, get_entries_worker);
+}
+
+GbBeautifierEntriesResult *
+gb_beautifier_config_get_entries_finish (GbBeautifierEditorAddin *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (g_task_is_valid (result, self));
- return entries;
+ return g_task_propagate_pointer (G_TASK (result), error);
}
diff --git a/src/plugins/beautifier/gb-beautifier-config.h b/src/plugins/beautifier/gb-beautifier-config.h
index 10920fc..e53bfd6 100644
--- a/src/plugins/beautifier/gb-beautifier-config.h
+++ b/src/plugins/beautifier/gb-beautifier-config.h
@@ -36,18 +36,40 @@ typedef struct
GFile *config_file;
gchar *name;
GbBeautifierConfigCommand command;
- GPtrArray *command_args;
+ GArray *command_args;
guint is_default : 1;
+ guint is_config_file_temp : 1;
} GbBeautifierConfigEntry;
typedef struct
{
+ gchar *str;
+ guint is_path : 1;
+ guint is_temp : 1;
+} GbBeautifierCommandArg;
+
+typedef struct
+{
gchar *lang_id;
gchar *mapped_lang_id;
gchar *default_profile;
} GbBeautifierMapEntry;
-GArray *gb_beautifier_config_get_entries (GbBeautifierEditorAddin *self,
- gboolean *has_default);
+typedef struct
+{
+ GArray *entries;
+ gboolean has_default;
+} GbBeautifierEntriesResult;
+
+void gb_beautifier_config_get_entries_async (GbBeautifierEditorAddin *self,
+ gboolean
*has_default,
+ GAsyncReadyCallback
callback,
+ GCancellable
*cancellable,
+ gpointer
user_data);
+GbBeautifierEntriesResult *gb_beautifier_config_get_entries_finish (GbBeautifierEditorAddin *self,
+ GAsyncResult
*result,
+ GError
**error);
+
+void gb_beautifier_entries_result_free (gpointer
data);
G_END_DECLS
diff --git a/src/plugins/beautifier/gb-beautifier-editor-addin.c
b/src/plugins/beautifier/gb-beautifier-editor-addin.c
index 9dd5bad..4cfa9da 100644
--- a/src/plugins/beautifier/gb-beautifier-editor-addin.c
+++ b/src/plugins/beautifier/gb-beautifier-editor-addin.c
@@ -351,6 +351,39 @@ add_shortcut_window_entry (GbBeautifierEditorAddin *self)
}
static void
+get_entries_async_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(GbBeautifierEditorAddin) self = (GbBeautifierEditorAddin *)object;
+ GbBeautifierEntriesResult *ret;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (G_IS_ASYNC_RESULT (result));
+
+ if (NULL == (ret = gb_beautifier_config_get_entries_finish (self, result, &error)))
+ {
+ g_warning ("\"%s\"", error->message);
+ g_warning ("Beautifier plugin disabled");
+
+ /* TODO: properly disable the plugin */
+ return;
+ }
+
+ self->entries = g_steal_pointer (&ret->entries);
+ self->has_default = ret->has_default;
+ gb_beautifier_entries_result_free (ret);
+
+ if (!self->has_default)
+ set_default_keybinding (self, "view.beautify-default::none");
+
+ ide_perspective_views_foreach (IDE_PERSPECTIVE (self->editor), (GtkCallback)setup_view_cb, self);
+
+ add_shortcut_window_entry (self);
+}
+
+static void
gb_beautifier_editor_addin_load (IdeEditorAddin *addin,
IdeEditorPerspective *editor)
{
@@ -363,14 +396,12 @@ gb_beautifier_editor_addin_load (IdeEditorAddin *addin,
dzl_set_weak_pointer (&self->editor, editor);
workbench = ide_widget_get_workbench (GTK_WIDGET (editor));
self->context = ide_workbench_get_context (workbench);
- self->entries = gb_beautifier_config_get_entries (self, &self->has_default);
-
- if (!self->has_default)
- set_default_keybinding (self, "view.beautify-default::none");
- ide_perspective_views_foreach (IDE_PERSPECTIVE (self->editor), (GtkCallback)setup_view_cb, self);
-
- add_shortcut_window_entry (self);
+ gb_beautifier_config_get_entries_async (self,
+ &self->has_default,
+ get_entries_async_cb,
+ NULL,
+ g_object_ref (self));
}
static void
@@ -378,6 +409,7 @@ gb_beautifier_editor_addin_unload (IdeEditorAddin *addin,
IdeEditorPerspective *editor)
{
GbBeautifierEditorAddin *self = (GbBeautifierEditorAddin *)addin;
+ GbBeautifierConfigEntry *entry;
g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
g_assert (IDE_IS_EDITOR_PERSPECTIVE (editor));
@@ -385,8 +417,13 @@ gb_beautifier_editor_addin_unload (IdeEditorAddin *addin,
ide_perspective_views_foreach (IDE_PERSPECTIVE (self->editor), (GtkCallback)cleanup_view_cb, self);
if (self->entries != NULL)
{
- g_array_free (self->entries, TRUE);
- self->entries = NULL;
+ for (gint i =0; i < self->entries->len; i++)
+ {
+ entry = &g_array_index (self->entries, GbBeautifierConfigEntry, i);
+ gb_beautifier_helper_config_entry_remove_temp_files (entry);
+ }
+
+ g_clear_pointer (&self->entries, g_array_unref);
}
dzl_clear_weak_pointer (&self->editor);
diff --git a/src/plugins/beautifier/gb-beautifier-helper.c b/src/plugins/beautifier/gb-beautifier-helper.c
index f8cc559..57d5238 100644
--- a/src/plugins/beautifier/gb-beautifier-helper.c
+++ b/src/plugins/beautifier/gb-beautifier-helper.c
@@ -19,6 +19,7 @@
#define G_LOG_DOMAIN "gb-beautifier-helper"
#include <glib.h>
+#include <glib/gstdio.h>
#include <gtksourceview/gtksource.h>
#include <ide.h>
#include <string.h>
@@ -33,11 +34,114 @@ typedef struct
gsize len;
} SaveTmpState;
+static gboolean
+check_path_is_in_tmp_dir (const gchar *path,
+ const gchar *tmp_dir)
+{
+ g_assert (!dzl_str_empty0 (path));
+ g_assert (!dzl_str_empty0 (tmp_dir));
+
+ return g_str_has_prefix (path, tmp_dir);
+}
+
+void
+gb_beautifier_helper_remove_temp_for_path (const gchar *path)
+{
+ const gchar *tmp_dir;
+
+ g_assert (path != NULL);
+
+ tmp_dir = g_get_tmp_dir ();
+
+ if (check_path_is_in_tmp_dir (path, tmp_dir))
+ g_unlink (path);
+ else
+ {
+ g_warning ("Beautifier plugin: blocked attempt to remove a config file outside of the tmp dir '%s':
'%s'",
+ tmp_dir,
+ path);
+ return;
+ }
+}
+
+void
+gb_beautifier_helper_remove_temp_for_file (GFile *file)
+{
+ const gchar *tmp_dir;
+ g_autofree gchar *path = NULL;
+
+ g_assert (G_IS_FILE (file));
+
+ tmp_dir = g_get_tmp_dir ();
+ path = g_file_get_path (file);
+
+ if (check_path_is_in_tmp_dir (path, tmp_dir))
+ g_file_delete (file, NULL, NULL);
+ else
+ {
+ g_warning ("Beautifier plugin: blocked attempt to remove a config file outside of the tmp dir '%s':
'%s'",
+ tmp_dir,
+ path);
+ return;
+ }
+}
+
+void
+gb_beautifier_helper_config_entry_remove_temp_files (GbBeautifierConfigEntry *config_entry)
+{
+ GbBeautifierCommandArg *arg;
+ g_autofree gchar *config_path = NULL;
+ const gchar *tmp_dir;
+
+ g_assert (config_entry != NULL);
+
+ tmp_dir = g_get_tmp_dir ();
+ if (config_entry->is_config_file_temp)
+ {
+
+ if (G_IS_FILE (config_entry->config_file))
+ {
+ config_path = g_file_get_path (config_entry->config_file);
+ if (check_path_is_in_tmp_dir (config_path, tmp_dir))
+ g_file_delete (config_entry->config_file, NULL, NULL);
+ else
+ {
+ g_warning ("Beautifier plugin: blocked attempt to remove a config file outside of the tmp dir
'%s': '%s'",
+ tmp_dir,
+ config_path);
+ return;
+ }
+ }
+ }
+
+ if (config_entry->command_args != NULL)
+ {
+ for (gint i = 0; i < config_entry->command_args->len; i++)
+ {
+ arg = &g_array_index (config_entry->command_args, GbBeautifierCommandArg, i);
+ if (arg->is_temp && !dzl_str_empty0 (arg->str))
+ {
+ if (check_path_is_in_tmp_dir (arg->str, tmp_dir))
+ g_unlink (arg->str);
+ else
+ {
+ g_warning ("Beautifier plugin: blocked attempt to remove a config file outside of the tmp
dir '%s': '%s'",
+ tmp_dir,
+ arg->str);
+ return;
+ }
+ }
+ }
+ }
+}
+
static void
save_tmp_state_free (gpointer data)
{
SaveTmpState *state = (SaveTmpState *)data;
+ g_assert (data != NULL);
+
if (!g_io_stream_is_closed ((GIOStream *)state->stream))
g_io_stream_close ((GIOStream *)state->stream, NULL, NULL);
@@ -65,7 +169,7 @@ gb_beautifier_helper_create_tmp_file_cb (GObject *object,
if (!g_output_stream_write_all_finish (output_stream, result, &count, &error))
g_task_return_error (task, g_steal_pointer (&error));
else if (g_task_return_error_if_cancelled (task))
- gb_beautifier_helper_remove_tmp_file (state->self, state->file);
+ g_file_delete (state->file, NULL, NULL);
else
g_task_return_pointer (task, g_steal_pointer (&state->file), g_object_unref);
}
@@ -122,19 +226,43 @@ gb_beautifier_helper_create_tmp_file_finish (GbBeautifierEditorAddin *self,
{
GTask *task = (GTask *)result;
- g_return_val_if_fail (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self), NULL);
- g_return_val_if_fail (g_task_is_valid (result, self), NULL);
+ g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (g_task_is_valid (result, self));
return g_task_propagate_pointer (task, error);
}
-void
-gb_beautifier_helper_remove_tmp_file (GbBeautifierEditorAddin *self,
- GFile *tmp_file)
+gchar *
+gb_beautifier_helper_match_and_replace (const gchar *str,
+ const gchar *pattern,
+ const gchar *replacement)
{
- g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_autofree gchar *head = NULL;
+ g_autofree gchar *tail = NULL;
+ gchar *needle;
+ gsize head_len;
- g_file_delete (tmp_file, NULL, NULL);
+ g_assert (!dzl_str_empty0 (str));
+ g_assert (!dzl_str_empty0 (pattern));
+
+ if (NULL != (needle = g_strstr_len (str, -1, pattern)))
+ {
+ head_len = needle - str;
+ if (head_len > 0)
+ head = g_strndup (str, head_len);
+ else
+ head = g_strdup ("");
+
+ tail = needle + strlen (pattern);
+ if (*tail != '\0')
+ tail = g_strdup (tail);
+ else
+ tail = g_strdup ("");
+
+ return g_strconcat (head, replacement, tail, NULL);
+ }
+ else
+ return NULL;
}
const gchar *
diff --git a/src/plugins/beautifier/gb-beautifier-helper.h b/src/plugins/beautifier/gb-beautifier-helper.h
index 1417226..0882c3c 100644
--- a/src/plugins/beautifier/gb-beautifier-helper.h
+++ b/src/plugins/beautifier/gb-beautifier-helper.h
@@ -22,22 +22,27 @@
#include "ide.h"
+#include "gb-beautifier-config.h"
#include "gb-beautifier-editor-addin.h"
G_BEGIN_DECLS
-void gb_beautifier_helper_create_tmp_file_async (GbBeautifierEditorAddin *self,
- const gchar *text,
- GAsyncReadyCallback callback,
- GCancellable *cancellable,
- gpointer user_data);
-GFile *gb_beautifier_helper_create_tmp_file_finish (GbBeautifierEditorAddin *self,
- GAsyncResult *result,
- GError **error);
-
-const gchar *gb_beautifier_helper_get_lang_id (GbBeautifierEditorAddin *self,
- IdeSourceView *view);
-void gb_beautifier_helper_remove_tmp_file (GbBeautifierEditorAddin *self,
- GFile *tmp_file);
+void gb_beautifier_helper_create_tmp_file_async (GbBeautifierEditorAddin *self,
+ const gchar *text,
+ GAsyncReadyCallback callback,
+ GCancellable *cancellable,
+ gpointer user_data);
+GFile *gb_beautifier_helper_create_tmp_file_finish (GbBeautifierEditorAddin *self,
+ GAsyncResult *result,
+ GError **error);
+
+const gchar *gb_beautifier_helper_get_lang_id (GbBeautifierEditorAddin *self,
+ IdeSourceView *view);
+gchar *gb_beautifier_helper_match_and_replace (const gchar *str,
+ const gchar *pattern,
+ const gchar *replacement);
+void gb_beautifier_helper_config_entry_remove_temp_files (GbBeautifierConfigEntry *config_entry);
+void gb_beautifier_helper_remove_temp_for_path (const gchar *path);
+void gb_beautifier_helper_remove_temp_for_file (GFile *file);
G_END_DECLS
diff --git a/src/plugins/beautifier/gb-beautifier-plugin.c b/src/plugins/beautifier/gb-beautifier-plugin.c
index 56e0522..d835d9e 100644
--- a/src/plugins/beautifier/gb-beautifier-plugin.c
+++ b/src/plugins/beautifier/gb-beautifier-plugin.c
@@ -22,7 +22,7 @@
#include "gb-beautifier-editor-addin.h"
void
-peas_register_types (PeasObjectModule *module)
+gb_beautifier_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
IDE_TYPE_EDITOR_ADDIN,
diff --git a/src/plugins/beautifier/gb-beautifier-process.c b/src/plugins/beautifier/gb-beautifier-process.c
index 14431e2..2c78725 100644
--- a/src/plugins/beautifier/gb-beautifier-process.c
+++ b/src/plugins/beautifier/gb-beautifier-process.c
@@ -33,7 +33,7 @@ typedef struct
GtkTextMark *begin_mark;
GtkTextMark *end_mark;
GbBeautifierConfigCommand command;
- GPtrArray *command_args;
+ GPtrArray *command_args_strs;
GFile *src_file;
GFile *config_file;
GFile *tmp_workdir_file;
@@ -55,16 +55,17 @@ process_state_free (gpointer data)
gtk_text_buffer_delete_mark (buffer, state->begin_mark);
gtk_text_buffer_delete_mark (buffer, state->end_mark);
- gb_beautifier_helper_remove_tmp_file (state->self, state->src_file);
+ gb_beautifier_helper_remove_temp_for_file (state->src_file);
+
g_clear_object (&state->src_file);
g_clear_object (&state->config_file);
if (state->tmp_config_file != NULL)
- g_file_delete (state->tmp_config_file, NULL, NULL);
+ gb_beautifier_helper_remove_temp_for_file (state->tmp_config_file);
if (state->tmp_src_file != NULL)
- g_file_delete (state->tmp_src_file, NULL, NULL);
+ gb_beautifier_helper_remove_temp_for_file (state->tmp_src_file);
if (state->tmp_workdir_file != NULL)
- g_file_delete (state->tmp_workdir_file, NULL, NULL);
+ gb_beautifier_helper_remove_temp_for_file (state->tmp_workdir_file);
g_clear_object (&state->tmp_workdir_file);
g_clear_object (&state->tmp_config_file);
@@ -73,45 +74,13 @@ process_state_free (gpointer data)
g_free (state->lang_id);
g_free (state->text);
- if (state->command_args != NULL)
- g_ptr_array_unref (state->command_args);
+ if (state->command_args_strs != NULL)
+ g_ptr_array_unref (state->command_args_strs);
g_slice_free (ProcessState, state);
}
-static gchar *
-match_and_replace (const gchar *str,
- const gchar *pattern,
- const gchar *replacement)
-{
- g_autofree gchar *head = NULL;
- g_autofree gchar *tail = NULL;
- gchar *needle;
- gsize head_len;
-
- g_assert (!dzl_str_empty0 (str));
- g_assert (!dzl_str_empty0 (pattern));
-
- if (NULL != (needle = g_strstr_len (str, -1, pattern)))
- {
- head_len = needle - str;
- if (head_len > 0)
- head = g_strndup (str, head_len);
- else
- head = g_strdup ("");
-
- tail = needle + strlen (pattern);
- if (*tail != '\0')
- tail = g_strdup (tail);
- else
- tail = g_strdup ("");
-
- return g_strconcat (head, replacement, tail, NULL);
- }
- else
- return NULL;
-}
-
+/* Substitute each @c@ annd @s@ pattern by the corresponding file */
static void
command_args_expand (GbBeautifierEditorAddin *self,
GPtrArray *args,
@@ -132,13 +101,13 @@ command_args_expand (GbBeautifierEditorAddin *self,
for (gint i = 0; g_ptr_array_index (args, i) != NULL; ++i)
{
arg_adr = (gchar **)&g_ptr_array_index (args, i);
- if (NULL != (new_arg = match_and_replace (*arg_adr, "@s@", src_path)))
+ if (NULL != (new_arg = gb_beautifier_helper_match_and_replace (*arg_adr, "@s@", src_path)))
{
g_free (*arg_adr);
*arg_adr = new_arg;
}
else if (has_config &&
- NULL != (new_arg = match_and_replace (*arg_adr, "@c@", config_path)))
+ NULL != (new_arg = gb_beautifier_helper_match_and_replace (*arg_adr, "@c@", config_path)))
{
g_free (*arg_adr);
*arg_adr = new_arg;
@@ -162,8 +131,9 @@ gb_beautifier_process_create_generic (GbBeautifierEditorAddin *self,
g_assert (!dzl_str_empty0 (src_path));
g_assert (!dzl_str_empty0 (state->lang_id));
- command_args_expand (self, state->command_args, state);
- subprocess = g_subprocess_newv ((const gchar * const *)state->command_args->pdata,
+ command_args_expand (self, state->command_args_strs, state);
+
+ subprocess = g_subprocess_newv ((const gchar * const *)state->command_args_strs->pdata,
G_SUBPROCESS_FLAGS_STDOUT_PIPE |
G_SUBPROCESS_FLAGS_STDERR_PIPE,
error);
@@ -308,9 +278,9 @@ process_communicate_utf8_cb (GObject *object,
}
static void
-create_tmp_file_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
+create_text_tmp_file_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
GbBeautifierEditorAddin *self = (GbBeautifierEditorAddin *)object;
g_autoptr (GTask) task = (GTask *)user_data;
@@ -354,16 +324,21 @@ fail:
return;
}
+/* We just need to keep the string part */
static GPtrArray *
-command_args_copy (GPtrArray *args)
+command_args_copy (GArray *args)
{
GPtrArray *args_copy;
g_assert (args != NULL);
args_copy = g_ptr_array_new_with_free_func (g_free);
- for (gint i = 0; g_ptr_array_index (args, i) != NULL; ++i)
- g_ptr_array_add (args_copy, g_strdup (g_ptr_array_index (args, i)));
+ for (gint i = 0; i < args->len; ++i)
+ {
+ GbBeautifierCommandArg *arg = &g_array_index (args, GbBeautifierCommandArg, i);
+
+ g_ptr_array_add (args_copy, g_strdup (arg->str));
+ }
g_ptr_array_add (args_copy, NULL);
@@ -415,17 +390,19 @@ gb_beautifier_process_launch_async (GbBeautifierEditorAddin *self,
state->lang_id = g_strdup (lang_id);
if (G_IS_FILE (entry->config_file))
- state->config_file = g_file_dup (entry->config_file);
+ state->config_file = g_object_ref (entry->config_file);
if (entry->command_args != NULL)
- state->command_args = command_args_copy (entry->command_args);
+ state->command_args_strs = command_args_copy (entry->command_args);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gb_beautifier_process_launch_async);
+ g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_task_data (task, state, process_state_free);
gb_beautifier_helper_create_tmp_file_async (self,
state->text,
- create_tmp_file_cb,
+ create_text_tmp_file_cb,
cancellable,
g_steal_pointer (&task));
}
diff --git a/src/plugins/beautifier/gb-beautifier.gresource.xml
b/src/plugins/beautifier/gb-beautifier.gresource.xml
index f5ec9f1..4346389 100644
--- a/src/plugins/beautifier/gb-beautifier.gresource.xml
+++ b/src/plugins/beautifier/gb-beautifier.gresource.xml
@@ -1,6 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
+ <gresource prefix="/org/gnome/builder/plugins">
+ <file>beautifier.plugin</file>
+ </gresource>
<gresource prefix="/org/gnome/builder/plugins/beautifier_plugin">
<file>gtk/menus.ui</file>
</gresource>
+ <gresource prefix="/org/gnome/builder/plugins/beautifier_plugin">
+ <file>config/global.ini</file>
+ <file>config/automake/config.ini</file>
+ <file>config/c/config.ini</file>
+ <file>config/c/gnu-indent.cfg</file>
+ <file>config/c/kr.cfg</file>
+ <file>config/c/linux-kernel.cfg</file>
+ <file>config/c-sharp/config.ini</file>
+ <file>config/c-sharp/mono.cfg</file>
+ <file>config/d/config.ini</file>
+ <file>config/d/d.cfg</file>
+ <file>config/html/config.ini</file>
+ <file>config/html/tidy-autoindent.cfg</file>
+ <file>config/html/tidy-indent.cfg</file>
+ <file>config/objc/config.ini</file>
+ <file>config/objc/objc.cfg</file>
+ <file>config/python/config.ini</file>
+ <file>config/xml/config.ini</file>
+ </gresource>
+ <gresource prefix="/org/gnome/builder/plugins/beautifier_plugin">
+ <file>internal/align_makefile.py</file>
+ </gresource>
</gresources>
diff --git a/src/plugins/beautifier/beautifier_plugin/internal/align_makefile.py
b/src/plugins/beautifier/internal/align_makefile.py
similarity index 100%
rename from src/plugins/beautifier/beautifier_plugin/internal/align_makefile.py
rename to src/plugins/beautifier/internal/align_makefile.py
diff --git a/src/plugins/beautifier/meson.build b/src/plugins/beautifier/meson.build
index f89b849..8e67241 100644
--- a/src/plugins/beautifier/meson.build
+++ b/src/plugins/beautifier/meson.build
@@ -19,26 +19,7 @@ beautifier_sources = [
'gb-beautifier-editor-addin.h',
]
-shared_module('beautifier_plugin', beautifier_sources,
- dependencies: [libpeas_dep, libide_plugin_dep],
- link_args: [gnome_builder_plugins_link_args],
- link_depends: [gnome_builder_plugins_link_deps],
- install: true,
- install_dir: plugindir,
-)
-
-configure_file(
- input: 'beautifier.plugin',
- output: 'beautifier.plugin',
- configuration: configuration_data(),
- install: true,
- install_dir: plugindir,
-)
-
-# TODO: Make the beautifier work with embedded resources so that
-# we can statically link the plugin into libgnome-builder-plugins.so
-beautifier_datadir = join_paths(get_option('prefix'), plugindatadir, 'beautifier_plugin')
-install_subdir('beautifier_plugin/data', install_dir: beautifier_datadir)
-install_subdir('beautifier_plugin/internal', install_dir: beautifier_datadir)
+gnome_builder_plugins_sources += files(beautifier_sources)
+gnome_builder_plugins_sources += beautifier_resources[0]
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]