[gtk/wip/matthiasc/builder-fixes: 103/159] widget: Add gtk_widget_get_size()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/builder-fixes: 103/159] widget: Add gtk_widget_get_size()
- Date: Fri, 13 Dec 2019 18:49:43 +0000 (UTC)
commit 5cbfadf65ce7f12c7972d34c46a2a0461da9c273
Author: Benjamin Otte <otte redhat com>
Date: Sat Oct 19 05:15:15 2019 +0200
widget: Add gtk_widget_get_size()
A little bit of convenience.
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/gtkwidget.c | 25 +++++++++++++++++++++++++
gtk/gtkwidget.h | 3 +++
3 files changed, 29 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 5b40995fc8..fa20b8e0bc 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4856,6 +4856,7 @@ gtk_widget_get_allocation
gtk_widget_get_allocated_baseline
gtk_widget_get_width
gtk_widget_get_height
+gtk_widget_get_size
gtk_widget_compute_bounds
gtk_widget_compute_transform
gtk_widget_compute_point
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index c758387130..1abaaaa651 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13364,6 +13364,31 @@ gtk_widget_get_height (GtkWidget *widget)
return priv->height;
}
+/**
+ * gtk_widget_get_size:
+ * @widget: a #GtkWidget
+ * @orientation: the orientation to query
+ *
+ * Returns the content width or height of the widget, depending on @orientation.
+ * This is equivalent to calling gtk_widget_get_width() for %GTK_ORIENTATION_HORIZONTAL
+ * or gtk_widget_get_height() for %GTK_ORIENTATION_VERTICAL, but can be used when
+ * writing orientation-independent code, such as when implementing #GtkOrientable
+ * widgets.
+ *
+ * Returns: The size of @widget in @orientation.
+ */
+int
+gtk_widget_get_size (GtkWidget *widget,
+ GtkOrientation orientation)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ return gtk_widget_get_width (widget);
+ else
+ return gtk_widget_get_height (widget);
+}
+
/**
* gtk_widget_class_set_layout_manager_type:
* @widget_class: class to set the layout manager type for
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index eab367b712..bd2af20f45 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -576,6 +576,9 @@ GDK_AVAILABLE_IN_ALL
int gtk_widget_get_width (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
int gtk_widget_get_height (GtkWidget *widget);
+GDK_AVAILABLE_IN_ALL
+int gtk_widget_get_size (GtkWidget *widget,
+ GtkOrientation orientation);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_child_focus (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]