Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
After investigating more closely the actual use cases of this functio…
Browse files Browse the repository at this point in the history
…n, I

2005-04-08  Tor Lillqvist  <tml@novell.com>

	* glib/gutils.c (g_get_system_data_dirs): After investigating more
	closely the actual use cases of this function, I understand better
	what it needs to do on Windows. In addition to the Windows
	COMMON_APPDATA and COMMON_DOCUMENTS folders, also return the
	"share" subfolders of GLib's installation location and the
	application .exe's installation location, hoping that either
	matches what the function's caller is looking for.
  • Loading branch information
Tor Lillqvist authored and Tor Lillqvist committed Apr 8, 2005
1 parent d7f079f commit 01f8253
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,5 +1,13 @@
2005-04-08 Tor Lillqvist <tml@novell.com>

* glib/gutils.c (g_get_system_data_dirs): After investigating more
closely the actual use cases of this function, I understand better
what it needs to do on Windows. In addition to the Windows
COMMON_APPDATA and COMMON_DOCUMENTS folders, also return the
"share" subfolders of GLib's installation location and the
application .exe's installation location, hoping that either
matches what the function's caller is looking for.

* glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): Use wide char API
if available, and store dll name in UTF-8.

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog.pre-2-10
@@ -1,5 +1,13 @@
2005-04-08 Tor Lillqvist <tml@novell.com>

* glib/gutils.c (g_get_system_data_dirs): After investigating more
closely the actual use cases of this function, I understand better
what it needs to do on Windows. In addition to the Windows
COMMON_APPDATA and COMMON_DOCUMENTS folders, also return the
"share" subfolders of GLib's installation location and the
application .exe's installation location, hoping that either
matches what the function's caller is looking for.

* glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): Use wide char API
if available, and store dll name in UTF-8.

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog.pre-2-12
@@ -1,5 +1,13 @@
2005-04-08 Tor Lillqvist <tml@novell.com>

* glib/gutils.c (g_get_system_data_dirs): After investigating more
closely the actual use cases of this function, I understand better
what it needs to do on Windows. In addition to the Windows
COMMON_APPDATA and COMMON_DOCUMENTS folders, also return the
"share" subfolders of GLib's installation location and the
application .exe's installation location, hoping that either
matches what the function's caller is looking for.

* glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): Use wide char API
if available, and store dll name in UTF-8.

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog.pre-2-8
@@ -1,5 +1,13 @@
2005-04-08 Tor Lillqvist <tml@novell.com>

* glib/gutils.c (g_get_system_data_dirs): After investigating more
closely the actual use cases of this function, I understand better
what it needs to do on Windows. In addition to the Windows
COMMON_APPDATA and COMMON_DOCUMENTS folders, also return the
"share" subfolders of GLib's installation location and the
application .exe's installation location, hoping that either
matches what the function's caller is looking for.

* glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): Use wide char API
if available, and store dll name in UTF-8.

Expand Down
52 changes: 43 additions & 9 deletions glib/gutils.c
Expand Up @@ -105,6 +105,8 @@ const guint glib_micro_version = GLIB_MICRO_VERSION;
const guint glib_interface_age = GLIB_INTERFACE_AGE;
const guint glib_binary_age = GLIB_BINARY_AGE;

G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)

/**
* glib_check_version:
* @required_major: the required major version.
Expand Down Expand Up @@ -1896,7 +1898,11 @@ g_get_system_data_dirs (void)
if (!g_system_data_dirs)
{
#ifdef G_OS_WIN32
gchar *glib_top_share_dir, *exe_top_share_dir;

/* Documents and Settings\All Users\Application Data */
char *appdata = get_special_folder (CSIDL_COMMON_APPDATA);
/* Documents and Settings\All Users\Documents */
char *docs = get_special_folder (CSIDL_COMMON_DOCUMENTS);

if (appdata && docs)
Expand All @@ -1913,18 +1919,48 @@ g_get_system_data_dirs (void)
else if (docs)
data_dirs = docs;
else
data_dirs = NULL;
data_dirs = g_strdup ("");

/* Using the above subfolders of Documents and Settings perhaps
* makes sense from a Windows perspective.
*
* But looking at the actual use cases of this function in GTK+
* and GNOME software, what we really want is the "share"
* subdirectory of the installation directory for the package
* our caller is a part of.
*
* As we don't know who calls us, punt, and use the installation
* location of GLib, and of the .exe file being run. To guard
* against neither of those being what we really want, callers
* of this function should have Win32-specific code to look up
* their installation folder themselves, and handle a subfolder
* "share" of it in the same way as the folders returned from
* this function.
*/
glib_top_share_dir = g_win32_get_package_installation_subdirectory (NULL, dll_name, "share");

if (data_dirs)
if (glib_top_share_dir)
{
data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
g_free (data_dirs);
gchar *tem = data_dirs;
data_dirs = g_strconcat (data_dirs, G_SEARCHPATH_SEPARATOR_S,
glib_top_share_dir, NULL);
g_free (tem);
g_free (glib_top_share_dir);
}
else

exe_top_share_dir = g_win32_get_package_installation_subdirectory (NULL, NULL, "share");

if (exe_top_share_dir)
{
/* Punt, return empty list */
data_dir_vector = g_strsplit ("", G_SEARCHPATH_SEPARATOR_S, 0);
gchar *tem = data_dirs;
data_dirs = g_strconcat (data_dirs, G_SEARCHPATH_SEPARATOR_S,
exe_top_share_dir, NULL);
g_free (tem);
g_free (exe_top_share_dir);
}

data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
g_free (data_dirs);
#else
data_dirs = (gchar *) g_getenv ("XDG_DATA_DIRS");

Expand Down Expand Up @@ -2396,8 +2432,6 @@ _g_utils_thread_init (void)

#ifdef G_PLATFORM_WIN32

G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)

static const gchar *
_glib_get_locale_dir (void)
{
Expand Down

0 comments on commit 01f8253

Please sign in to comment.