[gitg] Add platform support methods to get the right dirs
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add platform support methods to get the right dirs
- Date: Mon, 21 Dec 2015 15:14:00 +0000 (UTC)
commit ffb1622e5aa52fe1eef1220a7424ff59d5d20643
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Dec 21 15:54:10 2015 +0100
Add platform support methods to get the right dirs
gitg/gitg-dirs.vala | 6 ++--
libgitg/gitg-platform-support-osx.c | 23 +++++++++++++++++++
libgitg/gitg-platform-support-win32.c | 39 +++++++++++++++++++++++++++++++++
libgitg/gitg-platform-support.c | 22 ++++++++++++++++++
libgitg/gitg-platform-support.h | 6 +++++
vapi/gitg-platform-support.vapi | 4 +++
6 files changed, 97 insertions(+), 3 deletions(-)
---
diff --git a/gitg/gitg-dirs.vala b/gitg/gitg-dirs.vala
index 7ee9245..c414834 100644
--- a/gitg/gitg-dirs.vala
+++ b/gitg/gitg-dirs.vala
@@ -24,17 +24,17 @@ public class Dirs
{
public static string data_dir
{
- get { return Config.GITG_DATADIR; }
+ owned get { return PlatformSupport.get_data_dir(); }
}
public static string locale_dir
{
- get { return Config.GITG_LOCALEDIR; }
+ owned get { return PlatformSupport.get_locale_dir(); }
}
public static string lib_dir
{
- get { return Config.GITG_LIBDIR; }
+ owned get { return PlatformSupport.get_lib_dir(); }
}
public static string plugins_dir
diff --git a/libgitg/gitg-platform-support-osx.c b/libgitg/gitg-platform-support-osx.c
index 31a8e95..20e385f 100644
--- a/libgitg/gitg-platform-support-osx.c
+++ b/libgitg/gitg-platform-support-osx.c
@@ -17,6 +17,10 @@
* along with gitg. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "gitg-platform-support.h"
#include <gdk/gdkquartz.h>
@@ -167,4 +171,23 @@ gitg_platform_support_new_input_stream_from_fd (gint fd,
return g_unix_input_stream_new (fd, close_fd);
}
+/* FIXME: probably should use the bundle dirs? */
+gchar *
+gitg_platform_support_get_lib_dir (void)
+{
+ return g_strdup (GITG_LIBDIR);
+}
+
+gchar *
+gitg_platform_support_get_locale_dir (void)
+{
+ return g_strdup (GITG_LOCALEDIR);
+}
+
+gchar *
+gitg_platform_support_get_data_dir (void)
+{
+ return g_strdup (GITG_DATADIR);
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support-win32.c b/libgitg/gitg-platform-support-win32.c
index ac39775..a2bcb85 100644
--- a/libgitg/gitg-platform-support-win32.c
+++ b/libgitg/gitg-platform-support-win32.c
@@ -61,4 +61,43 @@ gitg_platform_support_new_input_stream_from_fd (gint fd,
return g_win32_input_stream_new ((void *)fd, close_fd);
}
+gchar *
+gitg_platform_support_get_lib_dir (void)
+{
+ gchar *module_dir;
+ gchar *lib_dir;
+
+ module_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ lib_dir = g_build_filename (module_dir, "lib", "gitg", NULL);
+ g_free (module_dir);
+
+ return lib_dir;
+}
+
+gchar *
+gitg_platform_support_get_locale_dir (void)
+{
+ gchar *module_dir;
+ gchar *locale_dir;
+
+ module_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ locale_dir = g_build_filename (module_dir, "share", "locale", NULL);
+ g_free (module_dir);
+
+ return locale_dir;
+}
+
+gchar *
+gitg_platform_support_get_data_dir (void)
+{
+ gchar *module_dir;
+ gchar *data_dir;
+
+ module_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ data_dir = g_build_filename (module_dir, "share", "gitg", NULL);
+ g_free (module_dir);
+
+ return data_dir;
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support.c b/libgitg/gitg-platform-support.c
index 2b2ff57..6bea618 100644
--- a/libgitg/gitg-platform-support.c
+++ b/libgitg/gitg-platform-support.c
@@ -17,6 +17,10 @@
* along with gitg. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "gitg-platform-support.h"
#include <gio/gunixinputstream.h>
@@ -95,4 +99,22 @@ gitg_platform_support_new_input_stream_from_fd (gint fd,
return g_unix_input_stream_new (fd, close_fd);
}
+gchar *
+gitg_platform_support_get_lib_dir (void)
+{
+ return g_strdup (GITG_LIBDIR);
+}
+
+gchar *
+gitg_platform_support_get_locale_dir (void)
+{
+ return g_strdup (GITG_LOCALEDIR);
+}
+
+gchar *
+gitg_platform_support_get_data_dir (void)
+{
+ return g_strdup (GITG_DATADIR);
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support.h b/libgitg/gitg-platform-support.h
index 6906282..aacc29c 100644
--- a/libgitg/gitg-platform-support.h
+++ b/libgitg/gitg-platform-support.h
@@ -44,6 +44,12 @@ cairo_surface_t *gitg_platform_support_create_cursor_surface (GdkDisplay *dis
GInputStream *gitg_platform_support_new_input_stream_from_fd (gint fd,
gboolean close_fd);
+gchar *gitg_platform_support_get_lib_dir (void);
+
+gchar *gitg_platform_support_get_locale_dir (void);
+
+gchar *gitg_platform_support_get_data_dir (void);
+
#endif /* __GITG_PLATFORM_SUPPORT_H__ */
// ex:ts=4 noet
diff --git a/vapi/gitg-platform-support.vapi b/vapi/gitg-platform-support.vapi
index d00f05a..18e1c5f 100644
--- a/vapi/gitg-platform-support.vapi
+++ b/vapi/gitg-platform-support.vapi
@@ -14,5 +14,9 @@ namespace Gitg
out int height = null);
public static GLib.InputStream new_input_stream_from_fd(int fd, bool close_fd);
+
+ public static string get_lib_dir();
+ public static string get_locale_dir();
+ public static string get_data_dir();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]