]> Pileus Git - ~andy/gtk/commitdiff
Change the Escape key binding to only close if the dialog contains a
authorOwen Taylor <otaylor@redhat.com>
Sat, 14 Dec 2002 00:14:54 +0000 (00:14 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 14 Dec 2002 00:14:54 +0000 (00:14 +0000)
Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkdialog.c: Change the Escape key binding to only close
        if the dialog contains a cancel button.  (Patch from
        James Willcox, #74221)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkdialog.c

index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index 056898de301b12ddca14ab1962798277c1cc78fc..7af59c5133b42c5fde4cdbc564eda01907633e8a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Dec 13 18:57:20 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkdialog.c: Change the Escape key binding to only close
+       if the dialog contains a cancel button.  (Patch from
+       James Willcox, #74221)
 Fri Dec 13 18:22:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfilesel.c (compare_cmpl_dir): Use 
index a2379aa1967a6c28f06014dda2e25feafe008901..c70b1541b4a5e1e7c4c15c15a55a535640e1cfd7 100644 (file)
 #include "gtkintl.h"
 #include "gtkbindings.h"
 
+typedef struct _ResponseData ResponseData;
+
+struct _ResponseData
+{
+  gint response_id;
+};
+
 static void gtk_dialog_class_init (GtkDialogClass *klass);
 static void gtk_dialog_init       (GtkDialog      *dialog);
 
@@ -60,6 +67,8 @@ static void gtk_dialog_map               (GtkWidget        *widget);
 
 static void gtk_dialog_close             (GtkDialog        *dialog);
 
+static ResponseData* get_response_data   (GtkWidget        *widget);
+
 enum {
   PROP_0,
   PROP_HAS_SEPARATOR
@@ -345,15 +354,42 @@ gtk_dialog_style_set (GtkWidget *widget,
   update_spacings (GTK_DIALOG (widget));
 }
 
+static gboolean
+dialog_has_cancel (GtkDialog *dialog)
+{
+  GList *children, *tmp_list;
+  gboolean ret = FALSE;
+      
+  children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+  for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
+    {
+      ResponseData *rd = get_response_data (tmp_list->data);
+      
+      if (rd && rd->response_id == GTK_RESPONSE_CANCEL)
+       {
+         ret = TRUE;
+         break;
+       }
+    }
+
+  g_list_free (children);
+
+  return ret;
+}
+
 static void
 gtk_dialog_close (GtkDialog *dialog)
 {
   /* Synthesize delete_event to close dialog. */
   
-  GdkEvent *event = gdk_event_new (GDK_DELETE);
-  GtkWidget *widget;
+  GtkWidget *widget = GTK_WIDGET (dialog);
+  GdkEvent *event;
 
-  widget = GTK_WIDGET (dialog);
+  if (!dialog_has_cancel (dialog))
+    return;
+
+  event = gdk_event_new (GDK_DELETE);
   
   event->any.window = g_object_ref (widget->window);
   event->any.send_event = TRUE;
@@ -459,13 +495,6 @@ gtk_dialog_new_with_buttons (const gchar    *title,
   return GTK_WIDGET (dialog);
 }
 
-typedef struct _ResponseData ResponseData;
-
-struct _ResponseData
-{
-  gint response_id;
-};
-
 static ResponseData*
 get_response_data (GtkWidget *widget)
 {