From aa62466091c92514e596f87cae8a34373caea67c Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 17 Oct 2002 16:04:53 +0000 Subject: [PATCH] add code to create big stacks of dialogs transient for each other, for 2002-10-17 Havoc Pennington * src/tools/metacity-window-demo.c (dialog_cb): add code to create big stacks of dialogs transient for each other, for testing. --- ChangeLog | 5 +++ src/tabpopup.c | 1 + src/tools/metacity-window-demo.c | 69 +++++++++++++++++++++++++------- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index de9edbd59..d54e5d096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-10-17 Havoc Pennington + + * src/tools/metacity-window-demo.c (dialog_cb): add code to create + big stacks of dialogs transient for each other, for testing. + 2002-10-16 Havoc Pennington * src/workspace.c: workspaces are all per-screen now, fix diff --git a/src/tabpopup.c b/src/tabpopup.c index 30378f175..5dfcf1ccb 100644 --- a/src/tabpopup.c +++ b/src/tabpopup.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2002 Red Hat, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/src/tools/metacity-window-demo.c b/src/tools/metacity-window-demo.c index 695b0f552..f4bd7ffc3 100644 --- a/src/tools/metacity-window-demo.c +++ b/src/tools/metacity-window-demo.c @@ -215,26 +215,65 @@ main (int argc, char **argv) return 0; } +static void +response_cb (GtkDialog *dialog, + int response_id, + void *data); + +static void +make_dialog (GtkWidget *parent, + int depth) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (GTK_WINDOW (parent), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "Here is a dialog %d", + depth); + + gtk_dialog_add_button (GTK_DIALOG (dialog), + "Open child dialog", + GTK_RESPONSE_ACCEPT); + + /* Close dialog on user response */ + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (response_cb), + NULL); + + g_object_set_data (G_OBJECT (dialog), "depth", + GINT_TO_POINTER (depth)); + + gtk_widget_show (dialog); +} + +static void +response_cb (GtkDialog *dialog, + int response_id, + void *data) +{ + switch (response_id) + { + case GTK_RESPONSE_ACCEPT: + make_dialog (GTK_WIDGET (dialog), + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), + "depth")) + 1); + break; + + default: + gtk_widget_destroy (GTK_WIDGET (dialog)); + break; + } +} + static void dialog_cb (gpointer callback_data, guint callback_action, GtkWidget *widget) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (GTK_WINDOW (callback_data), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, - "Here is a dialog"); - - /* Close dialog on user response */ - g_signal_connect (G_OBJECT (dialog), - "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - - gtk_widget_show (dialog); + make_dialog (GTK_WIDGET (callback_data), 1); } static void