RE: Dialog closing prematurely with response code of 0
- From: "Kevin Lambert" <kl lapis com>
- To: <gtk-app-devel-list gnome org>
- Subject: RE: Dialog closing prematurely with response code of 0
- Date: Thu, 5 Apr 2007 10:51:39 -0400
I have finally figured out what was going on. The dialogs were developed
using Glade-2 and the buttons had "Reponse ID" set to 0 by default which is
why they were returning when pressed.
Kevin
-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of David Neèas
(Yeti)
Sent: Thursday, March 22, 2007 7:12 PM
To: gtk-app-devel-list gnome org
Subject: Re: Dialog closing prematurely with response code of 0
On Thu, Mar 22, 2007 at 09:20:47AM -0400, Kevin Lambert wrote:
I have a button in DispenserLoadDialog that launches
DispenserLoadingDialog without emitting a return value for
DispenserLoadDialog. The response value from DispenserLoadingDialog
is only supposed to be caught by the buttons code and shouldn't be
causing gtk_dialog_run() in DispenserLoadDialog to return with an
invalid response.
DispenserLoadDialog->gtk_dialog_run() started with the
DispenserLoadDialog->DispenserLoadDialog
dialog pointer passed in
Load Button pushed which causes load_button_clicked to be executed
load_button_clicked() launches DispenserLoadingDialog()
DispenserLoadingDialog->gtk_dialog_run() started with the
DispenserLoadingDialog dialog pointer passed in
Ok button in DispenserLoadingDialog pressed which causes
ok_button_clicked to be executed
ok_button_clicked() calls gtk_dialog_response() with GTK_RESPONSE_OK
and the DispenserLoadingDialog pointer as the first parameter
load_button_clicked() finishes executing WITHOUT calling
DispenserLoadDialog->gtk_dialog_run() returns with a response code of
DispenserLoadDialog->0
(which is invalid as far as the documenation is concerned).
So it is something like this:
=======================================================================
#include <gtk/gtk.h>
static void
next_dialog(GtkWidget *button,
gpointer user_data)
{
GtkWindow *parent = NULL;
GtkWidget *dialog, *label;
gint response, level;
gchar *s;
if (button)
parent = GTK_WINDOW(gtk_widget_get_toplevel(button));
level = GPOINTER_TO_INT(user_data);
level++;
s = g_strdup_printf("Dialog %d", level);
dialog = gtk_dialog_new_with_buttons(s, parent, GTK_DIALOG_MODAL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
g_free(s);
s = g_strdup_printf("This is dialog level %d", level);
label = gtk_label_new(s);
gtk_misc_set_padding(GTK_MISC(label), 12, 12);
g_free(s);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
button = gtk_button_new_with_mnemonic("_Destroy Me");
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), button);
g_signal_connect_swapped(button, "clicked",
G_CALLBACK(gtk_widget_destroy), dialog);
button = gtk_button_new_with_mnemonic("_Go Deeper");
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), button);
g_signal_connect(button, "clicked",
G_CALLBACK(next_dialog), GINT_TO_POINTER(level));
gtk_widget_show_all(dialog);
gtk_window_present(GTK_WINDOW(dialog));
response = gtk_dialog_run(GTK_DIALOG(dialog));
g_printerr("level: %d, response: %d\n", level, response);
if (response != GTK_RESPONSE_NONE)
gtk_widget_destroy(dialog);
}
int
main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
next_dialog(NULL, NULL);
return 0;
} =======================================================================
Except that this program of course works.
The variable that holds the response id is initialized to GTK_RESPONSE_NONE
== -1, so whatever happens, you should not get 0 from gtk_dialog_run()
unless
- something sets it to 0 (note GtkDialog does not prevent you
from using zero response id)
- memory is corrupted
In either case I would assume it is not GtkDialog what
somehow breaks out of the inner main loop by force and/or sets the response
id to 0. You cannot expect much from reporting it to bugzilla either if you
don't show how to reproduce the problem with GtkDialog.
Yeti
--
http://gwyddion.net/ _______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]