I was at the very same crossroads, wth only some info and code on python gtk, but not in C.
After looking the docs again and again I realized I got confuse by same sounding names, unions, structures and enums and bitfields. I was handling things as booleans, when it was a bitfield thingy all along.
First:
g_signal_connect(G_OBJECT(window), "window-state-event", G_CALLBACK(callback_func), userDataPointer);
Then :
gboolean callback_func(GtkWidget *widget,GdkEventWindowState *event,gpointer user_data){
//some code
if(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED){//this means minimized
//some other code
}
//some more other code
return TRUE;
}
Remember this are bitfields and & is the "bit and" operator NOT the boolean &&
GDK_WINDOW_STATE_ICONIFIED =2 or 10 on binary
and event->new_window_state is an int which second bit is active
A Widget can be both maximized AND minimized at the same time,
GDK_WINDOW_STATE_MAXIMIZED = 4 or 100
If you minimized a maximized window its event->new_window_state = 6 or 110
You can experiment and see what works best for you.
More info:
http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-window-state-event
http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventWindowState
Final Beware and caveats :
I'm using gtk+2, because of dual win&lin development. The newer gtk+3 might do some things different.
the http://developer.gnome.org site has some links broken or wrong, or partially re-writen, with some errors. The page on the first url I put above has
gboolean user_function (GtkWidget *widget,GdkEvent *event,gpointer user_data){}
while the manual in the source code as well as other downloadable manuals has the correct:
gboolean user_function (GtkWidget *widget,GdkEventWindowState *event, gpointer user_data){}
The page also has the incorrect or broken link for the gtk3 page for GdkEventWindowState: developer.gnome.org/gdk3/stable/gdk-Event-Structures.html#GdkEventWindowState
The gtk+3 version seems as wrong as the gtk+2, I have not seen the gtk+3 manuals with the source code or separate so I don't know if gtk+3 truly modifies the callback for the event and the gdk structures
For the moment as gtk+3 stabilizes EXPECT inconsistencies. Use preferably the manuals that came with your source code or linux distro and version gtk+2.
I hope this helps