Mercurial > gftp.yaz
changeset 72:c48f19f24050
2002-12-2 Brian Masney <masneyb@gftp.org>
* src/gtk/misc-gtk.c (MakeEditDialog) - bind to enter and esc keys
author | masneyb |
---|---|
date | Tue, 03 Dec 2002 02:22:32 +0000 |
parents | 1ea16d3b5827 |
children | c226809c03c8 |
files | ChangeLog src/gtk/misc-gtk.c |
diffstat | 2 files changed, 41 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Dec 02 23:51:31 2002 +0000 +++ b/ChangeLog Tue Dec 03 02:22:32 2002 +0000 @@ -1,3 +1,6 @@ +2002-12-2 Brian Masney <masneyb@gftp.org> + * src/gtk/misc-gtk.c (MakeEditDialog) - bind to enter and esc keys + 2002-11-27 Brian Masney <masneyb@gftp.org> * Officially release 2.0.14rc1 @@ -340,7 +343,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.42 2002/11/27 14:29:54 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.43 2002/12/03 02:22:30 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/src/gtk/misc-gtk.c Mon Dec 02 23:51:31 2002 +0000 +++ b/src/gtk/misc-gtk.c Tue Dec 03 02:22:32 2002 +0000 @@ -832,7 +832,7 @@ dialog_response (GtkWidget * widget, gint response, gftp_dialog_data * ddata) { if (ddata->edit == NULL) - gtk_widget_destroy (widget); + gtk_widget_destroy (ddata->dialog); switch (response) { @@ -847,13 +847,42 @@ } if (ddata->edit != NULL) - gtk_widget_destroy (widget); + gtk_widget_destroy (ddata->dialog); g_free (ddata); } #endif +static gint +dialog_keypress (GtkWidget * widget, GdkEventKey * event, gpointer data) +{ + if (event->type != GDK_KEY_PRESS) + return (FALSE); + + if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return) + { +#if GTK_MAJOR_VERSION == 1 + ok_dialog_response (widget, data); +#else + dialog_response (widget, GTK_RESPONSE_YES, data); +#endif + return (TRUE); + } + else if (event->keyval == GDK_Escape) + { +#if GTK_MAJOR_VERSION == 1 + cancel_dialog_response (widget, data); +#else + dialog_response (widget, GTK_RESPONSE_NO, data); +#endif + return (TRUE); + } + + return (FALSE); +} + + void MakeEditDialog (char *diagtxt, char *infotxt, char *deftext, int passwd_item, char *checktext, @@ -926,6 +955,9 @@ gtk_widget_show (tempwid); ddata->edit = gtk_entry_new (); + gtk_signal_connect (GTK_OBJECT (ddata->edit), "key_press_event", + GTK_SIGNAL_FUNC (dialog_keypress), (gpointer) ddata); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ddata->edit, TRUE, TRUE, 0); gtk_widget_grab_focus (ddata->edit); @@ -1051,8 +1083,8 @@ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (ok_dialog_response), - ddata); + GTK_SIGNAL_FUNC (ok_dialog_response), ddata); + gtk_widget_grab_default (tempwid); gtk_widget_show (tempwid); @@ -1061,8 +1093,7 @@ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (cancel_dialog_response), - ddata); + GTK_SIGNAL_FUNC (cancel_dialog_response), ddata); gtk_widget_show (tempwid); #else