1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| static void
on_close_button_style_set (GtkWidget *button,
GtkStyle *previous_style,
gpointer user_data)
{
gint h, w;
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
GTK_ICON_SIZE_MENU, &w, &h);
gtk_widget_set_size_request (button, w + 2, h + 2);
}
static GtkWidget *
create_close_button ()
{
GtkWidget *button;
GtkWidget *image;
GtkRcStyle *rcstyle;
button = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
/* don't allow focus on the close button */
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
/* make it as small as possible */
rcstyle = gtk_rc_style_new ();
rcstyle->xthickness = rcstyle->ythickness = 0;
gtk_widget_modify_style (button, rcstyle);
gtk_rc_style_unref (rcstyle);
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (button), image);
/* Set minimal size */
g_signal_connect (button, "style-set",
G_CALLBACK (on_close_button_style_set), NULL);
return button;
} |