diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 9 | ||||
-rw-r--r-- | gtk/gtkrc.c | 81 | ||||
-rw-r--r-- | tests/testgtk.c | 27 | ||||
-rw-r--r-- | tests/testgtkrc | 23 |
10 files changed, 164 insertions, 30 deletions
@@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d6eff3cef2..c20cf995b5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Fri Feb 1 17:48:51 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkrc.c (gtk_rc_get_style): Fix ordering of + priorities so that priorities take precendence over + the ordering by type. (#70205) + + * test/testgtkrc tests/testgtk.c (create_rc_file): Add + some labels to test priorities in testgtkrc. + Fri Feb 1 00:37:49 2002 Kristian Rietveld <kris@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_move_cursor_page_up_down): use diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 3324a79e1c..3958add6e2 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -1441,12 +1441,54 @@ gtk_rc_styles_match (GSList *rc_styles, sets = sets->next; if (g_pattern_match (rc_set->pspec, path_length, path, path_reversed)) - rc_styles = g_slist_append (rc_styles, rc_set->rc_style); + rc_styles = g_slist_append (rc_styles, rc_set); } return rc_styles; } +static gint +rc_set_compare (gconstpointer a, gconstpointer b) +{ + const GtkRcSet *set_a = a; + const GtkRcSet *set_b = b; + + return (set_a->priority < set_b->priority) ? 1 : (set_a->priority == set_b->priority ? 0 : -1); +} + +static GSList * +sort_and_dereference_sets (GSList *styles) +{ + GSList *tmp_list; + + /* At this point, the list of sets is ordered by: + * + * a) 'widget' patterns are earlier than 'widget_class' patterns + * which are ealier than 'class' patterns. + * a) For two matches for class patterns, a match to a child type + * is before a match to a parent type + * c) a match later in the RC file (or in a later RC file) is before a + * match earlier in the RC file. + * + * With a) taking precedence over b) which takes precendence over c). + * + * Now sort by priority, which has the highest precendence for sort order + */ + styles = g_slist_sort (styles, rc_set_compare); + + /* Make styles->data = styles->data->rc_style + */ + tmp_list = styles; + while (tmp_list) + { + GtkRcSet *set = tmp_list->data; + tmp_list->data = set->rc_style; + tmp_list = tmp_list->next; + } + + return styles; +} + /** * gtk_rc_get_style: * @widget: a #GtkWidget @@ -1481,12 +1523,6 @@ gtk_rc_get_style (GtkWidget *widget) if (!rc_style_key_id) rc_style_key_id = g_quark_from_static_string ("gtk-rc-style"); - widget_rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), - rc_style_key_id); - - if (widget_rc_style) - rc_styles = g_slist_prepend (rc_styles, widget_rc_style); - if (context->rc_sets_widget) { gchar *path, *path_reversed; @@ -1532,6 +1568,14 @@ gtk_rc_get_style (GtkWidget *widget) } } + rc_styles = sort_and_dereference_sets (rc_styles); + + widget_rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), + rc_style_key_id); + + if (widget_rc_style) + rc_styles = g_slist_prepend (rc_styles, widget_rc_style); + if (rc_styles) return gtk_rc_init_style (rc_styles); @@ -1628,6 +1672,8 @@ gtk_rc_get_style_by_paths (GtkSettings *settings, type = g_type_parent (type); } } + + rc_styles = sort_and_dereference_sets (rc_styles); if (rc_styles) return gtk_rc_init_style (rc_styles); @@ -3309,21 +3355,6 @@ gtk_rc_parse_module_path_string (const gchar *mod_path) gtk_rc_append_default_module_path(); } -static gint -rc_set_compare (gconstpointer a, gconstpointer b) -{ - const GtkRcSet *set_a = a; - const GtkRcSet *set_b = b; - - return (set_a->priority < set_b->priority) ? 1 : (set_a->priority == set_b->priority ? 0 : -1); -} - -static GSList * -insert_rc_set (GSList *list, GtkRcSet *set) -{ - return g_slist_insert_sorted (list, set, rc_set_compare); -} - static guint gtk_rc_parse_path_pattern (GtkRcContext *context, GScanner *scanner) @@ -3415,11 +3446,11 @@ gtk_rc_parse_path_pattern (GtkRcContext *context, rc_set->priority = priority; if (path_type == GTK_PATH_WIDGET) - context->rc_sets_widget = insert_rc_set (context->rc_sets_widget, rc_set); + context->rc_sets_widget = g_slist_prepend (context->rc_sets_widget, rc_set); else if (path_type == GTK_PATH_WIDGET_CLASS) - context->rc_sets_widget_class = insert_rc_set (context->rc_sets_widget_class, rc_set); + context->rc_sets_widget_class = g_slist_prepend (context->rc_sets_widget_class, rc_set); else - context->rc_sets_class = insert_rc_set (context->rc_sets_class, rc_set); + context->rc_sets_class = g_slist_prepend (context->rc_sets_class, rc_set); } g_free (pattern); diff --git a/tests/testgtk.c b/tests/testgtk.c index f60fd6fa58..fbd4af4c64 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -10573,6 +10573,9 @@ create_rc_file (void) { static GtkWidget *window = NULL; GtkWidget *button; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *label; if (!window) { @@ -10582,6 +10585,24 @@ create_rc_file (void) GTK_SIGNAL_FUNC(destroy_idle_test), &window); + frame = gtk_aspect_frame_new ("Testing RC file prioritization", 0.5, 0.5, 0.0, TRUE); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (frame), vbox); + + label = gtk_label_new ("This label should be red"); + gtk_widget_set_name (label, "testgtk-red-label"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + label = gtk_label_new ("This label should be green"); + gtk_widget_set_name (label, "testgtk-green-label"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + label = gtk_label_new ("This label should be blue"); + gtk_widget_set_name (label, "testgtk-blue-label"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_window_set_title (GTK_WINDOW (window), "Reload Rc file"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); @@ -10592,7 +10613,6 @@ create_rc_file (void) 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 ("Reload All"); gtk_signal_connect (GTK_OBJECT (button), "clicked", @@ -10600,7 +10620,6 @@ create_rc_file (void) 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); button = gtk_button_new_with_label ("Close"); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", @@ -10609,12 +10628,10 @@ create_rc_file (void) 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); + gtk_widget_show_all (window); else gtk_widget_destroy (window); } diff --git a/tests/testgtkrc b/tests/testgtkrc index 4b4cc57416..87c3c66a2b 100644 --- a/tests/testgtkrc +++ b/tests/testgtkrc @@ -188,3 +188,26 @@ style "testthickness" { } #class "GtkFrame" style "testthickness" + +# Test ordering of RC file priorities + +style "testgtk-red-style" { + fg[NORMAL] = "red" +} + +style "testgtk-green-style" { + fg[NORMAL] = "green" +} + +style "testgtk-blue-style" { + fg[NORMAL] = "blue" +} + +widget_class "*.GtkAspectFrame.*.GtkLabel" style "testgtk-green-style" +widget_class "*.GtkAspectFrame.*.GtkLabel" style "testgtk-blue-style" # override because it's later + +widget "*.testgtk-red-label" style "testgtk-red-style" # override because it's widget, not widget_class + +widget "*.testgtk-green-label" style : highest "testgtk-green-style" +# overrides the following, because it is higher priority +widget "*.testgtk-green-label" style "testgtk-red-style" |