multi window



Hi, all,
It's my first time to post here. I've got a problem implementing multiple
windows with GTK+ library and Glade. I already searched someone who had the
same problem. I found it, but that thread didn't have an answer. Otherwise,
It was written in Perl, so I couldn't understand.

Okay, Glade generates the sources implementing a couple of windows on the
file, 'interface.c'. I was studying handling and communicating multiple
windows while reading Eddy's anjuta tutorial. The tutorial taught me some
ways to look up the signal-connecting functions widgets. I learned
'lookup_widget', gtk_widget_get_toplevel, g_object_get_data,
g_object_set_data. It explains to me how to pop up the new window when the
button on the parent window is clicked.

It was great for me to close another top level window using its own OK
button. It works fine, hide and show again. The new window disappears if I
click 'close' button on the titlebar. I believe it makes 'delete_event' and
'destroy' signal emit. In my view, that's why my new window is destroyed
instead of being hidden. I tried to put gtk_widget_hide in the my own
'destroy' call back function. It still has problem.

Let me show code snippets.

callback function when the info button was clicked on the parent top level
window
{
  GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(button));
  GtkWidget *info = gtk_object_get_data(G_OBJECT(window), "info window"); /*
It gets the pointer to new window that was saved in the 'main.c' */
  gtk_widget_show(info);
}

callback function when the ok button was clicked on the new window
{
  GtkWidget *info = gtk_widget_get_toplevel(GTK_WIDGET(button)); /* It gets
the pointer to the new window */
  gtk_widget_hide(info);
}

It works and I can click the parent top level window info button. I tried
the following, but failed.

callback function on 'destroy' signal
{
  gtk_widget_hide(GTK_WIDGET(object)):
}

I also tried to disconnect the destroy signal using
g_signal_handler_disconnect. It didn't work. I'm so poor at  C Programming.
I think the way I programmed could be wrong. Please, help me.

--
Seo, Jong Hwa
Plan for worst and hope for best

Seoul, Korea
Mobile: 010-3917-1801
http://tinydesk.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]