[gtk/wip/otte/listview: 145/215] Revert "Add GtkExpression"



commit 831bf7350b65787c13e402604fb3653667a31e92
Author: Benjamin Otte <otte redhat com>
Date:   Sun Nov 17 03:02:19 2019 +0100

    Revert "Add GtkExpression"
    
    This reverts commit cd6e8b8d330e1a10c3310a45a808325bcaa45002.

 demos/gtk-demo/fishbowl.ui |   17 +-
 gtk/gtkbuilder.c           |   57 +-
 gtk/gtkbuilderparser.c     |  133 +---
 gtk/gtkbuilderprivate.h    |    6 +-
 gtk/gtkexpression.c        | 1699 --------------------------------------------
 gtk/gtkexpressionprivate.h |   54 --
 gtk/meson.build            |    1 -
 7 files changed, 37 insertions(+), 1930 deletions(-)
---
diff --git a/demos/gtk-demo/fishbowl.ui b/demos/gtk-demo/fishbowl.ui
index ab8201f6d7..5d09b3477a 100644
--- a/demos/gtk-demo/fishbowl.ui
+++ b/demos/gtk-demo/fishbowl.ui
@@ -28,7 +28,22 @@
         </child>
         <child type="end">
           <object class="GtkLabel">
-            <binding name="label">bowl.count + " Icons, " + bowl.framerate + "fps"</binding>
+            <property name="label">fps</property>
+          </object>
+        </child>
+        <child type="end">
+          <object class="GtkLabel">
+            <property name="label" bind-source="bowl" bind-property="framerate-string"/>
+          </object>
+        </child>
+        <child type="end">
+          <object class="GtkLabel">
+            <property name="label">Icons, </property>
+          </object>
+        </child>
+        <child type="end">
+          <object class="GtkLabel">
+            <property name="label" bind-source="bowl" bind-property="count"/>
           </object>
         </child>
         <child type="end">
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 9cc3c10f29..118308a7bf 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -234,7 +234,6 @@
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
 #include "gtkdebug.h"
-#include "gtkexpressionprivate.h"
 #include "gtkmain.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
@@ -1030,9 +1029,19 @@ gtk_builder_apply_delayed_properties (GtkBuilder *builder)
   g_slist_free (props);
 }
 
-static inline gboolean
-gtk_builder_create_bindings (GtkBuilder  *builder,
-                             GError     **error)
+static inline void
+free_binding_info (gpointer data,
+                   gpointer user)
+{
+  BindingInfo *info = data;
+
+  g_free (info->source);
+  g_free (info->source_property);
+  g_slice_free (BindingInfo, data);
+}
+
+static inline void
+gtk_builder_create_bindings (GtkBuilder *builder)
 {
   GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
   GSList *l;
@@ -1042,43 +1051,17 @@ gtk_builder_create_bindings (GtkBuilder  *builder,
       BindingInfo *info = l->data;
       GObject *source;
 
-      if (info->tag_type == TAG_BINDING)
-        {
-          source = _gtk_builder_lookup_object (builder, info->source, info->line, info->col);
-          if (source)
-            g_object_bind_property (source, info->source_property,
-                                    info->target, info->target_pspec->name,
-                                    info->flags);
-        }
-      else
-        {
-          GtkExpression *expression, *assign;
-          GValue value = G_VALUE_INIT;
-
-          expression = gtk_expression_parse (builder, info->source, error);
-          if (expression == NULL)
-            {
-              g_prefix_error (error, "%s:%d:%d: ", priv->filename, info->line, info->col);
-              goto fail;
-            }
-          assign = gtk_expression_new_assign (info->target, info->target_pspec->name, expression);
-          if (gtk_expression_evaluate (assign, &value))
-            g_value_unset (&value);
-          gtk_expression_unref (assign);
-        }
+      source = _gtk_builder_lookup_object (builder, info->source, info->line, info->col);
+      if (source)
+        g_object_bind_property (source, info->source_property,
+                                info->target, info->target_pspec->name,
+                                info->flags);
 
-      _free_binding_info (info, NULL);
-    }
-
-fail:
-  for (; l; l = l->next)
-    {
-      _free_binding_info (l->data, NULL);
+      free_binding_info (info, NULL);
     }
 
   g_slist_free (priv->bindings);
   priv->bindings = NULL;
-  return TRUE;
 }
 
 /**
@@ -1774,8 +1757,6 @@ _gtk_builder_finish (GtkBuilder  *builder,
 {
   gtk_builder_apply_delayed_properties (builder);
   gtk_builder_create_bindings (builder);
-  if (!gtk_builder_create_bindings (builder, error))
-    return FALSE;
   return gtk_builder_connect_signals (builder, error);
 }
 
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 6fdab9aab2..a853151806 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -928,8 +928,7 @@ parse_property (ParserData   *data,
     {
       BindingInfo *binfo;
 
-      binfo = g_slice_new0 (BindingInfo);
-      binfo->tag_type = TAG_BINDING;
+      binfo = g_slice_new (BindingInfo);
       binfo->target = NULL;
       binfo->target_pspec = pspec;
       binfo->source = g_strdup (bind_source);
@@ -961,87 +960,6 @@ parse_property (ParserData   *data,
   state_push (data, info);
 }
 
-static void
-parse_binding (ParserData   *data,
-               const gchar  *element_name,
-               const gchar **names,
-               const gchar **values,
-               GError      **error)
-{
-  BindingInfo *info;
-  const gchar *name = NULL;
-  const gchar *context = NULL;
-  gboolean translatable = FALSE;
-  ObjectInfo *object_info;
-  GParamSpec *pspec = NULL;
-  gint line, col;
-
-  object_info = state_peek_info (data, ObjectInfo);
-  if (!object_info ||
-      !(object_info->tag_type == TAG_OBJECT ||
-        object_info->tag_type == TAG_TEMPLATE))
-    {
-      error_invalid_tag (data, element_name, NULL, error);
-      return;
-    }
-
-  if (!g_markup_collect_attributes (element_name, names, values, error,
-                                    G_MARKUP_COLLECT_STRING, "name", &name,
-                                    G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", 
&translatable,
-                                    G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &context,
-                                    G_MARKUP_COLLECT_INVALID))
-    {
-      _gtk_builder_prefix_error (data->builder, &data->ctx, error);
-      return;
-    }
-
-  pspec = g_object_class_find_property (object_info->oclass, name);
-
-  if (!pspec)
-    {
-      g_set_error (error,
-                   GTK_BUILDER_ERROR,
-                   GTK_BUILDER_ERROR_INVALID_PROPERTY,
-                   "Invalid property: %s.%s",
-                   g_type_name (object_info->type), name);
-      _gtk_builder_prefix_error (data->builder, &data->ctx, error);
-      return;
-    }
-  else if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
-    {
-      g_set_error (error,
-                   GTK_BUILDER_ERROR,
-                   GTK_BUILDER_ERROR_INVALID_PROPERTY,
-                   "%s.%s is a construct-only property",
-                   g_type_name (object_info->type), name);
-      _gtk_builder_prefix_error (data->builder, &data->ctx, error);
-      return;
-    }
-  else if (!(pspec->flags & G_PARAM_WRITABLE))
-    {
-      g_set_error (error,
-                   GTK_BUILDER_ERROR,
-                   GTK_BUILDER_ERROR_INVALID_PROPERTY,
-                   "%s.%s is a non-writable property",
-                   g_type_name (object_info->type), name);
-      _gtk_builder_prefix_error (data->builder, &data->ctx, error);
-      return;
-    }
-
-  gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
-
-  info = g_slice_new0 (BindingInfo);
-  info->tag_type = TAG_EXPRESSION;
-  info->target = NULL;
-  info->target_pspec = pspec;
-  info->source = NULL;
-  info->flags = 0;
-  info->line = line;
-  info->col = col;
-
-  state_push (data, info);
-}
-
 static void
 free_property_info (PropertyInfo *info)
 {
@@ -1134,16 +1052,6 @@ _free_signal_info (SignalInfo *info,
   g_slice_free (SignalInfo, info);
 }
 
-void
-_free_binding_info (BindingInfo *info,
-                    gpointer     user)
-{
-  g_free (info->source);
-  g_free (info->source_property);
-  g_slice_free (BindingInfo, info);
-}
-
-
 static void
 free_requires_info (RequiresInfo *info,
                     gpointer      user_data)
@@ -1384,8 +1292,6 @@ start_element (GtkBuildableParseContext  *context,
     }
   else if (strcmp (element_name, "property") == 0)
     parse_property (data, element_name, names, values, error);
-  else if (strcmp (element_name, "binding") == 0)
-    parse_binding (data, element_name, names, values, error);
   else if (strcmp (element_name, "child") == 0)
     parse_child (data, element_name, names, values, error);
   else if (strcmp (element_name, "signal") == 0)
@@ -1471,23 +1377,6 @@ end_element (GtkBuildableParseContext  *context,
       else
         g_assert_not_reached ();
     }
-  else if (strcmp (element_name, "binding") == 0)
-    {
-      BindingInfo *binfo = state_pop_info (data, BindingInfo);
-      CommonInfo *info = state_peek_info (data, CommonInfo);
-
-      g_assert (info != NULL);
-
-      /* Normal properties */
-      if (info->tag_type == TAG_OBJECT ||
-          info->tag_type == TAG_TEMPLATE)
-        {
-          ObjectInfo *object_info = (ObjectInfo*)info;
-          object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
-        }
-      else
-        g_assert_not_reached ();
-    }
   else if (strcmp (element_name, "object") == 0 ||
            strcmp (element_name, "template") == 0)
     {
@@ -1628,22 +1517,6 @@ text (GtkBuildableParseContext  *context,
 
       g_string_append_len (prop_info->text, text, text_len);
     }
-  else if (strcmp (gtk_buildable_parse_context_get_element (context), "binding") == 0)
-    {
-      BindingInfo *binfo = (BindingInfo *) info;
-
-      if (binfo->source == NULL)
-        {
-          binfo->source = g_strndup (text, text_len);
-        }
-      else
-        {
-          char *s;
-          s = g_strdup_printf ("%s%*s", binfo->source, (guint) text_len, text);
-          g_free (binfo->source);
-          binfo->source = s;
-        }
-    }
 }
 
 static void
@@ -1658,10 +1531,6 @@ free_info (CommonInfo *info)
       case TAG_CHILD:
         free_child_info ((ChildInfo *)info);
         break;
-      case TAG_BINDING:
-      case TAG_EXPRESSION:
-        _free_binding_info ((BindingInfo *)info, NULL);
-        break;
       case TAG_PROPERTY:
         free_property_info ((PropertyInfo *)info);
         break;
diff --git a/gtk/gtkbuilderprivate.h b/gtk/gtkbuilderprivate.h
index a24c204acc..0e72efe273 100644
--- a/gtk/gtkbuilderprivate.h
+++ b/gtk/gtkbuilderprivate.h
@@ -24,8 +24,7 @@
 
 enum {
   TAG_PROPERTY,
-  TAG_BINDING,
-  TAG_EXPRESSION,
+  TAG_MENU,
   TAG_REQUIRES,
   TAG_OBJECT,
   TAG_CHILD,
@@ -85,7 +84,6 @@ typedef struct {
 
 typedef struct
 {
-  guint tag_type;
   GObject *target;
   GParamSpec *target_pspec;
   gchar *source;
@@ -181,8 +179,6 @@ gboolean  _gtk_builder_finish (GtkBuilder  *builder,
                                GError     **error);
 void _free_signal_info (SignalInfo *info,
                         gpointer user_data);
-void _free_binding_info (BindingInfo *info,
-                         gpointer user_data);
 
 /* Internal API which might be made public at some point */
 gboolean _gtk_builder_boolean_from_string (const gchar  *string,
diff --git a/gtk/meson.build b/gtk/meson.build
index 6ea60652e0..e390d26b23 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -231,7 +231,6 @@ gtk_public_sources = files([
   'gtkeventcontrollermotion.c',
   'gtkeventcontrollerscroll.c',
   'gtkexpander.c',
-  'gtkexpression.c',
   'gtkfilechooser.c',
   'gtkfilechooserbutton.c',
   'gtkfilechooserdialog.c',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]