0
votes

Is there any callback function, so that when I click a button the window maximizes. By the way I'm using GTK 3.0 and C++ (Not gtkmm). I wrote a function which is called during the button click event and put this line

int maximise(){
gtk_window_fullscreen(GTK_WINDOW(window));
}

It gets compiled, but while I click the button the program terminates showing segmentation fault. (This function is inside the class)

1

1 Answers

1
votes

Check whether the callback is called using i.e. g_print

Make sure that signal is correctly connected to the button

g_signal_connect (button, "clicked",
              G_CALLBACK (maximise), NULL);

And that window is GtkWidget * type

Note that as it was written GtkButton reference the callback have to look like that:

void user_function (GtkButton *button, gpointer user_data)

and you have type of callback int

For me both versions (with int and void callback works)