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/gtktextview.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/gtktextview.c')
-rw-r--r-- | gtk/gtktextview.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 7fffd99767..9197bf7420 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -383,12 +383,13 @@ static void gtk_text_view_get_property (GObject *object, static void gtk_text_view_destroy (GtkWidget *widget); static void gtk_text_view_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void gtk_text_view_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_text_view_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural); +static void gtk_text_view_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline); static void gtk_text_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_text_view_map (GtkWidget *widget); @@ -747,8 +748,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass) widget_class->style_updated = gtk_text_view_style_updated; widget_class->direction_changed = gtk_text_view_direction_changed; widget_class->state_flags_changed = gtk_text_view_state_flags_changed; - widget_class->get_preferred_width = gtk_text_view_get_preferred_width; - widget_class->get_preferred_height = gtk_text_view_get_preferred_height; + widget_class->measure = gtk_text_view_measure; widget_class->size_allocate = gtk_text_view_size_allocate; widget_class->event = gtk_text_view_event; widget_class->key_press_event = gtk_text_view_key_press_event; @@ -4035,30 +4035,24 @@ gtk_text_view_size_request (GtkWidget *widget, } static void -gtk_text_view_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) +gtk_text_view_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline) { GtkRequisition requisition; gtk_text_view_size_request (widget, &requisition); - *minimum = *natural = requisition.width; -} - -static void -gtk_text_view_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkRequisition requisition; - - gtk_text_view_size_request (widget, &requisition); - - *minimum = *natural = requisition.height; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + *minimum = *natural = requisition.width; + else + *minimum = *natural = requisition.height; } - static void gtk_text_view_compute_child_allocation (GtkTextView *text_view, GtkTextViewChild *vc, |