diff options
author | Dodji Seketeli <dodji@gnome.org> | 2004-02-29 11:54:43 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2004-02-29 11:54:43 +0000 |
commit | 6a2cb75412be707fd68b20399e2e1376b10b9f33 (patch) | |
tree | 5bea8663419646af5f3dd7f1aa734c74baa4b4f6 /src/cr-statement.c | |
parent | 3ead86bfa0d3c7dd5749649a3ba805a944b33689 (diff) | |
download | libcroco-6a2cb75412be707fd68b20399e2e1376b10b9f33.tar.gz |
applied a patch from Rob BUIS that provides new apis to manipulate CSS
2004-02-29 Dodji Seketeli <dodji@gnome.org>
* src/cr-statement.[ch],src/cr-stylesheet.[ch]:
applied a patch from Rob BUIS that provides new apis
to manipulate CSS statements.
Diffstat (limited to 'src/cr-statement.c')
-rw-r--r-- | src/cr-statement.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/cr-statement.c b/src/cr-statement.c index b675826..b8ff481 100644 --- a/src/cr-statement.c +++ b/src/cr-statement.c @@ -753,6 +753,45 @@ cr_statement_dump_page (CRStatement *a_this, FILE *a_fp, gulong a_indent) } /** + *Return the number of rules in the statement list; + *@param a_this the current instance of #CRStatement. + *@return number of rules in the statement list. + */ +int +cr_statement_nr_rules (CRStatement *a_this) +{ + CRStatement *cur = NULL ; + int nr = 0; + + g_return_val_if_fail (a_this, -1) ; + + for (cur = a_this ; cur ; cur = cur->next) + nr ++; + return nr; +} + +/** + *Use an index to get a CRStatement from the statement list. + *@param a_this the current instance of #CRStatement. + *@param itemnr the index into the statement list. + *@return CRStatement at position itemnr, if itemnr > number of statements - 1, + *it will return NULL. + */ +CRStatement * +cr_statement_get_from_list (CRStatement *a_this, int itemnr) +{ + CRStatement *cur = NULL ; + int nr = 0; + + g_return_val_if_fail (a_this, NULL) ; + + for (cur = a_this ; cur ; cur = cur->next) + if (nr++ == itemnr) + return cur; + return NULL; +} + +/** *Dumps an @media rule statement to a file. *@param a_this the statement to dump. *@param a_fp the destination file pointer @@ -2108,6 +2147,40 @@ cr_statement_at_import_rule_get_url (CRStatement *a_this, } /** + *Return the number of rules in the media rule; + *@param a_this the current instance of #CRStatement. + *@return number of rules in the media rule. + */ +int +cr_statement_at_media_nr_rules (CRStatement *a_this) +{ + g_return_val_if_fail (a_this + && a_this->type == AT_MEDIA_RULE_STMT + && a_this->kind.media_rule, + CR_BAD_PARAM_ERROR) ; + + return cr_statement_nr_rules (a_this->kind.media_rule->rulesets); +} + +/** + *Use an index to get a CRStatement from the media rule list of rules. + *@param a_this the current instance of #CRStatement. + *@param itemnr the index into the media rule list of rules. + *@return CRStatement at position itemnr, if itemnr > number of rules - 1, + *it will return NULL. + */ +CRStatement * +cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) +{ + g_return_val_if_fail (a_this + && a_this->type == AT_MEDIA_RULE_STMT + && a_this->kind.media_rule, + NULL) ; + + return cr_statement_get_from_list (a_this->kind.media_rule->rulesets, itemnr); +} + +/** *Sets a declaration list to the current @page rule statement. *@param a_this the current @page rule statement. *@param a_decl_list the declaration list to add. Will be freed |