Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use paths relative to the bundle on OS X #569

Merged
merged 6 commits into from
Apr 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions geanygendoc/src/ggd-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
24 changes: 17 additions & 7 deletions geniuspaste/src/geniuspaste.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
27 changes: 19 additions & 8 deletions git-changebar/src/gcb-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -1444,7 +1456,6 @@ plugin_configure (GtkDialog *dialog)
}

g_free (path);
g_free (prefix);
g_object_unref (builder);

return base;
Expand Down
26 changes: 19 additions & 7 deletions overview/overview/overviewprefspanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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");
Expand Down
16 changes: 9 additions & 7 deletions pohelper/src/gph-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 18 additions & 1 deletion scope/src/scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down