summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-12-14 00:14:54 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-12-14 00:14:54 +0000
commit59f712ad5f622d40ebd854dfa8d0882730adf106 (patch)
tree49f2f1190988c24237c5dbfd4b0952a4356355c9
parent137ad5b9ae32c00114743ff07684dcd46a5cc9f7 (diff)
downloadgdk-pixbuf-59f712ad5f622d40ebd854dfa8d0882730adf106.tar.gz
Change the Escape key binding to only close if the dialog contains a
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)
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-2-106
-rw-r--r--ChangeLog.pre-2-26
-rw-r--r--ChangeLog.pre-2-46
-rw-r--r--ChangeLog.pre-2-66
-rw-r--r--ChangeLog.pre-2-86
-rw-r--r--gtk/gtkdialog.c49
7 files changed, 75 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 056898de3..7af59c513 100644
--- 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
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 056898de3..7af59c513 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 056898de3..7af59c513 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 056898de3..7af59c513 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 056898de3..7af59c513 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 056898de3..7af59c513 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index a2379aa19..c70b1541b 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -35,6 +35,13 @@
#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)
{