简体   繁体   中英

Gtk hiding window on it's callback

I have a function that I want to hide on pressing a button. I've read that I can define multiple callbacks on a signal and they will be called in the same order as defined. So I wanted to execute two functions on button press and I wanted one of them to hide window that contains this button. I tried to do it like this:

g_signal_connect(btn_confirm, "clicked", G_CALLBACK(function_that_does_stuff), NULL);
g_signal_connect(btn_confirm, "clicked", G_CALLBACK(kill_window), add_conn_win);
...
void kill_window ( GtkWidget* wdgt, GtkWidget* win )
{
  gtk_widget_hide_all(win);
}

But this isn't working. Window's still there. Can someone tell me how to do that?

First things first, see what the documentation says about gtk_widget_hide_all() :

gtk_widget_hide_all has been deprecated since version 2.24 and should not be used in newly-written code

Instead you should use gtk_widget_hide () . The specification says that it

Reverses the effects of gtk_widget_show(), causing the widget to be hidden (invisible to the user).

As a comment said, make sure your callbacks are being triggered. Then try

gtk_widget_hide (win);

I think that should do the work, let me know if it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM