window delete, hide, and present on Win32
- From: "David Necas (Yeti)" <yeti physics muni cz>
- To: gtk-list gnome org
- Subject: window delete, hide, and present on Win32
- Date: Tue, 27 Sep 2005 15:57:56 +0200
Hello,
I have window positioning troubles when a window is re-shown
after gtk_widget_hide() on Win32. The attached program
should demonstrate it clearly.
It has a main window with a button to show an auxiliary
window. The auxiliary window exists though all program
lifetime, but can be hidden and shown again. It can be
hidden by two means:
- using close button provided by MS Windows (`window manager
decorations')
- with Hide button in the window itself
When the first method is used, it reappears on its previous
position.
When the second method is used, it always appears in the
upper left corner. It's also reported to always appear on
the first monitor on a multihead setup, but I can't check
that.
Am I doing something wrong -- or is it a bug?
TIA,
Yeti
--
That's enough.
=============================================================================
#define GDK_MULTIHEAD_SAFE 1
#include <gtk/gtk.h>
static void
set_visible(GtkWidget *dialog,
gboolean visible)
{
gboolean current;
current = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dialog), "visible"));
if (current == visible)
return;
g_object_set_data(G_OBJECT(dialog), "visible", GINT_TO_POINTER(visible));
if (visible)
gtk_window_present(GTK_WINDOW(dialog));
else
gtk_widget_hide(dialog);
}
static void
response(GtkWidget *dialog,
gint response)
{
switch (response) {
case GTK_RESPONSE_CLOSE:
g_print("Closed\n");
set_visible(dialog, FALSE);
break;
case GTK_RESPONSE_DELETE_EVENT:
g_print("Deleted\n");
set_visible(dialog, FALSE);
break;
default:
g_print("Destroyed?!\n");
break;
}
}
static void
show_dialog(GtkWidget *dialog)
{
set_visible(dialog, TRUE);
}
static gboolean
no_destroy(void)
{
return TRUE;
}
int
main(int argc,
char *argv[])
{
GtkWidget *window, *dialog, *button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
button = gtk_button_new_with_label("Show auxiliary dialog");
gtk_container_add(GTK_CONTAINER(window), button);
dialog = gtk_dialog_new_with_buttons("Auxiliary dialog", NULL, 0, NULL);
g_signal_connect_swapped(button, "clicked",
G_CALLBACK(show_dialog), dialog);
gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_UTILITY);
button = gtk_dialog_add_button(GTK_DIALOG(dialog),
"Hide", GTK_RESPONSE_CLOSE);
g_signal_connect(dialog, "response", G_CALLBACK(response), NULL);
g_signal_connect(dialog, "delete-event", G_CALLBACK(no_destroy), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]