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
This commit is contained in:
Jasper St. Pierre 2012-09-13 16:57:56 -03:00
parent ff31ccdd30
commit 8ee74e5661

View File

@ -935,21 +935,20 @@ add_matched_properties (StTheme *a_this,
} }
} }
#define ORIGIN_AUTHOR_IMPORTANT (ORIGIN_AUTHOR + 1) #define ORIGIN_OFFSET_IMPORTANT (NB_ORIGINS)
#define ORIGIN_USER_IMPORTANT (ORIGIN_AUTHOR + 2) #define ORIGIN_OFFSET_EXTENSION (NB_ORIGINS * 2)
static inline int static inline int
get_origin (const CRDeclaration * decl) get_origin (const CRDeclaration * decl)
{ {
enum CRStyleOrigin origin = decl->parent_statement->parent_sheet->origin; 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 (decl->important)
{ origin += ORIGIN_OFFSET_IMPORTANT;
if (origin == ORIGIN_AUTHOR)
return ORIGIN_AUTHOR_IMPORTANT; if (is_extension_sheet)
else if (origin == ORIGIN_USER) origin += ORIGIN_OFFSET_EXTENSION;
return ORIGIN_USER_IMPORTANT;
}
return origin; return origin;
} }
@ -963,7 +962,6 @@ compare_declarations (gconstpointer a,
/* g_ptr_array_sort() is broooken */ /* g_ptr_array_sort() is broooken */
CRDeclaration *decl_a = *(CRDeclaration **) a; CRDeclaration *decl_a = *(CRDeclaration **) a;
CRDeclaration *decl_b = *(CRDeclaration **) b; CRDeclaration *decl_b = *(CRDeclaration **) b;
gboolean a_is_extension_sheet, b_is_extension_sheet;
int origin_a = get_origin (decl_a); int origin_a = get_origin (decl_a);
int origin_b = get_origin (decl_b); 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) if (decl_a->parent_statement->specificity != decl_b->parent_statement->specificity)
return 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; return 0;
} }