Add gtk compatability for margin setting.
This commit is contained in:
parent
df4e9e322d
commit
5e51600cfe
13
gtk/compat.c
13
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
|
||||
}
|
||||
|
|
14
gtk/compat.h
14
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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue