/** * cr_om_parser_parse_paths_to_cascade: *@a_this: the current instance of #CROMParser *@a_author_path: the path to the author stylesheet *@a_user_path: the path to the user stylesheet *@a_ua_path: the path to the User Agent stylesheet *@a_encoding: the encoding of the sheets. *@a_result: out parameter. The resulting cascade if the parsing *was okay * *Parses three sheets located by their paths and build a cascade * *Returns CR_OK upon successful completion, an error code otherwise */ enum CRStatus cr_om_parser_parse_paths_to_cascade (CROMParser * a_this, const guchar * a_author_path, const guchar * a_user_path, const guchar * a_ua_path, enum CREncoding a_encoding, CRCascade ** a_result) { enum CRStatus status = CR_OK; /*0->author sheet, 1->user sheet, 2->UA sheet */ CRStyleSheet *sheets[3]; guchar *paths[3]; CRCascade *result = NULL; gint i = 0; g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR); memset (sheets, 0, sizeof (CRStyleSheet*) * 3); paths[0] = (guchar *) a_author_path; paths[1] = (guchar *) a_user_path; paths[2] = (guchar *) a_ua_path; for (i = 0; i < 3; i++) { status = cr_om_parser_parse_file (a_this, paths[i], a_encoding, &sheets[i]); if (status != CR_OK) { if (sheets[i]) { cr_stylesheet_unref (sheets[i]); sheets[i] = NULL; } continue; } } result = cr_cascade_new (sheets[0], sheets[1], sheets[2]); if (!result) { for (i = 0; i < 3; i++) { cr_stylesheet_unref (sheets[i]); sheets[i] = 0; } return CR_ERROR; } *a_result = result; return CR_OK; }
/** * cr_cascade_set_sheet: *@a_this: the current instance of #CRCascade. *@a_sheet: the stylesheet to set. *@a_origin: the origin of the stylesheet. * *Sets a stylesheet in the cascade * *Returns CR_OK upon successfull completion, an error *code otherwise. */ enum CRStatus cr_cascade_set_sheet (CRCascade * a_this, CRStyleSheet * a_sheet, enum CRStyleOrigin a_origin) { g_return_val_if_fail (a_this && a_sheet && (unsigned)a_origin < NB_ORIGINS, CR_BAD_PARAM_ERROR); if (PRIVATE (a_this)->sheets[a_origin]) cr_stylesheet_unref (PRIVATE (a_this)->sheets[a_origin]); PRIVATE (a_this)->sheets[a_origin] = a_sheet; cr_stylesheet_ref (a_sheet); a_sheet->origin = a_origin; return CR_OK; }
/** * cr_cascade_destroy: * @a_this: the current instance of #CRCascade * * Destructor of #CRCascade. */ void cr_cascade_destroy (CRCascade * a_this) { g_return_if_fail (a_this); if (PRIVATE (a_this)) { gulong i = 0; for (i = 0; PRIVATE (a_this)->sheets && i < NB_ORIGINS; i++) { if (PRIVATE (a_this)->sheets[i]) { if (cr_stylesheet_unref (PRIVATE (a_this)->sheets[i]) == TRUE) { PRIVATE (a_this)->sheets[i] = NULL; } } } g_free (PRIVATE (a_this)); PRIVATE (a_this) = NULL; } g_free (a_this); }