summaryrefslogtreecommitdiff
path: root/gtk/gtkmisc.c
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2011-12-04 13:55:51 +0100
committerPaolo Borelli <pborelli@gnome.org>2012-01-22 13:36:47 +0100
commite34589ddeab1419a9124062a93ff483c3843a218 (patch)
treee544ef6a3b7eeb98d2f3a06542ae8d8205ac75f1 /gtk/gtkmisc.c
parentbf7779bfb71b6e27c90bf4bde246276f014107e7 (diff)
downloadgtk+-e34589ddeab1419a9124062a93ff483c3843a218.tar.gz
Factor out _gtk_misc_get_padding_and_border
The new semi-private function will allow to implement support for css padding and border in widgets inheriting from GtkMisc. Use the new function for GtkLabel, GtkArrow and GtkImage.
Diffstat (limited to 'gtk/gtkmisc.c')
-rw-r--r--gtk/gtkmisc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c
index ea5adc4ee0..d7b49eeeff 100644
--- a/gtk/gtkmisc.c
+++ b/gtk/gtkmisc.c
@@ -403,3 +403,36 @@ gtk_misc_realize (GtkWidget *widget)
gdk_window_set_background_pattern (window, NULL);
}
}
+
+/* Semi-private function used by gtk widgets inheriting from
+ * GtkMisc that takes into account both css padding and border
+ * and the padding specified with the GtkMisc properties.
+ */
+void
+_gtk_misc_get_padding_and_border (GtkMisc *misc,
+ GtkBorder *border)
+{
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder tmp;
+ gint xpad, ypad;
+
+ g_return_if_fail (GTK_IS_MISC (misc));
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (misc));
+ state = gtk_widget_get_state_flags (GTK_WIDGET (misc));
+
+ gtk_style_context_get_padding (context, state, border);
+
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+
+ border->right = border->left = xpad;
+ border->top = border->bottom = xpad;
+
+ gtk_style_context_get_border (context, state, &tmp);
+ border->top += tmp.top;
+ border->right += tmp.right;
+ border->bottom += tmp.bottom;
+ border->left += tmp.left;
+}
+