summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--ChangeLog.pre-2-016
-rw-r--r--ChangeLog.pre-2-1016
-rw-r--r--ChangeLog.pre-2-216
-rw-r--r--ChangeLog.pre-2-416
-rw-r--r--ChangeLog.pre-2-616
-rw-r--r--ChangeLog.pre-2-816
-rw-r--r--docs/styles.txt8
-rw-r--r--gdk/gdk.h2
-rw-r--r--gdk/gdkwindow.c19
-rw-r--r--gdk/x11/gdkwindow-x11.c19
-rw-r--r--gtk/gtkrc.c91
-rw-r--r--gtk/gtkrc.h1
-rw-r--r--gtk/gtkwidget.c12
-rw-r--r--gtk/gtkwidget.h3
-rw-r--r--gtk/testgtk.c66
-rw-r--r--tests/testgtk.c66
17 files changed, 394 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4008086af..b331044da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 4008086af..b331044da 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,19 @@
+Fri May 1 12:06:43 1998 Owen Taylor <otaylor@gtk.org>
+
+ * gtk/gtkwindow.[ch] (gtk_widget_reset_rc_styles): New
+ function to reset the RC styles for a heirarchy
+
+ Clear the window background if necessary in
+ gtk_window_style_set.
+
+ * gtk/gtkrc.[ch]: New function gtk_rc_reparse_all() which
+ rereads all previously read RC files.
+
+ * gdk/gdkwindow.c gdk/gdk.h: New function gdk_window_get_toplevels().
+ (Should it just be called gdk_get_toplevels?)
+
+ * gtk/testgtk.c: New test to reload RC files.
+
Fri May 1 13:57:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.h:
diff --git a/docs/styles.txt b/docs/styles.txt
index 051dc4b10..e66cafd19 100644
--- a/docs/styles.txt
+++ b/docs/styles.txt
@@ -25,13 +25,17 @@ gtk_widget_set_rc_style ()
restore the default style otherwise.
This will override a previously set user style or rc style.
+gtk_widget_reset_rc_styles ()
+ Descends through a widget heirarchy and sets the rc style
+ on all widgets that don't have a user style set.
+
gtk_widget_restore_default_style ()
Reset the widget's style to the default style, this is only usefull if
the widgets default style had been saved by previous calls to
gtk_widget_set_style() or gtk_widget_set_rc_style().
gtk_widget_ensure_style ()
- Ensure taht the widget either has a user style set, or an rc lookup
+ Ensure that the widget either has a user style set, or an rc lookup
has been performed.
gtk_rc_get_style ()
@@ -55,7 +59,7 @@ gtk_widget_set_parent ()
that do not have a user style set.
gtk_style_copy ()
- This function can be used to copy a widgets style.
+ This function can be used to copy a widget's style.
The style can subsequntly be changed (e.g., by modifications to the
red/green/blue values of a certain color) and then be applied to the
widget via gtk_widget_set_style().
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 1cfa3e608..6d453c069 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -299,6 +299,8 @@ void gdk_window_set_decorations (GdkWindow *window,
GdkWMDecoration decorations);
void gdk_window_set_functions (GdkWindow *window,
GdkWMFunction functions);
+GList * gdk_window_get_toplevels (void);
+
/* Cursors
*/
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index d95327ca1..022baa370 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -233,7 +233,7 @@ gdk_window_new (GdkWindow *parent,
private->parent = parent;
- if (parent_private != &gdk_root_parent)
+ if (parent_private)
parent_private->children = g_list_prepend (parent_private->children, window);
private->xdisplay = parent_display;
@@ -1956,3 +1956,20 @@ gdk_window_set_functions (GdkWindow *window,
gdk_window_set_mwm_hints (window, &hints);
}
+
+GList *
+gdk_window_get_toplevels (void)
+{
+ GList *new_list = NULL;
+ GList *tmp_list;
+
+ tmp_list = gdk_root_parent.children;
+ while (tmp_list)
+ {
+ new_list = g_list_prepend (new_list, tmp_list->data);
+ tmp_list = tmp_list->next;
+ }
+
+ return new_list;
+}
+
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index d95327ca1..022baa370 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -233,7 +233,7 @@ gdk_window_new (GdkWindow *parent,
private->parent = parent;
- if (parent_private != &gdk_root_parent)
+ if (parent_private)
parent_private->children = g_list_prepend (parent_private->children, window);
private->xdisplay = parent_display;
@@ -1956,3 +1956,20 @@ gdk_window_set_functions (GdkWindow *window,
gdk_window_set_mwm_hints (window, &hints);
}
+
+GList *
+gdk_window_get_toplevels (void)
+{
+ GList *new_list = NULL;
+ GList *tmp_list;
+
+ tmp_list = gdk_root_parent.children;
+ while (tmp_list)
+ {
+ new_list = g_list_prepend (new_list, tmp_list->data);
+ tmp_list = tmp_list->next;
+ }
+
+ return new_list;
+}
+
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 26bde5aad..c0657d89d 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -207,6 +207,8 @@ static GSList *widget_class_sets = NULL;
#define GTK_RC_MAX_PIXMAP_PATHS 128
static gchar *pixmap_path[GTK_RC_MAX_PIXMAP_PATHS];
+/* The files we have parsed, to reread later if necessary */
+GSList *rc_files;
void
gtk_rc_init ()
@@ -230,6 +232,8 @@ gtk_rc_parse (const gchar *filename)
g_return_if_fail (filename != NULL);
+ rc_files = g_slist_append (rc_files, g_strdup (filename));
+
fd = open (filename, O_RDONLY);
if (fd < 0)
return;
@@ -239,6 +243,93 @@ gtk_rc_parse (const gchar *filename)
close (fd);
}
+void
+gtk_rc_clear_hash_node (gpointer key,
+ gpointer data,
+ gpointer user_data)
+{
+ int i;
+ GtkRcStyle *rc_style = data;
+ GList *tmp_list;
+
+ g_free (rc_style->name);
+ g_free (rc_style->font_name);
+ g_free (rc_style->fontset_name);
+
+ for (i=0 ; i<5 ; i++)
+ g_free (rc_style->bg_pixmap_name[i]);
+
+ gtk_style_unref (rc_style->proto_style);
+
+ tmp_list = rc_style->styles;
+ while (tmp_list)
+ {
+ GtkRcNode *node = tmp_list->data;
+
+ gdk_colormap_unref (node->cmap);
+ gtk_style_unref (node->style);
+
+ g_free (node);
+ tmp_list = tmp_list->next;
+ }
+
+ g_free (rc_style);
+}
+
+void
+gtk_rc_reparse_all (void)
+{
+ GSList *tmp_list, *tmp_files;
+ GtkRcSet *rc_set;
+
+ /* Clear out all old rc_styles */
+
+ g_hash_table_foreach (rc_style_ht, gtk_rc_clear_hash_node, NULL);
+ g_hash_table_destroy (rc_style_ht);
+ rc_style_ht = NULL;
+
+ tmp_list = widget_sets;
+ while (tmp_list)
+ {
+ rc_set = (GtkRcSet *)tmp_list->data;
+ g_free (rc_set->set);
+ g_free (rc_set);
+
+ tmp_list = tmp_list->next;
+ }
+ g_slist_free (widget_sets);
+ widget_sets = NULL;
+
+ tmp_list = widget_class_sets;
+ while (tmp_list)
+ {
+ rc_set = (GtkRcSet *)tmp_list->data;
+ g_free (rc_set->set);
+ g_free (rc_set);
+
+ tmp_list = tmp_list->next;
+ }
+ g_slist_free (widget_class_sets);
+ widget_class_sets = NULL;
+
+ /* Now read the RC's again */
+
+ gtk_rc_init ();
+
+ tmp_files = rc_files;
+ rc_files = NULL;
+
+ tmp_list = tmp_files;
+ while (tmp_list)
+ {
+ gtk_rc_parse ((gchar *)tmp_list->data);
+ g_free (tmp_list->data);
+
+ tmp_list = tmp_list->next;
+ }
+ g_slist_free (tmp_files);
+}
+
GtkStyle*
gtk_rc_get_style (GtkWidget *widget)
{
diff --git a/gtk/gtkrc.h b/gtk/gtkrc.h
index 4b43b72a1..335448668 100644
--- a/gtk/gtkrc.h
+++ b/gtk/gtkrc.h
@@ -32,6 +32,7 @@ extern "C" {
void gtk_rc_init (void);
void gtk_rc_parse (const gchar *filename);
void gtk_rc_parse_string (const gchar *rc_string);
+void gtk_rc_reparse_all (void);
GtkStyle* gtk_rc_get_style (GtkWidget *widget);
void gtk_rc_add_widget_name_style (GtkStyle *style,
const gchar *pattern);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index faf2a41a9..9e58abad2 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2581,7 +2581,11 @@ gtk_widget_style_set (GtkWidget *widget,
{
if (GTK_WIDGET_REALIZED (widget) &&
!GTK_WIDGET_NO_WINDOW (widget))
- gtk_style_set_background (widget->style, widget->window, widget->state);
+ {
+ gtk_style_set_background (widget->style, widget->window, widget->state);
+ if (GTK_WIDGET_DRAWABLE (widget))
+ gdk_window_clear (widget->window);
+ }
}
static void
@@ -2647,6 +2651,12 @@ gtk_widget_set_style_recurse (GtkWidget *widget,
}
void
+gtk_widget_reset_rc_styles (GtkWidget *widget)
+{
+ gtk_widget_set_style_recurse (widget, NULL);
+}
+
+void
gtk_widget_set_default_style (GtkStyle *style)
{
if (style != default_style)
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 0ec99d519..9b43d2cd5 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -474,6 +474,9 @@ void gtk_widget_ensure_style (GtkWidget *widget);
GtkStyle* gtk_widget_get_style (GtkWidget *widget);
void gtk_widget_restore_default_style (GtkWidget *widget);
+/* Descend recursively and set rc-style on all widgets without user styles */
+void gtk_widget_reset_rc_styles (GtkWidget *widget);
+
/* Tell other Gtk applications to use the same default colors.
*/
void gtk_widget_propagate_default_style (void);
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 7dc08bf40..d158d8e7a 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -6446,6 +6446,71 @@ create_idle_test ()
gtk_widget_destroy (window);
}
+void
+reload_rc_file (void)
+{
+ GList *toplevels;
+
+ gtk_rc_reparse_all ();
+
+ toplevels = gdk_window_get_toplevels();
+ while (toplevels)
+ {
+ GtkWidget *widget;
+ gdk_window_get_user_data (toplevels->data, (gpointer *)&widget);
+
+ if (widget)
+ gtk_widget_reset_rc_styles (widget);
+
+ toplevels = toplevels->next;
+ }
+
+ g_list_free (toplevels);
+}
+
+void
+create_rc_file ()
+{
+ static GtkWidget *window = NULL;
+ GtkWidget *button;
+
+ if (!window)
+ {
+ window = gtk_dialog_new ();
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC(destroy_idle_test),
+ &window);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Reload Rc file");
+ gtk_container_border_width (GTK_CONTAINER (window), 0);
+
+ button = gtk_button_new_with_label ("Reload");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(reload_rc_file), NULL);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
+ button, TRUE, TRUE, 0);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+
+ button = gtk_button_new_with_label ("Close");
+ gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (window));
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
+ button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ }
+
+ if (!GTK_WIDGET_VISIBLE (window))
+ gtk_widget_show (window);
+ else
+ gtk_widget_destroy (window);
+}
+
/*
* Test of recursive mainloop
*/
@@ -6550,6 +6615,7 @@ create_main_window ()
{ "progress bar", create_progress_bar },
{ "radio buttons", create_radio_buttons },
{ "range controls", create_range_controls },
+ { "rc file", create_rc_file },
{ "reparent", create_reparent },
{ "rulers", create_rulers },
{ "scrolled windows", create_scrolled_windows },
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 7dc08bf40..d158d8e7a 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -6446,6 +6446,71 @@ create_idle_test ()
gtk_widget_destroy (window);
}
+void
+reload_rc_file (void)
+{
+ GList *toplevels;
+
+ gtk_rc_reparse_all ();
+
+ toplevels = gdk_window_get_toplevels();
+ while (toplevels)
+ {
+ GtkWidget *widget;
+ gdk_window_get_user_data (toplevels->data, (gpointer *)&widget);
+
+ if (widget)
+ gtk_widget_reset_rc_styles (widget);
+
+ toplevels = toplevels->next;
+ }
+
+ g_list_free (toplevels);
+}
+
+void
+create_rc_file ()
+{
+ static GtkWidget *window = NULL;
+ GtkWidget *button;
+
+ if (!window)
+ {
+ window = gtk_dialog_new ();
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC(destroy_idle_test),
+ &window);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Reload Rc file");
+ gtk_container_border_width (GTK_CONTAINER (window), 0);
+
+ button = gtk_button_new_with_label ("Reload");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(reload_rc_file), NULL);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
+ button, TRUE, TRUE, 0);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+
+ button = gtk_button_new_with_label ("Close");
+ gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (window));
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
+ button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ }
+
+ if (!GTK_WIDGET_VISIBLE (window))
+ gtk_widget_show (window);
+ else
+ gtk_widget_destroy (window);
+}
+
/*
* Test of recursive mainloop
*/
@@ -6550,6 +6615,7 @@ create_main_window ()
{ "progress bar", create_progress_bar },
{ "radio buttons", create_radio_buttons },
{ "range controls", create_range_controls },
+ { "rc file", create_rc_file },
{ "reparent", create_reparent },
{ "rulers", create_rulers },
{ "scrolled windows", create_scrolled_windows },