diff --git a/geanygendoc/src/ggd-utils.c b/geanygendoc/src/ggd-utils.c index 07a6d7dbd..29a2ba8b1 100644 --- a/geanygendoc/src/ggd-utils.c +++ b/geanygendoc/src/ggd-utils.c @@ -135,6 +135,24 @@ ggd_copy_file (const gchar *input, return success; } +static gchar * +get_data_dir_path (const gchar *filename) +{ + gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module (NULL); +#elif defined(__APPLE__) + if (g_getenv ("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename (g_getenv ("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); +#endif + path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, filename, NULL); + g_free (prefix); + return path; +} + /** * ggd_get_config_file: * @name: The name of the configuration file to get (ASCII string) @@ -161,7 +179,6 @@ ggd_get_config_file (const gchar *name, GError **error) { gchar *path = NULL; - gchar *system_prefix = NULL; gchar *user_dir; gchar *user_path; gchar *system_dir; @@ -170,17 +187,12 @@ ggd_get_config_file (const gchar *name, g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); -#ifdef G_OS_WIN32 - system_prefix = g_win32_get_package_installation_directory_of_module (NULL); -#endif - /* here we guess the locale encoding is ASCII-compatible, anyway it's the case * on Windows since we use UTF-8 and on UNIX it would cause too much troubles * everywhere if it is not anyway */ user_dir = g_build_filename (geany->app->configdir, "plugins", GGD_PLUGIN_CNAME, section, NULL); - system_dir = g_build_filename (system_prefix ? system_prefix : "", - PLUGINDATADIR, section, NULL); + system_dir = get_data_dir_path (section); user_path = g_build_filename (user_dir, name, NULL); system_path = g_build_filename (system_dir, name, NULL); if (perms_req & GGD_PERM_R) { @@ -259,7 +271,6 @@ ggd_get_config_file (const gchar *name, if (path != system_path) g_free (system_path); g_free (user_dir); g_free (system_dir); - g_free (system_prefix); return path; } diff --git a/geniuspaste/src/geniuspaste.c b/geniuspaste/src/geniuspaste.c index 5cd29a53f..d39b47ee0 100644 --- a/geniuspaste/src/geniuspaste.c +++ b/geniuspaste/src/geniuspaste.c @@ -244,17 +244,29 @@ static void load_pastebins_in_dir(const gchar *path) } } -static void load_all_pastebins(void) +static gchar *get_data_dir_path(const gchar *filename) { -#ifdef G_OS_WIN32 - gchar *prefix = g_win32_get_package_installation_directory_of_module(NULL); -#else gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module(NULL); +#elif defined(__APPLE__) + if (g_getenv("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename(g_getenv("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); #endif + path = g_build_filename(prefix ? prefix : "", PLUGINDATADIR, filename, NULL); + g_free(prefix); + return path; +} + +static void load_all_pastebins(void) +{ gchar *paths[] = { g_build_filename(geany->app->configdir, "plugins", "geniuspaste", "pastebins", NULL), - g_build_filename(prefix ? prefix : "", PLUGINDATADIR, "pastebins", NULL) + get_data_dir_path("pastebins") }; guint i; @@ -264,8 +276,6 @@ static void load_all_pastebins(void) g_free(paths[i]); } pastebins = g_slist_sort(pastebins, sort_pastebins); - - g_free(prefix); } static void free_all_pastebins(void) diff --git a/git-changebar/src/gcb-plugin.c b/git-changebar/src/gcb-plugin.c index 5f29ced7e..8f9d7e12d 100644 --- a/git-changebar/src/gcb-plugin.c +++ b/git-changebar/src/gcb-plugin.c @@ -1386,19 +1386,31 @@ on_plugin_configure_response (GtkDialog *dialog, } } +static gchar * +get_data_dir_path (const gchar *filename) +{ + gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module (NULL); +#elif defined(__APPLE__) + if (g_getenv ("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename (g_getenv ("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); +#endif + path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, filename, NULL); + g_free (prefix); + return path; +} + GtkWidget * plugin_configure (GtkDialog *dialog) { GError *error = NULL; GtkWidget *base = NULL; GtkBuilder *builder = gtk_builder_new (); -#ifdef G_OS_WIN32 - gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL); -#else - gchar *prefix = NULL; -#endif - gchar *path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, - "prefs.ui", NULL); + gchar *path = get_data_dir_path ("prefs.ui"); gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); if (! gtk_builder_add_from_file (builder, path, &error)) { @@ -1444,7 +1456,6 @@ plugin_configure (GtkDialog *dialog) } g_free (path); - g_free (prefix); g_object_unref (builder); return base; diff --git a/overview/overview/overviewprefspanel.c b/overview/overview/overviewprefspanel.c index 60f01063b..a88c1c30b 100644 --- a/overview/overview/overviewprefspanel.c +++ b/overview/overview/overviewprefspanel.c @@ -192,18 +192,31 @@ overview_prefs_panel_load_prefs (OverviewPrefsPanel *self) g_signal_emit_by_name (self, "prefs-loaded", self->prefs); } +static gchar * +get_data_dir_path (const gchar *filename) +{ + gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module (NULL); +#elif defined(__APPLE__) + if (g_getenv ("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename (g_getenv ("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); +#endif + path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, filename, NULL); + g_free (prefix); + return path; +} + static void overview_prefs_panel_init (OverviewPrefsPanel *self) { GtkBuilder *builder; GError *error = NULL; GtkWidget *overlay_frame; -#ifdef G_OS_WIN32 - gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL); -#else - gchar *prefix = NULL; -#endif - gchar *ui_file_path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, "prefs.ui", NULL); + gchar *ui_file_path = get_data_dir_path ("prefs.ui"); builder = gtk_builder_new (); if (! gtk_builder_add_from_file (builder, ui_file_path, &error)) @@ -215,7 +228,6 @@ overview_prefs_panel_init (OverviewPrefsPanel *self) } g_free (ui_file_path); - g_free (prefix); self->prefs_table = builder_get_widget (builder, "prefs-table"); self->width_spin = builder_get_widget (builder, "width-spin"); diff --git a/pohelper/src/gph-plugin.c b/pohelper/src/gph-plugin.c index 4f4c495c2..48675b817 100644 --- a/pohelper/src/gph-plugin.c +++ b/pohelper/src/gph-plugin.c @@ -1360,16 +1360,18 @@ on_color_button_color_notify (GtkWidget *widget, static gchar * get_data_dir_path (const gchar *filename) { -#ifdef G_OS_WIN32 - gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL); -#else gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module (NULL); +#elif defined(__APPLE__) + if (g_getenv ("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename( g_getenv ("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); #endif - gchar *path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, - filename, NULL); - + path = g_build_filename (prefix ? prefix : "", PLUGINDATADIR, filename, NULL); g_free (prefix); - return path; } diff --git a/scope/src/scope.c b/scope/src/scope.c index 02a859647..d61d832a4 100644 --- a/scope/src/scope.c +++ b/scope/src/scope.c @@ -524,10 +524,27 @@ void configure_panel(void) gtk_notebook_set_tab_pos(GTK_NOTEBOOK(debug_panel), pref_panel_tab_pos); } +static gchar *get_data_dir_path(const gchar *filename) +{ + gchar *prefix = NULL; + gchar *path; + +#ifdef G_OS_WIN32 + prefix = g_win32_get_package_installation_directory_of_module(NULL); +#elif defined(__APPLE__) + if (g_getenv("GEANY_PLUGINS_SHARE_PATH")) + return g_build_filename(g_getenv("GEANY_PLUGINS_SHARE_PATH"), + PLUGIN, filename, NULL); +#endif + path = g_build_filename(prefix ? prefix : "", PLUGINDATADIR, filename, NULL); + g_free(prefix); + return path; +} + void plugin_init(G_GNUC_UNUSED GeanyData *gdata) { GeanyKeyGroup *scope_key_group; - char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL); + char *gladefile = get_data_dir_path("scope.glade"); GError *gerror = NULL; GtkWidget *menubar1 = ui_lookup_widget(geany->main_widgets->window, "menubar1"); guint item;