[gtk+/wip/baedert/drawing: 50/143] flowbox: Remove gadgets
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 50/143] flowbox: Remove gadgets
- Date: Fri, 19 May 2017 13:27:37 +0000 (UTC)
commit f279e7672f0fe32e57921a093077c7725cf0af19
Author: Timm Bäder <mail baedert org>
Date: Fri May 5 09:27:06 2017 +0200
flowbox: Remove gadgets
gtk/gtkflowbox.c | 230 +++++++++++++++---------------------------------------
1 files changed, 64 insertions(+), 166 deletions(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index edde6cd..3c00da1 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -79,7 +79,6 @@
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
-#include "gtkcsscustomgadgetprivate.h"
#include "gtkcontainerprivate.h"
#include "a11y/gtkflowboxaccessibleprivate.h"
@@ -264,7 +263,6 @@ typedef struct _GtkFlowBoxChildPrivate GtkFlowBoxChildPrivate;
struct _GtkFlowBoxChildPrivate
{
GSequenceIter *iter;
- GtkCssGadget *gadget;
gboolean selected;
};
@@ -397,7 +395,7 @@ gtk_flow_box_child_get_request_mode (GtkWidget *widget)
}
static void
-gtk_flow_box_child_measure_ (GtkWidget *widget,
+gtk_flow_box_child_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
@@ -405,27 +403,8 @@ gtk_flow_box_child_measure_ (GtkWidget *widget,
int *minimum_baseline,
int *natural_baseline)
{
- gtk_css_gadget_get_preferred_size (CHILD_PRIV (GTK_FLOW_BOX_CHILD (widget))->gadget,
- orientation,
- for_size,
- minimum, natural,
- minimum_baseline, natural_baseline);
-}
-
-static void
-gtk_flow_box_child_measure (GtkCssGadget *gadget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline,
- gpointer data)
-{
- GtkWidget *widget;
GtkWidget *child;
- widget = gtk_css_gadget_get_owner (gadget);
child = gtk_bin_get_child (GTK_BIN (widget));
if (!child || ! gtk_widget_get_visible (child))
{
@@ -442,56 +421,27 @@ gtk_flow_box_child_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkAllocation clip;
-
- gtk_widget_set_allocation (widget, allocation);
-
- gtk_css_gadget_allocate (CHILD_PRIV (GTK_FLOW_BOX_CHILD (widget))->gadget,
- allocation,
- gtk_widget_get_allocated_baseline (widget),
- &clip);
-
- gtk_widget_set_clip (widget, &clip);
-}
-
-static void
-gtk_flow_box_child_allocate (GtkCssGadget *gadget,
- const GtkAllocation *allocation,
- int baseline,
- GtkAllocation *out_clip,
- gpointer data)
-{
- GtkWidget *widget;
GtkWidget *child;
- widget = gtk_css_gadget_get_owner (gadget);
-
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, (GtkAllocation *)allocation);
- gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
+ gtk_container_get_children_clip (GTK_CONTAINER (widget), &clip);
+
+ gtk_widget_set_clip (widget, &clip);
}
/* GObject implementation {{{2 */
static void
-gtk_flow_box_child_finalize (GObject *object)
-{
- g_clear_object (&CHILD_PRIV (GTK_FLOW_BOX_CHILD (object))->gadget);
-
- G_OBJECT_CLASS (gtk_flow_box_child_parent_class)->finalize (object);
-}
-
-static void
gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
- object_class->finalize = gtk_flow_box_child_finalize;
-
widget_class->get_request_mode = gtk_flow_box_child_get_request_mode;
- widget_class->measure = gtk_flow_box_child_measure_;
+ widget_class->measure = gtk_flow_box_child_measure;
widget_class->size_allocate = gtk_flow_box_child_size_allocate;
widget_class->focus = gtk_flow_box_child_focus;
@@ -528,14 +478,6 @@ gtk_flow_box_child_init (GtkFlowBoxChild *child)
{
gtk_widget_set_can_focus (GTK_WIDGET (child), TRUE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (child), TRUE);
-
- CHILD_PRIV (child)->gadget = gtk_css_custom_gadget_new_for_node (gtk_widget_get_css_node (GTK_WIDGET
(child)),
- GTK_WIDGET (child),
- gtk_flow_box_child_measure,
- gtk_flow_box_child_allocate,
- NULL,
- NULL,
- NULL);
}
/* Public API {{{2 */
@@ -709,7 +651,6 @@ struct _GtkFlowBoxPrivate {
GSequence *children;
GdkWindow *view_window;
- GtkCssGadget *gadget;
GtkFlowBoxFilterFunc filter_func;
gpointer filter_data;
GDestroyNotify filter_destroy;
@@ -1462,33 +1403,7 @@ gtk_flow_box_size_allocate (GtkWidget *widget,
{
GtkFlowBox *box = GTK_FLOW_BOX (widget);
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
- GtkAllocation clip;
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (priv->view_window)
- gdk_window_move_resize (priv->view_window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- gtk_css_gadget_allocate (BOX_PRIV (widget)->gadget,
- allocation,
- gtk_widget_get_allocated_baseline (widget),
- &clip);
-
- _gtk_widget_set_simple_clip (widget, &clip);
-}
-
-static void
-gtk_flow_box_allocate (GtkCssGadget *gadget,
- const GtkAllocation *allocation,
- int baseline,
- GtkAllocation *out_clip,
- gpointer unused)
-{
- GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
- GtkFlowBox *box = GTK_FLOW_BOX (widget);
- GtkFlowBoxPrivate *priv = BOX_PRIV (box);
+ GtkAllocation clip = *allocation;
GtkAllocation widget_allocation;
GtkAllocation child_allocation;
gint avail_size, avail_other_size, min_items, item_spacing, line_spacing;
@@ -1506,6 +1421,13 @@ gtk_flow_box_allocate (GtkCssGadget *gadget,
gint i, this_line_size;
GSequenceIter *iter;
+ if (priv->view_window)
+ gdk_window_move_resize (priv->view_window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+
+
+
gtk_widget_get_allocation (widget, &widget_allocation);
min_items = MAX (1, priv->min_children_per_line);
@@ -1838,7 +1760,9 @@ gtk_flow_box_allocate (GtkCssGadget *gadget,
g_free (item_sizes);
g_free (line_sizes);
- gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
+ gtk_container_get_children_clip (GTK_CONTAINER (widget), &clip);
+
+ gtk_widget_set_clip (widget, &clip);
}
static GtkSizeRequestMode
@@ -1919,7 +1843,7 @@ get_largest_aligned_line_length (GtkFlowBox *box,
}
static void
-gtk_flow_box_measure_ (GtkWidget *widget,
+gtk_flow_box_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
@@ -1927,24 +1851,6 @@ gtk_flow_box_measure_ (GtkWidget *widget,
int *minimum_baseline,
int *natural_baseline)
{
- gtk_css_gadget_get_preferred_size (BOX_PRIV (widget)->gadget,
- orientation,
- for_size,
- minimum, natural,
- minimum_baseline, natural_baseline);
-}
-
-static void
-gtk_flow_box_measure (GtkCssGadget *gadget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline,
- gpointer data)
-{
- GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkFlowBox *box = GTK_FLOW_BOX (widget);
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
@@ -2016,17 +1922,18 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
{
/* Return the width for the minimum height */
gint min_height;
-
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_VERTICAL,
- -1,
- &min_height, NULL,
- NULL, NULL);
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_HORIZONTAL,
- min_height,
- &min_width, &nat_width,
- NULL, NULL);
+ int dummy;
+
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_VERTICAL,
+ -1,
+ &min_height, &dummy,
+ NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ min_height,
+ &min_width, &nat_width,
+ NULL, NULL);
}
*minimum = min_width;
@@ -2047,28 +1954,29 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
/* Return the minimum width */
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_HORIZONTAL,
- -1,
- &min_width, &nat_width,
- NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ -1,
+ &min_width, &nat_width,
+ NULL, NULL);
}
else /* GTK_ORIENTATION_VERTICAL */
{
gint min_height;
gint line_length;
gint item_size, extra_pixels;
+ int dummy;
n_children = get_visible_children (box);
if (n_children <= 0)
goto out_width;
/* Make sure its no smaller than the minimum */
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_VERTICAL,
- -1,
- &min_height, NULL,
- NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_VERTICAL,
+ -1,
+ &min_height, &dummy,
+ NULL, NULL);
avail_size = MAX (for_size, min_height);
if (avail_size <= 0)
@@ -2205,17 +2113,18 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
{
/* Return the height for the minimum width */
gint min_width;
-
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_HORIZONTAL,
- -1,
- &min_width, NULL,
- NULL, NULL);
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_VERTICAL,
- min_width,
- &min_height, &nat_height,
- NULL, NULL);
+ int dummy;
+
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ -1,
+ &min_width, &dummy,
+ NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_VERTICAL,
+ min_width,
+ &min_height, &nat_height,
+ NULL, NULL);
}
else /* GTK_ORIENTATION_VERTICAL */
{
@@ -2294,17 +2203,18 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
gint min_width;
gint line_length;
gint item_size, extra_pixels;
+ int dummy;
n_children = get_visible_children (box);
if (n_children <= 0)
goto out_height;
/* Make sure its no smaller than the minimum */
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_HORIZONTAL,
- -1,
- &min_width, NULL,
- NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ -1,
+ &min_width, &dummy,
+ NULL, NULL);
avail_size = MAX (for_size, min_width);
if (avail_size <= 0)
@@ -2424,11 +2334,11 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
else /* GTK_ORIENTATION_VERTICAL */
{
/* Return the minimum height */
- gtk_css_gadget_get_preferred_size (gadget,
- GTK_ORIENTATION_VERTICAL,
- -1,
- &min_height, &nat_height,
- NULL, NULL);
+ gtk_flow_box_measure (widget,
+ GTK_ORIENTATION_VERTICAL,
+ -1,
+ &min_height, &nat_height,
+ NULL, NULL);
}
out_height:
@@ -3604,8 +3514,6 @@ gtk_flow_box_finalize (GObject *obj)
g_clear_object (&priv->bound_model);
}
- g_clear_object (&priv->gadget);
-
G_OBJECT_CLASS (gtk_flow_box_parent_class)->finalize (obj);
}
@@ -3633,7 +3541,7 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
widget_class->snapshot = gtk_flow_box_snapshot;
widget_class->key_press_event = gtk_flow_box_key_press_event;
widget_class->get_request_mode = gtk_flow_box_get_request_mode;
- widget_class->measure = gtk_flow_box_measure_;
+ widget_class->measure = gtk_flow_box_measure;
container_class->add = gtk_flow_box_add;
container_class->remove = gtk_flow_box_remove;
@@ -3942,7 +3850,6 @@ static void
gtk_flow_box_init (GtkFlowBox *box)
{
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
- GtkCssNode *widget_node;
gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), TRUE);
@@ -3985,15 +3892,6 @@ gtk_flow_box_init (GtkFlowBox *box)
G_CALLBACK (gtk_flow_box_drag_gesture_update), box);
g_signal_connect (priv->drag_gesture, "drag-end",
G_CALLBACK (gtk_flow_box_drag_gesture_end), box);
-
- widget_node = gtk_widget_get_css_node (GTK_WIDGET (box));
- priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
- GTK_WIDGET (box),
- gtk_flow_box_measure,
- gtk_flow_box_allocate,
- NULL,
- NULL,
- NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]