diff options
author | Timm Bäder <mail@baedert.org> | 2016-10-22 16:06:14 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2016-10-22 19:05:47 +0200 |
commit | 9992a616efa47205ac16ed8be255eda5e7aadf6c (patch) | |
tree | 3879538642de33a77472bafe3e6e8afea3b3e343 /gtk/gtkcheckbutton.c | |
parent | 6525b95e2502080c08b65317c910204c2b6125da (diff) | |
download | gtk+-9992a616efa47205ac16ed8be255eda5e7aadf6c.tar.gz |
widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
Diffstat (limited to 'gtk/gtkcheckbutton.c')
-rw-r--r-- | gtk/gtkcheckbutton.c | 155 |
1 files changed, 25 insertions, 130 deletions
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index f6f8d376f5..646ea6ac1e 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -78,26 +78,6 @@ */ -static void gtk_check_button_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_check_button_get_preferred_width_for_height (GtkWidget *widget, - gint height, - gint *minimum, - gint *natural); -static void gtk_check_button_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_check_button_get_preferred_height_for_width (GtkWidget *widget, - gint width, - gint *minimum, - gint *natural); -static void gtk_check_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget, - gint width, - gint *minimum, - gint *natural, - gint *minimum_baseline, - gint *natural_baseline); static void gtk_check_button_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static GskRenderNode *gtk_check_button_get_render_node (GtkWidget *widget, @@ -196,6 +176,30 @@ gtk_check_button_remove (GtkContainer *container, } static void +gtk_check_button_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline) +{ + GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); + GtkCssGadget *gadget; + + if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) + gadget = priv->gadget; + else + gadget = GTK_BUTTON (widget)->priv->gadget; + + gtk_css_gadget_get_preferred_size (gadget, + orientation, + for_size, + minimum, natural, + minimum_baseline, natural_baseline); +} + +static void gtk_check_button_class_init (GtkCheckButtonClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); @@ -204,11 +208,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) object_class->finalize = gtk_check_button_finalize; - widget_class->get_preferred_width = gtk_check_button_get_preferred_width; - widget_class->get_preferred_width_for_height = gtk_check_button_get_preferred_width_for_height; - widget_class->get_preferred_height = gtk_check_button_get_preferred_height; - widget_class->get_preferred_height_for_width = gtk_check_button_get_preferred_height_for_width; - widget_class->get_preferred_height_and_baseline_for_width = gtk_check_button_get_preferred_height_and_baseline_for_width; + widget_class->measure = gtk_check_button_measure; widget_class->size_allocate = gtk_check_button_size_allocate; widget_class->get_render_node = gtk_check_button_get_render_node; widget_class->state_flags_changed = gtk_check_button_state_flags_changed; @@ -338,111 +338,6 @@ gtk_check_button_new_with_mnemonic (const gchar *label) } static void -gtk_check_button_get_preferred_width_for_height (GtkWidget *widget, - gint height, - gint *minimum, - gint *natural) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkCssGadget *gadget; - - if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) - gadget = priv->gadget; - else - gadget = GTK_BUTTON (widget)->priv->gadget; - - gtk_css_gadget_get_preferred_size (gadget, - GTK_ORIENTATION_HORIZONTAL, - height, - minimum, natural, - NULL, NULL); -} - -static void -gtk_check_button_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkCssGadget *gadget; - - if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) - gadget = priv->gadget; - else - gadget = GTK_BUTTON (widget)->priv->gadget; - - gtk_css_gadget_get_preferred_size (gadget, - GTK_ORIENTATION_HORIZONTAL, - -1, - minimum, natural, - NULL, NULL); -} - -static void -gtk_check_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget, - gint width, - gint *minimum, - gint *natural, - gint *minimum_baseline, - gint *natural_baseline) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkCssGadget *gadget; - - if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) - gadget = priv->gadget; - else - gadget = GTK_BUTTON (widget)->priv->gadget; - - gtk_css_gadget_get_preferred_size (gadget, - GTK_ORIENTATION_VERTICAL, - width, - minimum, natural, - minimum_baseline, natural_baseline); -} - -static void -gtk_check_button_get_preferred_height_for_width (GtkWidget *widget, - gint width, - gint *minimum, - gint *natural) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkCssGadget *gadget; - - if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) - gadget = priv->gadget; - else - gadget = GTK_BUTTON (widget)->priv->gadget; - - gtk_css_gadget_get_preferred_size (gadget, - GTK_ORIENTATION_VERTICAL, - width, - minimum, natural, - NULL, NULL); -} - -static void -gtk_check_button_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkCssGadget *gadget; - - if (gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget))) - gadget = priv->gadget; - else - gadget = GTK_BUTTON (widget)->priv->gadget; - - gtk_css_gadget_get_preferred_size (gadget, - GTK_ORIENTATION_VERTICAL, - -1, - minimum, natural, - NULL, NULL); -} - -static void gtk_check_button_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { |