#define lstat stat
#endif
-#ifdef G_OS_WIN32
-#include <windows.h> /* For GetWindowsDirectory */
-#include <io.h>
-#endif
-
#include <glib.h>
#include "gdkconfig.h"
+#include "gtkcompat.h"
#include "gtkrc.h"
#include "gtkbindings.h"
#include "gtkthemes.h"
#include "gtkintl.h"
#include "gtkiconfactory.h"
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
+
typedef struct _GtkRcSet GtkRcSet;
typedef struct _GtkRcNode GtkRcNode;
typedef struct _GtkRcFile GtkRcFile;
};
static guint gtk_rc_style_hash (const char *name);
-static gint gtk_rc_style_compare (const char *a,
+static gboolean gtk_rc_style_equal (const char *a,
const char *b);
static guint gtk_rc_styles_hash (const GSList *rc_styles);
-static gint gtk_rc_styles_compare (const GSList *a,
+static gboolean gtk_rc_styles_equal (const GSList *a,
const GSList *b);
static GtkRcStyle* gtk_rc_style_find (const char *name);
static GSList * gtk_rc_styles_match (GSList *rc_styles,
#ifdef G_OS_WIN32
-gchar *
-gtk_win32_get_installation_directory (void)
+static gchar *
+get_gtk_dll_name (void)
{
- static gboolean been_here = FALSE;
- static gchar gtk_installation_dir[200];
- gchar win_dir[100];
- HKEY reg_key = NULL;
- DWORD type;
- DWORD nbytes = sizeof (gtk_installation_dir);
+ static gchar *gtk_dll = NULL;
- if (been_here)
- return gtk_installation_dir;
+ if (!gtk_dll)
+ gtk_dll = g_strdup_printf ("gtk-%d.%d.dll", GTK_MAJOR_VERSION, GTK_MINOR_VERSION);
- been_here = TRUE;
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\GNU\\GTk+", 0,
- KEY_QUERY_VALUE, ®_key) != ERROR_SUCCESS
- || RegQueryValueEx (reg_key, "InstallationDirectory", 0,
- &type, gtk_installation_dir, &nbytes) != ERROR_SUCCESS
- || type != REG_SZ)
- {
- /* Uh oh. Use the old hard-coded %WinDir%\GTk+ value */
- GetWindowsDirectory (win_dir, sizeof (win_dir));
- sprintf (gtk_installation_dir, "%s\\gtk+", win_dir);
- }
-
- if (reg_key != NULL)
- RegCloseKey (reg_key);
-
- return gtk_installation_dir;
+ return gtk_dll;
}
static gchar *
get_themes_directory (void)
{
- static gchar themes_dir[200];
-
- sprintf (themes_dir, "%s\\themes", gtk_win32_get_installation_directory ());
- return themes_dir;
+ return g_win32_get_package_installation_subdirectory (GETTEXT_PACKAGE,
+ get_gtk_dll_name (),
+ "themes");
}
#endif
#ifndef G_OS_WIN32
var = getenv("GTK_EXE_PREFIX");
if (var)
- path = g_strdup_printf("%s%s%s", var, "/lib/gtk-2.0/" GTK_VERSION "/", type);
+ path = g_strconcat (var, "/lib/gtk-2.0/" GTK_VERSION "/", type, NULL);
else
- path = g_strdup_printf("%s%s%s", GTK_EXE_PREFIX, "/lib/gtk-2.0/" GTK_VERSION "/", type);
+ path = g_strconcat (GTK_LIBDIR "/gtk-2.0/" GTK_VERSION "/", type, NULL);
#else
- path = g_strdup_printf ("%s\\%s", get_themes_directory (), type);
+ path = g_strconcat ("%s\\%s", get_themes_directory (), type);
#endif
return path;
gchar *
gtk_rc_get_im_module_file (void)
{
- gchar *result = g_getenv ("GTK_IM_MODULE_FILE");
+ gchar *result = g_strdup (g_getenv ("GTK_IM_MODULE_FILE"));
if (!result)
{
if (im_module_file)
- result = im_module_file;
+ result = g_strdup (im_module_file);
else
- result = GTK_SYSCONFDIR G_DIR_SEPARATOR_S "gtk-2.0" G_DIR_SEPARATOR_S "gtk.immodules";
+#ifndef G_OS_WIN32
+ result = g_strdup (GTK_SYSCONFDIR G_DIR_SEPARATOR_S "gtk-2.0" G_DIR_SEPARATOR_S "gtk.immodules");
+#else
+ result = g_strdup_printf ("%s\\gtk.immodules", g_win32_get_package_installation_directory (GETTEXT_PACKAGE, get_gtk_dll_name ()));
+#endif
}
- return g_strdup (result);
+ return result;
}
gchar *
#ifndef G_OS_WIN32
var = getenv("GTK_DATA_PREFIX");
if (var)
- path = g_strdup_printf("%s%s", var, "/share/themes");
+ path = g_strconcat (var, "/share/themes", NULL);
else
- path = g_strdup_printf("%s%s", GTK_DATA_PREFIX, "/share/themes");
+ path = g_strconcat (GTK_DATA_PREFIX, "/share/themes", NULL);
#else
path = g_strdup (get_themes_directory ());
#endif
#ifndef G_OS_WIN32
var = getenv("GTK_EXE_PREFIX");
if (var)
- path = g_strdup_printf("%s%s", var, "/lib/gtk-2.0/" GTK_VERSION "/engines");
+ path = g_strconcat(var, "/lib/gtk-2.0/" GTK_VERSION "/engines", NULL);
else
- path = g_strdup_printf("%s%s", GTK_EXE_PREFIX, "/lib/gtk-2.0/" GTK_VERSION "/engines");
+ path = g_strdup (GTK_LIBDIR "/gtk-2.0/" GTK_VERSION "/engines");
#else
- path = g_strdup_printf ("%s%s", get_themes_directory (), "\\engines");
+ path = g_strconcat (get_themes_directory (), "\\engines", NULL);
#endif
module_path[n++] = path;
else
sep = "";
/* This produces something like ~/.gtk-2.0/2.0/engines */
- path = g_strdup_printf ("%s%s%s", var, sep,
- ".gtk-2.0" G_DIR_SEPARATOR_S
- GTK_VERSION G_DIR_SEPARATOR_S
- "engines");
+ path = g_strconcat (var, sep,
+ ".gtk-2.0" G_DIR_SEPARATOR_S
+ GTK_VERSION G_DIR_SEPARATOR_S
+ "engines", NULL);
module_path[n++] = path;
}
module_path[n] = NULL;
#ifndef G_OS_WIN32
str = g_strdup (GTK_SYSCONFDIR G_DIR_SEPARATOR_S "gtk-2.0" G_DIR_SEPARATOR_S "gtkrc");
#else
- str = g_strdup_printf ("%s\\gtkrc", gtk_win32_get_installation_directory ());
+ str = g_strdup_printf ("%s\\gtkrc", g_win32_get_package_installation_directory (GETTEXT_PACKAGE, get_gtk_dll_name ()));
#endif
gtk_rc_add_default_file (str);
if (only_digit)
{
- strcpy (retval, "iso");
+ memcpy (retval, "iso", 4);
wp = retval + 3;
}
else
gint i, j;
- static gboolean initted = FALSE;
+ static gboolean initialized = FALSE;
- if (!initted)
+ if (!initialized)
{
gint length;
gchar *locale;
#else
locale = setlocale (LC_CTYPE, NULL);
#endif
-
- initted = TRUE;
+ initialized = TRUE;
pixmap_path[0] = NULL;
module_path[0] = NULL;
return result;
}
-static gint
-gtk_rc_styles_compare (const GSList *a,
- const GSList *b)
+static gboolean
+gtk_rc_styles_equal (const GSList *a,
+ const GSList *b)
{
while (a && b)
{
return result;
}
-static gint
-gtk_rc_style_compare (const char *a,
- const char *b)
+static gboolean
+gtk_rc_style_equal (const char *a,
+ const char *b)
{
return (strcmp (a, b) == 0);
}
if (!realized_style_ht)
realized_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_styles_hash,
- (GCompareFunc) gtk_rc_styles_compare);
+ (GEqualFunc) gtk_rc_styles_equal);
style = g_hash_table_lookup (realized_style_ht, rc_styles);
guint token;
token = g_scanner_peek_next_token (scanner);
-
+
switch (token)
{
+ gboolean is_varname;
+ gchar *p;
case GTK_RC_TOKEN_INCLUDE:
token = g_scanner_get_next_token (scanner);
if (token != GTK_RC_TOKEN_INCLUDE)
return GTK_RC_TOKEN_INCLUDE;
-
+
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
-
+
gtk_rc_parse_file (scanner->value.v_string, FALSE);
return G_TOKEN_NONE;
-
+
case GTK_RC_TOKEN_STYLE:
return gtk_rc_parse_style (scanner);
-
+
case GTK_RC_TOKEN_BINDING:
return gtk_binding_parse_binding (scanner);
-
+
case GTK_RC_TOKEN_PIXMAP_PATH:
return gtk_rc_parse_pixmap_path (scanner);
-
+
case GTK_RC_TOKEN_WIDGET:
return gtk_rc_parse_path_pattern (scanner);
-
+
case GTK_RC_TOKEN_WIDGET_CLASS:
return gtk_rc_parse_path_pattern (scanner);
-
+
case GTK_RC_TOKEN_CLASS:
return gtk_rc_parse_path_pattern (scanner);
-
+
case GTK_RC_TOKEN_MODULE_PATH:
return gtk_rc_parse_module_path (scanner);
-
+
case GTK_RC_TOKEN_IM_MODULE_PATH:
return gtk_rc_parse_im_module_path (scanner);
-
+
case GTK_RC_TOKEN_IM_MODULE_FILE:
return gtk_rc_parse_im_module_file (scanner);
-
+
default:
g_scanner_get_next_token (scanner);
return /* G_TOKEN_SYMBOL */ GTK_RC_TOKEN_STYLE;
{
if (!rc_style_ht)
rc_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_style_hash,
- (GCompareFunc) gtk_rc_style_compare);
+ (GEqualFunc) gtk_rc_style_equal);
g_hash_table_insert (rc_style_ht, rc_style->name, rc_style);
}