@@ -63,18 +63,13 @@ struct _StTheme
6363{
6464 GObject parent ;
6565
66- char * application_stylesheet ;
67- char * default_stylesheet ;
68- char * theme_stylesheet ;
69-
7066 char * fallback_stylesheet ;
7167
7268 GSList * custom_stylesheets ;
7369
7470 GHashTable * stylesheets_by_filename ;
7571 GHashTable * filenames_by_stylesheet ;
7672
77- CRCascade * cascade ;
7873 CRStyleSheet * fallback_cr_stylesheet ;
7974};
8075
@@ -86,9 +81,6 @@ struct _StThemeClass
8681enum
8782{
8883 PROP_0 ,
89- PROP_APPLICATION_STYLESHEET ,
90- PROP_THEME_STYLESHEET ,
91- PROP_DEFAULT_STYLESHEET ,
9284 PROP_FALLBACK_STYLESHEET
9385};
9486
@@ -111,7 +103,8 @@ st_theme_init (StTheme *theme)
111103{
112104 theme -> stylesheets_by_filename = g_hash_table_new_full (g_str_hash , g_str_equal ,
113105 (GDestroyNotify )g_free , (GDestroyNotify )cr_stylesheet_unref );
114- theme -> filenames_by_stylesheet = g_hash_table_new (g_direct_hash , g_direct_equal );
106+ theme -> filenames_by_stylesheet = g_hash_table_new_full (g_direct_hash , g_direct_equal ,
107+ NULL , (GDestroyNotify )g_free );
115108}
116109
117110static void
@@ -124,48 +117,6 @@ st_theme_class_init (StThemeClass *klass)
124117 object_class -> set_property = st_theme_set_property ;
125118 object_class -> get_property = st_theme_get_property ;
126119
127- /**
128- * StTheme:application-stylesheet:
129- *
130- * The highest priority stylesheet, representing application-specific
131- * styling; this is associated with the CSS "author" stylesheet.
132- */
133- g_object_class_install_property (object_class ,
134- PROP_APPLICATION_STYLESHEET ,
135- g_param_spec_string ("application-stylesheet" ,
136- "Application Stylesheet" ,
137- "Stylesheet with application-specific styling" ,
138- NULL ,
139- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY ));
140-
141- /**
142- * StTheme:theme-stylesheet:
143- *
144- * The second priority stylesheet, representing theme-specific styling;
145- * this is associated with the CSS "user" stylesheet.
146- */
147- g_object_class_install_property (object_class ,
148- PROP_THEME_STYLESHEET ,
149- g_param_spec_string ("theme-stylesheet" ,
150- "Theme Stylesheet" ,
151- "Stylesheet with theme-specific styling" ,
152- NULL ,
153- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY ));
154-
155- /**
156- * StTheme:default-stylesheet:
157- *
158- * The lowest priority stylesheet, representing global default
159- * styling; this is associated with the CSS "user agent" stylesheet.
160- */
161- g_object_class_install_property (object_class ,
162- PROP_DEFAULT_STYLESHEET ,
163- g_param_spec_string ("default-stylesheet" ,
164- "Default Stylesheet" ,
165- "Stylesheet with global default styling" ,
166- NULL ,
167- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY ));
168-
169120 /**
170121 * StTheme:fallback-stylesheet:
171122 *
@@ -242,14 +193,17 @@ insert_stylesheet (StTheme *theme,
242193{
243194 char * filename_copy ;
244195
245- if (stylesheet == NULL )
196+ if (stylesheet == NULL || filename == NULL )
246197 return ;
247198
248- filename_copy = g_strdup (filename );
249- cr_stylesheet_ref (stylesheet );
199+ if (!g_hash_table_contains (theme -> stylesheets_by_filename , filename ))
200+ {
201+ filename_copy = g_strdup (filename );
202+ cr_stylesheet_ref (stylesheet );
203+ g_hash_table_insert (theme -> stylesheets_by_filename , filename_copy , stylesheet );
204+ }
250205
251- g_hash_table_insert (theme -> stylesheets_by_filename , filename_copy , stylesheet );
252- g_hash_table_insert (theme -> filenames_by_stylesheet , stylesheet , filename_copy );
206+ g_hash_table_insert (theme -> filenames_by_stylesheet , stylesheet , g_strdup (filename ));
253207}
254208
255209gboolean
@@ -322,31 +276,14 @@ st_theme_constructor (GType type,
322276{
323277 GObject * object ;
324278 StTheme * theme ;
325- CRStyleSheet * application_stylesheet ;
326- CRStyleSheet * theme_stylesheet ;
327- CRStyleSheet * default_stylesheet ;
328279
329280 object = (* G_OBJECT_CLASS (st_theme_parent_class )-> constructor ) (type ,
330281 n_construct_properties ,
331282 construct_properties );
332283 theme = ST_THEME (object );
333284
334- application_stylesheet = parse_stylesheet_nofail (theme -> application_stylesheet );
335- theme_stylesheet = parse_stylesheet_nofail (theme -> theme_stylesheet );
336- default_stylesheet = parse_stylesheet_nofail (theme -> default_stylesheet );
337-
338285 theme -> fallback_cr_stylesheet = parse_stylesheet_nofail (theme -> fallback_stylesheet );
339-
340- theme -> cascade = cr_cascade_new (application_stylesheet ,
341- theme_stylesheet ,
342- default_stylesheet );
343-
344- if (theme -> cascade == NULL )
345- g_error ("Out of memory when creating cascade object" );
346-
347- insert_stylesheet (theme , theme -> application_stylesheet , application_stylesheet );
348- insert_stylesheet (theme , theme -> theme_stylesheet , theme_stylesheet );
349- insert_stylesheet (theme , theme -> default_stylesheet , default_stylesheet );
286+ insert_stylesheet (theme , theme -> fallback_stylesheet , theme -> fallback_cr_stylesheet );
350287
351288 return object ;
352289}
@@ -363,17 +300,8 @@ st_theme_finalize (GObject * object)
363300 g_hash_table_destroy (theme -> stylesheets_by_filename );
364301 g_hash_table_destroy (theme -> filenames_by_stylesheet );
365302
366- g_free (theme -> application_stylesheet );
367- g_free (theme -> theme_stylesheet );
368- g_free (theme -> default_stylesheet );
369303 g_free (theme -> fallback_stylesheet );
370304
371- if (theme -> cascade )
372- {
373- cr_cascade_unref (theme -> cascade );
374- theme -> cascade = NULL ;
375- }
376-
377305 G_OBJECT_CLASS (st_theme_parent_class )-> finalize (object );
378306}
379307
@@ -387,42 +315,6 @@ st_theme_set_property (GObject *object,
387315
388316 switch (prop_id )
389317 {
390- case PROP_APPLICATION_STYLESHEET :
391- {
392- const char * path = g_value_get_string (value );
393-
394- if (path != theme -> application_stylesheet )
395- {
396- g_free (theme -> application_stylesheet );
397- theme -> application_stylesheet = g_strdup (path );
398- }
399-
400- break ;
401- }
402- case PROP_THEME_STYLESHEET :
403- {
404- const char * path = g_value_get_string (value );
405-
406- if (path != theme -> theme_stylesheet )
407- {
408- g_free (theme -> theme_stylesheet );
409- theme -> theme_stylesheet = g_strdup (path );
410- }
411-
412- break ;
413- }
414- case PROP_DEFAULT_STYLESHEET :
415- {
416- const char * path = g_value_get_string (value );
417-
418- if (path != theme -> default_stylesheet )
419- {
420- g_free (theme -> default_stylesheet );
421- theme -> default_stylesheet = g_strdup (path );
422- }
423-
424- break ;
425- }
426318 case PROP_FALLBACK_STYLESHEET :
427319 {
428320 const char * path = g_value_get_string (value );
@@ -451,15 +343,6 @@ st_theme_get_property (GObject *object,
451343
452344 switch (prop_id )
453345 {
454- case PROP_APPLICATION_STYLESHEET :
455- g_value_set_string (value , theme -> application_stylesheet );
456- break ;
457- case PROP_THEME_STYLESHEET :
458- g_value_set_string (value , theme -> theme_stylesheet );
459- break ;
460- case PROP_DEFAULT_STYLESHEET :
461- g_value_set_string (value , theme -> default_stylesheet );
462- break ;
463346 case PROP_FALLBACK_STYLESHEET :
464347 g_value_set_string (value , theme -> fallback_stylesheet );
465348 break ;
@@ -469,30 +352,6 @@ st_theme_get_property (GObject *object,
469352 }
470353}
471354
472- /**
473- * st_theme_new:
474- * @application_stylesheet: The highest priority stylesheet, representing application-specific
475- * styling; this is associated with the CSS "author" stylesheet, may be %NULL
476- * @theme_stylesheet: The second priority stylesheet, representing theme-specific styling ;
477- * this is associated with the CSS "user" stylesheet, may be %NULL
478- * @default_stylesheet: The lowest priority stylesheet, representing global default styling;
479- * this is associated with the CSS "user agent" stylesheet, may be %NULL
480- *
481- * Return value: the newly created theme object
482- **/
483- StTheme *
484- st_theme_new (const char * application_stylesheet ,
485- const char * theme_stylesheet ,
486- const char * default_stylesheet )
487- {
488- StTheme * theme = g_object_new (ST_TYPE_THEME ,
489- "application-stylesheet" , application_stylesheet ,
490- "theme-stylesheet" , theme_stylesheet ,
491- "default-stylesheet" , default_stylesheet ,
492- NULL );
493-
494- return theme ;
495- }
496355
497356static gboolean
498357string_in_list (GString * stryng ,
@@ -1031,8 +890,6 @@ GPtrArray *
1031890_st_theme_get_matched_properties (StTheme * theme ,
1032891 StThemeNode * node )
1033892{
1034- enum CRStyleOrigin origin = 0 ;
1035- CRStyleSheet * sheet = NULL ;
1036893 GSList * iter ;
1037894 GPtrArray * props ;
1038895
@@ -1041,15 +898,6 @@ _st_theme_get_matched_properties (StTheme *theme,
1041898
1042899 props = g_ptr_array_new ();
1043900
1044- for (origin = ORIGIN_UA ; origin < NB_ORIGINS ; origin ++ )
1045- {
1046- sheet = cr_cascade_get_sheet (theme -> cascade , origin );
1047- if (!sheet )
1048- continue ;
1049-
1050- add_matched_properties (theme , sheet , node , props );
1051- }
1052-
1053901 for (iter = theme -> custom_stylesheets ; iter ; iter = iter -> next )
1054902 add_matched_properties (theme , iter -> data , node , props );
1055903
0 commit comments