2010-04-11 21:03:25 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
|
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-04-11 21:03:25 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2011-01-23 23:29:07 +00:00
|
|
|
|
|
2010-09-24 20:05:20 +00:00
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2010-11-12 20:43:13 +00:00
|
|
|
|
#include <cairo-gobject.h>
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-01-26 16:17:34 +00:00
|
|
|
|
#include "gtkcssproviderprivate.h"
|
|
|
|
|
|
2011-12-23 13:23:52 +00:00
|
|
|
|
#include "gtkbitmaskprivate.h"
|
2012-03-26 15:24:02 +00:00
|
|
|
|
#include "gtkcssarrayvalueprivate.h"
|
2012-11-25 01:28:59 +00:00
|
|
|
|
#include "gtkcsscolorvalueprivate.h"
|
2012-04-19 01:41:41 +00:00
|
|
|
|
#include "gtkcsskeyframesprivate.h"
|
2011-04-14 02:47:18 +00:00
|
|
|
|
#include "gtkcssparserprivate.h"
|
2011-06-17 00:02:24 +00:00
|
|
|
|
#include "gtkcsssectionprivate.h"
|
2011-05-14 11:27:31 +00:00
|
|
|
|
#include "gtkcssselectorprivate.h"
|
2011-12-31 12:50:03 +00:00
|
|
|
|
#include "gtkcssshorthandpropertyprivate.h"
|
2012-04-19 01:41:41 +00:00
|
|
|
|
#include "gtkcssstylefuncsprivate.h"
|
2014-01-24 13:04:04 +00:00
|
|
|
|
#include "gtksettingsprivate.h"
|
2011-01-23 23:29:07 +00:00
|
|
|
|
#include "gtkstyleprovider.h"
|
|
|
|
|
#include "gtkstylecontextprivate.h"
|
2011-05-21 01:30:36 +00:00
|
|
|
|
#include "gtkstylepropertyprivate.h"
|
2011-12-28 21:59:55 +00:00
|
|
|
|
#include "gtkstyleproviderprivate.h"
|
2014-07-19 21:26:12 +00:00
|
|
|
|
#include "gtkwidgetpath.h"
|
2011-01-28 00:52:03 +00:00
|
|
|
|
#include "gtkbindings.h"
|
2011-04-07 15:26:47 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2011-01-02 11:11:34 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2011-04-07 15:26:47 +00:00
|
|
|
|
#include "gtkintl.h"
|
2014-11-13 00:22:55 +00:00
|
|
|
|
#include "gtkversion.h"
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkcssprovider
|
|
|
|
|
* @Short_description: CSS-like styling for widgets
|
|
|
|
|
* @Title: GtkCssProvider
|
|
|
|
|
* @See_also: #GtkStyleContext, #GtkStyleProvider
|
|
|
|
|
*
|
2010-11-26 01:39:53 +00:00
|
|
|
|
* GtkCssProvider is an object implementing the #GtkStyleProvider interface.
|
2014-02-04 23:53:51 +00:00
|
|
|
|
* It is able to parse [CSS-like](http://www.w3.org/TR/CSS2)
|
2010-11-26 01:39:53 +00:00
|
|
|
|
* input in order to style widgets.
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* ## Default files
|
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* An application can cause GTK+ to parse a specific CSS style sheet by
|
|
|
|
|
* calling gtk_css_provider_load_from_file() and adding the provider with
|
|
|
|
|
* gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen().
|
|
|
|
|
* In addition, certain files will be read when GTK+ is initialized. First,
|
2014-02-03 21:20:00 +00:00
|
|
|
|
* the file `$XDG_CONFIG_HOME/gtk-3.0/gtk.css`
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* is loaded if it exists. Then, GTK+ tries to load
|
2014-02-05 00:20:16 +00:00
|
|
|
|
* `$HOME/.themes/theme-name/gtk-3.0/gtk.css`,
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* falling back to
|
2014-02-05 00:20:16 +00:00
|
|
|
|
* `datadir/share/themes/theme-name/gtk-3.0/gtk.css`,
|
|
|
|
|
* where theme-name is the name of the current theme
|
|
|
|
|
* (see the #GtkSettings:gtk-theme-name setting) and datadir
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* is the prefix configured when GTK+ was compiled, unless overridden by the
|
2014-02-03 21:20:00 +00:00
|
|
|
|
* `GTK_DATA_PREFIX` environment variable.
|
2014-02-05 02:00:58 +00:00
|
|
|
|
*
|
|
|
|
|
* # Style sheets
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* The basic structure of the style sheets understood by this provider is
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* a series of statements, which are either rule sets or “@-rules”, separated
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* by whitespace.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* A rule set consists of a selector and a declaration block, which is
|
|
|
|
|
* a series of declarations enclosed in curly braces ({ and }). The
|
|
|
|
|
* declarations are separated by semicolons (;). Multiple selectors can
|
|
|
|
|
* share the same declaration block, by putting all the separators in
|
|
|
|
|
* front of the block, separated by commas.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* An example of a rule set with two selectors:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* GtkButton, GtkEntry {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #ff00ea;
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* font: Comic Sans 12
|
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 01:21:05 +00:00
|
|
|
|
* # Selectors # {#gtkcssprovider-selectors}
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 01:21:05 +00:00
|
|
|
|
* Selectors work very similar to the way they do in CSS, with widget class
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* names taking the role of element names, and widget names taking the role
|
|
|
|
|
* of IDs. When used in a selector, widget names must be prefixed with a
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* '#' character. The “*” character represents the so-called universal
|
2014-02-05 01:21:05 +00:00
|
|
|
|
* selector, which matches any widget.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* To express more complicated situations, selectors can be combined in
|
|
|
|
|
* various ways:
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* - To require that a widget satisfies several conditions,
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* combine several selectors into one by concatenating them. E.g.
|
2014-03-28 20:55:03 +00:00
|
|
|
|
* `GtkButton#button1` matches a GtkButton widget
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* with the name button1.
|
|
|
|
|
* - To only match a widget when it occurs inside some other
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* widget, write the two selectors after each other, separated by whitespace.
|
2014-02-04 23:21:13 +00:00
|
|
|
|
* E.g. `GtkToolBar GtkButton` matches GtkButton widgets
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* that occur inside a GtkToolBar.
|
|
|
|
|
* - In the previous example, the GtkButton is matched even
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* if it occurs deeply nested inside the toolbar. To restrict the match
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* to direct children of the parent widget, insert a “>” character between
|
2014-02-04 23:21:13 +00:00
|
|
|
|
* the two selectors. E.g. `GtkNotebook > GtkLabel` matches
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* GtkLabel widgets that are direct children of a GtkNotebook.
|
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ## Examples of widget classes and names in selectors
|
2014-02-05 02:00:58 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme labels that are descendants of a window:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkWindow GtkLabel {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #898989
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme notebooks, and anything that’s within these:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkNotebook {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #a939f0
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme combo boxes, and entries that are direct children of a notebook:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkComboBox,
|
|
|
|
|
* GtkNotebook > GtkEntry {
|
2010-11-18 23:36:08 +00:00
|
|
|
|
* color: @fg_color;
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #1209a2
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme any widget within a GtkBin:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkBin * {
|
2011-06-01 23:55:45 +00:00
|
|
|
|
* font: Sans 20
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-11-20 05:22:29 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme a label named title-label:
|
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* GtkLabel#title-label {
|
2011-06-01 23:55:45 +00:00
|
|
|
|
* font: Sans 15
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme any widget named main-entry:
|
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* #main-entry {
|
|
|
|
|
* background-color: #f0a810
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Widgets may also define style classes, which can be used for matching.
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* When used in a selector, style classes must be prefixed with a “.”
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* character.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Refer to the documentation of individual widgets to learn which
|
2014-02-07 16:12:43 +00:00
|
|
|
|
* style classes they define and see
|
|
|
|
|
* [Style Classes and Regions][gtkstylecontext-classes]
|
2010-11-26 04:46:15 +00:00
|
|
|
|
* for a list of all style classes used by GTK+ widgets.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-01-19 17:55:48 +00:00
|
|
|
|
* Note that there is some ambiguity in the selector syntax when it comes
|
|
|
|
|
* to differentiation widget class names from regions. GTK+ currently treats
|
|
|
|
|
* a string as a widget class name if it contains any uppercase characters
|
|
|
|
|
* (which should work for more widgets with names like GtkLabel).
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ## Examples for style classes in selectors
|
|
|
|
|
*
|
|
|
|
|
* Theme all widgets defining the class entry:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* .entry {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #39f1f9;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme spinbuttons’ entry:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkSpinButton.entry {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #900185
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* In complicated widgets like e.g. a GtkNotebook, it may be desirable
|
|
|
|
|
* to style different parts of the widget differently. To make this
|
|
|
|
|
* possible, container widgets may define regions, whose names
|
|
|
|
|
* may be used for matching in selectors.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Some containers allow to further differentiate between regions by
|
|
|
|
|
* applying so-called pseudo-classes to the region. For example, the
|
|
|
|
|
* tab region in GtkNotebook allows to single out the first or last
|
|
|
|
|
* tab by using the :first-child or :last-child pseudo-class.
|
|
|
|
|
* When used in selectors, pseudo-classes must be prefixed with a
|
|
|
|
|
* ':' character.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Refer to the documentation of individual widgets to learn which
|
2010-11-26 04:49:07 +00:00
|
|
|
|
* regions and pseudo-classes they define and see
|
2014-02-07 16:12:43 +00:00
|
|
|
|
* [Style Classes and Regions][gtkstylecontext-classes]
|
|
|
|
|
* for a list of all regions
|
2010-11-26 04:49:07 +00:00
|
|
|
|
* used by GTK+ widgets.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ## Examples for regions in selectors
|
|
|
|
|
*
|
|
|
|
|
* Theme any label within a notebook:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkNotebook GtkLabel {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #f90192;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme labels within notebook tabs:
|
|
|
|
|
* |[
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* GtkNotebook tab GtkLabel {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #703910;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme labels in the any first notebook tab, both selectors are
|
|
|
|
|
* equivalent:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkNotebook tab:nth-child(first) GtkLabel,
|
|
|
|
|
* GtkNotebook tab:first-child GtkLabel {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* color: #89d012;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Another use of pseudo-classes is to match widgets depending on their
|
|
|
|
|
* state. This is conceptually similar to the :hover, :active or :focus
|
|
|
|
|
* pseudo-classes in CSS. The available pseudo-classes for widget states
|
|
|
|
|
* are :active, :prelight (or :hover), :insensitive, :selected, :focused
|
|
|
|
|
* and :inconsistent.
|
2014-02-05 02:00:58 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ## Examples for styling specific widget states
|
|
|
|
|
*
|
|
|
|
|
* Theme active (pressed) buttons:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkButton:active {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #0274d9;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme buttons with the mouse pointer on it, both are equivalent:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkButton:hover,
|
|
|
|
|
* GtkButton:prelight {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #3085a9;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme insensitive widgets, both are equivalent:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* :insensitive,
|
|
|
|
|
* *:insensitive {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #320a91;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme selection colors in entries:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkEntry:selected {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #56f9a0;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme focused labels:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkLabel:focused {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #b4940f;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-02-15 04:34:22 +00:00
|
|
|
|
* Theme inconsistent checkbuttons:
|
|
|
|
|
* |[
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* GtkCheckButton:inconsistent {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: #20395a;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Widget state pseudoclasses may only apply to the last element
|
|
|
|
|
* in a selector.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* To determine the effective style for a widget, all the matching rule
|
|
|
|
|
* sets are merged. As in CSS, rules apply by specificity, so the rules
|
|
|
|
|
* whose selectors more closely match a widget path will take precedence
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* over the others.
|
2014-02-05 02:00:58 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* # @ Rules
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* GTK+’s CSS supports the \@import rule, in order to load another
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* CSS style sheet in addition to the currently parsed one.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* An example for using the \@import rule:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* @import url ("path/to/common.css");
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-01-28 09:25:17 +00:00
|
|
|
|
* In order to extend key bindings affecting different widgets, GTK+
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* supports the \@binding-set rule to parse a set of bind/unbind
|
2011-01-31 04:34:52 +00:00
|
|
|
|
* directives, see #GtkBindingSet for the supported syntax. Note that
|
|
|
|
|
* the binding sets defined in this way must be associated with rule sets
|
|
|
|
|
* by setting the gtk-key-bindings style property.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-01-31 04:34:52 +00:00
|
|
|
|
* Customized key bindings are typically defined in a separate
|
2014-02-03 21:34:03 +00:00
|
|
|
|
* `gtk-keys.css` CSS file and GTK+ loads this file
|
2011-01-31 04:34:52 +00:00
|
|
|
|
* according to the current key theme, which is defined by the
|
|
|
|
|
* #GtkSettings:gtk-key-theme-name setting.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* An example for using the \@binding rule:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* @binding-set binding-set1 {
|
|
|
|
|
* bind "<alt>Left" { "move-cursor" (visual-positions, -3, 0) };
|
2011-01-28 09:25:17 +00:00
|
|
|
|
* unbind "End";
|
|
|
|
|
* };
|
|
|
|
|
*
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* @binding-set binding-set2 {
|
|
|
|
|
* bind "<alt>Right" { "move-cursor" (visual-positions, 3, 0) };
|
|
|
|
|
* bind "<alt>KP_space" { "delete-from-cursor" (whitespace, 1)
|
2011-01-31 04:34:52 +00:00
|
|
|
|
* "insert-at-cursor" (" ") };
|
2011-01-28 09:25:17 +00:00
|
|
|
|
* };
|
|
|
|
|
*
|
|
|
|
|
* GtkEntry {
|
2011-01-28 23:08:57 +00:00
|
|
|
|
* gtk-key-bindings: binding-set1, binding-set2;
|
2011-01-28 09:25:17 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* GTK+ also supports an additional \@define-color rule, in order
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* to define a color name which may be used instead of color numeric
|
|
|
|
|
* representations. Also see the #GtkSettings:gtk-color-scheme setting
|
|
|
|
|
* for a way to override the values of these named colors.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* An example for defining colors:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* @define-color bg_color #f9a039;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* * {
|
|
|
|
|
* background-color: @bg_color;
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Symbolic colors
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-20 05:22:29 +00:00
|
|
|
|
* Besides being able to define color names, the CSS parser is also able
|
|
|
|
|
* to read different color expressions, which can also be nested, providing
|
|
|
|
|
* a rich language to define colors which are derived from a set of base
|
|
|
|
|
* colors.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* An example for using symbolic colors:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* @define-color entry-color shade (@bg_color, 0.7);
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*
|
|
|
|
|
* GtkEntry {
|
|
|
|
|
* background-color: @entry-color;
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* GtkEntry:focused {
|
2014-01-27 20:42:15 +00:00
|
|
|
|
* background-color: mix (@entry-color,
|
|
|
|
|
* shade (#fff, 0.5),
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* 0.8);
|
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* # Specifying Colors # {#specifying-colors}
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* There are various ways to express colors in GTK+ CSS.
|
|
|
|
|
*
|
|
|
|
|
* ## rgb(r, g, b)
|
|
|
|
|
*
|
|
|
|
|
* An opaque color.
|
|
|
|
|
*
|
|
|
|
|
* - `r`, `g`, `b` can be either integers between 0 and 255, or percentages.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: rgb(128, 10, 54);
|
|
|
|
|
* background-color: rgb(20%, 30%, 0%);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## rgba(r, g, b, a)
|
|
|
|
|
*
|
|
|
|
|
* A translucent color.
|
|
|
|
|
*
|
|
|
|
|
* - `r`, `g`, `b` can be either integers between 0 and 255, or percentages.
|
|
|
|
|
* - `a` is a floating point number between 0 and 1.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: rgb(128, 10, 54, 0.5);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* ## \#xxyyzz
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
|
|
|
|
* An opaque color.
|
|
|
|
|
*
|
|
|
|
|
* - `xx`, `yy`, `zz` are hexadecimal numbers specifying `r`, `g`, `b`
|
|
|
|
|
* variants with between 1 and 4 hexadecimal digits per component.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: #f0c;
|
|
|
|
|
* background-color: #ff00cc;
|
|
|
|
|
* border-color: #ffff0000cccc;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* ## \@name
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* Reference to a color that has been defined with \@define-color
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: @bg_color;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## mix(color1, color2, factor)
|
|
|
|
|
*
|
|
|
|
|
* A linear combination of `color1` and `color2`.
|
|
|
|
|
*
|
|
|
|
|
* - `factor` is a floating point number between 0 and 1.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: mix(#ff1e0a, @bg_color, 0.8);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## shade(color, factor)
|
|
|
|
|
*
|
|
|
|
|
* A lighter or darker variant of `color`.
|
|
|
|
|
*
|
|
|
|
|
* - `factor` is a floating point number.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: shade(@fg_color, 0.5);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## lighter(color)
|
|
|
|
|
*
|
|
|
|
|
* A lighter variant of `color`.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: lighter(@fg_color);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## darker(color)
|
|
|
|
|
*
|
|
|
|
|
* A darker variant of `color`.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: darker(@bg_color);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## alpha(color, factor)
|
|
|
|
|
*
|
|
|
|
|
* Modifies passed color’s alpha by a factor.
|
|
|
|
|
*
|
|
|
|
|
* - `factor` is a floating point number. `factor` < 1.0 results in a more
|
|
|
|
|
* transparent color while `factor` > 1.0 results in a more opaque color.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* color: alpha(@fg_color, 0.5);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Gradients
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* Linear or radial gradients can be used as background images.
|
|
|
|
|
*
|
|
|
|
|
* ## Linear Gradients
|
|
|
|
|
*
|
|
|
|
|
* A linear gradient along the line from (`start_x`, `start_y`) to
|
|
|
|
|
* (`end_x`, `end_y`) is specified using the following syntax:
|
|
|
|
|
*
|
|
|
|
|
* > `-gtk-gradient (linear, start_x start_y, end_x end_y, color-stop (position, color), ...)`
|
|
|
|
|
*
|
|
|
|
|
* - `start_x` and `end_x` can be either a floating point number between
|
|
|
|
|
* 0 and 1, or one of the special values: “left”, “right”, or “center”.
|
|
|
|
|
* - `start_y` and `end_y` can be either a floating point number between 0 and 1, or one
|
|
|
|
|
* of the special values: “top”, “bottom” or “center”.
|
|
|
|
|
* - `position` is a floating point number between 0 and 1.
|
|
|
|
|
* - `color` is a color expression (see above).
|
|
|
|
|
*
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* The color-stop can be repeated multiple times to add more than one color
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* stop. “from (color)” and “to (color)” can be used as abbreviations for
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* color stops with position 0 and 1, respectively.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Example: Linear Gradient
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](gradient1.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* -gtk-gradient (linear,
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* left top, right bottom,
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* from(@yellow), to(@blue));
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Example: Linear Gradient 2
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](gradient2.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* -gtk-gradient (linear,
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* 0 0, 0 1,
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* color-stop(0, @yellow),
|
|
|
|
|
* color-stop(0.2, @blue),
|
|
|
|
|
* color-stop(1, #0f0))
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## Radial Gradients
|
|
|
|
|
*
|
|
|
|
|
* A radial gradient along the two circles defined by (`start_x`,
|
|
|
|
|
* `start_y`, `start_radius`) and (`end_x`, `end_y`, `end_radius`) is
|
|
|
|
|
* specified using the following syntax:
|
|
|
|
|
*
|
|
|
|
|
* > `-gtk-gradient (radial, start_x start_y, start_radius, end_x end_y, end_radius, color-stop (position, color), ...)`
|
|
|
|
|
*
|
|
|
|
|
* where `start_radius` and `end_radius` are floating point numbers
|
|
|
|
|
* and the other parameters are as before.
|
|
|
|
|
*
|
|
|
|
|
* ## Example: Radial Gradient
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](gradient3.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* -gtk-gradient (radial,
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* center center, 0,
|
|
|
|
|
* center center, 1,
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* from(@yellow), to(@green))
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Example: Radial Gradient 2
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](gradient4.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* -gtk-gradient (radial,
|
2010-11-22 06:41:45 +00:00
|
|
|
|
* 0.4 0.4, 0.1,
|
|
|
|
|
* 0.6 0.6, 0.7,
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* color-stop (0, #f00),
|
|
|
|
|
* color-stop (0.1, #a0f),
|
|
|
|
|
* color-stop (0.2, @yellow),
|
|
|
|
|
* color-stop (1, @green))
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-08 02:34:27 +00:00
|
|
|
|
* # Border images # {#border-images}
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-05-31 13:32:00 +00:00
|
|
|
|
* Images and gradients can also be used in slices for the purpose of creating
|
|
|
|
|
* scalable borders.
|
2014-02-04 23:53:51 +00:00
|
|
|
|
* For more information, see the [CSS3 documentation for the border-image property](http://www.w3.org/TR/css3-background/#border-images).
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](slices.png)
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* The parameters of the slicing process are controlled by four
|
|
|
|
|
* separate properties.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* - Image Source
|
|
|
|
|
* - Image Slice
|
|
|
|
|
* - Image Width
|
|
|
|
|
* - Image Repeat
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* Note that you can use the `border-image` shorthand property to set
|
|
|
|
|
* values for the properties at the same time.
|
|
|
|
|
*
|
|
|
|
|
* ## Image Source
|
|
|
|
|
*
|
|
|
|
|
* The border image source can be specified either as a
|
|
|
|
|
* URL or a gradient:
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-source: url(path);
|
|
|
|
|
* ]|
|
|
|
|
|
* or
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-source: -gtk-gradient(...);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## Image Slice
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-slice: top right bottom left;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* The sizes specified by the `top`, `right`, `bottom`, and `left` parameters
|
|
|
|
|
* are the offsets (in pixels) from the relevant edge where the image
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* should be “cut off” to build the slices used for the rendering
|
2011-05-31 13:32:00 +00:00
|
|
|
|
* of the border.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Image Width
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-width: top right bottom left;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2011-06-09 23:59:14 +00:00
|
|
|
|
* The sizes specified by the @top, @right, @bottom and @left parameters
|
|
|
|
|
* are inward distances from the border box edge, used to specify the
|
|
|
|
|
* rendered size of each slice determined by border-image-slice.
|
|
|
|
|
* If this property is not specified, the values of border-width will
|
|
|
|
|
* be used as a fallback.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Image Repeat
|
|
|
|
|
*
|
2011-05-31 13:32:00 +00:00
|
|
|
|
* Specifies how the image slices should be rendered in the area
|
|
|
|
|
* outlined by border-width.
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-repeat: [stretch|repeat|round|space];
|
|
|
|
|
* ]|
|
|
|
|
|
* or
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-repeat: [stretch|repeat|round|space] [stretch|repeat|round|space];
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* - The default (stretch) is to resize the slice to fill in the
|
|
|
|
|
* whole allocated area.
|
|
|
|
|
*
|
|
|
|
|
* - If the value of this property is “repeat”, the image slice will
|
|
|
|
|
* be tiled to fill the area.
|
|
|
|
|
*
|
|
|
|
|
* - If the value of this property is “round”, the image slice will be
|
|
|
|
|
* tiled to fill the area, and scaled to fit it exactly a whole number
|
|
|
|
|
* of times.
|
|
|
|
|
*
|
|
|
|
|
* - If the value of this property is “space”, the image slice will be
|
|
|
|
|
* tiled to fill the area, and if it doesn’t fit it exactly a whole
|
|
|
|
|
* number of times, the extra space is distributed as padding around
|
2011-05-31 13:32:00 +00:00
|
|
|
|
* the slices.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* - If two options are specified, the first one affects the
|
|
|
|
|
* horizontal behaviour and the second one the vertical behaviour. If
|
|
|
|
|
* only one option is specified, it affects both.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* ## Example: Border Image
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](border1.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* border-image: url("gradient1.png") 10 10 10 10;
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Example: Repeating Border Image
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](border2.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* border-image: url("gradient1.png") 10 10 10 10 repeat;
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* ## Example: Stetched Border Image
|
2014-02-03 22:19:27 +00:00
|
|
|
|
* ![](border3.png)
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* |[
|
|
|
|
|
* border-image: url("gradient1.png") 10 10 10 10 stretch;
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* # Supported Properties
|
|
|
|
|
*
|
|
|
|
|
* Properties are the part that differ the most to common CSS, not all
|
|
|
|
|
* properties are supported (some are planned to be supported
|
|
|
|
|
* eventually, some others are meaningless or don't map intuitively in
|
|
|
|
|
* a widget based environment).
|
|
|
|
|
*
|
|
|
|
|
* The currently supported properties are:
|
|
|
|
|
*
|
|
|
|
|
* ## engine: [name|none];
|
|
|
|
|
*
|
|
|
|
|
* - `none` means to use the default (ie. builtin engine)
|
|
|
|
|
* |[
|
|
|
|
|
* engine: clearlooks;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## background-color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* background-color: shade (@color1, 0.5);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* color: #fff;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-color: [color|transparent]{1,4};
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* - Four values used to specify: top right bottom left
|
|
|
|
|
* - Three values used to specify: top vertical bottom
|
|
|
|
|
* - Two values used to specify: horizontal vertical
|
|
|
|
|
* - One value used to specify: color
|
|
|
|
|
* |[
|
|
|
|
|
* border-color: red green blue;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-top-color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* border-top-color: @borders;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-right-color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* border-right-color: @borders;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-bottom-color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* border-bottom-color: @borders;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-left-color: [color|transparent];
|
|
|
|
|
*
|
|
|
|
|
* - `color`: See [Specifying Colors][specifying-colors]
|
|
|
|
|
* |[
|
|
|
|
|
* border-left-color: @borders;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## font-family: name;
|
|
|
|
|
*
|
|
|
|
|
* The name of the font family or font name to use.
|
|
|
|
|
*
|
|
|
|
|
* - Note: unlike the CSS2 Specification this does not support using a
|
|
|
|
|
* prioritized list of font family names and/or generic family
|
|
|
|
|
* names.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* font-family: Sans, Cantarell;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## font-style: [normal|oblique|italic];
|
|
|
|
|
*
|
|
|
|
|
* Selects between normal, italic and oblique faces within a font family.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* font-style: italic;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## font-variant: [normal|small-caps];
|
|
|
|
|
*
|
|
|
|
|
* In a small-caps font the lower case letters look similar to the
|
|
|
|
|
* uppercase ones, but in a smaller size and with slightly different
|
|
|
|
|
* proportions.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* font-variant: normal;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## font-weight: [normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900];
|
|
|
|
|
*
|
|
|
|
|
* Selects the weight of the font. The values '100' to '900' form an
|
|
|
|
|
* ordered sequence, where each number indicates a weight that is at
|
|
|
|
|
* least as dark as its predecessor. The keyword 'normal' is
|
|
|
|
|
* synonymous with '400', and 'bold' is synonymous with
|
|
|
|
|
* '700'. Keywords other than 'normal' and 'bold' have been shown to
|
|
|
|
|
* be often confused with font names and a numerical scale was
|
|
|
|
|
* therefore chosen for the 9-value list.
|
|
|
|
|
* - Maps to #PANGO_TYPE_WEIGHT
|
|
|
|
|
* |[
|
|
|
|
|
* font-weight: bold;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## font-size: [absolute-size|relative-size|percentage];
|
|
|
|
|
*
|
|
|
|
|
* - `absolute-size`: The size in normal size units like `px`, `pt`,
|
|
|
|
|
* and `em`. Or symbolic sizes like `xx-small`, `x-small`, `small`,
|
|
|
|
|
* `medium`, `large`, `x-large`, `xx-large`.
|
|
|
|
|
* - `relative-size`: `larger` or `smaller` relative to the parent.
|
|
|
|
|
* - `percentage`: A percentage difference from the nominal size.
|
|
|
|
|
* |[
|
|
|
|
|
* font-size: 12px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-08-28 11:50:49 +00:00
|
|
|
|
* ## font-stretch: [face]
|
|
|
|
|
*
|
|
|
|
|
* Selects a normal, condensed, or expanded face from a font family.
|
|
|
|
|
*
|
|
|
|
|
* Absolute keyword values have the following ordering, from narrowest to widest:
|
|
|
|
|
*
|
|
|
|
|
* - ultra-condensed
|
|
|
|
|
* - extra-condensed
|
|
|
|
|
* - condensed
|
|
|
|
|
* - semi-condensed
|
|
|
|
|
* - normal
|
|
|
|
|
* - semi-expanded
|
|
|
|
|
* - expanded
|
|
|
|
|
* - extra-expanded
|
|
|
|
|
* - ultra-expanded
|
|
|
|
|
*
|
|
|
|
|
* ## font: [family] [style] [variant] [stretch] [size];
|
2014-02-08 01:52:37 +00:00
|
|
|
|
*
|
|
|
|
|
* A shorthand for setting a few font properties at once.
|
|
|
|
|
* - Supports any format accepted by pango_font_description_from_string()
|
|
|
|
|
* - Note: this is somewhat different from the CSS2 Specification for this property.
|
|
|
|
|
* |[
|
|
|
|
|
* font: Bold 11;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## margin: [length|percentage]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* A shorthand for setting the margin space required on all sides of
|
|
|
|
|
* an element.
|
|
|
|
|
* - Four values used to specify: top right bottom left
|
|
|
|
|
* - Three values used to specify: top horizontal bottom
|
|
|
|
|
* - Two values used to specify: vertical horizontal
|
|
|
|
|
* - One value used to specify: margin
|
|
|
|
|
* |[
|
|
|
|
|
* margin: 1em 2em 4em;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## margin-top: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the margin space required on the top of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* margin-top: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## margin-right: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the margin space required on the right of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* margin-right: 0px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## margin-bottom: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the margin space required on the bottom of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* margin-bottom: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## margin-left: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the margin space required on the left of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* margin-left: 1em;
|
|
|
|
|
* ]|
|
2014-02-07 22:35:22 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* ## padding: [length|percentage]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* A shorthand for setting the padding space required on all sides of
|
|
|
|
|
* an element. The padding area is the space between the content of
|
|
|
|
|
* the element and its border.
|
|
|
|
|
* - Four values used to specify: top right bottom left
|
|
|
|
|
* - Three values used to specify: top horizontal bottom
|
|
|
|
|
* - Two values used to specify: vertical horizontal
|
|
|
|
|
* - One value used to specify: padding
|
|
|
|
|
* |[
|
|
|
|
|
* padding: 1em 2em 4em;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## padding-top: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the padding space required on the top of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* padding-top: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## padding-right: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the padding space required on the right of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* padding-right: 0px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## padding-bottom: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the padding space required on the bottom of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* padding-bottom: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## padding-left: [length|percentage];
|
|
|
|
|
*
|
|
|
|
|
* Sets the padding space required on the left of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* padding-left: 1em;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-width: [width]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* A shorthand for setting the border width on all sides of
|
|
|
|
|
* an element.
|
|
|
|
|
* - Four values used to specify: top right bottom left
|
|
|
|
|
* - Three values used to specify: top vertical bottom
|
|
|
|
|
* - Two values used to specify: horizontal vertical
|
|
|
|
|
* - One value used to specify: width
|
|
|
|
|
* |[
|
|
|
|
|
* border-width: 1px 2px 4px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-top-width: [width];
|
|
|
|
|
*
|
|
|
|
|
* Sets the border width required on the top of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* border-top: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-right-width: [width];
|
|
|
|
|
*
|
|
|
|
|
* Sets the border width required on the right of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* border-right: 0px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-bottom-width: [width];
|
|
|
|
|
*
|
|
|
|
|
* Sets the border width required on the bottom of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* border-bottom: 10px;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-left-width: [width];
|
|
|
|
|
*
|
|
|
|
|
* Sets the border width required on the left of an element.
|
|
|
|
|
* |[
|
|
|
|
|
* border-left: 1em;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-radius: [length|percentage]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* Allows setting how rounded all border corners are.
|
|
|
|
|
* - Four values used to specify: top-left top-right bottom-right bottom-left
|
|
|
|
|
* - Three values used to specify: top-left top-right-and-bottom-left bottom-right
|
|
|
|
|
* - Two values used to specify: top-left-and-bottom-right top-right-and-bottom-left
|
|
|
|
|
* - One value used to specify: radius on all sides
|
|
|
|
|
* |[
|
|
|
|
|
* border-radius: 8px
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-style: [none|solid|inset|outset]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* A shorthand property for setting the line style for all four sides
|
|
|
|
|
* of the elements border.
|
|
|
|
|
* - Four values used to specify: top right bottom left;
|
|
|
|
|
* - Three values used to specify: top horizontal bottom
|
|
|
|
|
* - Two values used to specify: vertical horizontal
|
|
|
|
|
* - One value used to specify: style
|
|
|
|
|
* |[
|
|
|
|
|
* border-style: solid;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-image: [source] [slice] [ / width ] [repeat]; A shorthand
|
|
|
|
|
* for setting an image on the borders of elements. See [Border
|
|
|
|
|
* Images][border-images].
|
|
|
|
|
* |[
|
|
|
|
|
* border-image: url("/path/to/image.png") 3 4 4 3 repeat stretch;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-image-source: [none|url|linear-gradient]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* Defines the image to use instead of the style of the border. If
|
|
|
|
|
* this property is set to none, the style defined by border-style is
|
|
|
|
|
* used instead.
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-source: url("/path/to/image.png");
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-image-slice: [number|percentage]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* Divides the image specified by border-image-source in nine regions:
|
|
|
|
|
* the four corners, the four edges and the middle. It does this by
|
|
|
|
|
* specifying 4 inwards offsets.
|
|
|
|
|
* - Four values used to specify: top right bottom left;
|
|
|
|
|
* - Three values used to specify: top vertical bottom
|
|
|
|
|
* - Two values used to specify: horizontal vertical
|
|
|
|
|
* - One value used to specify: slice
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-slice: 3 3 4 3;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-image-width: [length|percentage]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* Defines the offset to use for dividing the border image in nine
|
|
|
|
|
* parts, the top-left corner, central top edge, top-right-corner,
|
|
|
|
|
* central right edge, bottom-right corner, central bottom edge,
|
|
|
|
|
* bottom-left corner, and central right edge. They represent inward
|
|
|
|
|
* distance from the top, right, bottom, and left edges.
|
|
|
|
|
* - Four values used to specify: top right bottom left;
|
|
|
|
|
* - Three values used to specify: top horizontal bottom
|
|
|
|
|
* - Two values used to specify: vertical horizontal
|
|
|
|
|
* - One value used to specify: width
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-width: 4px 0 4px 0;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## border-image-repeat: [none|url|linear-gradient]{1,4};
|
|
|
|
|
*
|
|
|
|
|
* Defines how the middle part of a border image is handled to match
|
|
|
|
|
* the size of the border. It has a one-value syntax which describes
|
|
|
|
|
* the behavior for all sides, and a two-value syntax that sets a
|
|
|
|
|
* different value for the horizontal and vertical behavior.
|
|
|
|
|
* - Two values used to specify: horizontal vertical
|
|
|
|
|
* - One value used to specify: repeat
|
|
|
|
|
* |[
|
|
|
|
|
* border-image-repeat: stretch;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## background-image: [none|url|linear-gradient], ...
|
|
|
|
|
* Sets one or several background images for an element. The images
|
|
|
|
|
* are drawn on successive stacking context layers, with the first
|
|
|
|
|
* specified being drawn as if it is the closest to the user. The
|
|
|
|
|
* borders of the element are then drawn on top of them, and the
|
|
|
|
|
* background-color is drawn beneath them.
|
|
|
|
|
* - There can be several sources listed, separated by commas.
|
|
|
|
|
* |[
|
|
|
|
|
* background-image: gtk-gradient (linear,
|
|
|
|
|
* left top, right top,
|
|
|
|
|
* from (#fff), to (#000));
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## background-repeat: [repeat|no-repeat|space|round|repeat-x|repeat-y];
|
|
|
|
|
*
|
|
|
|
|
* Defines how background images are repeated. A background image can
|
|
|
|
|
* be repeated along the horizontal axis, the vertical axis, both, or
|
|
|
|
|
* not repeated at all.
|
|
|
|
|
* - `repeat`: The image is repeated in the given direction as much as
|
|
|
|
|
* needed to cover the whole background image painting area. The
|
|
|
|
|
* last image may be clipped if the whole thing won't fit in the
|
|
|
|
|
* remaining area.
|
|
|
|
|
* - `space`: The image is repeated in the given direction as much as
|
|
|
|
|
* needed to cover most of the background image painting area,
|
|
|
|
|
* without clipping an image. The remaining non-covered space is
|
|
|
|
|
* spaced out evenly between the images. The first and last images
|
|
|
|
|
* touches the edge of the element. The value of the
|
|
|
|
|
* background-position CSS property is ignored for the concerned
|
|
|
|
|
* direction, except if one single image is greater than the
|
|
|
|
|
* background image painting area, which is the only case where an
|
|
|
|
|
* image can be clipped when the space value is used.
|
|
|
|
|
* - `round`: The image is repeated in the given direction as much as
|
|
|
|
|
* needed to cover most of the background image painting area,
|
|
|
|
|
* without clipping an image. If it doesn't cover exactly the area,
|
|
|
|
|
* the tiles are resized in that direction in order to match it.
|
|
|
|
|
* - `no-repeat`: The image is not repeated (and hence the background
|
|
|
|
|
* image painting area will not necessarily been entirely
|
|
|
|
|
* covered). The position of the non-repeated background image is
|
|
|
|
|
* defined by the background-position CSS property.
|
|
|
|
|
* - Note if not specified, the style doesn’t respect the CSS3
|
|
|
|
|
* specification, since the background will be stretched to fill
|
|
|
|
|
* the area.
|
|
|
|
|
* |[
|
|
|
|
|
* background-repeat: no-repeat;
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## text-shadow: horizontal_offset vertical_offset [ blur_radius ] color;
|
|
|
|
|
*
|
|
|
|
|
* A shadow list can be applied to text or symbolic icons, using the CSS3
|
|
|
|
|
* text-shadow syntax, as defined in the
|
|
|
|
|
* [CSS3 Specification](http://www.w3.org/TR/css3-text/#text-shadow).
|
|
|
|
|
*
|
|
|
|
|
* - The offset of the shadow is specified with the
|
|
|
|
|
* `horizontal_offset` and `vertical_offset` parameters.
|
|
|
|
|
* - The optional blur radius is parsed, but it is currently not
|
|
|
|
|
* rendered by the GTK+ theming engine.
|
|
|
|
|
*
|
|
|
|
|
* To set a shadow on an icon, use the `icon-shadow` property instead,
|
|
|
|
|
* with the same syntax.
|
|
|
|
|
*
|
|
|
|
|
* To set multiple shadows on an element, you can specify a comma-separated list
|
|
|
|
|
* of shadow elements in the `text-shadow` or `icon-shadow` property. Shadows are
|
|
|
|
|
* always rendered front to back (i.e. the first shadow specified is on top of the
|
|
|
|
|
* others). Shadows can thus overlay each other, but they can never overlay the
|
|
|
|
|
* text or icon itself, which is always rendered on top of the shadow layer.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
2014-12-13 15:36:15 +00:00
|
|
|
|
* text-shadow: 1 1 0 blue, -4 -4 red;
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* ]|
|
|
|
|
|
|
|
|
|
|
* ## box-shadow: [ inset ] horizontal_offset vertical_offset [ blur_radius ] [ spread ] color;
|
|
|
|
|
*
|
|
|
|
|
* Themes can apply shadows on framed elements using the CSS3 box-shadow syntax,
|
|
|
|
|
* as defined in the
|
|
|
|
|
* [CSS3 Specification](http://www.w3.org/TR/css3-background/#the-box-shadow).
|
|
|
|
|
*
|
|
|
|
|
* - A positive offset will draw a shadow that is offset to the right (down) of the box,
|
|
|
|
|
* - A negative offset to the left (top).
|
|
|
|
|
* - The optional spread parameter defines an additional distance to
|
|
|
|
|
* expand the shadow shape in all directions, by the specified radius.
|
|
|
|
|
* - The optional blur radius parameter is parsed, but it is currently not rendered by
|
|
|
|
|
* the GTK+ theming engine.
|
|
|
|
|
* - The inset parameter defines whether the drop shadow should be rendered inside or outside
|
|
|
|
|
* the box canvas.
|
|
|
|
|
*
|
|
|
|
|
* To set multiple box-shadows on an element, you can specify a comma-separated list
|
|
|
|
|
* of shadow elements in the `box-shadow` property. Shadows are always rendered
|
|
|
|
|
* front to back (i.e. the first shadow specified is on top of the others) so they may
|
|
|
|
|
* overlap other boxes or other shadows.
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* box-shadow: inset 0 1px 1px alpha(black, 0.1);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* ## transition: duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] [loop];
|
|
|
|
|
*
|
|
|
|
|
* Styles can specify transitions that will be used to create a
|
|
|
|
|
* gradual change in the appearance when a widget state changes.
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* - The `duration` is the amount of time that the animation will take
|
|
|
|
|
* for a complete cycle from start to end.
|
|
|
|
|
* - If the loop option is given, the animation will be repated until
|
|
|
|
|
* the state changes again.
|
|
|
|
|
* - The option after the duration determines the transition function
|
|
|
|
|
* from a small set of predefined functions.
|
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - Linear
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* ![](linear.png)
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - Ease transition
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
|
|
|
|
* ![](ease.png)
|
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - Ease-in-out transition
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
|
|
|
|
* ![](ease-in-out.png)
|
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - Ease-in transition
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
|
|
|
|
* ![](ease-in.png)
|
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* - Ease-out transition
|
2014-02-04 22:20:43 +00:00
|
|
|
|
*
|
|
|
|
|
* ![](ease-out.png)
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* |[
|
|
|
|
|
* transition: 150ms ease-in-out;
|
|
|
|
|
* ]|
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
*
|
2014-02-08 01:52:37 +00:00
|
|
|
|
* ## gtk-key-bindings: binding1, binding2, ...;
|
|
|
|
|
*
|
|
|
|
|
* Key binding set name list.
|
|
|
|
|
*
|
|
|
|
|
* ## Other Properties
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2010-11-23 06:05:11 +00:00
|
|
|
|
* GtkThemingEngines can register their own, engine-specific style properties
|
|
|
|
|
* with the function gtk_theming_engine_register_property(). These properties
|
|
|
|
|
* can be set in CSS like other properties, using a name of the form
|
2014-02-07 22:35:22 +00:00
|
|
|
|
* `-namespace-name`, where namespace is typically
|
2014-02-05 00:20:16 +00:00
|
|
|
|
* the name of the theming engine, and name is the
|
2010-11-23 06:05:11 +00:00
|
|
|
|
* name of the property. Style properties that have been registered by widgets
|
|
|
|
|
* using gtk_widget_class_install_style_property() can also be set in this
|
2014-02-05 00:20:16 +00:00
|
|
|
|
* way, using the widget class name for namespace.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* An example for using engine-specific style properties:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2010-11-23 06:05:11 +00:00
|
|
|
|
* * {
|
|
|
|
|
* engine: clearlooks;
|
|
|
|
|
* border-radius: 4;
|
|
|
|
|
* -GtkPaned-handle-size: 6;
|
|
|
|
|
* -clearlooks-colorize-scrollbar: false;
|
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-05-17 20:04:40 +00:00
|
|
|
|
typedef struct GtkCssRuleset GtkCssRuleset;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
typedef struct _GtkCssScanner GtkCssScanner;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
typedef struct _PropertyValue PropertyValue;
|
|
|
|
|
typedef struct _WidgetPropertyValue WidgetPropertyValue;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
typedef enum ParserScope ParserScope;
|
2010-04-20 23:46:52 +00:00
|
|
|
|
typedef enum ParserSymbol ParserSymbol;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
struct _PropertyValue {
|
|
|
|
|
GtkCssStyleProperty *property;
|
2012-03-06 13:16:32 +00:00
|
|
|
|
GtkCssValue *value;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
GtkCssSection *section;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _WidgetPropertyValue {
|
|
|
|
|
WidgetPropertyValue *next;
|
2012-03-30 00:45:01 +00:00
|
|
|
|
char *name;
|
|
|
|
|
char *value;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
|
|
|
|
|
GtkCssSection *section;
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-17 20:04:40 +00:00
|
|
|
|
struct GtkCssRuleset
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-05-14 11:27:31 +00:00
|
|
|
|
GtkCssSelector *selector;
|
2012-11-29 14:29:14 +00:00
|
|
|
|
GtkCssSelectorTree *selector_match;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
WidgetPropertyValue *widget_style;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
PropertyValue *styles;
|
2011-12-23 13:23:52 +00:00
|
|
|
|
GtkBitmask *set_styles;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
guint n_styles;
|
|
|
|
|
guint owns_styles : 1;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
guint owns_widget_style : 1;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
struct _GtkCssScanner
|
2011-04-10 01:39:52 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssProvider *provider;
|
|
|
|
|
GtkCssParser *parser;
|
2011-06-17 02:52:43 +00:00
|
|
|
|
GtkCssSection *section;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *parent;
|
2011-04-10 01:51:43 +00:00
|
|
|
|
GSList *state;
|
2011-04-10 01:39:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-04-06 14:10:25 +00:00
|
|
|
|
struct _GtkCssProviderPrivate
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
|
|
|
|
GScanner *scanner;
|
2010-12-03 20:56:39 +00:00
|
|
|
|
|
2010-06-25 18:27:15 +00:00
|
|
|
|
GHashTable *symbolic_colors;
|
2012-04-19 01:41:41 +00:00
|
|
|
|
GHashTable *keyframes;
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
GArray *rulesets;
|
2012-11-28 10:21:06 +00:00
|
|
|
|
GtkCssSelectorTree *tree;
|
2012-02-03 14:50:49 +00:00
|
|
|
|
GResource *resource;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
enum {
|
|
|
|
|
PARSING_ERROR,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-29 11:57:22 +00:00
|
|
|
|
static gboolean gtk_keep_css_sections = FALSE;
|
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
static guint css_provider_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
static void gtk_css_provider_finalize (GObject *object);
|
|
|
|
|
static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface);
|
2011-12-28 21:59:55 +00:00
|
|
|
|
static void gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface);
|
2012-02-15 16:06:30 +00:00
|
|
|
|
static void widget_property_value_list_free (WidgetPropertyValue *head);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-11 23:10:13 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_css_provider_load_internal (GtkCssProvider *css_provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-11 23:10:13 +00:00
|
|
|
|
GFile *file,
|
|
|
|
|
const char *data,
|
|
|
|
|
GError **error);
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2010-11-18 03:29:39 +00:00
|
|
|
|
GQuark
|
|
|
|
|
gtk_css_provider_error_quark (void)
|
|
|
|
|
{
|
|
|
|
|
return g_quark_from_static_string ("gtk-css-provider-error-quark");
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkCssProvider)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
|
2011-12-28 21:59:55 +00:00
|
|
|
|
gtk_css_style_provider_iface_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE,
|
|
|
|
|
gtk_css_style_provider_private_iface_init));
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_parsing_error (GtkCssProvider *provider,
|
2011-06-17 05:39:11 +00:00
|
|
|
|
GtkCssSection *section,
|
|
|
|
|
const GError *error)
|
2011-04-07 15:26:47 +00:00
|
|
|
|
{
|
2011-04-10 23:51:49 +00:00
|
|
|
|
/* Only emit a warning when we have no error handlers. This is our
|
|
|
|
|
* default handlers. And in this case erroneous CSS files are a bug
|
|
|
|
|
* and should be fixed.
|
|
|
|
|
* Note that these warnings can also be triggered by a broken theme
|
|
|
|
|
* that people installed from some weird location on the internets.
|
|
|
|
|
*/
|
|
|
|
|
if (!g_signal_has_handler_pending (provider,
|
|
|
|
|
css_provider_signals[PARSING_ERROR],
|
|
|
|
|
0,
|
|
|
|
|
TRUE))
|
|
|
|
|
{
|
2012-09-27 13:10:52 +00:00
|
|
|
|
char *s = _gtk_css_section_to_string (section);
|
2011-06-17 05:39:11 +00:00
|
|
|
|
|
2012-09-27 13:10:52 +00:00
|
|
|
|
g_warning ("Theme parsing error: %s: %s",
|
|
|
|
|
s,
|
2011-06-17 05:39:11 +00:00
|
|
|
|
error->message);
|
|
|
|
|
|
2012-09-27 13:10:52 +00:00
|
|
|
|
g_free (s);
|
2011-04-10 23:51:49 +00:00
|
|
|
|
}
|
2011-04-07 15:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-06 16:16:26 +00:00
|
|
|
|
/* This is exported privately for use in GtkInspector.
|
|
|
|
|
* It is the callers responsibility to reparse the current theme.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_css_provider_set_keep_css_sections (void)
|
|
|
|
|
{
|
|
|
|
|
gtk_keep_css_sections = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_class_init (GtkCssProviderClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (g_getenv ("GTK_CSS_DEBUG"))
|
2014-07-06 16:16:26 +00:00
|
|
|
|
gtk_css_provider_set_keep_css_sections ();
|
2012-03-29 11:57:22 +00:00
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkCssProvider::parsing-error:
|
|
|
|
|
* @provider: the provider that had a parsing error
|
2011-06-17 05:39:11 +00:00
|
|
|
|
* @section: section the error happened in
|
2011-04-07 15:26:47 +00:00
|
|
|
|
* @error: The parsing error
|
|
|
|
|
*
|
|
|
|
|
* Signals that a parsing error occured. the @path, @line and @position
|
|
|
|
|
* describe the actual location of the error as accurately as possible.
|
|
|
|
|
*
|
|
|
|
|
* Parsing errors are never fatal, so the parsing will resume after
|
|
|
|
|
* the error. Errors may however cause parts of the given
|
|
|
|
|
* data or even all of it to not be parsed at all. So it is a useful idea
|
|
|
|
|
* to check that the parsing succeeds by connecting to this signal.
|
|
|
|
|
*
|
|
|
|
|
* Note that this signal may be emitted at any time as the css provider
|
|
|
|
|
* may opt to defer parsing parts or all of the input to a later time
|
|
|
|
|
* than when a loading function was called.
|
|
|
|
|
*/
|
|
|
|
|
css_provider_signals[PARSING_ERROR] =
|
|
|
|
|
g_signal_new (I_("parsing-error"),
|
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkCssProviderClass, parsing_error),
|
|
|
|
|
NULL, NULL,
|
2011-06-17 05:39:11 +00:00
|
|
|
|
_gtk_marshal_VOID__BOXED_BOXED,
|
|
|
|
|
G_TYPE_NONE, 2, GTK_TYPE_CSS_SECTION, G_TYPE_ERROR);
|
2011-04-07 15:26:47 +00:00
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
object_class->finalize = gtk_css_provider_finalize;
|
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
klass->parsing_error = gtk_css_provider_parsing_error;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_ruleset_init_copy (GtkCssRuleset *new,
|
2012-02-15 16:06:30 +00:00
|
|
|
|
GtkCssRuleset *ruleset,
|
2011-05-18 02:20:05 +00:00
|
|
|
|
GtkCssSelector *selector)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-05-18 02:20:05 +00:00
|
|
|
|
memcpy (new, ruleset, sizeof (GtkCssRuleset));
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
new->selector = selector;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
/* First copy takes over ownership */
|
2012-03-01 05:40:15 +00:00
|
|
|
|
if (ruleset->owns_styles)
|
|
|
|
|
ruleset->owns_styles = FALSE;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
if (ruleset->owns_widget_style)
|
|
|
|
|
ruleset->owns_widget_style = FALSE;
|
2011-12-23 13:23:52 +00:00
|
|
|
|
if (new->set_styles)
|
|
|
|
|
new->set_styles = _gtk_bitmask_copy (new->set_styles);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-05-18 02:20:05 +00:00
|
|
|
|
gtk_css_ruleset_clear (GtkCssRuleset *ruleset)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2012-03-01 05:40:15 +00:00
|
|
|
|
if (ruleset->owns_styles)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ruleset->n_styles; i++)
|
|
|
|
|
{
|
2012-03-06 13:16:32 +00:00
|
|
|
|
_gtk_css_value_unref (ruleset->styles[i].value);
|
|
|
|
|
ruleset->styles[i].value = NULL;
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (ruleset->styles[i].section)
|
|
|
|
|
gtk_css_section_unref (ruleset->styles[i].section);
|
2012-03-01 05:40:15 +00:00
|
|
|
|
}
|
|
|
|
|
g_free (ruleset->styles);
|
|
|
|
|
}
|
2011-12-23 13:23:52 +00:00
|
|
|
|
if (ruleset->set_styles)
|
|
|
|
|
_gtk_bitmask_free (ruleset->set_styles);
|
2012-02-15 16:06:30 +00:00
|
|
|
|
if (ruleset->owns_widget_style)
|
|
|
|
|
widget_property_value_list_free (ruleset->widget_style);
|
2011-05-17 20:04:40 +00:00
|
|
|
|
if (ruleset->selector)
|
|
|
|
|
_gtk_css_selector_free (ruleset->selector);
|
2011-01-16 11:52:43 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
memset (ruleset, 0, sizeof (GtkCssRuleset));
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 16:06:30 +00:00
|
|
|
|
static WidgetPropertyValue *
|
|
|
|
|
widget_property_value_new (char *name, GtkCssSection *section)
|
|
|
|
|
{
|
|
|
|
|
WidgetPropertyValue *value;
|
|
|
|
|
|
|
|
|
|
value = g_slice_new0 (WidgetPropertyValue);
|
|
|
|
|
|
|
|
|
|
value->name = name;
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (gtk_keep_css_sections)
|
|
|
|
|
value->section = gtk_css_section_ref (section);
|
2012-02-15 16:06:30 +00:00
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
widget_property_value_free (WidgetPropertyValue *value)
|
|
|
|
|
{
|
2012-03-30 00:45:01 +00:00
|
|
|
|
g_free (value->value);
|
2012-02-15 16:06:30 +00:00
|
|
|
|
g_free (value->name);
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (value->section)
|
|
|
|
|
gtk_css_section_unref (value->section);
|
2012-02-15 16:06:30 +00:00
|
|
|
|
|
|
|
|
|
g_slice_free (WidgetPropertyValue, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
widget_property_value_list_free (WidgetPropertyValue *head)
|
|
|
|
|
{
|
|
|
|
|
WidgetPropertyValue *l, *next;
|
|
|
|
|
for (l = head; l != NULL; l = next)
|
|
|
|
|
{
|
|
|
|
|
next = l->next;
|
|
|
|
|
widget_property_value_free (l);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WidgetPropertyValue *
|
|
|
|
|
widget_property_value_list_remove_name (WidgetPropertyValue *head, const char *name)
|
|
|
|
|
{
|
|
|
|
|
WidgetPropertyValue *l, **last;
|
|
|
|
|
|
|
|
|
|
last = &head;
|
|
|
|
|
|
|
|
|
|
for (l = head; l != NULL; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (l->name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
*last = l->next;
|
|
|
|
|
widget_property_value_free (l);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
last = &l->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_ruleset_add_style (GtkCssRuleset *ruleset,
|
|
|
|
|
char *name,
|
2012-02-15 16:06:30 +00:00
|
|
|
|
WidgetPropertyValue *value)
|
2011-05-18 02:20:05 +00:00
|
|
|
|
{
|
2012-02-15 16:06:30 +00:00
|
|
|
|
value->next = widget_property_value_list_remove_name (ruleset->widget_style, name);
|
|
|
|
|
ruleset->widget_style = value;
|
|
|
|
|
ruleset->owns_widget_style = TRUE;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:30:51 +00:00
|
|
|
|
static void
|
2012-03-01 04:28:41 +00:00
|
|
|
|
gtk_css_ruleset_add (GtkCssRuleset *ruleset,
|
2012-03-01 05:40:15 +00:00
|
|
|
|
GtkCssStyleProperty *property,
|
2012-03-26 15:24:02 +00:00
|
|
|
|
GtkCssValue *value,
|
2012-03-01 05:40:15 +00:00
|
|
|
|
GtkCssSection *section)
|
2011-05-18 02:30:51 +00:00
|
|
|
|
{
|
2012-03-01 05:40:15 +00:00
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (ruleset->owns_styles || ruleset->n_styles == 0);
|
2012-03-01 04:28:41 +00:00
|
|
|
|
|
2012-02-15 16:06:30 +00:00
|
|
|
|
if (ruleset->set_styles == NULL)
|
|
|
|
|
ruleset->set_styles = _gtk_bitmask_new ();
|
2011-05-18 02:36:43 +00:00
|
|
|
|
|
2012-02-08 18:19:59 +00:00
|
|
|
|
ruleset->set_styles = _gtk_bitmask_set (ruleset->set_styles,
|
|
|
|
|
_gtk_css_style_property_get_id (property),
|
|
|
|
|
TRUE);
|
2011-05-21 21:47:19 +00:00
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
ruleset->owns_styles = TRUE;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ruleset->n_styles; i++)
|
|
|
|
|
{
|
|
|
|
|
if (ruleset->styles[i].property == property)
|
|
|
|
|
{
|
2012-03-06 13:16:32 +00:00
|
|
|
|
_gtk_css_value_unref (ruleset->styles[i].value);
|
|
|
|
|
ruleset->styles[i].value = NULL;
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (ruleset->styles[i].section)
|
|
|
|
|
gtk_css_section_unref (ruleset->styles[i].section);
|
2012-03-01 05:40:15 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i == ruleset->n_styles)
|
|
|
|
|
{
|
|
|
|
|
ruleset->n_styles++;
|
|
|
|
|
ruleset->styles = g_realloc (ruleset->styles, ruleset->n_styles * sizeof (PropertyValue));
|
2012-03-06 13:16:32 +00:00
|
|
|
|
ruleset->styles[i].value = NULL;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
ruleset->styles[i].property = property;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
|
ruleset->styles[i].value = value;
|
2012-03-29 11:57:22 +00:00
|
|
|
|
if (gtk_keep_css_sections)
|
|
|
|
|
ruleset->styles[i].section = gtk_css_section_ref (section);
|
|
|
|
|
else
|
|
|
|
|
ruleset->styles[i].section = NULL;
|
2011-05-18 02:30:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_scanner_destroy (GtkCssScanner *scanner)
|
|
|
|
|
{
|
2011-12-23 16:13:42 +00:00
|
|
|
|
if (scanner->section)
|
|
|
|
|
gtk_css_section_unref (scanner->section);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
g_object_unref (scanner->provider);
|
|
|
|
|
_gtk_css_parser_free (scanner->parser);
|
|
|
|
|
|
|
|
|
|
g_slice_free (GtkCssScanner, scanner);
|
2011-04-10 01:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 05:39:11 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_emit_error (GtkCssProvider *provider,
|
|
|
|
|
GtkCssScanner *scanner,
|
|
|
|
|
const GError *error)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0,
|
2011-11-22 07:13:04 +00:00
|
|
|
|
scanner != NULL ? scanner->section : NULL, error);
|
2011-06-17 05:39:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-10 01:35:19 +00:00
|
|
|
|
static void
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_scanner_parser_error (GtkCssParser *parser,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2011-04-10 01:35:19 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner = user_data;
|
2011-04-10 23:28:00 +00:00
|
|
|
|
|
2011-06-17 05:39:11 +00:00
|
|
|
|
gtk_css_provider_emit_error (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
error);
|
2011-04-10 01:35:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static GtkCssScanner *
|
|
|
|
|
gtk_css_scanner_new (GtkCssProvider *provider,
|
|
|
|
|
GtkCssScanner *parent,
|
2011-06-17 02:52:43 +00:00
|
|
|
|
GtkCssSection *section,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GFile *file,
|
2011-06-17 03:15:48 +00:00
|
|
|
|
const gchar *text)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
scanner = g_slice_new0 (GtkCssScanner);
|
2011-04-10 01:39:52 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
g_object_ref (provider);
|
|
|
|
|
scanner->provider = provider;
|
|
|
|
|
scanner->parent = parent;
|
2011-06-17 02:52:43 +00:00
|
|
|
|
if (section)
|
|
|
|
|
scanner->section = gtk_css_section_ref (section);
|
2011-04-12 00:06:08 +00:00
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
scanner->parser = _gtk_css_parser_new (text,
|
2012-04-18 14:54:04 +00:00
|
|
|
|
file,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_scanner_parser_error,
|
|
|
|
|
scanner);
|
2011-04-11 14:48:00 +00:00
|
|
|
|
|
2010-10-08 16:36:46 +00:00
|
|
|
|
return scanner;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 00:50:25 +00:00
|
|
|
|
static gboolean
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_scanner_would_recurse (GtkCssScanner *scanner,
|
|
|
|
|
GFile *file)
|
2011-04-12 00:50:25 +00:00
|
|
|
|
{
|
|
|
|
|
while (scanner)
|
|
|
|
|
{
|
2012-04-18 20:19:30 +00:00
|
|
|
|
GFile *parser_file = _gtk_css_parser_get_file (scanner->parser);
|
|
|
|
|
if (parser_file && g_file_equal (parser_file, file))
|
2011-04-12 00:50:25 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
scanner = scanner->parent;
|
2011-04-12 00:50:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_scanner_push_section (GtkCssScanner *scanner,
|
|
|
|
|
GtkCssSectionType section_type)
|
|
|
|
|
{
|
2011-06-17 02:52:43 +00:00
|
|
|
|
GtkCssSection *section;
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2011-06-17 02:52:43 +00:00
|
|
|
|
section = _gtk_css_section_new (scanner->section,
|
2011-06-17 00:02:24 +00:00
|
|
|
|
section_type,
|
2012-04-18 20:15:32 +00:00
|
|
|
|
scanner->parser);
|
2011-06-17 02:52:43 +00:00
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
if (scanner->section)
|
|
|
|
|
gtk_css_section_unref (scanner->section);
|
2011-06-17 02:52:43 +00:00
|
|
|
|
scanner->section = section;
|
2011-06-17 00:02:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_css_scanner_pop_section (GtkCssScanner *scanner,
|
|
|
|
|
GtkCssSectionType check_type)
|
|
|
|
|
{
|
2011-06-17 02:52:43 +00:00
|
|
|
|
GtkCssSection *parent;
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2011-06-17 02:52:43 +00:00
|
|
|
|
g_assert (gtk_css_section_get_section_type (scanner->section) == check_type);
|
|
|
|
|
|
|
|
|
|
parent = gtk_css_section_get_parent (scanner->section);
|
|
|
|
|
if (parent)
|
|
|
|
|
gtk_css_section_ref (parent);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2011-06-17 02:52:43 +00:00
|
|
|
|
_gtk_css_section_end (scanner->section);
|
|
|
|
|
gtk_css_section_unref (scanner->section);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2011-06-17 02:52:43 +00:00
|
|
|
|
scanner->section = parent;
|
2011-06-17 00:02:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-08 16:36:46 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_init (GtkCssProvider *css_provider)
|
|
|
|
|
{
|
|
|
|
|
GtkCssProviderPrivate *priv;
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
priv = css_provider->priv = gtk_css_provider_get_instance_private (css_provider);
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
priv->rulesets = g_array_new (FALSE, FALSE, sizeof (GtkCssRuleset));
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
|
|
|
|
priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
|
(GDestroyNotify) g_free,
|
2012-11-25 01:28:59 +00:00
|
|
|
|
(GDestroyNotify) _gtk_css_value_unref);
|
2012-04-19 01:41:41 +00:00
|
|
|
|
priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
|
(GDestroyNotify) g_free,
|
2015-07-27 18:54:13 +00:00
|
|
|
|
(GDestroyNotify) _gtk_css_keyframes_unref);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-29 13:40:10 +00:00
|
|
|
|
static void
|
|
|
|
|
verify_tree_match_results (GtkCssProvider *provider,
|
|
|
|
|
const GtkCssMatcher *matcher,
|
|
|
|
|
GPtrArray *tree_rules)
|
|
|
|
|
{
|
|
|
|
|
#ifdef VERIFY_TREE
|
|
|
|
|
GtkCssProviderPrivate *priv = provider->priv;
|
|
|
|
|
GtkCssRuleset *ruleset;
|
2012-11-29 16:23:36 +00:00
|
|
|
|
gboolean should_match;
|
2012-11-29 13:40:10 +00:00
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
|
|
|
|
{
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < tree_rules->len; j++)
|
|
|
|
|
{
|
|
|
|
|
if (ruleset == tree_rules->pdata[j])
|
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-29 16:23:36 +00:00
|
|
|
|
should_match = _gtk_css_selector_matches (ruleset->selector, matcher);
|
|
|
|
|
if (found != !!should_match)
|
2012-11-29 13:40:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_error ("expected rule '%s' to %s, but it %s\n",
|
|
|
|
|
_gtk_css_selector_to_string (ruleset->selector),
|
2012-11-29 16:23:36 +00:00
|
|
|
|
should_match ? "match" : "not match",
|
2012-11-29 13:40:10 +00:00
|
|
|
|
found ? "matched" : "didn't match");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 10:27:43 +00:00
|
|
|
|
static void
|
|
|
|
|
verify_tree_get_change_results (GtkCssProvider *provider,
|
|
|
|
|
const GtkCssMatcher *matcher,
|
|
|
|
|
GtkCssChange change)
|
|
|
|
|
{
|
|
|
|
|
#ifdef VERIFY_TREE
|
|
|
|
|
{
|
|
|
|
|
GtkCssChange verify_change = 0;
|
|
|
|
|
GPtrArray *tree_rules;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
tree_rules = _gtk_css_selector_tree_match_all (provider->priv->tree, matcher);
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (tree_rules)
|
2012-12-10 10:27:43 +00:00
|
|
|
|
{
|
2015-09-09 14:55:31 +00:00
|
|
|
|
verify_tree_match_results (provider, matcher, tree_rules);
|
|
|
|
|
|
|
|
|
|
for (i = tree_rules->len - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
GtkCssRuleset *ruleset;
|
2012-12-10 10:27:43 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
ruleset = tree_rules->pdata[i];
|
2012-12-10 10:27:43 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
verify_change |= _gtk_css_selector_get_change (ruleset->selector);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_ptr_array_free (tree_rules, TRUE);
|
2012-12-10 10:27:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (change != verify_change)
|
|
|
|
|
{
|
|
|
|
|
GString *s;
|
|
|
|
|
|
|
|
|
|
s = g_string_new ("");
|
2015-08-27 12:07:10 +00:00
|
|
|
|
g_string_append (s, "expected change ");
|
|
|
|
|
gtk_css_change_print (verify_change, s);
|
|
|
|
|
g_string_append (s, ", but it was ");
|
|
|
|
|
gtk_css_change_print (change, s);
|
2012-12-10 10:27:43 +00:00
|
|
|
|
if ((change & ~verify_change) != 0)
|
2015-08-27 12:07:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_string_append (s, ", unexpectedly set: ");
|
|
|
|
|
gtk_css_change_print (change & ~verify_change, s);
|
|
|
|
|
}
|
2012-12-10 10:27:43 +00:00
|
|
|
|
if ((~change & verify_change) != 0)
|
2015-08-27 12:07:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_string_append_printf (s, ", unexpectedly not set: ");
|
|
|
|
|
gtk_css_change_print (~change & verify_change, s);
|
|
|
|
|
}
|
2012-12-10 10:27:43 +00:00
|
|
|
|
g_warning (s->str);
|
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-18 15:04:03 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_css_provider_get_style_property (GtkStyleProvider *provider,
|
|
|
|
|
GtkWidgetPath *path,
|
2010-11-30 01:14:00 +00:00
|
|
|
|
GtkStateFlags state,
|
2010-11-17 01:42:27 +00:00
|
|
|
|
GParamSpec *pspec,
|
2010-06-18 15:04:03 +00:00
|
|
|
|
GValue *value)
|
|
|
|
|
{
|
2011-05-16 15:55:50 +00:00
|
|
|
|
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
|
|
|
|
|
GtkCssProviderPrivate *priv = css_provider->priv;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
WidgetPropertyValue *val;
|
2012-11-29 16:13:59 +00:00
|
|
|
|
GPtrArray *tree_rules;
|
2012-03-17 01:36:11 +00:00
|
|
|
|
GtkCssMatcher matcher;
|
2010-06-18 15:04:03 +00:00
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
gchar *prop_name;
|
|
|
|
|
gint i;
|
|
|
|
|
|
2014-07-19 21:26:12 +00:00
|
|
|
|
if (state == gtk_widget_path_iter_get_state (path, -1))
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_path_ref (path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
path = gtk_widget_path_copy (path);
|
|
|
|
|
gtk_widget_path_iter_set_state (path, -1, state);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 10:24:29 +00:00
|
|
|
|
if (!_gtk_css_matcher_init (&matcher, path, NULL))
|
2014-07-19 21:26:12 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_path_unref (path);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-04-30 19:28:57 +00:00
|
|
|
|
|
2012-11-29 16:13:59 +00:00
|
|
|
|
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher);
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (tree_rules)
|
2010-06-18 15:04:03 +00:00
|
|
|
|
{
|
2015-09-09 14:55:31 +00:00
|
|
|
|
verify_tree_match_results (css_provider, &matcher, tree_rules);
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
prop_name = g_strdup_printf ("-%s-%s",
|
|
|
|
|
g_type_name (pspec->owner_type),
|
|
|
|
|
pspec->name);
|
2011-05-18 16:32:22 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
for (i = tree_rules->len - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
GtkCssRuleset *ruleset = tree_rules->pdata[i];
|
2011-05-18 16:32:22 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (ruleset->widget_style == NULL)
|
|
|
|
|
continue;
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
for (val = ruleset->widget_style; val != NULL; val = val->next)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (val->name, prop_name) == 0)
|
|
|
|
|
{
|
|
|
|
|
GtkCssScanner *scanner;
|
|
|
|
|
|
|
|
|
|
scanner = gtk_css_scanner_new (css_provider,
|
|
|
|
|
NULL,
|
|
|
|
|
val->section,
|
|
|
|
|
val->section != NULL ? gtk_css_section_get_file (val->section) : NULL,
|
|
|
|
|
val->value);
|
2015-10-28 18:35:23 +00:00
|
|
|
|
if (!val->section)
|
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
|
2015-09-09 14:55:31 +00:00
|
|
|
|
found = _gtk_css_style_funcs_parse_value (value, scanner->parser);
|
2015-10-28 18:35:23 +00:00
|
|
|
|
if (!val->section)
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
2015-09-09 14:55:31 +00:00
|
|
|
|
gtk_css_scanner_destroy (scanner);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
g_free (prop_name);
|
|
|
|
|
g_ptr_array_free (tree_rules, TRUE);
|
2010-06-18 15:04:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:26:12 +00:00
|
|
|
|
gtk_widget_path_unref (path);
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface)
|
|
|
|
|
{
|
2010-06-18 15:04:03 +00:00
|
|
|
|
iface->get_style_property = gtk_css_provider_get_style_property;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-25 01:28:59 +00:00
|
|
|
|
static GtkCssValue *
|
2011-12-28 21:59:55 +00:00
|
|
|
|
gtk_css_style_provider_get_color (GtkStyleProviderPrivate *provider,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
|
|
|
|
|
|
|
|
|
|
return g_hash_table_lookup (css_provider->priv->symbolic_colors, name);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-19 01:58:28 +00:00
|
|
|
|
static GtkCssKeyframes *
|
|
|
|
|
gtk_css_style_provider_get_keyframes (GtkStyleProviderPrivate *provider,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
|
|
|
|
|
|
|
|
|
|
return g_hash_table_lookup (css_provider->priv->keyframes, name);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-28 21:59:55 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
|
2012-03-17 01:36:11 +00:00
|
|
|
|
const GtkCssMatcher *matcher,
|
2014-12-09 18:31:17 +00:00
|
|
|
|
GtkCssLookup *lookup,
|
|
|
|
|
GtkCssChange *change)
|
2011-12-28 21:59:55 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCssProvider *css_provider;
|
|
|
|
|
GtkCssProviderPrivate *priv;
|
2012-11-09 09:06:55 +00:00
|
|
|
|
GtkCssRuleset *ruleset;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
guint j;
|
2012-11-28 10:21:06 +00:00
|
|
|
|
int i;
|
|
|
|
|
GPtrArray *tree_rules;
|
2011-12-28 21:59:55 +00:00
|
|
|
|
|
|
|
|
|
css_provider = GTK_CSS_PROVIDER (provider);
|
|
|
|
|
priv = css_provider->priv;
|
|
|
|
|
|
2012-11-28 10:21:06 +00:00
|
|
|
|
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (tree_rules)
|
2012-11-28 10:21:06 +00:00
|
|
|
|
{
|
2015-09-09 14:55:31 +00:00
|
|
|
|
verify_tree_match_results (css_provider, matcher, tree_rules);
|
2011-12-28 21:59:55 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
for (i = tree_rules->len - 1; i >= 0; i--)
|
2011-12-29 13:15:39 +00:00
|
|
|
|
{
|
2015-09-09 14:55:31 +00:00
|
|
|
|
ruleset = tree_rules->pdata[i];
|
2011-12-28 21:59:55 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (ruleset->styles == NULL)
|
2011-12-29 13:15:39 +00:00
|
|
|
|
continue;
|
2011-12-28 21:59:55 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup),
|
|
|
|
|
ruleset->set_styles))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < ruleset->n_styles; j++)
|
|
|
|
|
{
|
|
|
|
|
GtkCssStyleProperty *prop = ruleset->styles[j].property;
|
|
|
|
|
guint id = _gtk_css_style_property_get_id (prop);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_lookup_is_missing (lookup, id))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
_gtk_css_lookup_set (lookup,
|
|
|
|
|
id,
|
|
|
|
|
ruleset->styles[j].section,
|
|
|
|
|
ruleset->styles[j].value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_gtk_bitmask_is_empty (_gtk_css_lookup_get_missing (lookup)))
|
|
|
|
|
break;
|
2011-12-28 21:59:55 +00:00
|
|
|
|
}
|
2012-11-09 09:15:23 +00:00
|
|
|
|
|
2015-09-09 14:55:31 +00:00
|
|
|
|
g_ptr_array_free (tree_rules, TRUE);
|
2011-12-28 21:59:55 +00:00
|
|
|
|
}
|
2012-11-28 10:21:06 +00:00
|
|
|
|
|
2014-12-09 18:31:17 +00:00
|
|
|
|
if (change)
|
|
|
|
|
{
|
|
|
|
|
GtkCssMatcher change_matcher;
|
2012-03-17 20:09:51 +00:00
|
|
|
|
|
2014-12-09 18:31:17 +00:00
|
|
|
|
_gtk_css_matcher_superset_init (&change_matcher, matcher, GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS);
|
2012-11-28 10:21:06 +00:00
|
|
|
|
|
2014-12-09 18:31:17 +00:00
|
|
|
|
*change = _gtk_css_selector_tree_get_change_all (priv->tree, &change_matcher);
|
|
|
|
|
verify_tree_get_change_results (css_provider, &change_matcher, *change);
|
|
|
|
|
}
|
2012-03-17 20:09:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-12-28 21:59:55 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_color = gtk_css_style_provider_get_color;
|
2012-04-19 01:58:28 +00:00
|
|
|
|
iface->get_keyframes = gtk_css_style_provider_get_keyframes;
|
2011-12-28 21:59:55 +00:00
|
|
|
|
iface->lookup = gtk_css_style_provider_lookup;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_finalize (GObject *object)
|
|
|
|
|
{
|
2010-07-03 00:19:27 +00:00
|
|
|
|
GtkCssProvider *css_provider;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
GtkCssProviderPrivate *priv;
|
2011-05-30 17:26:28 +00:00
|
|
|
|
guint i;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2010-07-03 00:19:27 +00:00
|
|
|
|
css_provider = GTK_CSS_PROVIDER (object);
|
|
|
|
|
priv = css_provider->priv;
|
2010-06-19 14:04:30 +00:00
|
|
|
|
|
2011-05-30 17:26:28 +00:00
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
|
|
|
|
gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
|
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
g_array_free (priv->rulesets, TRUE);
|
2012-11-28 10:21:06 +00:00
|
|
|
|
_gtk_css_selector_tree_free (priv->tree);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2012-04-19 01:41:41 +00:00
|
|
|
|
g_hash_table_destroy (priv->symbolic_colors);
|
|
|
|
|
g_hash_table_destroy (priv->keyframes);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2012-02-03 14:50:49 +00:00
|
|
|
|
if (priv->resource)
|
|
|
|
|
{
|
|
|
|
|
g_resources_unregister (priv->resource);
|
|
|
|
|
g_resource_unref (priv->resource);
|
|
|
|
|
priv->resource = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_new:
|
|
|
|
|
*
|
|
|
|
|
* Returns a newly created #GtkCssProvider.
|
|
|
|
|
*
|
|
|
|
|
* Returns: A new #GtkCssProvider
|
|
|
|
|
**/
|
2010-04-11 21:03:25 +00:00
|
|
|
|
GtkCssProvider *
|
|
|
|
|
gtk_css_provider_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_CSS_PROVIDER, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-07 15:26:47 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_take_error (GtkCssProvider *provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-07 15:26:47 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2011-11-22 07:13:04 +00:00
|
|
|
|
gtk_css_provider_emit_error (provider,
|
2011-06-17 05:39:11 +00:00
|
|
|
|
scanner,
|
|
|
|
|
error);
|
|
|
|
|
|
|
|
|
|
g_error_free (error);
|
2011-04-07 15:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 16:18:02 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_error_literal (GtkCssProvider *provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-09 16:18:02 +00:00
|
|
|
|
GQuark domain,
|
|
|
|
|
gint code,
|
|
|
|
|
const char *message)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_take_error (provider,
|
2011-04-10 13:22:07 +00:00
|
|
|
|
scanner,
|
2011-04-09 16:18:02 +00:00
|
|
|
|
g_error_new_literal (domain, code, message));
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-07 11:37:03 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_error (GtkCssProvider *provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-07 11:37:03 +00:00
|
|
|
|
GQuark domain,
|
|
|
|
|
gint code,
|
|
|
|
|
const char *format,
|
2011-04-10 13:22:07 +00:00
|
|
|
|
...) G_GNUC_PRINTF (5, 6);
|
2011-04-07 11:37:03 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_error (GtkCssProvider *provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-07 11:37:03 +00:00
|
|
|
|
GQuark domain,
|
|
|
|
|
gint code,
|
|
|
|
|
const char *format,
|
|
|
|
|
...)
|
|
|
|
|
{
|
2011-04-07 15:26:47 +00:00
|
|
|
|
GError *error;
|
2011-04-07 11:37:03 +00:00
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start (args, format);
|
2011-04-07 15:26:47 +00:00
|
|
|
|
error = g_error_new_valist (domain, code, format, args);
|
2011-04-07 11:37:03 +00:00
|
|
|
|
va_end (args);
|
|
|
|
|
|
2011-04-10 13:22:07 +00:00
|
|
|
|
gtk_css_provider_take_error (provider, scanner, error);
|
2011-04-07 12:03:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 13:38:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_invalid_token (GtkCssProvider *provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner,
|
2011-04-06 13:38:06 +00:00
|
|
|
|
const char *expected)
|
|
|
|
|
{
|
2011-04-07 11:37:03 +00:00
|
|
|
|
gtk_css_provider_error (provider,
|
2011-04-10 13:22:07 +00:00
|
|
|
|
scanner,
|
2011-04-07 11:37:03 +00:00
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
2011-04-07 22:18:38 +00:00
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
2014-03-17 01:09:31 +00:00
|
|
|
|
"expected %s", expected);
|
2011-04-06 13:38:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
2011-04-10 23:28:00 +00:00
|
|
|
|
css_provider_commit (GtkCssProvider *css_provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GSList *selectors,
|
2011-05-18 02:20:05 +00:00
|
|
|
|
GtkCssRuleset *ruleset)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCssProviderPrivate *priv;
|
|
|
|
|
GSList *l;
|
|
|
|
|
|
2010-07-03 00:19:27 +00:00
|
|
|
|
priv = css_provider->priv;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
if (ruleset->styles == NULL && ruleset->widget_style == NULL)
|
2011-05-14 11:27:31 +00:00
|
|
|
|
{
|
|
|
|
|
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-04-07 00:15:02 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
for (l = selectors; l; l = l->next)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-05-18 02:20:05 +00:00
|
|
|
|
GtkCssRuleset new;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
gtk_css_ruleset_init_copy (&new, ruleset, l->data);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
g_array_append_val (priv->rulesets, new);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
2011-05-14 11:27:31 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
g_slist_free (selectors);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_reset (GtkCssProvider *css_provider)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssProviderPrivate *priv;
|
2011-05-18 02:20:05 +00:00
|
|
|
|
guint i;
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
priv = css_provider->priv;
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2012-02-03 15:01:51 +00:00
|
|
|
|
if (priv->resource)
|
|
|
|
|
{
|
|
|
|
|
g_resources_unregister (priv->resource);
|
|
|
|
|
g_resource_unref (priv->resource);
|
|
|
|
|
priv->resource = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-27 23:01:42 +00:00
|
|
|
|
g_hash_table_remove_all (priv->symbolic_colors);
|
2012-04-19 01:41:41 +00:00
|
|
|
|
g_hash_table_remove_all (priv->keyframes);
|
2011-05-27 23:01:42 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
|
|
|
|
gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
|
|
|
|
|
g_array_set_size (priv->rulesets, 0);
|
2012-11-28 10:21:06 +00:00
|
|
|
|
_gtk_css_selector_tree_free (priv->tree);
|
|
|
|
|
priv->tree = NULL;
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_propagate_error (GtkCssProvider *provider,
|
2011-08-31 22:24:53 +00:00
|
|
|
|
GtkCssSection *section,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
const GError *error,
|
|
|
|
|
GError **propagate_to)
|
|
|
|
|
{
|
2011-08-31 22:24:53 +00:00
|
|
|
|
|
2012-09-27 13:10:52 +00:00
|
|
|
|
char *s;
|
2011-08-31 22:24:53 +00:00
|
|
|
|
|
2011-05-18 16:35:37 +00:00
|
|
|
|
/* don't fail for deprecations */
|
|
|
|
|
if (g_error_matches (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_DEPRECATED))
|
|
|
|
|
{
|
2012-09-27 13:10:52 +00:00
|
|
|
|
s = _gtk_css_section_to_string (section);
|
|
|
|
|
g_warning ("Theme parsing error: %s: %s", s, error->message);
|
|
|
|
|
g_free (s);
|
2011-05-18 16:35:37 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
/* we already set an error. And we'd like to keep the first one */
|
|
|
|
|
if (*propagate_to)
|
|
|
|
|
return;
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
*propagate_to = g_error_copy (error);
|
2012-11-15 18:18:19 +00:00
|
|
|
|
if (section)
|
|
|
|
|
{
|
|
|
|
|
s = _gtk_css_section_to_string (section);
|
|
|
|
|
g_prefix_error (propagate_to, "%s", s);
|
|
|
|
|
g_free (s);
|
|
|
|
|
}
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
static gboolean
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_import (GtkCssScanner *scanner)
|
|
|
|
|
{
|
|
|
|
|
GFile *file;
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_IMPORT);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "@import", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 23:19:59 +00:00
|
|
|
|
if (_gtk_css_parser_is_string (scanner->parser))
|
2012-01-13 23:08:12 +00:00
|
|
|
|
{
|
|
|
|
|
char *uri;
|
|
|
|
|
|
|
|
|
|
uri = _gtk_css_parser_read_string (scanner->parser);
|
2012-04-18 20:19:30 +00:00
|
|
|
|
file = _gtk_css_parser_get_file_for_path (scanner->parser, uri);
|
2012-01-13 23:08:12 +00:00
|
|
|
|
g_free (uri);
|
|
|
|
|
}
|
2011-07-19 23:19:59 +00:00
|
|
|
|
else
|
2012-01-13 23:08:12 +00:00
|
|
|
|
{
|
2012-04-18 17:43:24 +00:00
|
|
|
|
file = _gtk_css_parser_read_url (scanner->parser);
|
2012-01-13 23:08:12 +00:00
|
|
|
|
}
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2012-01-13 23:08:12 +00:00
|
|
|
|
if (file == NULL)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2012-01-16 17:44:43 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, ";", FALSE))
|
2012-01-15 18:20:34 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_invalid_token (scanner->provider, scanner, "semicolon");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
}
|
|
|
|
|
else if (gtk_css_scanner_would_recurse (scanner, file))
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
|
|
|
|
char *path = g_file_get_path (file);
|
|
|
|
|
gtk_css_provider_error (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_IMPORT,
|
|
|
|
|
"Loading '%s' would recurse",
|
|
|
|
|
path);
|
|
|
|
|
g_free (path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_load_internal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
file,
|
2011-06-17 03:15:48 +00:00
|
|
|
|
NULL,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
NULL);
|
|
|
|
|
}
|
2010-06-25 18:27:15 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
g_object_unref (file);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
|
2012-01-16 17:44:43 +00:00
|
|
|
|
_gtk_css_parser_skip_whitespace (scanner->parser);
|
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-10-08 16:19:34 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
static gboolean
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_color_definition (GtkCssScanner *scanner)
|
|
|
|
|
{
|
2012-11-25 01:28:59 +00:00
|
|
|
|
GtkCssValue *color;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
char *name;
|
2010-10-08 16:19:34 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "@define-color", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
name = _gtk_css_parser_try_name (scanner->parser, TRUE);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Not a valid color name");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2012-11-25 01:28:59 +00:00
|
|
|
|
color = _gtk_css_color_value_parse (scanner->parser);
|
|
|
|
|
if (color == NULL)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
|
|
|
|
g_free (name);
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
|
|
|
|
|
{
|
|
|
|
|
g_free (name);
|
2012-11-25 01:28:59 +00:00
|
|
|
|
_gtk_css_value_unref (color);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Missing semicolon at end of color definition");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-11-18 06:59:27 +00:00
|
|
|
|
|
2012-11-25 01:28:59 +00:00
|
|
|
|
g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, color);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2011-04-08 14:08:28 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
static gboolean
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_binding_set (GtkCssScanner *scanner)
|
|
|
|
|
{
|
|
|
|
|
GtkBindingSet *binding_set;
|
|
|
|
|
char *name;
|
2011-04-08 14:08:28 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_BINDING_SET);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "@binding-set", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_BINDING_SET);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
name = _gtk_css_parser_try_ident (scanner->parser, TRUE);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected name for binding set");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
goto skip_semicolon;
|
|
|
|
|
}
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
binding_set = gtk_binding_set_find (name);
|
|
|
|
|
if (!binding_set)
|
|
|
|
|
{
|
|
|
|
|
binding_set = gtk_binding_set_new (name);
|
|
|
|
|
binding_set->parsed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_free (name);
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "{", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
2011-04-12 00:50:25 +00:00
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected '{' for binding set");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
goto skip_semicolon;
|
|
|
|
|
}
|
2010-10-08 16:36:46 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
while (!_gtk_css_parser_is_eof (scanner->parser) &&
|
|
|
|
|
!_gtk_css_parser_begins_with (scanner->parser, '}'))
|
|
|
|
|
{
|
|
|
|
|
name = _gtk_css_parser_read_value (scanner->parser);
|
|
|
|
|
if (name == NULL)
|
2011-01-28 00:52:03 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2011-07-20 00:11:51 +00:00
|
|
|
|
if (gtk_binding_entry_add_signal_from_string (binding_set, name) != G_TOKEN_NONE)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Failed to parse binding set.");
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
g_free (name);
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
|
|
|
|
|
{
|
|
|
|
|
if (!_gtk_css_parser_begins_with (scanner->parser, '}') &&
|
|
|
|
|
!_gtk_css_parser_is_eof (scanner->parser))
|
2011-01-28 00:52:03 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected semicolon");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
2011-01-28 00:52:03 +00:00
|
|
|
|
}
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "}", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"expected '}' after declarations");
|
|
|
|
|
if (!_gtk_css_parser_is_eof (scanner->parser))
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, FALSE, 0);
|
|
|
|
|
}
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
skip_semicolon:
|
2011-07-20 00:01:34 +00:00
|
|
|
|
if (_gtk_css_parser_begins_with (scanner->parser, ';'))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_DEPRECATED,
|
|
|
|
|
"Nonstandard semicolon at end of binding set");
|
|
|
|
|
_gtk_css_parser_try (scanner->parser, ";", TRUE);
|
|
|
|
|
}
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_BINDING_SET);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2012-04-19 01:41:41 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
parse_keyframes (GtkCssScanner *scanner)
|
|
|
|
|
{
|
|
|
|
|
GtkCssKeyframes *keyframes;
|
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "@keyframes", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = _gtk_css_parser_try_ident (scanner->parser, TRUE);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected name for keyframes");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "{", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected '{' for keyframes");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
g_free (name);
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyframes = _gtk_css_keyframes_parse (scanner->parser);
|
|
|
|
|
if (keyframes == NULL)
|
|
|
|
|
{
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
|
|
|
|
g_free (name);
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_insert (scanner->provider->priv->keyframes, name, keyframes);
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "}", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"expected '}' after declarations");
|
|
|
|
|
if (!_gtk_css_parser_is_eof (scanner->parser))
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, FALSE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
|
|
|
|
parse_at_keyword (GtkCssScanner *scanner)
|
|
|
|
|
{
|
2011-06-17 00:02:24 +00:00
|
|
|
|
if (parse_import (scanner))
|
|
|
|
|
return;
|
|
|
|
|
if (parse_color_definition (scanner))
|
|
|
|
|
return;
|
|
|
|
|
if (parse_binding_set (scanner))
|
|
|
|
|
return;
|
2012-04-19 01:41:41 +00:00
|
|
|
|
if (parse_keyframes (scanner))
|
|
|
|
|
return;
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"unknown @ rule");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-28 00:52:03 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static GSList *
|
|
|
|
|
parse_selector_list (GtkCssScanner *scanner)
|
|
|
|
|
{
|
|
|
|
|
GSList *selectors = NULL;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_SELECTOR);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
do {
|
2012-02-15 14:42:00 +00:00
|
|
|
|
GtkCssSelector *select = _gtk_css_selector_parse (scanner->parser);
|
2011-04-09 23:48:55 +00:00
|
|
|
|
|
2011-05-14 11:27:31 +00:00
|
|
|
|
if (select == NULL)
|
2011-04-09 23:48:55 +00:00
|
|
|
|
{
|
2011-05-14 11:27:31 +00:00
|
|
|
|
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
_gtk_css_parser_resync (scanner->parser, FALSE, 0);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_SELECTOR);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
return NULL;
|
2011-04-09 23:48:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-14 11:27:31 +00:00
|
|
|
|
selectors = g_slist_prepend (selectors, select);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
|
|
|
|
while (_gtk_css_parser_try (scanner->parser, ",", TRUE));
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_SELECTOR);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
return selectors;
|
|
|
|
|
}
|
2010-06-18 15:04:03 +00:00
|
|
|
|
|
2014-06-16 20:13:07 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
name_is_style_property (const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (name[0] != '-')
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (g_str_has_prefix (name, "-gtk-"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
static void
|
2011-05-18 02:20:05 +00:00
|
|
|
|
parse_declaration (GtkCssScanner *scanner,
|
|
|
|
|
GtkCssRuleset *ruleset)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
2011-12-31 15:08:23 +00:00
|
|
|
|
GtkStyleProperty *property;
|
2011-05-18 16:32:22 +00:00
|
|
|
|
char *name;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
name = _gtk_css_parser_try_ident (scanner->parser, TRUE);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
goto check_for_semicolon;
|
|
|
|
|
|
2011-05-19 12:04:51 +00:00
|
|
|
|
property = _gtk_style_property_lookup (name);
|
2014-06-16 20:13:07 +00:00
|
|
|
|
if (property == NULL && !name_is_style_property (name))
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_NAME,
|
|
|
|
|
"'%s' is not a valid property name",
|
|
|
|
|
name);
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
|
|
|
|
g_free (name);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, ":", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_invalid_token (scanner->provider, scanner, "':'");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
|
|
|
|
g_free (name);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-19 12:04:51 +00:00
|
|
|
|
if (property)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
|
GtkCssValue *value;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
|
2011-05-18 02:30:51 +00:00
|
|
|
|
g_free (name);
|
|
|
|
|
|
2011-06-17 03:58:04 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
|
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
|
value = _gtk_style_property_parse_value (property,
|
2012-04-18 20:04:44 +00:00
|
|
|
|
scanner->parser);
|
2012-03-26 15:24:02 +00:00
|
|
|
|
|
|
|
|
|
if (value == NULL)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
|
|
|
|
return;
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2012-03-26 15:24:02 +00:00
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_begins_with (scanner->parser, ';') &&
|
|
|
|
|
!_gtk_css_parser_begins_with (scanner->parser, '}') &&
|
|
|
|
|
!_gtk_css_parser_is_eof (scanner->parser))
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Junk at end of value");
|
2011-05-25 23:25:00 +00:00
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
2011-06-17 03:58:04 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
2011-05-25 23:25:00 +00:00
|
|
|
|
return;
|
2010-06-18 15:04:03 +00:00
|
|
|
|
}
|
2012-03-26 15:24:02 +00:00
|
|
|
|
|
|
|
|
|
if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
|
|
|
|
|
{
|
|
|
|
|
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
|
|
|
|
|
{
|
|
|
|
|
GtkCssStyleProperty *child = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
|
|
|
|
|
GtkCssValue *sub = _gtk_css_array_value_get_nth (value, i);
|
|
|
|
|
|
|
|
|
|
gtk_css_ruleset_add (ruleset, child, _gtk_css_value_ref (sub), scanner->section);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_gtk_css_value_unref (value);
|
|
|
|
|
}
|
|
|
|
|
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_ruleset_add (ruleset, GTK_CSS_STYLE_PROPERTY (property), value, scanner->section);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
_gtk_css_value_unref (value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-17 03:58:04 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2014-06-16 20:13:07 +00:00
|
|
|
|
else if (name_is_style_property (name))
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
2011-05-18 16:32:22 +00:00
|
|
|
|
char *value_str;
|
2010-08-04 15:51:19 +00:00
|
|
|
|
|
2011-06-17 03:58:04 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
|
|
|
|
|
|
2011-05-18 16:32:22 +00:00
|
|
|
|
value_str = _gtk_css_parser_read_value (scanner->parser);
|
|
|
|
|
if (value_str)
|
|
|
|
|
{
|
2012-02-15 16:06:30 +00:00
|
|
|
|
WidgetPropertyValue *val;
|
2011-05-18 16:32:22 +00:00
|
|
|
|
|
2012-02-15 16:06:30 +00:00
|
|
|
|
val = widget_property_value_new (name, scanner->section);
|
2012-03-30 00:45:01 +00:00
|
|
|
|
val->value = value_str;
|
2010-08-04 15:51:19 +00:00
|
|
|
|
|
2011-05-18 16:32:22 +00:00
|
|
|
|
gtk_css_ruleset_add_style (ruleset, name, val);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
2011-06-17 03:58:04 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
2011-05-18 16:32:22 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2011-06-17 03:58:04 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_free (name);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
check_for_semicolon:
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
|
|
|
|
|
{
|
|
|
|
|
if (!_gtk_css_parser_begins_with (scanner->parser, '}') &&
|
|
|
|
|
!_gtk_css_parser_is_eof (scanner->parser))
|
2011-04-07 22:08:10 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"Expected semicolon");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
2011-04-07 22:08:10 +00:00
|
|
|
|
}
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
static void
|
|
|
|
|
parse_declarations (GtkCssScanner *scanner,
|
|
|
|
|
GtkCssRuleset *ruleset)
|
2011-04-14 02:47:18 +00:00
|
|
|
|
{
|
|
|
|
|
while (!_gtk_css_parser_is_eof (scanner->parser) &&
|
|
|
|
|
!_gtk_css_parser_begins_with (scanner->parser, '}'))
|
|
|
|
|
{
|
2011-05-18 02:20:05 +00:00
|
|
|
|
parse_declaration (scanner, ruleset);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-07 22:08:10 +00:00
|
|
|
|
static void
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_ruleset (GtkCssScanner *scanner)
|
2011-04-07 22:08:10 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GSList *selectors;
|
2011-05-18 02:20:05 +00:00
|
|
|
|
GtkCssRuleset ruleset = { 0, };
|
2011-04-07 22:08:10 +00:00
|
|
|
|
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_RULESET);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
selectors = parse_selector_list (scanner);
|
|
|
|
|
if (selectors == NULL)
|
2011-06-17 00:02:24 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-04-07 22:08:10 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "{", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"expected '{' after selectors");
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, FALSE, 0);
|
2011-05-14 11:27:31 +00:00
|
|
|
|
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
parse_declarations (scanner, &ruleset);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
|
|
|
|
|
if (!_gtk_css_parser_try (scanner->parser, "}", TRUE))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_error_literal (scanner->provider,
|
|
|
|
|
scanner,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_SYNTAX,
|
|
|
|
|
"expected '}' after declarations");
|
|
|
|
|
if (!_gtk_css_parser_is_eof (scanner->parser))
|
|
|
|
|
{
|
|
|
|
|
_gtk_css_parser_resync (scanner->parser, FALSE, 0);
|
2011-05-14 11:27:31 +00:00
|
|
|
|
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
|
2011-05-18 02:20:05 +00:00
|
|
|
|
gtk_css_ruleset_clear (&ruleset);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
css_provider_commit (scanner->provider, selectors, &ruleset);
|
|
|
|
|
gtk_css_ruleset_clear (&ruleset);
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
|
2011-04-07 22:08:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-11 00:32:26 +00:00
|
|
|
|
static void
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_statement (GtkCssScanner *scanner)
|
2011-04-11 00:32:26 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (_gtk_css_parser_begins_with (scanner->parser, '@'))
|
|
|
|
|
parse_at_keyword (scanner);
|
|
|
|
|
else
|
|
|
|
|
parse_ruleset (scanner);
|
2011-04-11 00:32:26 +00:00
|
|
|
|
}
|
2011-04-08 00:57:33 +00:00
|
|
|
|
|
2011-04-11 17:57:42 +00:00
|
|
|
|
static void
|
2011-05-14 11:27:31 +00:00
|
|
|
|
parse_stylesheet (GtkCssScanner *scanner)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-06-17 00:02:24 +00:00
|
|
|
|
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_DOCUMENT);
|
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
_gtk_css_parser_skip_whitespace (scanner->parser);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
while (!_gtk_css_parser_is_eof (scanner->parser))
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
if (_gtk_css_parser_try (scanner->parser, "<!--", TRUE) ||
|
|
|
|
|
_gtk_css_parser_try (scanner->parser, "-->", TRUE))
|
|
|
|
|
continue;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_statement (scanner);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
2011-06-17 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DOCUMENT);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-14 11:27:31 +00:00
|
|
|
|
static int
|
|
|
|
|
gtk_css_provider_compare_rule (gconstpointer a_,
|
|
|
|
|
gconstpointer b_)
|
|
|
|
|
{
|
2011-05-18 02:20:05 +00:00
|
|
|
|
const GtkCssRuleset *a = (const GtkCssRuleset *) a_;
|
|
|
|
|
const GtkCssRuleset *b = (const GtkCssRuleset *) b_;
|
2011-05-14 11:27:31 +00:00
|
|
|
|
int compare;
|
|
|
|
|
|
|
|
|
|
compare = _gtk_css_selector_compare (a->selector, b->selector);
|
|
|
|
|
if (compare != 0)
|
|
|
|
|
return compare;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_postprocess (GtkCssProvider *css_provider)
|
|
|
|
|
{
|
|
|
|
|
GtkCssProviderPrivate *priv = css_provider->priv;
|
2012-11-28 10:21:06 +00:00
|
|
|
|
GtkCssSelectorTreeBuilder *builder;
|
|
|
|
|
guint i;
|
2011-05-14 11:27:31 +00:00
|
|
|
|
|
2011-05-18 02:20:05 +00:00
|
|
|
|
g_array_sort (priv->rulesets, gtk_css_provider_compare_rule);
|
2012-11-28 10:21:06 +00:00
|
|
|
|
|
|
|
|
|
builder = _gtk_css_selector_tree_builder_new ();
|
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
|
|
|
|
{
|
|
|
|
|
GtkCssRuleset *ruleset;
|
|
|
|
|
|
|
|
|
|
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
|
|
|
|
|
|
|
|
|
|
_gtk_css_selector_tree_builder_add (builder,
|
|
|
|
|
ruleset->selector,
|
2012-11-29 14:29:14 +00:00
|
|
|
|
&ruleset->selector_match,
|
2012-11-28 10:21:06 +00:00
|
|
|
|
ruleset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->tree = _gtk_css_selector_tree_builder_build (builder);
|
|
|
|
|
_gtk_css_selector_tree_builder_free (builder);
|
2012-11-29 16:28:51 +00:00
|
|
|
|
|
|
|
|
|
#ifndef VERIFY_TREE
|
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
|
|
|
|
{
|
|
|
|
|
GtkCssRuleset *ruleset;
|
|
|
|
|
|
|
|
|
|
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
|
|
|
|
|
|
|
|
|
|
_gtk_css_selector_free (ruleset->selector);
|
|
|
|
|
ruleset->selector = NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2011-05-14 11:27:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-11 17:55:34 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_css_provider_load_internal (GtkCssProvider *css_provider,
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *parent,
|
2011-04-11 17:55:34 +00:00
|
|
|
|
GFile *file,
|
2011-06-17 03:15:48 +00:00
|
|
|
|
const char *text,
|
2011-04-11 17:55:34 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2011-04-14 02:47:18 +00:00
|
|
|
|
GtkCssScanner *scanner;
|
2011-04-11 17:57:42 +00:00
|
|
|
|
gulong error_handler;
|
2011-05-30 17:26:28 +00:00
|
|
|
|
char *free_data = NULL;
|
2011-04-11 17:57:42 +00:00
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
error_handler = g_signal_connect (css_provider,
|
|
|
|
|
"parsing-error",
|
|
|
|
|
G_CALLBACK (gtk_css_provider_propagate_error),
|
|
|
|
|
error);
|
|
|
|
|
else
|
|
|
|
|
error_handler = 0; /* silence gcc */
|
2011-04-11 17:55:34 +00:00
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
if (text == NULL)
|
2011-04-11 18:08:57 +00:00
|
|
|
|
{
|
|
|
|
|
GError *load_error = NULL;
|
2011-04-11 17:55:34 +00:00
|
|
|
|
|
2011-04-11 18:08:57 +00:00
|
|
|
|
if (g_file_load_contents (file, NULL,
|
2011-06-17 03:15:48 +00:00
|
|
|
|
&free_data, NULL,
|
2011-04-11 18:08:57 +00:00
|
|
|
|
NULL, &load_error))
|
|
|
|
|
{
|
2011-06-17 03:15:48 +00:00
|
|
|
|
text = free_data;
|
2011-04-11 18:08:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-17 05:39:11 +00:00
|
|
|
|
GtkCssSection *section;
|
|
|
|
|
|
2011-04-12 00:06:08 +00:00
|
|
|
|
if (parent)
|
2011-06-17 05:39:11 +00:00
|
|
|
|
section = gtk_css_section_ref (parent->section);
|
2011-04-12 00:06:08 +00:00
|
|
|
|
else
|
2011-06-17 05:39:11 +00:00
|
|
|
|
section = _gtk_css_section_new_for_file (GTK_CSS_SECTION_DOCUMENT, file);
|
|
|
|
|
|
|
|
|
|
gtk_css_provider_error (css_provider,
|
|
|
|
|
parent,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR,
|
|
|
|
|
GTK_CSS_PROVIDER_ERROR_IMPORT,
|
|
|
|
|
"Failed to import: %s",
|
|
|
|
|
load_error->message);
|
|
|
|
|
|
|
|
|
|
gtk_css_section_unref (section);
|
2011-04-11 18:08:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-11 17:55:34 +00:00
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
if (text)
|
2011-04-11 18:08:57 +00:00
|
|
|
|
{
|
2011-06-17 02:52:43 +00:00
|
|
|
|
scanner = gtk_css_scanner_new (css_provider,
|
|
|
|
|
parent,
|
|
|
|
|
parent ? parent->section : NULL,
|
|
|
|
|
file,
|
2011-06-17 03:15:48 +00:00
|
|
|
|
text);
|
2011-04-11 18:08:57 +00:00
|
|
|
|
|
2011-04-14 02:47:18 +00:00
|
|
|
|
parse_stylesheet (scanner);
|
2011-04-11 18:08:57 +00:00
|
|
|
|
|
|
|
|
|
gtk_css_scanner_destroy (scanner);
|
2011-05-14 11:27:31 +00:00
|
|
|
|
|
|
|
|
|
if (parent == NULL)
|
|
|
|
|
gtk_css_provider_postprocess (css_provider);
|
2011-04-11 18:08:57 +00:00
|
|
|
|
}
|
2011-04-11 17:55:34 +00:00
|
|
|
|
|
2011-05-30 17:26:28 +00:00
|
|
|
|
g_free (free_data);
|
|
|
|
|
|
2011-04-11 17:57:42 +00:00
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handler_disconnect (css_provider, error_handler);
|
2011-05-30 17:26:28 +00:00
|
|
|
|
|
2011-04-11 17:57:42 +00:00
|
|
|
|
if (*error)
|
|
|
|
|
{
|
|
|
|
|
/* We clear all contents from the provider for backwards compat reasons */
|
|
|
|
|
gtk_css_provider_reset (css_provider);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2011-04-11 17:55:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_load_from_data:
|
|
|
|
|
* @css_provider: a #GtkCssProvider
|
2011-06-01 00:37:43 +00:00
|
|
|
|
* @data: (array length=length) (element-type guint8): CSS data loaded in memory
|
2011-06-17 03:15:48 +00:00
|
|
|
|
* @length: the length of @data in bytes, or -1 for NUL terminated strings. If
|
|
|
|
|
* @length is not -1, the code will assume it is not NUL terminated and will
|
|
|
|
|
* potentially do a copy.
|
2010-10-19 08:59:46 +00:00
|
|
|
|
* @error: (out) (allow-none): return location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Loads @data into @css_provider, making it clear any previously loaded
|
|
|
|
|
* information.
|
|
|
|
|
*
|
2012-09-19 13:30:21 +00:00
|
|
|
|
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
|
|
|
|
|
* returned for backwards compatibility reasons if an @error is not
|
|
|
|
|
* %NULL and a loading error occured. To track errors while loading
|
2014-10-04 20:06:30 +00:00
|
|
|
|
* CSS, connect to the #GtkCssProvider::parsing-error signal.
|
2010-10-19 08:59:46 +00:00
|
|
|
|
**/
|
2010-04-11 21:03:25 +00:00
|
|
|
|
gboolean
|
2010-11-18 01:24:18 +00:00
|
|
|
|
gtk_css_provider_load_from_data (GtkCssProvider *css_provider,
|
|
|
|
|
const gchar *data,
|
|
|
|
|
gssize length,
|
|
|
|
|
GError **error)
|
2010-04-11 21:03:25 +00:00
|
|
|
|
{
|
2011-06-17 03:15:48 +00:00
|
|
|
|
char *free_data;
|
|
|
|
|
gboolean ret;
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
|
|
|
|
|
g_return_val_if_fail (data != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (length < 0)
|
2011-06-17 03:15:48 +00:00
|
|
|
|
{
|
|
|
|
|
length = strlen (data);
|
|
|
|
|
free_data = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
free_data = g_strndup (data, length);
|
|
|
|
|
data = free_data;
|
|
|
|
|
}
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-04-07 22:08:10 +00:00
|
|
|
|
gtk_css_provider_reset (css_provider);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
ret = gtk_css_provider_load_internal (css_provider, NULL, NULL, data, error);
|
|
|
|
|
|
|
|
|
|
g_free (free_data);
|
|
|
|
|
|
2012-04-08 15:35:24 +00:00
|
|
|
|
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
|
|
|
|
|
|
2011-06-17 03:15:48 +00:00
|
|
|
|
return ret;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_load_from_file:
|
|
|
|
|
* @css_provider: a #GtkCssProvider
|
|
|
|
|
* @file: #GFile pointing to a file to load
|
|
|
|
|
* @error: (out) (allow-none): return location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Loads the data contained in @file into @css_provider, making it
|
|
|
|
|
* clear any previously loaded information.
|
|
|
|
|
*
|
2012-09-19 13:30:21 +00:00
|
|
|
|
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
|
|
|
|
|
* returned for backwards compatibility reasons if an @error is not
|
|
|
|
|
* %NULL and a loading error occured. To track errors while loading
|
2014-10-04 20:06:30 +00:00
|
|
|
|
* CSS, connect to the #GtkCssProvider::parsing-error signal.
|
2010-10-19 08:59:46 +00:00
|
|
|
|
**/
|
2010-04-11 21:03:25 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_css_provider_load_from_file (GtkCssProvider *css_provider,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2012-04-08 15:35:24 +00:00
|
|
|
|
gboolean success;
|
|
|
|
|
|
2010-04-11 21:03:25 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
|
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), FALSE);
|
|
|
|
|
|
2011-04-07 22:08:10 +00:00
|
|
|
|
gtk_css_provider_reset (css_provider);
|
2010-04-11 21:03:25 +00:00
|
|
|
|
|
2012-04-08 15:35:24 +00:00
|
|
|
|
success = gtk_css_provider_load_internal (css_provider, NULL, file, NULL, error);
|
|
|
|
|
|
|
|
|
|
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
|
|
|
|
|
|
|
|
|
|
return success;
|
2010-04-11 21:03:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_load_from_path:
|
|
|
|
|
* @css_provider: a #GtkCssProvider
|
|
|
|
|
* @path: the path of a filename to load, in the GLib filename encoding
|
|
|
|
|
* @error: (out) (allow-none): return location for a #GError, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Loads the data contained in @path into @css_provider, making it clear
|
|
|
|
|
* any previously loaded information.
|
|
|
|
|
*
|
2012-09-19 13:30:21 +00:00
|
|
|
|
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
|
|
|
|
|
* returned for backwards compatibility reasons if an @error is not
|
|
|
|
|
* %NULL and a loading error occured. To track errors while loading
|
2014-10-04 20:06:30 +00:00
|
|
|
|
* CSS, connect to the #GtkCssProvider::parsing-error signal.
|
2010-10-19 08:59:46 +00:00
|
|
|
|
**/
|
2010-10-08 16:36:46 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
|
|
|
|
|
const gchar *path,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2011-04-11 23:22:16 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
gboolean result;
|
|
|
|
|
|
2010-10-08 16:36:46 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
|
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
|
|
2011-04-11 23:22:16 +00:00
|
|
|
|
file = g_file_new_for_path (path);
|
|
|
|
|
|
|
|
|
|
result = gtk_css_provider_load_from_file (css_provider, file, error);
|
|
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
|
|
|
|
|
return result;
|
2010-10-08 16:36:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-04 19:52:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_load_from_resource:
|
|
|
|
|
* @css_provider: a #GtkCssProvider
|
|
|
|
|
* @resource_path: a #GResource resource path
|
|
|
|
|
*
|
|
|
|
|
* Loads the data contained in the resource at @resource_path into
|
|
|
|
|
* the #GtkCssProvider, clearing any previously loaded information.
|
|
|
|
|
*
|
2014-10-04 20:06:30 +00:00
|
|
|
|
* To track errors while loading CSS, connect to the
|
|
|
|
|
* #GtkCssProvider::parsing-error signal.
|
2014-10-04 19:52:02 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.16
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_css_provider_load_from_resource (GtkCssProvider *css_provider,
|
|
|
|
|
const gchar *resource_path)
|
2012-01-12 18:14:33 +00:00
|
|
|
|
{
|
|
|
|
|
GFile *file;
|
2014-10-04 19:52:02 +00:00
|
|
|
|
gchar *uri, *escaped;
|
2012-01-12 18:14:33 +00:00
|
|
|
|
|
2012-09-19 13:18:19 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
|
|
|
|
|
g_return_if_fail (resource_path != NULL);
|
2012-01-12 18:14:33 +00:00
|
|
|
|
|
|
|
|
|
escaped = g_uri_escape_string (resource_path,
|
|
|
|
|
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
|
|
|
|
|
uri = g_strconcat ("resource://", escaped, NULL);
|
|
|
|
|
g_free (escaped);
|
|
|
|
|
|
|
|
|
|
file = g_file_new_for_uri (uri);
|
|
|
|
|
g_free (uri);
|
|
|
|
|
|
2014-10-04 20:06:30 +00:00
|
|
|
|
gtk_css_provider_load_from_file (css_provider, file, NULL);
|
2012-01-12 18:14:33 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 02:10:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_get_default:
|
|
|
|
|
*
|
|
|
|
|
* Returns the provider containing the style settings used as a
|
|
|
|
|
* fallback for all widgets.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): The provider used for fallback styling.
|
|
|
|
|
* This memory is owned by GTK+, and you must not free it.
|
|
|
|
|
**/
|
|
|
|
|
GtkCssProvider *
|
|
|
|
|
gtk_css_provider_get_default (void)
|
2010-09-22 21:39:15 +00:00
|
|
|
|
{
|
2012-09-18 02:10:59 +00:00
|
|
|
|
static GtkCssProvider *provider;
|
2010-09-22 21:39:15 +00:00
|
|
|
|
|
2012-09-18 02:10:59 +00:00
|
|
|
|
if (G_UNLIKELY (!provider))
|
2012-09-11 20:50:20 +00:00
|
|
|
|
{
|
2012-09-18 02:10:59 +00:00
|
|
|
|
provider = gtk_css_provider_new ();
|
2012-09-11 20:50:20 +00:00
|
|
|
|
}
|
2010-08-20 09:50:39 +00:00
|
|
|
|
|
2012-09-18 02:10:59 +00:00
|
|
|
|
return provider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
|
_gtk_css_provider_get_theme_dir (void)
|
|
|
|
|
{
|
|
|
|
|
const gchar *var;
|
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
|
|
var = g_getenv ("GTK_DATA_PREFIX");
|
|
|
|
|
if (var)
|
|
|
|
|
path = g_build_filename (var, "share", "themes", NULL);
|
|
|
|
|
else
|
|
|
|
|
path = g_build_filename (_gtk_get_data_prefix (), "share", "themes", NULL);
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
#if (GTK_MINOR_VERSION % 2)
|
|
|
|
|
#define MINOR (GTK_MINOR_VERSION + 1)
|
|
|
|
|
#else
|
|
|
|
|
#define MINOR GTK_MINOR_VERSION
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Look for
|
|
|
|
|
* $dir/$subdir/gtk-3.16/gtk-$variant.css
|
|
|
|
|
* $dir/$subdir/gtk-3.14/gtk-$variant.css
|
|
|
|
|
* ...
|
|
|
|
|
* $dir/$subdir/gtk-3.0/gtk-$variant.css
|
|
|
|
|
* and return the first found file.
|
|
|
|
|
* We don't check versions before 3.14,
|
|
|
|
|
* since those GTK+ versions didn't have
|
|
|
|
|
* the versioned loading mechanism.
|
|
|
|
|
*/
|
2014-11-12 23:20:35 +00:00
|
|
|
|
static gchar *
|
2014-11-13 00:22:55 +00:00
|
|
|
|
_gtk_css_find_theme_dir (const gchar *dir,
|
|
|
|
|
const gchar *subdir,
|
|
|
|
|
const gchar *name,
|
|
|
|
|
const gchar *variant)
|
|
|
|
|
{
|
|
|
|
|
gchar *file;
|
|
|
|
|
gchar *base;
|
|
|
|
|
gchar *subsubdir;
|
|
|
|
|
gint i;
|
2014-11-12 23:20:35 +00:00
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
|
|
if (variant)
|
2014-11-13 00:22:55 +00:00
|
|
|
|
file = g_strconcat ("gtk-", variant, ".css", NULL);
|
2014-11-12 23:20:35 +00:00
|
|
|
|
else
|
2014-11-13 00:22:55 +00:00
|
|
|
|
file = g_strdup ("gtk.css");
|
2014-11-12 23:20:35 +00:00
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
if (subdir)
|
|
|
|
|
base = g_build_filename (dir, subdir, name, NULL);
|
|
|
|
|
else
|
|
|
|
|
base = g_build_filename (dir, name, NULL);
|
|
|
|
|
|
|
|
|
|
for (i = MINOR; i >= 0; i = i - 2)
|
2014-11-12 23:20:35 +00:00
|
|
|
|
{
|
2014-11-13 00:22:55 +00:00
|
|
|
|
if (i < 14)
|
|
|
|
|
i = 0;
|
2014-11-12 23:20:35 +00:00
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
subsubdir = g_strdup_printf ("gtk-3.%d", i);
|
|
|
|
|
path = g_build_filename (base, subsubdir, file, NULL);
|
|
|
|
|
g_free (subsubdir);
|
2014-11-12 23:20:35 +00:00
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
|
|
|
|
break;
|
2014-11-12 23:20:35 +00:00
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
g_free (path);
|
|
|
|
|
path = NULL;
|
2014-11-12 23:20:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-13 00:22:55 +00:00
|
|
|
|
g_free (file);
|
|
|
|
|
g_free (base);
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef MINOR
|
|
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
|
_gtk_css_find_theme (const gchar *name,
|
|
|
|
|
const gchar *variant)
|
|
|
|
|
{
|
|
|
|
|
gchar *path;
|
|
|
|
|
const gchar *var;
|
|
|
|
|
|
|
|
|
|
/* First look in the user's config directory */
|
|
|
|
|
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
|
|
|
|
|
if (path)
|
|
|
|
|
return path;
|
|
|
|
|
|
|
|
|
|
/* Next look in the user's home directory */
|
|
|
|
|
path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name, variant);
|
|
|
|
|
if (path)
|
|
|
|
|
return path;
|
|
|
|
|
|
|
|
|
|
/* Finally, try in the default theme directory */
|
|
|
|
|
var = g_getenv ("GTK_DATA_PREFIX");
|
|
|
|
|
if (!var)
|
|
|
|
|
var = _gtk_get_data_prefix ();
|
|
|
|
|
|
|
|
|
|
path = _gtk_css_find_theme_dir (var, "share" G_DIR_SEPARATOR_S "themes", name, variant);
|
2014-11-12 23:20:35 +00:00
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-19 14:15:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* _gtk_css_provider_load_named:
|
|
|
|
|
* @provider: a #GtkCssProvider
|
|
|
|
|
* @name: A theme name
|
|
|
|
|
* @variant: (allow-none): variant to load, for example, "dark", or
|
|
|
|
|
* %NULL for the default
|
|
|
|
|
*
|
|
|
|
|
* Loads a theme from the usual theme paths. The actual process of
|
|
|
|
|
* finding the theme might change between releases, but it is
|
|
|
|
|
* guaranteed that this function uses the same mechanism to load the
|
|
|
|
|
* theme than GTK uses for loading its own theme.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
_gtk_css_provider_load_named (GtkCssProvider *provider,
|
|
|
|
|
const gchar *name,
|
|
|
|
|
const gchar *variant)
|
2012-09-18 02:10:59 +00:00
|
|
|
|
{
|
2014-11-13 00:22:55 +00:00
|
|
|
|
gchar *path;
|
2012-09-19 14:07:39 +00:00
|
|
|
|
gchar *resource_path;
|
2012-09-18 02:10:59 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_CSS_PROVIDER (provider));
|
|
|
|
|
g_return_if_fail (name != NULL);
|
2012-09-18 02:10:59 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
gtk_css_provider_reset (provider);
|
2012-02-09 22:16:03 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
/* try loading the resource for the theme. This is mostly meant for built-in
|
|
|
|
|
* themes.
|
|
|
|
|
*/
|
|
|
|
|
if (variant)
|
2014-01-23 23:59:20 +00:00
|
|
|
|
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s-%s.css", name, variant);
|
2012-09-19 14:07:39 +00:00
|
|
|
|
else
|
2014-01-23 23:59:20 +00:00
|
|
|
|
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s.css", name);
|
2012-02-09 22:16:03 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
|
|
|
|
|
{
|
|
|
|
|
gtk_css_provider_load_from_resource (provider, resource_path);
|
2012-09-18 02:10:59 +00:00
|
|
|
|
g_free (resource_path);
|
2012-09-19 14:07:39 +00:00
|
|
|
|
return;
|
2012-02-09 22:16:03 +00:00
|
|
|
|
}
|
2012-09-19 14:07:39 +00:00
|
|
|
|
g_free (resource_path);
|
2012-02-09 22:16:03 +00:00
|
|
|
|
|
2014-11-12 23:20:35 +00:00
|
|
|
|
/* Next try looking for files in the various theme directories. */
|
|
|
|
|
path = _gtk_css_find_theme (name, variant);
|
2012-09-19 14:07:39 +00:00
|
|
|
|
if (path)
|
|
|
|
|
{
|
|
|
|
|
char *dir, *resource_file;
|
|
|
|
|
GResource *resource;
|
2012-09-18 02:10:59 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
dir = g_path_get_dirname (path);
|
|
|
|
|
resource_file = g_build_filename (dir, "gtk.gresource", NULL);
|
|
|
|
|
resource = g_resource_load (resource_file, NULL);
|
|
|
|
|
g_free (resource_file);
|
2012-03-04 16:51:07 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
if (resource != NULL)
|
|
|
|
|
g_resources_register (resource);
|
2012-02-03 14:50:49 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
gtk_css_provider_load_from_path (provider, path, NULL);
|
2012-09-19 13:32:38 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
/* Only set this after load, as load_from_path will clear it */
|
|
|
|
|
provider->priv->resource = resource;
|
2011-02-05 02:13:56 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
g_free (path);
|
|
|
|
|
g_free (dir);
|
2010-08-20 09:50:39 +00:00
|
|
|
|
}
|
2012-09-19 14:30:27 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Things failed! Fall back! Fall back! */
|
|
|
|
|
|
|
|
|
|
if (variant)
|
|
|
|
|
{
|
|
|
|
|
/* If there was a variant, try without */
|
|
|
|
|
_gtk_css_provider_load_named (provider, name, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-01-24 13:04:04 +00:00
|
|
|
|
/* Worst case, fall back to the default */
|
|
|
|
|
g_return_if_fail (!g_str_equal (name, DEFAULT_THEME_NAME)); /* infloop protection */
|
|
|
|
|
_gtk_css_provider_load_named (provider, DEFAULT_THEME_NAME, NULL);
|
2012-09-19 14:30:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-19 14:07:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_get_named:
|
|
|
|
|
* @name: A theme name
|
|
|
|
|
* @variant: (allow-none): variant to load, for example, "dark", or
|
|
|
|
|
* %NULL for the default
|
|
|
|
|
*
|
|
|
|
|
* Loads a theme from the usual theme paths
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): a #GtkCssProvider with the theme loaded.
|
|
|
|
|
* This memory is owned by GTK+, and you must not free it.
|
|
|
|
|
*/
|
|
|
|
|
GtkCssProvider *
|
|
|
|
|
gtk_css_provider_get_named (const gchar *name,
|
|
|
|
|
const gchar *variant)
|
|
|
|
|
{
|
|
|
|
|
static GHashTable *themes = NULL;
|
|
|
|
|
GtkCssProvider *provider;
|
|
|
|
|
gchar *key;
|
|
|
|
|
|
|
|
|
|
if (variant == NULL)
|
|
|
|
|
key = g_strdup (name);
|
|
|
|
|
else
|
|
|
|
|
key = g_strconcat (name, "-", variant, NULL);
|
|
|
|
|
if (G_UNLIKELY (!themes))
|
|
|
|
|
themes = g_hash_table_new (g_str_hash, g_str_equal);
|
2010-08-20 09:50:39 +00:00
|
|
|
|
|
2012-09-19 14:07:39 +00:00
|
|
|
|
provider = g_hash_table_lookup (themes, key);
|
|
|
|
|
|
|
|
|
|
if (!provider)
|
|
|
|
|
{
|
|
|
|
|
provider = gtk_css_provider_new ();
|
2012-09-19 14:15:05 +00:00
|
|
|
|
_gtk_css_provider_load_named (provider, name, variant);
|
2012-09-19 14:07:39 +00:00
|
|
|
|
g_hash_table_insert (themes, g_strdup (key), provider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (key);
|
2011-01-31 00:30:00 +00:00
|
|
|
|
|
2010-08-20 09:50:39 +00:00
|
|
|
|
return provider;
|
|
|
|
|
}
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
2011-05-18 02:36:43 +00:00
|
|
|
|
static int
|
2012-03-01 05:40:15 +00:00
|
|
|
|
compare_properties (gconstpointer a, gconstpointer b, gpointer style)
|
2011-05-18 02:36:43 +00:00
|
|
|
|
{
|
2012-03-01 05:40:15 +00:00
|
|
|
|
const guint *ua = a;
|
|
|
|
|
const guint *ub = b;
|
|
|
|
|
PropertyValue *styles = style;
|
|
|
|
|
|
|
|
|
|
return strcmp (_gtk_style_property_get_name (GTK_STYLE_PROPERTY (styles[*ua].property)),
|
|
|
|
|
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (styles[*ub].property)));
|
2012-02-15 16:06:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
compare_names (gconstpointer a, gconstpointer b)
|
|
|
|
|
{
|
|
|
|
|
const WidgetPropertyValue *aa = a;
|
|
|
|
|
const WidgetPropertyValue *bb = b;
|
|
|
|
|
return strcmp (aa->name, bb->name);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 20:03:35 +00:00
|
|
|
|
static void
|
2011-05-17 20:04:40 +00:00
|
|
|
|
gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
|
|
|
|
|
GString *str)
|
2011-04-06 20:03:35 +00:00
|
|
|
|
{
|
2012-02-15 16:06:30 +00:00
|
|
|
|
GList *values, *walk;
|
|
|
|
|
WidgetPropertyValue *widget_value;
|
2012-03-01 05:40:15 +00:00
|
|
|
|
guint i;
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
2012-11-29 15:00:01 +00:00
|
|
|
|
_gtk_css_selector_tree_match_print (ruleset->selector_match, str);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
|
|
|
|
g_string_append (str, " {\n");
|
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
if (ruleset->styles)
|
2011-04-06 20:03:35 +00:00
|
|
|
|
{
|
2012-03-01 05:40:15 +00:00
|
|
|
|
guint *sorted = g_new (guint, ruleset->n_styles);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ruleset->n_styles; i++)
|
|
|
|
|
sorted[i] = i;
|
2012-02-15 16:06:30 +00:00
|
|
|
|
|
2011-05-18 02:36:43 +00:00
|
|
|
|
/* so the output is identical for identical selector styles */
|
2012-03-01 05:40:15 +00:00
|
|
|
|
g_qsort_with_data (sorted, ruleset->n_styles, sizeof (guint), compare_properties, ruleset->styles);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
for (i = 0; i < ruleset->n_styles; i++)
|
2011-05-18 02:36:43 +00:00
|
|
|
|
{
|
2012-03-01 05:40:15 +00:00
|
|
|
|
PropertyValue *prop = &ruleset->styles[sorted[i]];
|
2011-05-18 02:36:43 +00:00
|
|
|
|
g_string_append (str, " ");
|
2012-03-01 05:40:15 +00:00
|
|
|
|
g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop->property)));
|
2011-05-18 02:36:43 +00:00
|
|
|
|
g_string_append (str, ": ");
|
2012-07-16 12:28:58 +00:00
|
|
|
|
_gtk_css_value_print (prop->value, str);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
g_string_append (str, ";\n");
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-01 05:40:15 +00:00
|
|
|
|
g_free (sorted);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 02:36:43 +00:00
|
|
|
|
if (ruleset->widget_style)
|
|
|
|
|
{
|
2012-02-15 16:06:30 +00:00
|
|
|
|
values = NULL;
|
|
|
|
|
for (widget_value = ruleset->widget_style; widget_value != NULL; widget_value = widget_value->next)
|
|
|
|
|
values = g_list_prepend (values, widget_value);
|
|
|
|
|
|
2011-05-18 02:36:43 +00:00
|
|
|
|
/* so the output is identical for identical selector styles */
|
2012-02-15 16:06:30 +00:00
|
|
|
|
values = g_list_sort (values, compare_names);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
|
2012-02-15 16:06:30 +00:00
|
|
|
|
for (walk = values; walk; walk = walk->next)
|
2011-05-18 02:36:43 +00:00
|
|
|
|
{
|
2012-02-15 16:06:30 +00:00
|
|
|
|
widget_value = walk->data;
|
2011-05-18 02:36:43 +00:00
|
|
|
|
|
|
|
|
|
g_string_append (str, " ");
|
2012-02-15 16:06:30 +00:00
|
|
|
|
g_string_append (str, widget_value->name);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
g_string_append (str, ": ");
|
2012-03-30 00:45:01 +00:00
|
|
|
|
g_string_append (str, widget_value->value);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
g_string_append (str, ";\n");
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 16:06:30 +00:00
|
|
|
|
g_list_free (values);
|
2011-05-18 02:36:43 +00:00
|
|
|
|
}
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
|
|
|
|
g_string_append (str, "}\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_print_colors (GHashTable *colors,
|
|
|
|
|
GString *str)
|
|
|
|
|
{
|
|
|
|
|
GList *keys, *walk;
|
|
|
|
|
|
|
|
|
|
keys = g_hash_table_get_keys (colors);
|
|
|
|
|
/* so the output is identical for identical styles */
|
|
|
|
|
keys = g_list_sort (keys, (GCompareFunc) strcmp);
|
|
|
|
|
|
|
|
|
|
for (walk = keys; walk; walk = walk->next)
|
|
|
|
|
{
|
|
|
|
|
const char *name = walk->data;
|
2012-11-25 01:28:59 +00:00
|
|
|
|
GtkCssValue *color = g_hash_table_lookup (colors, (gpointer) name);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
|
|
|
|
g_string_append (str, "@define-color ");
|
|
|
|
|
g_string_append (str, name);
|
|
|
|
|
g_string_append (str, " ");
|
2012-11-25 01:28:59 +00:00
|
|
|
|
_gtk_css_value_print (color, str);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
g_string_append (str, ";\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_free (keys);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-19 01:41:41 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_css_provider_print_keyframes (GHashTable *keyframes,
|
|
|
|
|
GString *str)
|
|
|
|
|
{
|
|
|
|
|
GList *keys, *walk;
|
|
|
|
|
|
|
|
|
|
keys = g_hash_table_get_keys (keyframes);
|
|
|
|
|
/* so the output is identical for identical styles */
|
|
|
|
|
keys = g_list_sort (keys, (GCompareFunc) strcmp);
|
|
|
|
|
|
|
|
|
|
for (walk = keys; walk; walk = walk->next)
|
|
|
|
|
{
|
|
|
|
|
const char *name = walk->data;
|
|
|
|
|
GtkCssKeyframes *keyframe = g_hash_table_lookup (keyframes, (gpointer) name);
|
|
|
|
|
|
|
|
|
|
if (str->len > 0)
|
|
|
|
|
g_string_append (str, "\n");
|
|
|
|
|
g_string_append (str, "@keyframes ");
|
|
|
|
|
g_string_append (str, name);
|
|
|
|
|
g_string_append (str, " {\n");
|
|
|
|
|
_gtk_css_keyframes_print (keyframe, str);
|
|
|
|
|
g_string_append (str, "}\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_free (keys);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 20:03:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_css_provider_to_string:
|
|
|
|
|
* @provider: the provider to write to a string
|
|
|
|
|
*
|
2014-03-02 08:47:31 +00:00
|
|
|
|
* Converts the @provider into a string representation in CSS
|
2011-04-06 20:03:35 +00:00
|
|
|
|
* format.
|
2014-03-02 08:47:31 +00:00
|
|
|
|
*
|
2011-04-06 20:03:35 +00:00
|
|
|
|
* Using gtk_css_provider_load_from_data() with the return value
|
|
|
|
|
* from this function on a new provider created with
|
2014-03-02 11:09:48 +00:00
|
|
|
|
* gtk_css_provider_new() will basically create a duplicate of
|
2011-04-06 20:03:35 +00:00
|
|
|
|
* this @provider.
|
|
|
|
|
*
|
|
|
|
|
* Returns: a new string representing the @provider.
|
2011-12-30 05:38:06 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.2
|
2011-04-06 20:03:35 +00:00
|
|
|
|
**/
|
|
|
|
|
char *
|
|
|
|
|
gtk_css_provider_to_string (GtkCssProvider *provider)
|
|
|
|
|
{
|
|
|
|
|
GtkCssProviderPrivate *priv;
|
|
|
|
|
GString *str;
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (provider), NULL);
|
|
|
|
|
|
|
|
|
|
priv = provider->priv;
|
|
|
|
|
|
|
|
|
|
str = g_string_new ("");
|
|
|
|
|
|
|
|
|
|
gtk_css_provider_print_colors (priv->symbolic_colors, str);
|
2012-04-19 01:41:41 +00:00
|
|
|
|
gtk_css_provider_print_keyframes (priv->keyframes, str);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
|
2011-05-17 20:04:40 +00:00
|
|
|
|
for (i = 0; i < priv->rulesets->len; i++)
|
2011-04-06 20:03:35 +00:00
|
|
|
|
{
|
2012-04-05 20:28:21 +00:00
|
|
|
|
if (str->len != 0)
|
2011-04-06 20:03:35 +00:00
|
|
|
|
g_string_append (str, "\n");
|
2011-05-18 02:20:05 +00:00
|
|
|
|
gtk_css_ruleset_print (&g_array_index (priv->rulesets, GtkCssRuleset, i), str);
|
2011-04-06 20:03:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_string_free (str, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|