Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6846727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:39:33+00:00 2026-05-27T00:39:33+00:00

If I want some function to be called when a window gets closed I

  • 0

If I want some function to be called when a window gets closed I connect with delete_event. What should I connect with if I want the function to be called when the user minimizes a Gtk Window. Something like: minimize_event? I couldn’t find anything in the docs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:39:33+00:00Added an answer on May 27, 2026 at 12:39 am

    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
        //Minimized window check
        if(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED){
        //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 in binary
    and event->new_window_state is an int of which the 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 itsevent->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 Gnome Developer Site 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.
    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most systems will have a user-defined function (UDF) available. Some will not. i want
I want to make some C++ program and I'm using function popen here to
I have a failure in some inner library function in Octave. I want to
i want to use .animate function but i have some problems i want to
my function: struct hostent * gethost(char * hostname){ if(/*some condition under which I want
I've got some data (the output of a ddply function) that I want to
Possible Duplicate: Faster DirectoryExists function? I want to check if some file exists on
I'm passing to Django's template a function, which returns some records. I want to
I have a javascript function (function1) that checks some global variables (can the user
I have a file called: refdes2.php <script> function go(){ window.frames[0].document.body.innerHTML='<form target=_parent action=http://www.site.com/refdes3.php></form>'; window.frames[0].document.forms[0].submit() }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.