summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/compat.c13
-rw-r--r--gtk/compat.h14
-rw-r--r--gtk/tabs.c2
3 files changed, 28 insertions, 1 deletions
diff --git a/gtk/compat.c b/gtk/compat.c
index 8484c02fd..0717f5260 100644
--- a/gtk/compat.c
+++ b/gtk/compat.c
@@ -583,3 +583,16 @@ void nsgtk_widget_set_alignment(GtkWidget *widget, GtkAlign halign, GtkAlign val
gtk_misc_set_alignment(GTK_MISC(widget), x, y);
#endif
}
+
+/* exported interface documented in gtk/compat.h */
+void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin)
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(widget, hmargin);
+ gtk_widget_set_margin_right(widget, hmargin);
+ gtk_widget_set_margin_top(widget, vmargin);
+ gtk_widget_set_margin_bottom(widget, vmargin);
+#else
+ gtk_misc_set_padding(GTK_MISC(widget), hmargin, vmargin);
+#endif
+}
diff --git a/gtk/compat.h b/gtk/compat.h
index d35c5d75f..e90cdc615 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -94,6 +94,20 @@ typedef enum {
*/
void nsgtk_widget_set_alignment(GtkWidget *widget, GtkAlign halign, GtkAlign valign);
+/**
+ * Set the margins of a widget
+ *
+ * Sets the margin all round a widget.
+ *
+ * @note this type of margin was not available prior to GTK 3.0 so
+ * we emulate it using gtk_misc_set_padding.
+ *
+ * \param widget The widget to set alignent on.
+ * \param hmargin The horizontal margin.
+ * \param vmargin The vertical margin.
+ */
+void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin);
+
void nsgtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
gboolean nsgtk_widget_has_focus(GtkWidget *widget);
gboolean nsgtk_widget_get_visible(GtkWidget *widget);
diff --git a/gtk/tabs.c b/gtk/tabs.c
index cf2941d8e..f892fa638 100644
--- a/gtk/tabs.c
+++ b/gtk/tabs.c
@@ -76,7 +76,7 @@ static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window)
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE);
nsgtk_widget_set_alignment(label, GTK_ALIGN_START, GTK_ALIGN_CENTER);
- gtk_misc_set_padding(GTK_MISC(label), 0, 0);
+ nsgtk_widget_set_margins(label, 0, 0);
gtk_widget_show(label);
button = gtk_button_new();