gtk :: GtkButton :: defaultinit
# A widget that emits a signal when clicked on
# See: https://developer.gnome.org/gtk3/stable/GtkButton.html
extern class GtkButton `{GtkButton *`}
super GtkBin
new `{
return (GtkButton *)gtk_button_new();
`}
# Create a GtkButton with text
new with_label(text: String) import String.to_cstring `{
return (GtkButton *)gtk_button_new_with_label(String_to_cstring(text));
`}
new from_stock(stock_id: String) import String.to_cstring `{
return (GtkButton *)gtk_button_new_from_stock(String_to_cstring(stock_id));
`}
fun text: String import CString.to_s `{
return CString_to_s((char *)gtk_button_get_label(self));
`}
fun text=(value: String) import String.to_cstring `{
gtk_button_set_label(self, String_to_cstring(value));
`}
fun on_click(to_call: GtkCallable, user_data: nullable Object) do
signal_connect("clicked", to_call, user_data)
end
# Set the image of button to the given widget
fun image=(image: GtkWidget) `{
gtk_button_set_image(self, image);
`}
# Get the widget that is currenty set as the image of button
fun image: GtkWidget `{
return gtk_button_get_image(self);
`}
end
lib/gtk/v3_4/gtk_core.nit:788,1--827,3