Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a GtkButton round

Tags:

gtk

How can I make GtkBtton round in shape?

like image 270
boom Avatar asked Oct 20 '25 14:10

boom


1 Answers

The accepted answer said:

There is no roundness option in the base set.

Well, there is now! See the GTKWidget documentation:

In special cases, buttons can be made round by adding the .circular style class.

So, for example:

gtk_style_context_add_class (gtk_widget_get_style_context (button),
                             "circular");

This works using both of the standard themes, Adwaita and HighContrast.

In GTK4, there are convenience functions to avoid having to get the StyleContext yourself:

gtk_widget_add_css_class (button, "circular");

The above assumebutton is a GtkWidget*. If, instead, it's a GtkButton* or subclass, just substitute in GTK_WIDGET (button) of course.

like image 84
underscore_d Avatar answered Oct 22 '25 04:10

underscore_d