[gtk+] gadget: Add api to get the border allocation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gadget: Add api to get the border allocation
- Date: Wed, 16 Dec 2015 03:00:36 +0000 (UTC)
commit b14dc6b5a4a1fa0f8aafe720eddb7c5f28feaec0
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 15 21:55:22 2015 -0500
gadget: Add api to get the border allocation
This can be useful for giving input windows the right size.
gtk/gtkcssgadget.c | 28 ++++++++++++++++++++++++++++
gtk/gtkcssgadgetprivate.h | 4 ++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c
index f1a0e97..0be480f 100644
--- a/gtk/gtkcssgadget.c
+++ b/gtk/gtkcssgadget.c
@@ -670,3 +670,31 @@ gtk_css_node_style_changed_for_widget (GtkCssNode *node,
_gtk_bitmask_free (changes);
}
+void
+gtk_css_gadget_get_border_allocation (GtkCssGadget *gadget,
+ GtkAllocation *allocation,
+ int *baseline)
+{
+ GtkCssGadgetPrivate *priv = gtk_css_gadget_get_instance_private (gadget);
+ GtkBorder margin;
+
+ g_return_if_fail (GTK_IS_CSS_GADGET (gadget));
+
+ get_box_margin (gtk_css_gadget_get_style (gadget), &margin);
+
+ if (allocation)
+ {
+ allocation->x = priv->allocated_size.x + margin.left;
+ allocation->y = priv->allocated_size.y + margin.top;
+ allocation->width = priv->allocated_size.width - margin.left - margin.right;
+ allocation->height = priv->allocated_size.height - margin.top - margin.bottom;
+ }
+ if (baseline)
+ {
+ if (priv->allocated_baseline >= 0)
+ *baseline = priv->allocated_baseline - margin.top;
+ else
+ *baseline = -1;
+ }
+}
+
diff --git a/gtk/gtkcssgadgetprivate.h b/gtk/gtkcssgadgetprivate.h
index 4000724..9d4b6e4 100644
--- a/gtk/gtkcssgadgetprivate.h
+++ b/gtk/gtkcssgadgetprivate.h
@@ -97,6 +97,10 @@ void gtk_css_gadget_allocate (GtkCssGadget
void gtk_css_gadget_draw (GtkCssGadget *gadget,
cairo_t *cr);
+void gtk_css_gadget_get_border_allocation (GtkCssGadget *gadget,
+ GtkAllocation *allocation,
+ int *baseline);
+
G_END_DECLS
#endif /* __GTK_CSS_GADGET_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]