[geany/geany-plugins] cfd70a: Merge pull request #569 from geany/osx_relpath
Frank Lanitz
git-noreply at xxxxx
Sat Apr 29 09:44:18 UTC 2017
Branch: refs/heads/master
Author: Frank Lanitz <frank at frank.uvena.de>
Committer: GitHub <noreply at github.com>
Date: Sat, 29 Apr 2017 09:44:18 UTC
Commit: cfd70a8bea776bcc0309ca2db0252c9b39b75a07
https://github.com/geany/geany-plugins/commit/cfd70a8bea776bcc0309ca2db0252c9b39b75a07
Log Message:
-----------
Merge pull request #569 from geany/osx_relpath
Use paths relative to the bundle on OS X
Modified Paths:
--------------
geanygendoc/src/ggd-utils.c
geniuspaste/src/geniuspaste.c
git-changebar/src/gcb-plugin.c
overview/overview/overviewprefspanel.c
pohelper/src/gph-plugin.c
scope/src/scope.c
Modified: geanygendoc/src/ggd-utils.c
27 lines changed, 19 insertions(+), 8 deletions(-)
===================================================================
@@ -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;
}
Modified: geniuspaste/src/geniuspaste.c
24 lines changed, 17 insertions(+), 7 deletions(-)
===================================================================
@@ -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)
Modified: git-changebar/src/gcb-plugin.c
27 lines changed, 19 insertions(+), 8 deletions(-)
===================================================================
@@ -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;
Modified: overview/overview/overviewprefspanel.c
26 lines changed, 19 insertions(+), 7 deletions(-)
===================================================================
@@ -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");
Modified: pohelper/src/gph-plugin.c
16 lines changed, 9 insertions(+), 7 deletions(-)
===================================================================
@@ -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;
}
Modified: scope/src/scope.c
19 lines changed, 18 insertions(+), 1 deletions(-)
===================================================================
@@ -526,10 +526,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;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list