I'm using anjuta with glade and gtk+.
I'm trying to get the button in my app to change the window title:
void changetitle(GtkWidget *win)
{
gtk_window_set_title(GTK_WINDOW(win),"My Window");
FILE *fh = fopen("/tmp/output.txt", "w");
fclose(fh);
}
I'm trying to get the button to execute this action, but I seem to be failing with passing the window as an argument.
Here's what I've tried:
the second function (creating the file) seems to work.
From the GTK+ 3 Reference Manual:
This means that, when the callback function is called, the first argument passed to it will be the button, not the window.
To fix this, you have two options:
You can either change
changetitle
to the following:Or (i.e. don't do both together), in Glade when you connect the signal, check the "swap" box:
By doing so, the order of the parameters will be swapped, so the first parameter will be your specified data (i.e. the window), and the second parameter (which isn't specified in your callback function and hence will not matter) will be your button.