Re: patch for GtkDialog
- From: James Willcox <jwillcox cs indiana edu>
- To: Havoc Pennington <hp redhat com>
- Cc: gtk-devel-list gnome org, Seth Nickell <snickell stanford edu>, calum benson ireland sun com
- Subject: Re: patch for GtkDialog
- Date: 29 Mar 2002 13:46:18 -0500
On Fri, 2002-03-29 at 11:16, Havoc Pennington wrote:
>
> Havoc Pennington <hp redhat com> writes:
> > My opinion is that in practice, if you make this change then NO dialog
> > will have Escape, even those that _do_ have cancel buttons. I don't
> > think it's realistic to expect people to special-case dialogs with
> > cancel vs. non-cancel. So in making a decision we may want to keep
> > that in mind. Adding an Escape shortcut manually would be decidedly
> > nontrivial with current API.
>
> Clever idea: have the close window shortcut only apply if the dialog
> has a button with GTK_RESPONSE_CANCEL. (i.e. return FALSE from the
> keybinding handler. Ugh, once again we should have made all keybinding
> signals return boolean...)
>
> Havoc
Actually, disregard the last patch....I think this one is better....
Thanks,
James
? gtk_jwillcox_dialog_patch_v1.diff
? gtk_jwillcox_dialog_patch_v2.diff
? gtk_jwillcox_dialog_patch_v3.diff
? gtk/.gtkdialog.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.3305
diff -u -5 -r1.3305 ChangeLog
--- ChangeLog 29 Mar 2002 06:22:31 -0000 1.3305
+++ ChangeLog 29 Mar 2002 18:45:29 -0000
@@ -1,5 +1,10 @@
+Fri Mar 29 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)
+
Fri Mar 29 00:19:41 2002 Owen Taylor <otaylor redhat com>
* NEWS: Updates
* configure.in: Version 2.0.1, binary, interface age 1.
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 29 Mar 2002 18:45:29 -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]