Ethereal-dev: Re: [ethereal-dev] misc. suggestions for go to frame

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Thu, 16 Mar 2000 23:44:32 -0800
> > > go to frame - take focus in entry area when bringing up window
> 
> gtk_widget_grab_focus(entrywidget);

I've checked that in, for "Find Frame" and "Go To Frame" at least.

> > > go to frame - accept 'enter/return' as submitting the request
> > 
> > Isn't GTK+ wonderful?  I'll have to check into what needs to be done to
> > make it do that, assuming the mere presence of an entry area renders it
> > incapable of treating <Enter> as meaning "activate the default button"
> > even if you're in a GtkEntry widget rather than a GtkText widget (where
> > <Enter> has to mean "insert a newline").
> 
>         gtk_signal_connect(GTK_OBJECT(scw->entry_msg), "activate",
>                 GTK_SIGNAL_FUNC(startchat_callback), (gpointer) scw);
> 
> I use that in gtkyahoo.

I have an experimental "GtkDialogBox" widget, which pops up a new window
with a specified title, a specified parent window, and a mode specified
either as "non-modal" or "modal" (API shamelessly modeled after that of
QDialog in Qt), and which...

> > (It'd be even more wonderful if it could be arranged that <Esc> means
> > "activate the Cancel button of a dialog box" in GTK+; given that <Esc>F
> > does *NOT* appear to mean "next word" in that GtkEntry widget, this
> > presumably isn't another consequence of trying to provide EMACS-like key
> > bindings, as UNIX Netscape's use of <Alt>+{C,V,X} instead of
> > <Ctrl>+{C,V,X} and *lack* of use of <Alt> to introduce a mnemonic to
> > e.g. pop up menus from the menu bar apparently is.)
> 
> You probably just need to add a event handler for the keypress event and
> trap it if it's escape.

...grabs the keypress event and grabs Escape *AND* Return *AND* the
keypad "Enter" key.  You can specify a "Cancel" button for the widget;
if such a widget exists, the Escape key activates it.  If there's a
default widget for the dialog box window, Return and keypad Enter
activate it - which obviates the need to connect a signal to any
GtkEntry widgets in the dialog box itself.

That seems to make Return and Escape do what I want, namely to have the
former hit the "OK" button and the latter hit the "Cancel" button.

There's more tweaking I might want to do, but it's at least a start.

(Ultimately, I'd like to send it to the GTK+ folk, as something that
acts like a Standard Dialog Box, Dammit - i.e., lets you activate it
with <Return> and cancel it with <Escape> - might be useful.  Windows
dialog boxes can be made to do that, Motif dialog boxes can be made to
do that, I suspect that in Qt you can do it by setting up button widgets
to poke the right slots in a QDialog and presumably a KDialog works the
same way - but there's no standard way to do that in GTK+, and a quick
look at the GNOME API doesn't show one either.)