Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fcb4a0344 | |||
| 170ce886c9 | |||
| 68f6fe7732 | |||
| 5e8d5dafc1 | |||
| 7afac64225 | |||
| cb11ba4ca0 |
@@ -74,22 +74,6 @@ static void
|
||||
build_constraints (SimpleGrid *self,
|
||||
GtkConstraintLayout *manager)
|
||||
{
|
||||
GtkConstraintGuide *guide;
|
||||
|
||||
guide = g_object_new (GTK_TYPE_CONSTRAINT_GUIDE,
|
||||
"min-width", 10,
|
||||
"min-height", 10,
|
||||
"nat-width", 100,
|
||||
"nat-height", 10,
|
||||
NULL);
|
||||
gtk_constraint_layout_add_guide (manager, guide);
|
||||
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new_constant (GTK_CONSTRAINT_TARGET (self->button1),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_WIDTH,
|
||||
GTK_CONSTRAINT_RELATION_LE,
|
||||
200.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
@@ -110,21 +94,12 @@ build_constraints (SimpleGrid *self,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (self->button1,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
guide,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (guide,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
self->button2,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
0.0,
|
||||
-12.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (self->button2,
|
||||
|
||||
+92
-147
@@ -1,186 +1,128 @@
|
||||
/* Constraints/Interactive
|
||||
/* Constraints/Grid
|
||||
*
|
||||
* Demonstrate how constraints can be updates during
|
||||
* user interaction.
|
||||
* GtkConstraintLayout lets you define complex layouts
|
||||
* like grids.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE (InteractiveGrid, interactive_grid, INTERACTIVE, GRID, GtkWidget)
|
||||
G_DECLARE_FINAL_TYPE (ComplexGrid, complex_grid, COMPLEX, GRID, GtkWidget)
|
||||
|
||||
struct _InteractiveGrid
|
||||
struct _ComplexGrid
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *button1, *button2;
|
||||
GtkWidget *button3;
|
||||
GtkConstraintGuide *guide;
|
||||
GtkConstraint *constraint;
|
||||
GtkWidget *button1, *button2, *button3;
|
||||
GtkWidget *button4, *button5;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (InteractiveGrid, interactive_grid, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (ComplexGrid, complex_grid, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
interactive_grid_destroy (GtkWidget *widget)
|
||||
complex_grid_destroy (GtkWidget *widget)
|
||||
{
|
||||
InteractiveGrid *self = INTERACTIVE_GRID (widget);
|
||||
ComplexGrid *self = COMPLEX_GRID (widget);
|
||||
|
||||
g_clear_pointer (&self->button1, gtk_widget_destroy);
|
||||
g_clear_pointer (&self->button2, gtk_widget_destroy);
|
||||
g_clear_pointer (&self->button3, gtk_widget_destroy);
|
||||
g_clear_pointer (&self->button4, gtk_widget_destroy);
|
||||
g_clear_pointer (&self->button5, gtk_widget_destroy);
|
||||
|
||||
GTK_WIDGET_CLASS (interactive_grid_parent_class)->destroy (widget);
|
||||
GTK_WIDGET_CLASS (complex_grid_parent_class)->destroy (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
interactive_grid_class_init (InteractiveGridClass *klass)
|
||||
complex_grid_class_init (ComplexGridClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->destroy = interactive_grid_destroy;
|
||||
widget_class->destroy = complex_grid_destroy;
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_CONSTRAINT_LAYOUT);
|
||||
}
|
||||
|
||||
/* Layout:
|
||||
*
|
||||
* +--------------------------------------+
|
||||
* | +-----------+ |
|
||||
* | | Child 4 | |
|
||||
* | +-----------+-----------+----------+ |
|
||||
* | | Child 1 | Child 2 | Child 3 | |
|
||||
* | +-----------+-----------+----------+ |
|
||||
* | | Child 5 | |
|
||||
* | +-----------+ |
|
||||
* +--------------------------------------+
|
||||
*
|
||||
*/
|
||||
static void
|
||||
build_constraints (InteractiveGrid *self,
|
||||
build_constraints (ComplexGrid *self,
|
||||
GtkConstraintLayout *manager)
|
||||
{
|
||||
self->guide = g_object_new (GTK_TYPE_CONSTRAINT_GUIDE, NULL);
|
||||
gtk_constraint_layout_add_guide (manager, self->guide);
|
||||
GtkGridConstraint *constraint;
|
||||
GtkConstraint *s;
|
||||
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new_constant (GTK_CONSTRAINT_TARGET (self->guide),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_WIDTH,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
s = gtk_constraint_new (NULL, GTK_CONSTRAINT_ATTRIBUTE_LEFT,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
self->button1, GTK_CONSTRAINT_ATTRIBUTE_LEFT,
|
||||
1.0, 0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (manager, s);
|
||||
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->button1),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
-8.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button1),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->guide),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button2),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->guide),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button2),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
1.0,
|
||||
-8.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->button3),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
-8.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
s = gtk_constraint_new (self->button3, GTK_CONSTRAINT_ATTRIBUTE_RIGHT,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
NULL, GTK_CONSTRAINT_ATTRIBUTE_RIGHT,
|
||||
1.0, 0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (manager, s);
|
||||
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button3),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_END,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->guide),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_START,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
s = gtk_constraint_new (NULL, GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
self->button4, GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
1.0, 0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (manager, s);
|
||||
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->button1),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
1.0,
|
||||
-8.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button2),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->button1),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button3),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
GTK_CONSTRAINT_TARGET (self->button2),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
gtk_constraint_layout_add_constraint (manager,
|
||||
gtk_constraint_new (GTK_CONSTRAINT_TARGET (self->button3),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
1.0,
|
||||
-8.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
||||
s = gtk_constraint_new (NULL, GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
self->button5, GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
1.0, 0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (manager, s);
|
||||
|
||||
constraint = gtk_grid_constraint_new ();
|
||||
g_object_set (constraint, "column-homogeneous", TRUE, NULL);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button1,
|
||||
0, 1, 0, 1);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button2,
|
||||
1, 2, 0, 1);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button3,
|
||||
2, 3, 0, 1);
|
||||
gtk_constraint_layout_add_grid_constraint (manager, constraint);
|
||||
|
||||
constraint = gtk_grid_constraint_new ();
|
||||
g_object_set (constraint, "row-homogeneous", TRUE, NULL);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button4,
|
||||
0, 1, 0, 1);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button2,
|
||||
0, 1, 1, 2);
|
||||
gtk_grid_constraint_add (constraint,
|
||||
self->button5,
|
||||
0, 1, 2, 3);
|
||||
gtk_constraint_layout_add_grid_constraint (manager, constraint);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_cb (GtkGestureDrag *drag,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
InteractiveGrid *self)
|
||||
{
|
||||
GtkConstraintLayout *layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (self)));
|
||||
double x, y;
|
||||
|
||||
if (self->constraint)
|
||||
{
|
||||
gtk_constraint_layout_remove_constraint (layout, self->constraint);
|
||||
g_clear_object (&self->constraint);
|
||||
}
|
||||
|
||||
gtk_gesture_drag_get_start_point (drag, &x, &y);
|
||||
self->constraint = gtk_constraint_new_constant (GTK_CONSTRAINT_TARGET (self->guide),
|
||||
GTK_CONSTRAINT_ATTRIBUTE_LEFT,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
x + offset_x,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (layout, g_object_ref (self->constraint));
|
||||
gtk_widget_queue_allocate (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
interactive_grid_init (InteractiveGrid *self)
|
||||
complex_grid_init (ComplexGrid *self)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (self);
|
||||
GtkGesture *drag;
|
||||
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
||||
|
||||
self->button1 = gtk_button_new_with_label ("Child 1");
|
||||
gtk_widget_set_parent (self->button1, widget);
|
||||
@@ -194,12 +136,15 @@ interactive_grid_init (InteractiveGrid *self)
|
||||
gtk_widget_set_parent (self->button3, widget);
|
||||
gtk_widget_set_name (self->button3, "button3");
|
||||
|
||||
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
||||
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
|
||||
self->button4 = gtk_button_new_with_label ("Child 4");
|
||||
gtk_widget_set_parent (self->button4, widget);
|
||||
gtk_widget_set_name (self->button4, "button4");
|
||||
|
||||
drag = gtk_gesture_drag_new ();
|
||||
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_cb), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag));
|
||||
self->button5 = gtk_button_new_with_label ("Child 5");
|
||||
gtk_widget_set_parent (self->button5, widget);
|
||||
gtk_widget_set_name (self->button5, "button5");
|
||||
|
||||
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@@ -224,7 +169,7 @@ do_constraints2 (GtkWidget *do_widget)
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
grid = g_object_new (interactive_grid_get_type (), NULL);
|
||||
grid = g_object_new (complex_grid_get_type (), NULL);
|
||||
gtk_widget_set_hexpand (grid, TRUE);
|
||||
gtk_widget_set_vexpand (grid, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (box), grid);
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
/* Constraints/Words
|
||||
*
|
||||
* GtkConstraintLayout lets you define big grids.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define WORDS_TYPE_BASE (words_base_get_type ())
|
||||
#define WORDS_TYPE_GRID (words_grid_get_type ())
|
||||
#define WORDS_TYPE_CONSTRAINT (words_constraint_get_type ())
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
} WordsBase;
|
||||
|
||||
typedef WordsBase WordsGrid;
|
||||
typedef WordsBase WordsConstraint;
|
||||
|
||||
typedef GtkWidgetClass WordsBaseClass;
|
||||
typedef GtkWidgetClass WordsGridClass;
|
||||
typedef GtkWidgetClass WordsConstraintClass;
|
||||
|
||||
G_DEFINE_TYPE (WordsBase, words_base, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (WordsGrid, words_grid, WORDS_TYPE_BASE)
|
||||
G_DEFINE_TYPE (WordsConstraint, words_constraint, WORDS_TYPE_BASE)
|
||||
|
||||
static void
|
||||
words_grid_init (WordsGrid *words)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
words_grid_class_init (WordsGridClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_GRID_LAYOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
words_constraint_init (WordsGrid *words)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
words_constraint_class_init (WordsConstraintClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_CONSTRAINT_LAYOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
word_base_dispose (GObject *object)
|
||||
{
|
||||
GtkWidget *self = GTK_WIDGET (object);
|
||||
GtkWidget *child;
|
||||
|
||||
while ((child = gtk_widget_get_first_child (self)) != NULL)
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (words_base_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
words_base_class_init (WordsBaseClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = word_base_dispose;
|
||||
}
|
||||
|
||||
static int num_words = 100;
|
||||
static gboolean use_constraints = FALSE;
|
||||
|
||||
static void
|
||||
read_words (WordsBase *self)
|
||||
{
|
||||
GBytes *data;
|
||||
const char *words;
|
||||
int left, top;
|
||||
GtkWidget *child = NULL;
|
||||
GtkLayoutManager *layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
||||
GtkGridConstraint *grid;
|
||||
GtkConstraint *constraint;
|
||||
int count;
|
||||
int rightmost;
|
||||
GtkWidget *right_child = NULL;
|
||||
gboolean use_constraint = GTK_IS_CONSTRAINT_LAYOUT (layout);
|
||||
|
||||
if (use_constraint)
|
||||
{
|
||||
grid = gtk_grid_constraint_new ();
|
||||
g_object_set (grid,
|
||||
"row-homogeneous", TRUE,
|
||||
"column-homogeneous", FALSE,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_grid_layout_set_row_homogeneous (GTK_GRID_LAYOUT (layout), TRUE);
|
||||
gtk_grid_layout_set_column_homogeneous (GTK_GRID_LAYOUT (layout), FALSE);
|
||||
}
|
||||
|
||||
data = g_resources_lookup_data ("/constraints3/words", 0, NULL);
|
||||
words = g_bytes_get_data (data, NULL);
|
||||
count = 0;
|
||||
|
||||
rightmost = 0;
|
||||
left = 0;
|
||||
top = 0;
|
||||
while (words && words[0])
|
||||
{
|
||||
char *p = strchr (words, '\n');
|
||||
char *word;
|
||||
int len;
|
||||
|
||||
if (p)
|
||||
{
|
||||
word = strndup (words, p - words);
|
||||
words = p + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
word = strdup (words);
|
||||
words = NULL;
|
||||
}
|
||||
|
||||
len = strlen (word);
|
||||
child = gtk_button_new_with_label (word);
|
||||
|
||||
if (left + len > 50)
|
||||
{
|
||||
top++;
|
||||
left = 0;
|
||||
}
|
||||
|
||||
gtk_widget_set_parent (child, GTK_WIDGET (self));
|
||||
|
||||
if (left + len > rightmost)
|
||||
{
|
||||
rightmost = left + len;
|
||||
right_child = child;
|
||||
}
|
||||
|
||||
if (use_constraint)
|
||||
{
|
||||
gtk_grid_constraint_add (grid, child,
|
||||
left, left + len,
|
||||
top, top + 1);
|
||||
if (left == 0 && top == 0)
|
||||
{
|
||||
constraint = gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
child,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_TOP,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (layout),
|
||||
constraint);
|
||||
constraint = gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_LEFT,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
child,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_LEFT,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (layout),
|
||||
constraint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkGridLayoutChild *grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (layout, child));
|
||||
|
||||
g_object_set (grid_child,
|
||||
"left-attach", left,
|
||||
"top-attach", top,
|
||||
"column-span", len,
|
||||
"row-span", 1,
|
||||
NULL);
|
||||
}
|
||||
|
||||
left = left + len;
|
||||
count++;
|
||||
|
||||
if (count >= num_words)
|
||||
break;
|
||||
}
|
||||
|
||||
if (use_constraint)
|
||||
{
|
||||
constraint = gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_RIGHT,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
right_child,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_RIGHT,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (layout),
|
||||
constraint);
|
||||
constraint = gtk_constraint_new (NULL,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
child,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_BOTTOM,
|
||||
1.0,
|
||||
0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (layout),
|
||||
constraint);
|
||||
|
||||
gtk_constraint_layout_add_grid_constraint (GTK_CONSTRAINT_LAYOUT (layout),
|
||||
grid);
|
||||
}
|
||||
|
||||
g_bytes_unref (data);
|
||||
}
|
||||
|
||||
static void
|
||||
words_base_init (WordsBase *self)
|
||||
{
|
||||
read_words (self);
|
||||
}
|
||||
|
||||
static void
|
||||
show_words (GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *header, *box, *grid, *button;
|
||||
GtkWidget *swin;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window),
|
||||
GTK_WINDOW (gtk_widget_get_root (parent)));
|
||||
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), use_constraints ? "Constraints" : "Grid");
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
swin = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (swin), TRUE);
|
||||
gtk_scrolled_window_set_propagate_natural_height (GTK_SCROLLED_WINDOW (swin), TRUE);
|
||||
gtk_widget_set_hexpand (swin, TRUE);
|
||||
gtk_widget_set_vexpand (swin, TRUE);
|
||||
gtk_widget_set_halign (swin, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (swin, GTK_ALIGN_FILL);
|
||||
gtk_container_add (GTK_CONTAINER (box), swin);
|
||||
|
||||
if (use_constraints)
|
||||
grid = g_object_new (WORDS_TYPE_CONSTRAINT, NULL);
|
||||
else
|
||||
grid = g_object_new (WORDS_TYPE_GRID, NULL);
|
||||
|
||||
gtk_widget_set_halign (swin, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (swin, GTK_ALIGN_START);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (swin), grid);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK (gtk_widget_destroy), window);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
use_constraints_cb (GtkButton *button)
|
||||
{
|
||||
use_constraints = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
||||
}
|
||||
|
||||
static void
|
||||
word_count_cb (GtkSpinButton *button)
|
||||
{
|
||||
num_words = gtk_spin_button_get_value_as_int (button);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_constraints3 (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *header, *grid, *button, *label;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Words");
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
g_object_set (grid,
|
||||
"margin", 12,
|
||||
"row-spacing", 12,
|
||||
"column-spacing", 6,
|
||||
"halign", GTK_ALIGN_FILL,
|
||||
"valign", GTK_ALIGN_FILL,
|
||||
"hexpand", TRUE,
|
||||
"vexpand", TRUE,
|
||||
NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), grid);
|
||||
|
||||
label = gtk_label_new ("Constraints:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
|
||||
button = gtk_check_button_new ();
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (use_constraints_cb), NULL);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
|
||||
label = gtk_label_new ("Words:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
|
||||
button = gtk_spin_button_new_with_range (0, 1300, 1);
|
||||
g_signal_connect (button, "value-changed", G_CALLBACK (word_count_cb), NULL);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), 10);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, 1, 1, 1, 1);
|
||||
|
||||
button = gtk_button_new_with_label ("Show");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_END);
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK (show_words), window);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 2, 1);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -12,6 +12,9 @@
|
||||
<gresource prefix="/builder">
|
||||
<file>demo.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/constraints3">
|
||||
<file>words</file>
|
||||
</gresource>
|
||||
<gresource prefix="/css_accordion">
|
||||
<file>css_accordion.css</file>
|
||||
<file>reset.css</file>
|
||||
@@ -152,6 +155,7 @@
|
||||
<file>combobox.c</file>
|
||||
<file>constraints.c</file>
|
||||
<file>constraints2.c</file>
|
||||
<file>constraints3.c</file>
|
||||
<file>css_accordion.c</file>
|
||||
<file>css_basics.c</file>
|
||||
<file>css_blendmodes.c</file>
|
||||
|
||||
@@ -10,6 +10,7 @@ demos = files([
|
||||
'combobox.c',
|
||||
'constraints.c',
|
||||
'constraints2.c',
|
||||
'constraints3.c',
|
||||
'css_accordion.c',
|
||||
'css_basics.c',
|
||||
'css_blendmodes.c',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -132,6 +132,7 @@
|
||||
#include <gtk/gtkgesturezoom.h>
|
||||
#include <gtk/gtkglarea.h>
|
||||
#include <gtk/gtkgrid.h>
|
||||
#include <gtk/gtkgridconstraint.h>
|
||||
#include <gtk/gtkgridlayout.h>
|
||||
#include <gtk/gtkheaderbar.h>
|
||||
#include <gtk/gtkicontheme.h>
|
||||
|
||||
+51
-85
@@ -46,10 +46,10 @@
|
||||
#include "gtkwidget.h"
|
||||
|
||||
enum {
|
||||
PROP_TARGET = 1,
|
||||
PROP_TARGET_WIDGET = 1,
|
||||
PROP_TARGET_ATTRIBUTE,
|
||||
PROP_RELATION,
|
||||
PROP_SOURCE,
|
||||
PROP_SOURCE_WIDGET,
|
||||
PROP_SOURCE_ATTRIBUTE,
|
||||
PROP_MULTIPLIER,
|
||||
PROP_CONSTANT,
|
||||
@@ -72,8 +72,8 @@ gtk_constraint_set_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TARGET:
|
||||
self->target = g_value_get_object (value);
|
||||
case PROP_TARGET_WIDGET:
|
||||
self->target_widget = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_TARGET_ATTRIBUTE:
|
||||
@@ -84,8 +84,8 @@ gtk_constraint_set_property (GObject *gobject,
|
||||
self->relation = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_SOURCE:
|
||||
self->source = g_value_get_object (value);
|
||||
case PROP_SOURCE_WIDGET:
|
||||
self->source_widget = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SOURCE_ATTRIBUTE:
|
||||
@@ -120,8 +120,8 @@ gtk_constraint_get_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TARGET:
|
||||
g_value_set_object (value, self->target);
|
||||
case PROP_TARGET_WIDGET:
|
||||
g_value_set_object (value, self->target_widget);
|
||||
break;
|
||||
|
||||
case PROP_TARGET_ATTRIBUTE:
|
||||
@@ -132,8 +132,8 @@ gtk_constraint_get_property (GObject *gobject,
|
||||
g_value_set_enum (value, self->relation);
|
||||
break;
|
||||
|
||||
case PROP_SOURCE:
|
||||
g_value_set_object (value, self->source);
|
||||
case PROP_SOURCE_WIDGET:
|
||||
g_value_set_object (value, self->source_widget);
|
||||
break;
|
||||
|
||||
case PROP_SOURCE_ATTRIBUTE:
|
||||
@@ -178,31 +178,31 @@ gtk_constraint_class_init (GtkConstraintClass *klass)
|
||||
gobject_class->finalize = gtk_constraint_finalize;
|
||||
|
||||
/**
|
||||
* GtkConstraint:target:
|
||||
* GtkConstraint:target-widget:
|
||||
*
|
||||
* The target of the constraint.
|
||||
* The target widget of the constraint.
|
||||
*
|
||||
* The constraint will set the #GtkConstraint:target-attribute of the
|
||||
* target using the #GtkConstraint:source-attribute of the source
|
||||
* target widget using the #GtkConstraint:source-attribute of the source
|
||||
* widget.
|
||||
*/
|
||||
obj_props[PROP_TARGET] =
|
||||
g_param_spec_object ("target",
|
||||
P_("Target"),
|
||||
P_("The target of the constraint"),
|
||||
GTK_TYPE_CONSTRAINT_TARGET,
|
||||
obj_props[PROP_TARGET_WIDGET] =
|
||||
g_param_spec_object ("target-widget",
|
||||
P_("Target Widget"),
|
||||
P_("The target widget of the constraint"),
|
||||
GTK_TYPE_WIDGET,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
/**
|
||||
* GtkConstraint:target-attribute:
|
||||
*
|
||||
* The attribute of the #GtkConstraint:target set by the constraint.
|
||||
* The attribute of the #GtkConstraint:target-widget set by the constraint.
|
||||
*/
|
||||
obj_props[PROP_TARGET_ATTRIBUTE] =
|
||||
g_param_spec_enum ("target-attribute",
|
||||
P_("Target Attribute"),
|
||||
P_("The attribute of the target set by the constraint"),
|
||||
P_("The attribute of the target widget set by the constraint"),
|
||||
GTK_TYPE_CONSTRAINT_ATTRIBUTE,
|
||||
GTK_CONSTRAINT_ATTRIBUTE_NONE,
|
||||
G_PARAM_READWRITE |
|
||||
@@ -223,25 +223,26 @@ gtk_constraint_class_init (GtkConstraintClass *klass)
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
/**
|
||||
* GtkConstraint:source:
|
||||
* GtkConstraint:source-widget:
|
||||
*
|
||||
* The source of the constraint.
|
||||
* The source widget of the constraint.
|
||||
*
|
||||
* The constraint will set the #GtkConstraint:target-attribute of the
|
||||
* target using the #GtkConstraint:source-attribute of the source.
|
||||
* target widget using the #GtkConstraint:source-attribute of the source
|
||||
* widget.
|
||||
*/
|
||||
obj_props[PROP_SOURCE] =
|
||||
g_param_spec_object ("source",
|
||||
P_("Source"),
|
||||
P_("The source of the constraint"),
|
||||
GTK_TYPE_CONSTRAINT_TARGET,
|
||||
obj_props[PROP_SOURCE_WIDGET] =
|
||||
g_param_spec_object ("source-widget",
|
||||
P_("Source Widget"),
|
||||
P_("The source widget of the constraint"),
|
||||
GTK_TYPE_WIDGET,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
/**
|
||||
* GtkConstraint:source-attribute:
|
||||
*
|
||||
* The attribute of the #GtkConstraint:source read by the constraint.
|
||||
* The attribute of the #GtkConstraint:source-widget read by the constraint.
|
||||
*/
|
||||
obj_props[PROP_SOURCE_ATTRIBUTE] =
|
||||
g_param_spec_enum ("source-attribute",
|
||||
@@ -315,38 +316,39 @@ gtk_constraint_init (GtkConstraint *self)
|
||||
|
||||
/**
|
||||
* gtk_constraint_new:
|
||||
* @target: (nullable) (type GtkConstraintTarget): a #GtkConstraintTarget
|
||||
* @target_attribute: the attribute of @target to be set
|
||||
* @target_widget: (nullable): a #GtkWidget
|
||||
* @target_attribute: the attribute of @target_widget to be set
|
||||
* @relation: the relation equivalence between @target_attribute and @source_attribute
|
||||
* @source: (nullable) (type GtkConstraintTarget): a #GtkConstraintTarget
|
||||
* @source_attribute: the attribute of @source to be read
|
||||
* @source_widget: (nullable): a #GtkWidget
|
||||
* @source_attribute: the attribute of @source_widget to be read
|
||||
* @multiplier: a multiplication factor to be applied to @source_attribute
|
||||
* @constant: a constant factor to be added to @source_attribute
|
||||
* @strength: the strength of the constraint
|
||||
*
|
||||
* Creates a new #GtkConstraint representing a relation between a layout
|
||||
* attribute on a source and a layout attribute on a target.
|
||||
* attribute on a source #GtkWidget and a layout attribute on a target
|
||||
* #GtkWidget.
|
||||
*
|
||||
* Returns: the newly created #GtkConstraint
|
||||
*/
|
||||
GtkConstraint *
|
||||
gtk_constraint_new (gpointer target,
|
||||
gtk_constraint_new (GtkWidget *target_widget,
|
||||
GtkConstraintAttribute target_attribute,
|
||||
GtkConstraintRelation relation,
|
||||
gpointer source,
|
||||
GtkWidget *source_widget,
|
||||
GtkConstraintAttribute source_attribute,
|
||||
double multiplier,
|
||||
double constant,
|
||||
int strength)
|
||||
{
|
||||
g_return_val_if_fail (target == NULL || GTK_IS_CONSTRAINT_TARGET (target), NULL);
|
||||
g_return_val_if_fail (source == NULL || GTK_IS_CONSTRAINT_TARGET (source), NULL);
|
||||
g_return_val_if_fail (target_widget == NULL || GTK_IS_WIDGET (target_widget), NULL);
|
||||
g_return_val_if_fail (source_widget == NULL || GTK_IS_WIDGET (source_widget), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_CONSTRAINT,
|
||||
"target", target,
|
||||
"target-widget", target_widget,
|
||||
"target-attribute", target_attribute,
|
||||
"relation", relation,
|
||||
"source", source,
|
||||
"source-widget", source_widget,
|
||||
"source-attribute", source_attribute,
|
||||
"multiplier", multiplier,
|
||||
"constant", constant,
|
||||
@@ -356,28 +358,28 @@ gtk_constraint_new (gpointer target,
|
||||
|
||||
/**
|
||||
* gtk_constraint_new_constant:
|
||||
* @target: (nullable) (type GtkConstraintTarget): a #GtkConstraintTarget
|
||||
* @target_attribute: the attribute of @target to be set
|
||||
* @target_widget: (nullable): a #GtkWidget
|
||||
* @target_attribute: the attribute of @target_widget to be set
|
||||
* @relation: the relation equivalence between @target_attribute and @constant
|
||||
* @constant: a constant factor to be set on @target_attribute
|
||||
* @strength: the strength of the constraint
|
||||
*
|
||||
* Creates a new #GtkConstraint representing a relation between a layout
|
||||
* attribute on a target and a constant value.
|
||||
* attribute on a target #GtkWidget and a constant value.
|
||||
*
|
||||
* Returns: the newly created #GtkConstraint
|
||||
*/
|
||||
GtkConstraint *
|
||||
gtk_constraint_new_constant (gpointer target,
|
||||
gtk_constraint_new_constant (GtkWidget *target_widget,
|
||||
GtkConstraintAttribute target_attribute,
|
||||
GtkConstraintRelation relation,
|
||||
double constant,
|
||||
int strength)
|
||||
{
|
||||
g_return_val_if_fail (target == NULL || GTK_IS_CONSTRAINT_TARGET (target), NULL);
|
||||
g_return_val_if_fail (target_widget == NULL || GTK_IS_WIDGET (target_widget), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_CONSTRAINT,
|
||||
"target", target,
|
||||
"target-widget", target_widget,
|
||||
"target-attribute", target_attribute,
|
||||
"relation", relation,
|
||||
"source-attribute", GTK_CONSTRAINT_ATTRIBUTE_NONE,
|
||||
@@ -399,18 +401,7 @@ gtk_constraint_get_target_widget (GtkConstraint *constraint)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CONSTRAINT (constraint), NULL);
|
||||
|
||||
if (GTK_IS_WIDGET (constraint->target))
|
||||
return GTK_WIDGET (constraint->target);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkConstraintTarget *
|
||||
gtk_constraint_get_target (GtkConstraint *constraint)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CONSTRAINT (constraint), NULL);
|
||||
|
||||
return constraint->target;
|
||||
return constraint->target_widget;
|
||||
}
|
||||
|
||||
GtkConstraintAttribute
|
||||
@@ -434,18 +425,7 @@ gtk_constraint_get_source_widget (GtkConstraint *constraint)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CONSTRAINT (constraint), NULL);
|
||||
|
||||
if (GTK_IS_WIDGET (constraint->source))
|
||||
return GTK_WIDGET (constraint->source);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkConstraintTarget *
|
||||
gtk_constraint_get_source (GtkConstraint *constraint)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CONSTRAINT (constraint), NULL);
|
||||
|
||||
return constraint->source;
|
||||
return constraint->source_widget;
|
||||
}
|
||||
|
||||
GtkConstraintAttribute
|
||||
@@ -572,7 +552,7 @@ gtk_constraint_is_constant (GtkConstraint *constraint)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CONSTRAINT (constraint), FALSE);
|
||||
|
||||
return constraint->source == NULL &&
|
||||
return constraint->source_widget == NULL &&
|
||||
constraint->source_attribute == GTK_CONSTRAINT_ATTRIBUTE_NONE;
|
||||
}
|
||||
|
||||
@@ -601,17 +581,3 @@ gtk_constraint_detach (GtkConstraint *constraint)
|
||||
constraint->constraint_ref = NULL;
|
||||
constraint->solver = NULL;
|
||||
}
|
||||
|
||||
typedef struct _GtkConstraintTargetInterface GtkConstraintTargetInterface;
|
||||
|
||||
struct _GtkConstraintTargetInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
};
|
||||
|
||||
G_DEFINE_INTERFACE (GtkConstraintTarget, gtk_constraint_target, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_constraint_target_default_init (GtkConstraintTargetInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
+3
-22
@@ -24,21 +24,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkConstraintTarget GtkConstraintTarget;
|
||||
|
||||
#define GTK_TYPE_CONSTRAINT_TARGET (gtk_constraint_target_get_type ())
|
||||
|
||||
/**
|
||||
* GtkConstraintTarget:
|
||||
*
|
||||
* The GtkConstraintTarget interface is implemented by objects that
|
||||
* can be used as source or target in #GtkConstraints. Besides
|
||||
* #GtkWidget, it is also implemented by #GtkConstraintGuide.
|
||||
*/
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (GtkConstraintTarget, gtk_constraint_target, GTK, CONSTRAINT_TARGET, GObject)
|
||||
|
||||
#define GTK_TYPE_CONSTRAINT (gtk_constraint_get_type ())
|
||||
|
||||
/**
|
||||
@@ -58,16 +43,16 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkConstraint, gtk_constraint, GTK, CONSTRAINT, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraint * gtk_constraint_new (gpointer target,
|
||||
GtkConstraint * gtk_constraint_new (GtkWidget *target_widget,
|
||||
GtkConstraintAttribute target_attribute,
|
||||
GtkConstraintRelation relation,
|
||||
gpointer source,
|
||||
GtkWidget *source_widget,
|
||||
GtkConstraintAttribute source_attribute,
|
||||
double multiplier,
|
||||
double constant,
|
||||
int strength);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraint * gtk_constraint_new_constant (gpointer target,
|
||||
GtkConstraint * gtk_constraint_new_constant (GtkWidget *target_widget,
|
||||
GtkConstraintAttribute target_attribute,
|
||||
GtkConstraintRelation relation,
|
||||
double constant,
|
||||
@@ -76,14 +61,10 @@ GtkConstraint * gtk_constraint_new_constant (gpointer
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_constraint_get_target_widget (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintTarget * gtk_constraint_get_target (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintAttribute gtk_constraint_get_target_attribute (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_constraint_get_source_widget (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintTarget * gtk_constraint_get_source (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintAttribute gtk_constraint_get_source_attribute (GtkConstraint *constraint);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintRelation gtk_constraint_get_relation (GtkConstraint *constraint);
|
||||
|
||||
+311
-544
File diff suppressed because it is too large
Load Diff
+10
-28
@@ -20,35 +20,12 @@
|
||||
|
||||
#include <gtk/gtklayoutmanager.h>
|
||||
#include <gtk/gtkconstraint.h>
|
||||
#include <gtk/gtkgridconstraint.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CONSTRAINT_LAYOUT (gtk_constraint_layout_get_type ())
|
||||
#define GTK_TYPE_CONSTRAINT_LAYOUT_CHILD (gtk_constraint_layout_child_get_type ())
|
||||
#define GTK_TYPE_CONSTRAINT_GUIDE (gtk_constraint_guide_get_type ())
|
||||
|
||||
/**
|
||||
* GtkConstraintLayoutChild:
|
||||
*
|
||||
* A #GtkLayoutChild in a #GtkConstraintLayout.
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkConstraintLayoutChild, gtk_constraint_layout_child, GTK, CONSTRAINT_LAYOUT_CHILD, GtkLayoutChild)
|
||||
|
||||
/**
|
||||
* GtkConstraintGuide:
|
||||
*
|
||||
* An object that can be added to a #GtkConstraintLayout and be
|
||||
* used in constraints like a widget, without being drawn. Guides
|
||||
* have a minimal and natural size. Depending on the constraints
|
||||
* that are applied, they can act like a guideline that widgets
|
||||
* can be aligned to, or like 'flexible space'.
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkConstraintGuide, gtk_constraint_guide, GTK, CONSTRAINT_GUIDE, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkConstraintGuide * gtk_constraint_guide_new (void);
|
||||
|
||||
/**
|
||||
* GtkConstraintLayout:
|
||||
@@ -70,10 +47,15 @@ void gtk_constraint_layout_remove_constraint (GtkConstraintLa
|
||||
GtkConstraint *constraint);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_constraint_layout_add_guide (GtkConstraintLayout *manager,
|
||||
GtkConstraintGuide *guide);
|
||||
void gtk_constraint_layout_add_grid_constraint (GtkConstraintLayout *manager,
|
||||
GtkGridConstraint *constraint);
|
||||
|
||||
/**
|
||||
* GtkConstraintLayoutChild:
|
||||
*
|
||||
* A #GtkLayoutChild in a #GtkConstraintLayout.
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_constraint_layout_remove_guide (GtkConstraintLayout *manager,
|
||||
GtkConstraintGuide *guide);
|
||||
G_DECLARE_FINAL_TYPE (GtkConstraintLayoutChild, gtk_constraint_layout_child, GTK, CONSTRAINT_LAYOUT_CHILD, GtkLayoutChild)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -31,8 +31,8 @@ struct _GtkConstraint
|
||||
GtkConstraintAttribute target_attribute;
|
||||
GtkConstraintAttribute source_attribute;
|
||||
|
||||
GtkConstraintTarget *target;
|
||||
GtkConstraintTarget *source;
|
||||
GtkWidget *target_widget;
|
||||
GtkWidget *source_widget;
|
||||
|
||||
GtkConstraintRelation relation;
|
||||
|
||||
|
||||
@@ -1972,7 +1972,6 @@ gtk_constraint_solver_suggest_value (GtkConstraintSolver *self,
|
||||
double value)
|
||||
{
|
||||
EditInfo *ei = g_hash_table_lookup (self->edit_var_map, variable);
|
||||
double delta;
|
||||
if (ei == NULL)
|
||||
{
|
||||
g_critical ("Suggesting value '%g' but variable %p is not editable",
|
||||
@@ -1988,10 +1987,9 @@ gtk_constraint_solver_suggest_value (GtkConstraintSolver *self,
|
||||
return;
|
||||
}
|
||||
|
||||
delta = value - ei->prev_constant;
|
||||
ei->prev_constant = value;
|
||||
ei->prev_constant = value - ei->prev_constant;
|
||||
|
||||
gtk_constraint_solver_delta_edit_constant (self, delta, ei->eplus, ei->eminus);
|
||||
gtk_constraint_solver_delta_edit_constant (self, ei->prev_constant, ei->eplus, ei->eminus);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
/* gtkgridconstraint.c: Make a grid with constraints
|
||||
* Copyright 2019 Red Hat, inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Matthias Clasen
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkgridconstraint.h"
|
||||
#include "gtkgridconstraintprivate.h"
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
enum {
|
||||
PROP_ROW_HOMOGENEOUS = 1,
|
||||
PROP_COLUMN_HOMOGENEOUS,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[N_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkGridConstraint, gtk_grid_constraint, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_constraint_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkGridConstraint *self = GTK_GRID_CONSTRAINT (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ROW_HOMOGENEOUS:
|
||||
self->row_homogeneous = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_COLUMN_HOMOGENEOUS:
|
||||
self->column_homogeneous = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_constraint_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkGridConstraint *self = GTK_GRID_CONSTRAINT (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ROW_HOMOGENEOUS:
|
||||
g_value_set_boolean (value, self->row_homogeneous);
|
||||
break;
|
||||
|
||||
case PROP_COLUMN_HOMOGENEOUS:
|
||||
g_value_set_boolean (value, self->column_homogeneous);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_constraint_finalize (GObject *gobject)
|
||||
{
|
||||
GtkGridConstraint *self = GTK_GRID_CONSTRAINT (gobject);
|
||||
|
||||
gtk_grid_constraint_detach (self);
|
||||
|
||||
g_ptr_array_free (self->children, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (gtk_grid_constraint_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_grid_constraint_class_init (GtkGridConstraintClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = gtk_constraint_set_property;
|
||||
gobject_class->get_property = gtk_constraint_get_property;
|
||||
gobject_class->finalize = gtk_constraint_finalize;
|
||||
|
||||
/**
|
||||
* GtkGridConstraint:row-homogeneous:
|
||||
*
|
||||
* Whether to make all rows the same height.
|
||||
*/
|
||||
obj_props[PROP_ROW_HOMOGENEOUS] =
|
||||
g_param_spec_boolean ("row-homogeneous",
|
||||
P_("Row homogeneous"),
|
||||
P_("Row homogeneous"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkGridConstraint:column-homogeneous:
|
||||
*
|
||||
* Whether to make all columns the same width.
|
||||
*/
|
||||
obj_props[PROP_COLUMN_HOMOGENEOUS] =
|
||||
g_param_spec_boolean ("column-homogeneous",
|
||||
P_("Column homogeneous"),
|
||||
P_("Column homogeneous"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, obj_props);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_grid_constraint_init (GtkGridConstraint *self)
|
||||
{
|
||||
self->children = g_ptr_array_new_with_free_func (g_free);
|
||||
}
|
||||
|
||||
GtkGridConstraint *
|
||||
gtk_grid_constraint_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_GRID_CONSTRAINT, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_grid_constraint_add (GtkGridConstraint *self,
|
||||
GtkWidget *child,
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom)
|
||||
{
|
||||
GtkGridConstraintChild *data;
|
||||
|
||||
g_return_if_fail (GTK_IS_GRID_CONSTRAINT (self));
|
||||
g_return_if_fail (GTK_IS_WIDGET (child));
|
||||
g_return_if_fail (left < right);
|
||||
g_return_if_fail (top < bottom);
|
||||
g_return_if_fail (self->refs == NULL);
|
||||
|
||||
data = g_new0 (GtkGridConstraintChild, 1);
|
||||
|
||||
data->child = child;
|
||||
data->left = left;
|
||||
data->right = right;
|
||||
data->top = top;
|
||||
data->bottom = bottom;
|
||||
|
||||
g_ptr_array_add (self->children, data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_grid_constraint_is_attached (GtkGridConstraint *self)
|
||||
{
|
||||
return self->refs != NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_grid_constraint_attach (GtkGridConstraint *self,
|
||||
GtkConstraintSolver *solver,
|
||||
GPtrArray *refs)
|
||||
{
|
||||
g_return_if_fail (self->refs == NULL);
|
||||
|
||||
self->solver = solver;
|
||||
self->refs = g_ptr_array_ref (refs);
|
||||
}
|
||||
|
||||
void gtk_grid_constraint_detach (GtkGridConstraint *self)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (self->refs == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < self->refs->len; i++)
|
||||
{
|
||||
GtkConstraintRef *ref = g_ptr_array_index (self->refs, i);
|
||||
gtk_constraint_solver_remove_constraint (self->solver, ref);
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->refs, g_ptr_array_unref);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_GRID_CONSTRAINT_H__
|
||||
#define __GTK_GRID_CONSTRAINT_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_GRID_CONSTRAINT (gtk_grid_constraint_get_type ())
|
||||
|
||||
/**
|
||||
* GtkGridConstraint:
|
||||
*
|
||||
* An object used for managing constraints for children in
|
||||
* a constraints layout that are to be arranged in a grid.
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkGridConstraint, gtk_grid_constraint, GTK, GRID_CONSTRAINT, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkGridConstraint * gtk_grid_constraint_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_grid_constraint_add (GtkGridConstraint *self,
|
||||
GtkWidget *child,
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_GRID_CONSTRAINT_H__ */
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2019 Red Hat, inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Matthias Clasen
|
||||
*/
|
||||
|
||||
#include "gtkgridconstraint.h"
|
||||
#include "gtkconstraintsolverprivate.h"
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *child;
|
||||
int left;
|
||||
int right;
|
||||
int top;
|
||||
int bottom;
|
||||
} GtkGridConstraintChild;
|
||||
|
||||
struct _GtkGridConstraint {
|
||||
GObject parent;
|
||||
|
||||
gboolean row_homogeneous;
|
||||
gboolean column_homogeneous;
|
||||
|
||||
GPtrArray *children;
|
||||
|
||||
GtkConstraintSolver *solver;
|
||||
GPtrArray *refs;
|
||||
};
|
||||
|
||||
gboolean gtk_grid_constraint_is_attached (GtkGridConstraint *constraint);
|
||||
void gtk_grid_constraint_attach (GtkGridConstraint *constraint,
|
||||
GtkConstraintSolver *solver,
|
||||
GPtrArray *refs);
|
||||
void gtk_grid_constraint_detach (GtkGridConstraint *constraint);
|
||||
@@ -73,7 +73,6 @@
|
||||
#include "gtkwindowgroup.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
#include "gtknativeprivate.h"
|
||||
#include "gtkconstraint.h"
|
||||
|
||||
#include "a11y/gtkwidgetaccessible.h"
|
||||
#include "inspector/window.h"
|
||||
@@ -771,13 +770,6 @@ gtk_widget_get_type (void)
|
||||
NULL /* interface data */
|
||||
};
|
||||
|
||||
const GInterfaceInfo constraint_target_info =
|
||||
{
|
||||
(GInterfaceInitFunc) NULL,
|
||||
(GInterfaceFinalizeFunc) NULL,
|
||||
NULL /* interface data */
|
||||
};
|
||||
|
||||
widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, g_intern_static_string ("GtkWidget"),
|
||||
&widget_info, G_TYPE_FLAG_ABSTRACT);
|
||||
|
||||
@@ -790,8 +782,6 @@ gtk_widget_get_type (void)
|
||||
&accessibility_info) ;
|
||||
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
|
||||
&buildable_info) ;
|
||||
g_type_add_interface_static (widget_type, GTK_TYPE_CONSTRAINT_TARGET,
|
||||
&constraint_target_info) ;
|
||||
}
|
||||
|
||||
return widget_type;
|
||||
|
||||
@@ -252,6 +252,7 @@ gtk_public_sources = files([
|
||||
'gtkgesturezoom.c',
|
||||
'gtkglarea.c',
|
||||
'gtkgrid.c',
|
||||
'gtkgridconstraint.c',
|
||||
'gtkgridlayout.c',
|
||||
'gtkheaderbar.c',
|
||||
'gtkicontheme.c',
|
||||
|
||||
@@ -254,27 +254,15 @@ constraint_solver_edit_var_suggest (void)
|
||||
gtk_constraint_solver_suggest_value (solver, a, 2.0);
|
||||
gtk_constraint_solver_resolve (solver);
|
||||
|
||||
g_test_message ("Check values after first edit");
|
||||
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (a), 2.0, 0.001);
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (b), 2.0, 0.001);
|
||||
|
||||
gtk_constraint_solver_suggest_value (solver, a, 10.0);
|
||||
gtk_constraint_solver_resolve (solver);
|
||||
|
||||
g_test_message ("Check values after second edit");
|
||||
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (a), 10.0, 0.001);
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (b), 10.0, 0.001);
|
||||
|
||||
gtk_constraint_solver_suggest_value (solver, a, 12.0);
|
||||
gtk_constraint_solver_resolve (solver);
|
||||
|
||||
g_test_message ("Check values after third edit");
|
||||
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (a), 12.0, 0.001);
|
||||
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (b), 12.0, 0.001);
|
||||
|
||||
gtk_constraint_variable_unref (a);
|
||||
gtk_constraint_variable_unref (b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user