Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was at the very same crossroads, wth only some info and code on python gtk, but not in C.</p> <p>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.</p> <p>First:</p> <pre><code>g_signal_connect( G_OBJECT(window), "window-state-event", G_CALLBACK(callback_func), userDataPointer); </code></pre> <p>Then:</p> <pre><code>gboolean callback_func( GtkWidget *widget, GdkEventWindowState *event, gpointer user_data) { //some code //Minimized window check if(event-&gt;new_window_state &amp; GDK_WINDOW_STATE_ICONIFIED){ //some other code } //some more other code return TRUE; } </code></pre> <p>Remember this are bitfields and <code>&amp;</code> is the "bit and" operator <strong>not</strong> the boolean <code>&amp;&amp;</code>. <code>GDK_WINDOW_STATE_ICONIFIED =2</code> or <code>10</code> in binary and <code>event-&gt;new_window_state</code> is an <code>int</code> of which the second bit is active</p> <p>A Widget can be both maximized <strong>and</strong> minimized at the same time, <code>GDK_WINDOW_STATE_MAXIMIZED = 4</code> or <code>100</code></p> <p>If you minimized a maximized window its<code>event-&gt;new_window_state = 6</code> or 110</p> <p>You can experiment and see what works best for you.</p> <p>More info:</p> <ul> <li><a href="http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-window-state-event" rel="noreferrer">http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-window-state-event</a></li> <li><a href="http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventWindowState" rel="noreferrer">http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventWindowState</a></li> </ul> <p>Final Beware and caveats: </p> <p>I'm using gtk+2, because of dual win&amp;lin development. The newer gtk+3 might do some things different.</p> <p>The <a href="http://developer.gnome.org" rel="noreferrer">Gnome Developer Site</a> site has some links broken or wrong, or partially re-writen, with some errors. The page on the first url I put above has</p> <pre><code>gboolean user_function (GtkWidget *widget,GdkEvent *event,gpointer user_data){} </code></pre> <p>while the manual in the source code as well as other downloadable manuals has the correct:</p> <pre><code>gboolean user_function ( GtkWidget *widget, GdkEventWindowState *event, gpointer user_data){} </code></pre> <p>The page also has the <a href="http://developer.gnome.org/gdk3/stable/gdk-Event-Structures.html#GdkEventWindowState" rel="noreferrer">incorrect or broken link for the gtk3 page for <code>GdkEventWindowState</code></a>. 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</p> <p>For the moment as gtk+3 stabilizes*<em>expect</em>* inconsistencies. Use preferably the manuals that came with your source code or linux distro and version gtk+2.</p> <p>I hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload