? gtk_jwillcox_dialog_patch_v1.diff
? gtk_jwillcox_dialog_patch_v2.diff
? gtk_jwillcox_dialog_patch_v3.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.3325
diff -u -5 -r1.3325 ChangeLog
--- ChangeLog	8 Apr 2002 19:32:36 -0000	1.3325
+++ ChangeLog	9 Apr 2002 03:56:57 -0000
@@ -1,5 +1,10 @@
+Sat Mar 30 09:08:23 2002  James Willcox  <jwillcox@cs.indiana.edu>
+
+	* gtk/gtkdialog.c:  Change the Escape key binding to only close
+	if the dialog contains a cancel button.  (#74221)
+
 2002-04-08  Manish Singh  <yosh@gimp.org>
 
 	* tests/testgtk.c: really revert testgtk.c
 
 Mon Apr  8 20:28:54 2002  Kristian Rietveld  <kris@gtk.org>
Index: gtk/gtkdialog.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkdialog.c,v
retrieving revision 1.42
diff -u -5 -r1.42 gtkdialog.c
--- gtk/gtkdialog.c	30 Jan 2002 18:58:31 -0000	1.42
+++ gtk/gtkdialog.c	9 Apr 2002 03:56:58 -0000
@@ -58,10 +58,11 @@
 static void gtk_dialog_style_set         (GtkWidget        *widget,
                                           GtkStyle         *prev_style);
 static void gtk_dialog_map               (GtkWidget        *widget);
 
 static void gtk_dialog_close             (GtkDialog        *dialog);
+static gboolean gtk_dialog_has_cancel    (GtkDialog        *dialog);
 
 enum {
   PROP_0,
   PROP_HAS_SEPARATOR
 };
@@ -349,10 +350,13 @@
 {
   /* Synthesize delete_event to close dialog. */
   
   GdkEventAny event;
   GtkWidget *widget;
+  
+  if (!gtk_dialog_has_cancel (dialog))
+	  return;
 
   widget = GTK_WIDGET (dialog);
   
   event.type = GDK_DELETE;
   event.window = widget->window;
@@ -484,10 +488,37 @@
                                 ad,
                                 g_free);
     }
 
   return ad;
+}
+
+static gboolean
+gtk_dialog_has_cancel (GtkDialog *dialog)
+{
+  GList *children, *tmp_list;
+  gboolean ret = FALSE;
+      
+  tmp_list = children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+  while (tmp_list)
+  {
+    GtkWidget *widget = tmp_list->data;
+    ResponseData *rd = get_response_data (widget);
+
+    if (rd && rd->response_id == GTK_RESPONSE_CANCEL)
+    {
+      ret = TRUE;
+      break;
+    }
+
+    tmp_list = g_list_next (tmp_list);
+  }
+
+  g_list_free (children);
+
+  return ret;
 }
 
 static void
 action_widget_activated (GtkWidget *widget, GtkDialog *dialog)
 {
