Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2241
This commit is contained in:
Matthias Clasen 2020-07-14 02:43:25 +00:00
commit ccc34ca06c
8 changed files with 174 additions and 3 deletions

8
NEWS
View File

@ -30,6 +30,9 @@ Overview of Changes in GTK 3.99.0
- Improve scrolling behavior
- Autoscroll and autoexpand during DND
* GtkScrolledWindow:
- Make autoscrolling work again
* GtkFilterListModel:
- Add incremental filtering
@ -48,12 +51,15 @@ Overview of Changes in GTK 3.99.0
- Improve frame clock accuracy
* GSK:
- Use gL_ARB_framebuffer_object
- Use GL_ARB_framebuffer_object
* gtk-demo:
- Add incremental refill to the color grid
- Improve performance of the color grid
- Add an incrementally filtering word list
- Improve the sidebar
* Install print-editor as another demo
* Translation updates
Basque

View File

@ -215,6 +215,7 @@ do_listview_words (GtkWidget *do_widget)
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress);
sw = gtk_scrolled_window_new ();
gtk_widget_set_vexpand (sw, TRUE);
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
listview = gtk_list_view_new_with_factory (

View File

@ -7541,9 +7541,13 @@ gtk_expression_watch_unwatch
<SUBSECTION>
gtk_property_expression_new
gtk_property_expression_new_for_pspec
gtk_property_expression_get_expression
gtk_property_expression_get_pspec
gtk_constant_expression_new
gtk_constant_expression_new_for_value
gtk_constant_expression_get_value
gtk_object_expression_new
gtk_object_expression_get_object
gtk_closure_expression_new
gtk_cclosure_expression_new

View File

@ -855,6 +855,24 @@ gtk_constant_expression_new_for_value (const GValue *value)
return result;
}
/**
* gtk_constant_expression_get_value:
* @expression: a constant #GtkExpression
*
* Gets the value that a constant expression evaluates to.
*
* Returns: (transfer none): the value
*/
const GValue *
gtk_constant_expression_get_value (GtkExpression *expression)
{
GtkConstantExpression *self = (GtkConstantExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_CONSTANT_EXPRESSION), NULL);
return &self->value;
}
/* }}} */
/* {{{ GtkObjectExpression */
@ -1002,6 +1020,24 @@ gtk_object_expression_new (GObject *object)
return result;
}
/**
* gtk_object_expression_get_object:
* @expression: an object #GtkExpression
*
* Gets the object that the expression evaluates to.
*
* Returns: (transfer none): the object, or %NULL
*/
GObject *
gtk_object_expression_get_object (GtkExpression *expression)
{
GtkObjectExpression *self = (GtkObjectExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_OBJECT_EXPRESSION), NULL);
return self->object;
}
/* }}} */
/* {{{ GtkPropertyExpression */
@ -1307,6 +1343,44 @@ gtk_property_expression_new_for_pspec (GtkExpression *expression,
return result;
}
/**
* gtk_property_expression_get_expression:
* @expression: a property #GtkExpression
*
* Gets the expression specifying the object of
* a property expression.
*
* Returns: (transfer none): the object expression
*/
GtkExpression *
gtk_property_expression_get_expression (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->expr;
}
/**
* gtk_property_expression_get_pspec:
* @expression: a property #GtkExpression
*
* Gets the #GParamSpec specifying the property of
* a property expression.
*
* Returns: (transfer none): the #GParamSpec
*/
GParamSpec *
gtk_property_expression_get_pspec (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->pspec;
}
/* }}} */
/* {{{ GtkClosureExpression */

View File

@ -93,6 +93,11 @@ GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression,
GParamSpec *pspec);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_get_expression (GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
GParamSpec * gtk_property_expression_get_pspec (GtkExpression *expression);
#define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type())
typedef struct _GtkConstantExpression GtkConstantExpression;
@ -105,6 +110,9 @@ GtkExpression * gtk_constant_expression_new (GType
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_constant_expression_new_for_value (const GValue *value);
GDK_AVAILABLE_IN_ALL
const GValue * gtk_constant_expression_get_value (GtkExpression *expression);
#define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type())
typedef struct _GtkObjectExpression GtkObjectExpression;
@ -114,6 +122,9 @@ GType gtk_object_expression_get_type (void) G_GNUC_CO
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_object_expression_new (GObject *object);
GDK_AVAILABLE_IN_ALL
GObject * gtk_object_expression_get_object (GtkExpression *expression);
#define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type())
typedef struct _GtkClosureExpression GtkClosureExpression;

View File

@ -681,6 +681,8 @@ add_device (GtkInspectorGeneral *gen,
"Ignore",
"X",
"Y",
"Delta X",
"Delta Y",
"Pressure",
"X Tilt",
"Y Tilt",
@ -692,7 +694,6 @@ add_device (GtkInspectorGeneral *gen,
const char *source_name[] = {
"Mouse",
"Pen",
"Eraser",
"Cursor",
"Keyboard",
"Touchscreen",

View File

@ -1066,6 +1066,7 @@ setup_name_cb (GtkSignalListItemFactory *factory,
label = gtk_label_new (NULL);
gtk_label_set_width_chars (GTK_LABEL (label), 15);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_list_item_set_child (list_item, label);
}
@ -1092,7 +1093,8 @@ setup_label_cb (GtkSignalListItemFactory *factory,
GtkWidget *label;
label = gtk_label_new (NULL);
gtk_label_set_width_chars (GTK_LABEL (label), 15);
gtk_label_set_width_chars (GTK_LABEL (label), 25);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_list_item_set_child (list_item, label);
}

View File

@ -768,6 +768,67 @@ font_changed (GObject *object, GParamSpec *pspec, gpointer data)
pango_font_description_free (fb_font_desc);
}
static char *
describe_expression (GtkExpression *expression)
{
if (expression == NULL)
return NULL;
if (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_CONSTANT_EXPRESSION))
{
const GValue *value = gtk_constant_expression_get_value (expression);
GValue dest = G_VALUE_INIT;
g_value_init (&dest, G_TYPE_STRING);
if (g_value_transform (value, &dest))
{
char *res = g_strdup_printf (_("%s with value \"%s\""),
g_type_name (G_TYPE_FROM_INSTANCE (expression)),
g_value_get_string (&dest));
g_value_unset (&dest);
return res;
}
else
{
return g_strdup_printf (_("%s with type %s"),
g_type_name (G_TYPE_FROM_INSTANCE (expression)),
g_type_name (G_VALUE_TYPE (value)));
}
}
else if (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_OBJECT_EXPRESSION))
{
gpointer obj = gtk_object_expression_get_object (expression);
if (obj)
return g_strdup_printf (_("%s for %s %p"),
g_type_name (G_TYPE_FROM_INSTANCE (expression)),
G_OBJECT_TYPE_NAME (obj), obj);
else
return g_strdup_printf (_("%s"),
g_type_name (G_TYPE_FROM_INSTANCE (expression)));
}
else if (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION))
{
GParamSpec *pspec = gtk_property_expression_get_pspec (expression);
GtkExpression *expr = gtk_property_expression_get_expression (expression);
char *str;
char *res;
str = describe_expression (expr);
res = g_strdup_printf ("%s for property %s:%s on: %s",
g_type_name (G_TYPE_FROM_INSTANCE (expression)),
g_type_name (pspec->owner_type),
pspec->name,
str);
g_free (str);
return res;
}
else
return g_strdup_printf (_("%s with value type %s"),
g_type_name (G_TYPE_FROM_INSTANCE (expression)),
g_type_name (gtk_expression_get_value_type (expression)));
}
static GtkWidget *
property_editor (GObject *object,
GParamSpec *spec,
@ -1034,6 +1095,17 @@ property_editor (GObject *object,
gtk_widget_set_halign (prop_edit, GTK_ALIGN_START);
gtk_widget_set_valign (prop_edit, GTK_ALIGN_CENTER);
}
else if (type == GTK_TYPE_PARAM_SPEC_EXPRESSION)
{
GtkExpression *expression;
g_object_get (object, spec->name, &expression, NULL);
msg = describe_expression (expression);
prop_edit = gtk_label_new (msg);
g_free (msg);
g_clear_pointer (&expression, gtk_expression_unref);
gtk_widget_set_halign (prop_edit, GTK_ALIGN_START);
gtk_widget_set_valign (prop_edit, GTK_ALIGN_CENTER);
}
else
{
msg = g_strdup_printf (_("Uneditable property type: %s"),