Merge branch 'ebassi/expression-type' into 'master'

Ebassi/expression type

See merge request GNOME/gtk!2014
This commit is contained in:
Matthias Clasen 2020-06-01 22:48:26 +00:00
commit 67a972182e
8 changed files with 791 additions and 147 deletions

View File

@ -534,11 +534,9 @@ gtk_builder_get_parameters (GtkBuilder *builder,
g_value_init (&property_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
if (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) == GTK_TYPE_EXPRESSION)
g_value_set_boxed (&property_value, prop->value);
gtk_value_set_expression (&property_value, prop->value);
else
{
g_assert_not_reached();
}
g_assert_not_reached ();
}
else if (prop->bound && (!prop->text || prop->text->len == 0))
{

View File

@ -315,7 +315,7 @@ gtk_drop_down_get_property (GObject *object,
break;
case PROP_EXPRESSION:
g_value_set_boxed (value, self->expression);
gtk_value_set_expression (value, self->expression);
break;
default:
@ -355,7 +355,7 @@ gtk_drop_down_set_property (GObject *object,
break;
case PROP_EXPRESSION:
gtk_drop_down_set_expression (self, g_value_get_boxed (value));
gtk_drop_down_set_expression (self, gtk_value_get_expression (value));
break;
default:
@ -497,7 +497,7 @@ gtk_drop_down_class_init (GtkDropDownClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkDropDown:expression:
* GtkDropDown:expression: (type GtkExpression)
*
* An expression to evaluate to obtain strings to match against the search
* term (see #GtkDropDown:enable-search). If #GtkDropDown:factory is not set,
@ -505,11 +505,10 @@ gtk_drop_down_class_init (GtkDropDownClass *klass)
* default factory.
*/
properties[PROP_EXPRESSION] =
g_param_spec_boxed ("expression",
P_("Expression"),
P_("Expression to determine strings to search for"),
GTK_TYPE_EXPRESSION,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
gtk_param_spec_expression ("expression",
P_("Expression"),
P_("Expression to determine strings to search for"),
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,10 @@
G_BEGIN_DECLS
#define GTK_TYPE_EXPRESSION (gtk_expression_get_type ())
#define GTK_IS_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXPRESSION))
#define GTK_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXPRESSION, GtkExpression))
typedef struct _GtkExpression GtkExpression;
typedef struct _GtkExpressionWatch GtkExpressionWatch;
@ -37,10 +41,6 @@ typedef struct _GtkExpressionWatch GtkExpressionWatch;
*/
typedef void (* GtkExpressionNotify) (gpointer user_data);
#define GTK_IS_EXPRESSION(expr) ((expr) != NULL)
#define GTK_TYPE_EXPRESSION (gtk_expression_get_type ())
GDK_AVAILABLE_IN_ALL
GType gtk_expression_get_type (void) G_GNUC_CONST;
@ -79,6 +79,12 @@ gboolean gtk_expression_watch_evaluate (GtkExpressionWa
GDK_AVAILABLE_IN_ALL
void gtk_expression_watch_unwatch (GtkExpressionWatch *watch);
#define GTK_TYPE_PROPERTY_EXPRESSION (gtk_property_expression_get_type())
typedef struct _GtkPropertyExpression GtkPropertyExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_property_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_new (GType this_type,
GtkExpression *expression,
@ -86,18 +92,46 @@ GtkExpression * gtk_property_expression_new (GType
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression,
GParamSpec *pspec);
#define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type())
typedef struct _GtkConstantExpression GtkConstantExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_constant_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_constant_expression_new (GType value_type,
...);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_constant_expression_new_for_value (const GValue *value);
#define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type())
typedef struct _GtkObjectExpression GtkObjectExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_object_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_object_expression_new (GObject *object);
#define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type())
typedef struct _GtkClosureExpression GtkClosureExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_closure_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_closure_expression_new (GType value_type,
GClosure *closure,
guint n_params,
GtkExpression **params);
#define GTK_TYPE_CCLOSURE_EXPRESSION (gtk_cclosure_expression_get_type())
typedef struct _GtkCClosureExpression GtkCClosureExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_cclosure_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_cclosure_expression_new (GType value_type,
GClosureMarshal marshal,
@ -107,6 +141,38 @@ GtkExpression * gtk_cclosure_expression_new (GType
gpointer user_data,
GClosureNotify user_destroy);
/* GObject integration, so we can use GtkBuilder */
#define GTK_VALUE_HOLDS_EXPRESSION(value) (G_VALUE_HOLDS ((value), GTK_TYPE_EXPRESSION))
GDK_AVAILABLE_IN_ALL
void gtk_value_set_expression (GValue *value,
GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
void gtk_value_take_expression (GValue *value,
GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_value_get_expression (const GValue *value);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_value_dup_expression (const GValue *value);
#define GTK_TYPE_PARAM_SPEC_EXPRESSION (gtk_param_expression_get_type())
#define GTK_PARAM_SPEC_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PARAM_SPEC_EXPRESSION, GtkParamSpecExpression))
#define GTK_IS_PARAM_SPEC_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PARAM_SPEC_EXPRESSION))
typedef struct {
/*< private >*/
GParamSpec parent_instance;
} GtkParamSpecExpression;
GDK_AVAILABLE_IN_ALL
GType gtk_param_expression_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GParamSpec * gtk_param_spec_expression (const char *name,
const char *nick,
const char *blurb,
GParamFlags flags);
G_END_DECLS
#endif /* __GTK_EXPRESSION_H__ */

View File

@ -212,7 +212,7 @@ gtk_numeric_sorter_set_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
gtk_numeric_sorter_set_expression (self, g_value_get_boxed (value));
gtk_numeric_sorter_set_expression (self, gtk_value_get_expression (value));
break;
case PROP_SORT_ORDER:
@ -236,7 +236,7 @@ gtk_numeric_sorter_get_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
g_value_set_boxed (value, self->expression);
gtk_value_set_expression (value, self->expression);
break;
case PROP_SORT_ORDER:
@ -273,16 +273,15 @@ gtk_numeric_sorter_class_init (GtkNumericSorterClass *class)
object_class->dispose = gtk_numeric_sorter_dispose;
/**
* GtkNumericSorter:expression:
* GtkNumericSorter:expression: (type GtkExpression)
*
* The expression to evalute on items to get a number to compare with
*/
properties[PROP_EXPRESSION] =
g_param_spec_boxed ("expression",
P_("Expression"),
P_("Expression to compare with"),
GTK_TYPE_EXPRESSION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
gtk_param_spec_expression ("expression",
P_("Expression"),
P_("Expression to compare with"),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkNumericSorter:sort-order:
@ -290,12 +289,12 @@ gtk_numeric_sorter_class_init (GtkNumericSorterClass *class)
* Whether the sorter will sort smaller numbers first
*/
properties[PROP_SORT_ORDER] =
g_param_spec_enum ("sort-order",
P_("Sort order"),
P_("Whether to sort smaller numbers first"),
GTK_TYPE_SORT_TYPE,
GTK_SORT_ASCENDING,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
g_param_spec_enum ("sort-order",
P_("Sort order"),
P_("Whether to sort smaller numbers first"),
GTK_TYPE_SORT_TYPE,
GTK_SORT_ASCENDING,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
@ -338,7 +337,7 @@ gtk_numeric_sorter_new (GtkExpression *expression)
*
* Gets the expression that is evaluated to obtain numbers from items.
*
* Returns: (nullable): a #GtkExpression, or %NULL
* Returns: (transfer none) (nullable): a #GtkExpression, or %NULL
*/
GtkExpression *
gtk_numeric_sorter_get_expression (GtkNumericSorter *self)

View File

@ -164,7 +164,7 @@ gtk_string_filter_set_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
gtk_string_filter_set_expression (self, g_value_get_boxed (value));
gtk_string_filter_set_expression (self, gtk_value_get_expression (value));
break;
case PROP_IGNORE_CASE:
@ -196,7 +196,7 @@ gtk_string_filter_get_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
g_value_set_boxed (value, self->expression);
gtk_value_set_expression (value, self->expression);
break;
case PROP_IGNORE_CASE:
@ -243,16 +243,15 @@ gtk_string_filter_class_init (GtkStringFilterClass *class)
object_class->dispose = gtk_string_filter_dispose;
/**
* GtkStringFilter:expression:
* GtkStringFilter:expression: (type GtkExpression)
*
* The expression to evalute on item to get a string to compare with
*/
properties[PROP_EXPRESSION] =
g_param_spec_boxed ("expression",
P_("Expression"),
P_("Expression to compare with"),
GTK_TYPE_EXPRESSION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
gtk_param_spec_expression ("expression",
P_("Expression"),
P_("Expression to compare with"),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkStringFilter:ignore-case:
@ -382,7 +381,7 @@ gtk_string_filter_set_search (GtkStringFilter *self,
* Gets the expression that the string filter uses to
* obtain strings from items.
*
* Returns: a #GtkExpression
* Returns: (transfer none): a #GtkExpression
*/
GtkExpression *
gtk_string_filter_get_expression (GtkStringFilter *self)

View File

@ -148,7 +148,7 @@ gtk_string_sorter_set_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
gtk_string_sorter_set_expression (self, g_value_get_boxed (value));
gtk_string_sorter_set_expression (self, gtk_value_get_expression (value));
break;
case PROP_IGNORE_CASE:
@ -172,7 +172,7 @@ gtk_string_sorter_get_property (GObject *object,
switch (prop_id)
{
case PROP_EXPRESSION:
g_value_set_boxed (value, self->expression);
gtk_value_set_expression (value, self->expression);
break;
case PROP_IGNORE_CASE:
@ -209,16 +209,15 @@ gtk_string_sorter_class_init (GtkStringSorterClass *class)
object_class->dispose = gtk_string_sorter_dispose;
/**
* GtkStringSorter:expression:
* GtkStringSorter:expression: (type GtkExpression)
*
* The expression to evalute on item to get a string to compare with
*/
properties[PROP_EXPRESSION] =
g_param_spec_boxed ("expression",
P_("Expression"),
P_("Expression to compare with"),
GTK_TYPE_EXPRESSION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
gtk_param_spec_expression ("expression",
P_("Expression"),
P_("Expression to compare with"),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkStringSorter:ignore-case:
@ -274,7 +273,7 @@ gtk_string_sorter_new (GtkExpression *expression)
*
* Gets the expression that is evaluated to obtain strings from items.
*
* Returns: (nullable): a #GtkExpression, or %NULL
* Returns: (transfer none) (nullable): a #GtkExpression, or %NULL
*/
GtkExpression *
gtk_string_sorter_get_expression (GtkStringSorter *self)

View File

@ -84,6 +84,7 @@ test_parse (gconstpointer d)
GError *error = NULL;
GString *string;
g_test_message ("filename: %s", filename);
expected_file = get_expected_filename (filename);
string = g_string_sized_new (0);