From 8ee74e566167864008a47428b9d99eedc87cc209 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 13 Sep 2012 16:57:56 -0300 Subject: [PATCH] st-theme: Fix extension ordering with !important Extensions need to have priority over !important styles too. https://bugzilla.gnome.org/show_bug.cgi?id=684163 --- src/st/st-theme.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/st/st-theme.c b/src/st/st-theme.c index 42d75cb9b..ab7cbd0e8 100644 --- a/src/st/st-theme.c +++ b/src/st/st-theme.c @@ -935,21 +935,20 @@ add_matched_properties (StTheme *a_this, } } -#define ORIGIN_AUTHOR_IMPORTANT (ORIGIN_AUTHOR + 1) -#define ORIGIN_USER_IMPORTANT (ORIGIN_AUTHOR + 2) +#define ORIGIN_OFFSET_IMPORTANT (NB_ORIGINS) +#define ORIGIN_OFFSET_EXTENSION (NB_ORIGINS * 2) static inline int get_origin (const CRDeclaration * decl) { enum CRStyleOrigin origin = decl->parent_statement->parent_sheet->origin; + gboolean is_extension_sheet = GPOINTER_TO_UINT (decl->parent_statement->parent_sheet->app_data); if (decl->important) - { - if (origin == ORIGIN_AUTHOR) - return ORIGIN_AUTHOR_IMPORTANT; - else if (origin == ORIGIN_USER) - return ORIGIN_USER_IMPORTANT; - } + origin += ORIGIN_OFFSET_IMPORTANT; + + if (is_extension_sheet) + origin += ORIGIN_OFFSET_EXTENSION; return origin; } @@ -963,7 +962,6 @@ compare_declarations (gconstpointer a, /* g_ptr_array_sort() is broooken */ CRDeclaration *decl_a = *(CRDeclaration **) a; CRDeclaration *decl_b = *(CRDeclaration **) b; - gboolean a_is_extension_sheet, b_is_extension_sheet; int origin_a = get_origin (decl_a); int origin_b = get_origin (decl_b); @@ -974,12 +972,6 @@ compare_declarations (gconstpointer a, if (decl_a->parent_statement->specificity != decl_b->parent_statement->specificity) return decl_a->parent_statement->specificity - decl_b->parent_statement->specificity; - a_is_extension_sheet = GPOINTER_TO_UINT (decl_a->parent_statement->parent_sheet->app_data); - b_is_extension_sheet = GPOINTER_TO_UINT (decl_b->parent_statement->parent_sheet->app_data); - - if (a_is_extension_sheet != b_is_extension_sheet) - return a_is_extension_sheet ? 1 : -1; - return 0; }