]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssshorthandproperty.c
filechooser: Use _gtk_file_has_native_path() throughout when testing for local_only
[~andy/gtk] / gtk / gtkcssshorthandproperty.c
index 64c8633d033466a4e9ab85947b4409f0d635aa3e..c6ca6146890cae4c12db2c4dab906d319805657a 100644 (file)
@@ -12,8 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors: Benjamin Otte <otte@gnome.org>
  */
 
 #include "gtkcssshorthandpropertyprivate.h"
 
+#include "gtkcssarrayvalueprivate.h"
+#include "gtkcssinheritvalueprivate.h"
+#include "gtkcssinitialvalueprivate.h"
+#include "gtkcssstylefuncsprivate.h"
 #include "gtkintl.h"
 
 enum {
@@ -59,10 +62,93 @@ gtk_css_shorthand_property_set_property (GObject      *object,
     }
 }
 
+static void
+_gtk_css_shorthand_property_assign (GtkStyleProperty   *property,
+                                    GtkStyleProperties *props,
+                                    GtkStateFlags       state,
+                                    const GValue       *value)
+{
+  GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
+
+  shorthand->assign (shorthand, props, state, value);
+}
+
+static void
+_gtk_css_shorthand_property_query (GtkStyleProperty   *property,
+                                   GValue             *value,
+                                   GtkStyleQueryFunc   query_func,
+                                   gpointer            query_data)
+{
+  GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
+
+  return shorthand->query (shorthand, value, query_func, query_data);
+}
+
+static GtkCssValue *
+gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
+                                        GtkCssParser     *parser)
+{
+  GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
+  GtkCssValue **data;
+  GtkCssValue *result;
+  guint i;
+
+  data = g_new0 (GtkCssValue *, shorthand->subproperties->len);
+
+  if (_gtk_css_parser_try (parser, "initial", TRUE))
+    {
+      /* the initial value can be explicitly specified with the
+       * ‘initial’ keyword which all properties accept.
+       */
+      for (i = 0; i < shorthand->subproperties->len; i++)
+        {
+          data[i] = _gtk_css_initial_value_new ();
+        }
+    }
+  else if (_gtk_css_parser_try (parser, "inherit", TRUE))
+    {
+      /* All properties accept the ‘inherit’ value which
+       * explicitly specifies that the value will be determined
+       * by inheritance. The ‘inherit’ value can be used to
+       * strengthen inherited values in the cascade, and it can
+       * also be used on properties that are not normally inherited.
+       */
+      for (i = 0; i < shorthand->subproperties->len; i++)
+        {
+          data[i] = _gtk_css_inherit_value_new ();
+        }
+    }
+  else if (!shorthand->parse (shorthand, data, parser))
+    {
+      for (i = 0; i < shorthand->subproperties->len; i++)
+        {
+          if (data[i] != NULL)
+            _gtk_css_value_unref (data[i]);
+        }
+      g_free (data);
+      return NULL;
+    }
+
+  /* All values that aren't set by the parse func are set to their
+   * default values here.
+   * XXX: Is the default always initial or can it be inherit? */
+  for (i = 0; i < shorthand->subproperties->len; i++)
+    {
+      if (data[i] == NULL)
+        data[i] = _gtk_css_initial_value_new ();
+    }
+
+  result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len);
+  g_free (data);
+  
+  return result;
+}
+
 static void
 _gtk_css_shorthand_property_class_init (GtkCssShorthandPropertyClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkStylePropertyClass *property_class = GTK_STYLE_PROPERTY_CLASS (klass);
 
   object_class->set_property = gtk_css_shorthand_property_set_property;
 
@@ -73,6 +159,10 @@ _gtk_css_shorthand_property_class_init (GtkCssShorthandPropertyClass *klass)
                                                        P_("The list of subproperties"),
                                                        G_TYPE_STRV,
                                                        G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+  property_class->assign = _gtk_css_shorthand_property_assign;
+  property_class->query = _gtk_css_shorthand_property_query;
+  property_class->parse_value = gtk_css_shorthand_property_parse_value;
 }
 
 static void