]> Pileus Git - ~andy/gtk/blob - gtk/gtkwin32.c
e9ba709d873848238cedc4d0cf774a5780f02700
[~andy/gtk] / gtk / gtkwin32.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #include "config.h"
28
29 #include "gdk/gdk.h"
30
31 #include "gtkprivate.h"
32
33 #define STRICT
34 #include <windows.h>
35 #undef STRICT
36
37 static HMODULE gtk_dll;
38
39 BOOL WINAPI
40 DllMain (HINSTANCE hinstDLL,
41          DWORD     fdwReason,
42          LPVOID    lpvReserved)
43 {
44   switch (fdwReason)
45     {
46     case DLL_PROCESS_ATTACH:
47       gtk_dll = (HMODULE) hinstDLL;
48       break;
49     }
50
51   return TRUE;
52 }
53
54 const gchar *
55 _gtk_get_libdir (void)
56 {
57   static char *gtk_libdir = NULL;
58   if (gtk_libdir == NULL)
59     {
60       gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
61       gchar *slash = strrchr (root, '\\');
62       if (slash != NULL &&
63           g_ascii_strcasecmp (slash + 1, ".libs") == 0)
64         gtk_libdir = GTK_LIBDIR;
65       else
66         gtk_libdir = g_build_filename (root, "lib", NULL);
67       g_free (root);
68     }
69
70   return gtk_libdir;
71 }
72
73 const gchar *
74 _gtk_get_localedir (void)
75 {
76   static char *gtk_localedir = NULL;
77   if (gtk_localedir == NULL)
78     {
79       const gchar *p;
80       gchar *root, *temp;
81
82       /* GTK_LOCALEDIR ends in either /lib/locale or
83        * /share/locale. Scan for that slash.
84        */
85       p = GTK_LOCALEDIR + strlen (GTK_LOCALEDIR);
86       while (*--p != '/')
87         ;
88       while (*--p != '/')
89         ;
90
91       root = g_win32_get_package_installation_directory_of_module (gtk_dll);
92       temp = g_build_filename (root, p, NULL);
93       g_free (root);
94
95       /* gtk_localedir is passed to bindtextdomain() which isn't
96        * UTF-8-aware.
97        */
98       gtk_localedir = g_win32_locale_filename_from_utf8 (temp);
99       g_free (temp);
100     }
101   return gtk_localedir;
102 }
103
104 const gchar *
105 _gtk_get_datadir (void)
106 {
107   static char *gtk_datadir = NULL;
108   if (gtk_datadir == NULL)
109     {
110       gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
111       gtk_datadir = g_build_filename (root, "share", NULL);
112       g_free (root);
113     }
114
115   return gtk_datadir;
116 }
117
118 const gchar *
119 _gtk_get_sysconfdir (void)
120 {
121   static char *gtk_sysconfdir = NULL;
122   if (gtk_sysconfdir == NULL)
123     {
124       gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
125       gtk_sysconfdir = g_build_filename (root, "etc", NULL);
126       g_free (root);
127     }
128
129   return gtk_sysconfdir;
130 }
131
132 const gchar *
133 _gtk_get_data_prefix (void)
134 {
135   static char *gtk_data_prefix = NULL;
136   if (gtk_data_prefix == NULL)
137     gtk_data_prefix = g_win32_get_package_installation_directory_of_module (gtk_dll);
138
139   return gtk_data_prefix;
140 }