Re: patch for GtkDialog



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

Very good idea.  Here's another patch :)

Thanks,
James

? gtk_jwillcox_dialog_patch_v1.diff
? gtk_jwillcox_dialog_patch_v2.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 17:31:12 -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 17:31:13 -0000
@@ -349,10 +349,13 @@
 {
   /* Synthesize delete_event to close dialog. */
   
   GdkEventAny event;
   GtkWidget *widget;
+  
+  if (g_object_get_data (G_OBJECT (dialog), "has-cancel") == NULL)
+	  return;
 
   widget = GTK_WIDGET (dialog);
   
   event.type = GDK_DELETE;
   event.window = widget->window;
@@ -558,10 +561,12 @@
                     child,
                     FALSE, TRUE, 0);
   
   if (response_id == GTK_RESPONSE_HELP)
     gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dialog->action_area), child, TRUE);
+  if (response_id == GTK_RESPONSE_CANCEL)
+    g_object_set_data (G_OBJECT (dialog), "has-cancel", GINT_TO_POINTER (TRUE));
 }
 
 /**
  * gtk_dialog_add_button:
  * @dialog: a #GtkDialog


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]