entry activating default button



Hi,

Appended patch is for http://bugzilla.gnome.org/show_bug.cgi?id=50960,
problem of making entries in dialogs close the dialog. Analagous to
gnome_dialog_editable_enters().

The patch adds gtk_entry_set_activate_default(), which has this effect
in the default handler for "activate":


  GtkWindow *window;
  GtkWidget *widget;

  widget = GTK_WIDGET (entry);

  if (entry->activate_default)
    {
      window = (GtkWindow *) gtk_widget_get_toplevel (widget);
      
      if (window &&
          window->default_widget != widget)
        gtk_window_activate_default (window);
    }

Rationale:

 - this is more convenient than manually connecting a signal handler
   to "activate"

 - this is a property of the entry rather than e.g. the dialog since
   it works well in a GUI builder to toggle this in the property sheet
   of the entry

 - we discussed making this setting an enum instead, to support
   a third option which would make "activate" move the focus
   to the next widget. Other widget sets don't seem to do this - 
   I don't think users would really expect it to work. Also, I don't 
   know why you'd set this per-entry; seems to me that if hitting
   Enter moves the focus, you would expect all entries to do that 
   by default.

For comparison, WinForms does this as a boolean property of the
TextBox control called AcceptReturn or something like that. If TRUE
(the default), hitting Enter puts a newline in the widget (TextBox is
both the multiline and single line widget). If FALSE, hitting Enter
activates the default button for the window.

Havoc


  




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