grim/gplugin

81e32c5911a4
Parents dca3194601e5
Children ab10450d42bf
Use the new gplugin_manager_prepend_paths_from_environment

Testing Done:
Ran `gplugin-query` in the devenv and verified it was still working.

Reviewed at https://reviews.imfreedom.org/r/1093/
--- a/gplugin-gtk3-viewer/gplugin-gtk-viewer.c Sat Oct 23 02:11:16 2021 -0500
+++ b/gplugin-gtk3-viewer/gplugin-gtk-viewer.c Sun Oct 24 02:10:58 2021 -0500
@@ -164,7 +164,6 @@
GError *error = NULL;
GOptionContext *ctx = NULL;
GtkWidget *window = NULL;
- const gchar *env_paths = NULL;
ctx = g_option_context_new("");
g_option_context_add_main_entries(ctx, entries, NULL);
@@ -193,17 +192,8 @@
manager = gplugin_manager_get_default();
- env_paths = g_getenv("GPLUGIN_PLUGIN_PATH");
- if(env_paths != NULL) {
- gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0);
- gint i;
-
- for(i = 0; paths[i] != NULL; i++) {
- gplugin_manager_prepend_path(manager, paths[i]);
- }
-
- g_strfreev(paths);
- }
+ gplugin_manager_prepend_paths_from_environment(manager,
+ "GPLUGIN_PLUGIN_PATH");
gplugin_manager_refresh(manager);
--- a/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sat Oct 23 02:11:16 2021 -0500
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sun Oct 24 02:10:58 2021 -0500
@@ -53,22 +53,12 @@
startup_cb(G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data)
{
GPluginManager *manager = NULL;
- const gchar *env_paths = NULL;
gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
manager = gplugin_manager_get_default();
- env_paths = g_getenv("GPLUGIN_PLUGIN_PATH");
- if(env_paths != NULL) {
- gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0);
- gint i;
-
- for(i = 0; paths[i] != NULL; i++) {
- gplugin_manager_prepend_path(manager, paths[i]);
- }
-
- g_strfreev(paths);
- }
+ gplugin_manager_prepend_paths_from_environment(manager,
+ "GPLUGIN_PLUGIN_PATH");
gplugin_manager_refresh(manager);
}
--- a/gplugin-query/gplugin-query.c Sat Oct 23 02:11:16 2021 -0500
+++ b/gplugin-query/gplugin-query.c Sun Oct 24 02:10:58 2021 -0500
@@ -298,7 +298,6 @@
GError *error = NULL;
GOptionContext *ctx = NULL;
GOptionGroup *group = NULL;
- const gchar *env_paths = NULL;
gint i = 0, ret = 0;
ctx = g_option_context_new("PLUGIN-ID...");
@@ -329,18 +328,8 @@
manager = gplugin_manager_get_default();
- env_paths = g_getenv("GPLUGIN_PLUGIN_PATH");
- if(env_paths != NULL) {
- gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0);
- gint i;
-
- for(i = 0; paths[i] != NULL; i++) {
- gplugin_manager_prepend_path(manager, paths[i]);
- }
-
- g_strfreev(paths);
- }
-
+ gplugin_manager_prepend_paths_from_environment(manager,
+ "GPLUGIN_PLUGIN_PATH");
if(output_paths) {
GList *path = NULL;
--- a/gplugin/gplugin-manager.c Sat Oct 23 02:11:16 2021 -0500
+++ b/gplugin/gplugin-manager.c Sun Oct 24 02:10:58 2021 -0500
@@ -133,7 +133,6 @@
gchar **paths;
gint i;
const gchar *from_env;
- void (*changer)(GPluginManager *, const gchar *);
from_env = g_getenv(name);
if(from_env == NULL) {
@@ -141,16 +140,13 @@
}
paths = g_strsplit(from_env, G_SEARCHPATH_SEPARATOR_S, 0);
- if(prepend) {
- changer = &gplugin_manager_prepend_path;
- } else {
- changer = &gplugin_manager_append_path;
+ for(i = 0; paths[i]; i++) {
+ if(prepend) {
+ gplugin_manager_prepend_path(manager, paths[i]);
+ } else {
+ gplugin_manager_append_path(manager, paths[i]);
+ }
}
-
- for(i = 0; paths[i]; i++) {
- (*changer)(manager, paths[i]);
- }
-
g_strfreev(paths);
}