From 93df23d9628efe20ea50fab0eb044f6e6e52e486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 4 Dec 2017 12:42:52 +0100 Subject: [PATCH] Remove some more gtk_widget_get_content_size uses --- gtk/gtkcolorswatch.c | 6 ++---- gtk/gtkentry.c | 12 ++++++------ gtk/gtkframe.c | 3 ++- gtk/gtkicon.c | 3 ++- gtk/gtklabel.c | 18 ++++++------------ gtk/gtkmenu.c | 10 +++++----- gtk/gtkpaned.c | 13 +++++-------- gtk/gtkpopover.c | 3 ++- gtk/gtkrange.c | 13 +++++++------ gtk/gtkscale.c | 3 ++- gtk/gtkscrolledwindow.c | 3 ++- gtk/gtkswitch.c | 7 ++++--- gtk/gtktextview.c | 6 ++---- gtk/gtkviewport.c | 13 +++++++------ 14 files changed, 54 insertions(+), 59 deletions(-) diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index f12eb1a06c..12e0f3acd1 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -98,17 +98,15 @@ swatch_snapshot (GtkWidget *widget, { cairo_pattern_t *pattern; cairo_matrix_t matrix; - int width, height; GskRoundedRect content_box; - gtk_widget_get_content_size (widget, &width, &height); - gtk_rounded_boxes_init_for_style (NULL, NULL, &content_box, gtk_style_context_lookup_style (context), 0, 0, - width, height); + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)); gtk_snapshot_push_rounded_clip (snapshot, &content_box, "ColorSwatchClip"); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 7b5f5ea152..9230fa0006 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3383,15 +3383,13 @@ gtk_entry_snapshot (GtkWidget *widget, { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); - int width, height; graphene_rect_t bounds; int i; - gtk_widget_get_content_size (widget, &width, &height); - graphene_rect_init (&bounds, 0, 0, - width, height); + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)); gtk_snapshot_push_clip (snapshot, &bounds, "Entry Clip"); @@ -5821,8 +5819,9 @@ gtk_entry_draw_text (GtkEntry *entry, return; context = gtk_widget_get_style_context (widget); - gtk_widget_get_content_size (widget, &width, &height); layout = gtk_entry_ensure_layout (entry, TRUE); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); gtk_entry_get_layout_offsets (entry, &x, &y); @@ -5881,7 +5880,8 @@ gtk_entry_draw_cursor (GtkEntry *entry, layout = gtk_entry_ensure_layout (entry, TRUE); text = pango_layout_get_text (layout); gtk_entry_get_layout_offsets (entry, &x, &y); - gtk_widget_get_content_size (widget, &width, &height); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); if (type == CURSOR_DND) cursor_index = g_utf8_offset_to_pointer (text, priv->dnd_position) - text; diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 455654b623..4d824ade29 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -683,7 +683,8 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame, int frame_width, frame_height; gint height; - gtk_widget_get_content_size (GTK_WIDGET (frame), &frame_width, &frame_height); + frame_width = gtk_widget_get_width (GTK_WIDGET (frame)); + frame_height = gtk_widget_get_height (GTK_WIDGET (frame)); if (priv->label_widget) { diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c index 8f08af6b8d..3c2822864d 100644 --- a/gtk/gtkicon.c +++ b/gtk/gtkicon.c @@ -43,7 +43,8 @@ gtk_icon_snapshot (GtkWidget *widget, GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget)); int width, height; - gtk_widget_get_content_size (widget, &width, &height); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); if (width > 0 && height > 0) gtk_css_style_snapshot_icon (style, diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index f222906ea8..ca5576c106 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3306,17 +3306,9 @@ gtk_label_update_layout_width (GtkLabel *label) g_assert (priv->layout); if (priv->ellipsize || priv->wrap) - { - int width, height; - - gtk_widget_get_content_size (GTK_WIDGET (label), &width, &height); - - pango_layout_set_width (priv->layout, width * PANGO_SCALE); - } + pango_layout_set_width (priv->layout, gtk_widget_get_width (GTK_WIDGET (label)) * PANGO_SCALE); else - { - pango_layout_set_width (priv->layout, -1); - } + pango_layout_set_width (priv->layout, -1); } static void @@ -3666,7 +3658,8 @@ get_layout_location (GtkLabel *label, req_width = logical.width; req_height = logical.height; - gtk_widget_get_content_size (widget, &label_width, &label_height); + label_width = gtk_widget_get_width (widget); + label_height = gtk_widget_get_height (widget); baseline = gtk_widget_get_allocated_baseline (widget); @@ -3908,7 +3901,8 @@ gtk_label_snapshot (GtkWidget *widget, context = _gtk_widget_get_style_context (widget); - gtk_widget_get_content_size (widget, &width, &height); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); x = 0; if (priv->text && (*priv->text != '\0')) diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 351d227403..26ceb72a5f 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -2805,14 +2805,14 @@ static void gtk_menu_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) { - int width, height; - - gtk_widget_get_content_size (widget, &width, &height); - /* XXX The arrows *might* be missing here */ gtk_snapshot_push_clip (snapshot, - &GRAPHENE_RECT_INIT(0, 0, width, height), "MenuClip"); + &GRAPHENE_RECT_INIT( + 0, 0, + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)), + "MenuClip"); GTK_WIDGET_CLASS (gtk_menu_parent_class)->snapshot (widget, snapshot); diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index f1029290f1..329b9d5692 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -1412,13 +1412,12 @@ gtk_paned_snapshot (GtkWidget *widget, { GtkPanedPrivate *priv = gtk_paned_get_instance_private (GTK_PANED (widget)); GtkAllocation child_allocation; - int width, height; - gtk_widget_get_content_size (widget, &width, &height); gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT ( 0, 0, - width, height + gtk_widget_get_width (widget), + gtk_widget_get_height (widget) ), "GtkPaned"); @@ -1467,7 +1466,8 @@ gtk_paned_render_handle (GtkGizmo *gizmo, GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget)); int width, height; - gtk_widget_get_content_size (widget, &width, &height); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); if (width > 0 && height > 0) gtk_css_style_snapshot_icon (style, @@ -1566,13 +1566,10 @@ update_drag (GtkPaned *paned, int ypos) { GtkPanedPrivate *priv = paned->priv; - int width, height; gint pos; gint handle_size; gint size; - gtk_widget_get_content_size (GTK_WIDGET (paned), &width, &height); - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) pos = xpos; else @@ -1588,7 +1585,7 @@ update_drag (GtkPaned *paned, NULL, &handle_size, NULL, NULL); - size = width - pos - handle_size; + size = gtk_widget_get_width (GTK_WIDGET (paned)) - pos - handle_size; } else { diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 64032ea699..00d6e0324b 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -826,7 +826,8 @@ gtk_popover_get_gap_coords (GtkPopover *popover, int popover_width, popover_height; gtk_popover_get_pointing_to (popover, &rect); - gtk_widget_get_content_size (widget, &popover_width, &popover_height); + popover_width = gtk_widget_get_width (widget); + popover_height = gtk_widget_get_height (widget); #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget))) diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 3bea191712..30892e3d4f 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1695,16 +1695,15 @@ gtk_range_render_trough (GtkGizmo *gizmo, GtkWidget *widget = gtk_widget_get_parent (GTK_WIDGET (gizmo)); GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; - int width, height; - - gtk_widget_get_content_size (GTK_WIDGET (gizmo), &width, &height); /* HACK: GtkColorScale wants to draw its own trough * so we let it... */ if (GTK_IS_COLOR_SCALE (widget)) gtk_color_scale_snapshot_trough (GTK_COLOR_SCALE (widget), snapshot, - 0, 0, width, height); + 0, 0, + gtk_widget_get_width (GTK_WIDGET (gizmo)), + gtk_widget_get_height (GTK_WIDGET (gizmo))); if (priv->show_fill_level && gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) - @@ -2303,7 +2302,8 @@ update_autoscroll_mode (GtkRange *range) int width, height; gint size, pos; - gtk_widget_get_content_size (GTK_WIDGET (range), &width, &height); + width = gtk_widget_get_width (GTK_WIDGET (range)); + height = gtk_widget_get_height (GTK_WIDGET (range)); if (range->priv->orientation == GTK_ORIENTATION_VERTICAL) { @@ -2680,7 +2680,8 @@ gtk_range_compute_slider_position (GtkRange *range, &slider_height, NULL, NULL, NULL); - gtk_widget_get_content_size (priv->trough_widget, &trough_width, &trough_height); + trough_width = gtk_widget_get_width (priv->trough_widget); + trough_height = gtk_widget_get_height (priv->trough_widget); if (priv->orientation == GTK_ORIENTATION_VERTICAL) { diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 01e54fe29f..536ffdeca9 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -330,7 +330,8 @@ gtk_scale_allocate_value (GtkScale *scale, GtkAllocation slider_alloc, value_alloc; int range_width, range_height; - gtk_widget_get_content_size (widget, &range_width, &range_height); + range_width = gtk_widget_get_width (widget); + range_height = gtk_widget_get_height (widget); slider_widget = gtk_range_get_slider_widget (range); gtk_widget_get_outer_allocation (slider_widget, &slider_alloc); diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index bff8c4100c..ece2bb2155 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -2986,7 +2986,8 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget, gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1, &sb_height, NULL, NULL, NULL); - gtk_widget_get_content_size (widget, &width, &height); + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); allocation->x = 0; allocation->y = 0; diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index e3a4dabbb5..da56ec0a8c 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -221,16 +221,17 @@ gtk_switch_pan_gesture_pan (GtkGesturePan *gesture, { GtkWidget *widget = GTK_WIDGET (sw); GtkSwitchPrivate *priv = gtk_switch_get_instance_private (sw); - gint width; + int width; int height; + width = gtk_widget_get_width (widget); + height = gtk_widget_get_height (widget); + if (direction == GTK_PAN_DIRECTION_LEFT) offset = -offset; gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); - gtk_widget_get_content_size (widget, &width, &height); - if (priv->is_active) offset += width / 2; diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 359c14550d..04806c0731 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -5589,13 +5589,11 @@ gtk_text_view_snapshot (GtkWidget *widget, GtkStyleContext *context; graphene_rect_t bounds; cairo_t *cr; - int width, height; - - gtk_widget_get_content_size (widget, &width, &height); graphene_rect_init (&bounds, 0, 0, - width, height); + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)); gtk_snapshot_push_clip (snapshot, &bounds, "Textview Clip"); diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 03447593a6..2e8989d344 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -127,7 +127,8 @@ viewport_set_adjustment_values (GtkViewport *viewport, int viewport_size, other_viewport_size; int view_width, view_height; - gtk_widget_get_content_size (GTK_WIDGET (viewport), &view_width, &view_height); + view_width = gtk_widget_get_width (GTK_WIDGET (viewport)); + view_height = gtk_widget_get_height (GTK_WIDGET (viewport)); if (orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -511,12 +512,12 @@ static void gtk_viewport_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) { - int width, height; - - gtk_widget_get_content_size (widget, &width, &height); - gtk_snapshot_push_clip (snapshot, - &GRAPHENE_RECT_INIT(0, 0, width, height), "Viewport"); + &GRAPHENE_RECT_INIT( + 0, 0, + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)), + "Viewport"); GTK_WIDGET_CLASS (gtk_viewport_parent_class)->snapshot (widget, snapshot);