diff options
Diffstat (limited to 'demos/constraint-editor/constraint-editor-window.c')
-rw-r--r-- | demos/constraint-editor/constraint-editor-window.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/demos/constraint-editor/constraint-editor-window.c b/demos/constraint-editor/constraint-editor-window.c index 2ec0f4cd67..ca18e27cf8 100644 --- a/demos/constraint-editor/constraint-editor-window.c +++ b/demos/constraint-editor/constraint-editor-window.c @@ -36,7 +36,7 @@ struct _ConstraintEditorWindow G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW); static GtkConstraintTarget * -find_target (GListModel *model, +find_target (GListModel *model, GtkConstraintTarget *orig) { const char *name; @@ -163,20 +163,30 @@ constraint_editor_window_load (ConstraintEditorWindow *self, GtkConstraint *clone; GtkConstraintTarget *target; GtkConstraintTarget *source; + GtkConstraintAttribute source_attr; item = g_list_model_get_item (list, i); constraint = GTK_CONSTRAINT (item); target = gtk_constraint_get_target (constraint); source = gtk_constraint_get_source (constraint); - clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target), + source_attr = gtk_constraint_get_source_attribute (constraint); + + if (source == NULL && source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE) + clone = gtk_constraint_new_constant (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target), gtk_constraint_get_target_attribute (constraint), gtk_constraint_get_relation (constraint), - find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source), - gtk_constraint_get_target_attribute (constraint), - gtk_constraint_get_multiplier (constraint), gtk_constraint_get_constant (constraint), gtk_constraint_get_strength (constraint)); + else + clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target), + gtk_constraint_get_target_attribute (constraint), + gtk_constraint_get_relation (constraint), + find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source), + source_attr, + gtk_constraint_get_multiplier (constraint), + gtk_constraint_get_constant (constraint), + gtk_constraint_get_strength (constraint)); constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone); |