diff options
author | CST 1998 Shawn T. Amundson <amundson@gtk.org> | 1998-12-09 01:05:41 +0000 |
---|---|---|
committer | Shawn Amundson <amundson@src.gnome.org> | 1998-12-09 01:05:41 +0000 |
commit | 6421c96ccc2032d56e0f467e54ffa1634768f88e (patch) | |
tree | c939c91c106b02b7565b0a97b704fffa62102b87 /gtk | |
parent | 9806d64e401e8c2f782392ee973ea17a51c61fbc (diff) | |
download | gtk+-6421c96ccc2032d56e0f467e54ffa1634768f88e.tar.gz |
Released GTK+ 1.1.6GTK_1_1_6
Tue Dec 8 18:29:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.6
* NEWS: updated
* gtk/Makefile.am:
gtk/testgtk.c:
gtk/gtkrc.h:
gtk/gtkrc.c: Read in default files.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/Makefile.am | 1 | ||||
-rw-r--r-- | gtk/gtkrc.c | 103 | ||||
-rw-r--r-- | gtk/gtkrc.h | 3 | ||||
-rw-r--r-- | gtk/testgtk.c | 4 |
4 files changed, 109 insertions, 2 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 4643c56103..93a902f69a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -343,6 +343,7 @@ INCLUDES = \ -DG_LOG_DOMAIN=\"Gtk\" \ -DGTK_EXE_PREFIX=\"$(exec_prefix)\" \ -DGTK_DATA_PREFIX=\"$(prefix)\" \ + -DGTK_SYSCONFDIR=\"$(sysconfdir)\" \ -I$(top_srcdir) \ @GTK_DEBUG_FLAGS@ \ @GTK_XIM_FLAGS@ \ diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 3de06c5c2c..fce03fa803 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -23,6 +23,7 @@ #include <fcntl.h> #include <string.h> #include <stdio.h> +#include <stdlib.h> #include "gtkrc.h" #include "gtkbindings.h" #include "gtkthemes.h" @@ -95,6 +96,7 @@ static void gtk_rc_clear_styles (void); static void gtk_rc_append_default_pixmap_path (void); static void gtk_rc_append_default_module_path (void); static void gtk_rc_append_pixmap_path (gchar *dir); +static void gtk_rc_add_initial_default_files (void); static const GScannerConfig gtk_rc_scanner_config = @@ -180,6 +182,10 @@ static GSList *gtk_rc_sets_widget = NULL; static GSList *gtk_rc_sets_widget_class = NULL; static GSList *gtk_rc_sets_class = NULL; +#define GTK_RC_MAX_DEFAULT_FILES 128 +static gchar *gtk_rc_default_files[GTK_RC_MAX_DEFAULT_FILES]; +static gboolean gtk_rc_auto_parse = TRUE; + #define GTK_RC_MAX_PIXMAP_PATHS 128 static gchar *pixmap_path[GTK_RC_MAX_PIXMAP_PATHS]; #define GTK_RC_MAX_MODULE_PATHS 128 @@ -303,15 +309,112 @@ gtk_rc_append_default_module_path(void) g_free(path); } +static void +gtk_rc_add_initial_default_files (void) +{ + static gint init = FALSE; + gchar *var, *str; + gchar **files; + gint i; + + if (init) + return; + + gtk_rc_default_files[0] = NULL; + init = TRUE; + + var = getenv("GTK_RC_FILES"); + if (var) + { + files = g_strsplit (var, ":", 128); + i=0; + while (files[i]) + { + gtk_rc_add_default_file (files[i]); + i++; + } + } + else + { + str = g_malloc (strlen(GTK_SYSCONFDIR) + strlen("/gtkrc")); + sprintf (str, "%s%s", GTK_SYSCONFDIR, "/gtkrc"); + gtk_rc_add_default_file (str); + + var = g_get_home_dir (); + str = g_malloc (strlen(var) + strlen("/.gtkrc")); + sprintf (str, "%s%s", var, "/.gtkrc"); + gtk_rc_add_default_file (str); + } +} + +void +gtk_rc_add_default_file (const gchar *file) +{ + guint n; + + gtk_rc_add_initial_default_files (); + + for (n = 0; gtk_rc_default_files[n]; n++) ; + if (n >= GTK_RC_MAX_DEFAULT_FILES - 1) + return; + + gtk_rc_default_files[n++] = g_strdup (file); + gtk_rc_default_files[n] = NULL; +} + +void +gtk_rc_set_default_files (gchar **files) +{ + gint i; + + gtk_rc_add_initial_default_files (); + + i = 0; + while (gtk_rc_default_files[i]) + { + g_free (gtk_rc_default_files[i]); + i++; + } + + gtk_rc_default_files[0] = NULL; + gtk_rc_auto_parse = FALSE; + + i = 0; + while (files[i] != NULL) + { + gtk_rc_add_default_file (files[i]); + i++; + } +} + +gchar ** +gtk_rc_get_default_files (void) +{ + gtk_rc_add_initial_default_files (); + + return gtk_rc_default_files; +} + void gtk_rc_init (void) { + guint i; + rc_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_style_hash, (GCompareFunc) gtk_rc_style_compare); pixmap_path[0] = NULL; module_path[0] = NULL; gtk_rc_append_default_pixmap_path(); gtk_rc_append_default_module_path(); + + gtk_rc_add_initial_default_files (); + + i = 0; + while (gtk_rc_default_files[i] != NULL) + { + gtk_rc_parse (gtk_rc_default_files[i]); + i++; + } } void diff --git a/gtk/gtkrc.h b/gtk/gtkrc.h index bbd65a68ad..e7c2437b00 100644 --- a/gtk/gtkrc.h +++ b/gtk/gtkrc.h @@ -56,6 +56,9 @@ struct _GtkRcStyle }; void gtk_rc_init (void); +void gtk_rc_add_default_file (const gchar *filename); +void gtk_rc_set_default_files (gchar **filenames); +gchar** gtk_rc_get_default_files (void); void gtk_rc_parse (const gchar *filename); void gtk_rc_parse_string (const gchar *rc_string); gboolean gtk_rc_reparse_all (void); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 9f936bd844..eb4e6ccba3 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -8350,6 +8350,8 @@ main (int argc, char *argv[]) gtk_set_locale (); + gtk_rc_add_default_file ("testgtkrc"); + gtk_init (&argc, &argv); gdk_rgb_init (); @@ -8363,8 +8365,6 @@ main (int argc, char *argv[]) 1, GTK_TYPE_STRING, "GtkWidgetClass <ctrl><release>9 test"); - gtk_rc_parse ("testgtkrc"); - create_main_window (); gtk_main (); |