chiark / gitweb /
Add documentation for `msg'.
[mgLib] / cancel.c
CommitLineData
1c48db0c 1/* -*-c-*-
2 *
8e774312 3 * $Id: cancel.c,v 1.2 1999/03/25 23:36:07 mdw Exp $
1c48db0c 4 *
5 * Handle Escape keypresses, directing them to cancel buttons
6 *
7 * (c) 1998 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mgLib GTK utilities library.
13 *
14 * mgLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * mgLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with mgLib; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29/*----- Revision history --------------------------------------------------*
30 *
31 * $Log: cancel.c,v $
8e774312 32 * Revision 1.2 1999/03/25 23:36:07 mdw
33 * Compile to nothing in absence of GTK, for the benefit of parent packages
34 * which contain non-GTK-dependent parts.
35 *
1c48db0c 36 * Revision 1.1 1998/12/11 09:44:21 mdw
37 * Initial version.
38 *
39 */
40
8e774312 41#ifdef HAVE_GTK
42
1c48db0c 43/*----- Header files ------------------------------------------------------*/
44
45#include <gtk/gtk.h>
46#include <gdk/gdkkeysyms.h>
47
48#include "cancel.h"
49
50/*----- Main code ---------------------------------------------------------*/
51
52/* --- @cancel@ --- *
53 *
54 * Arguments: @GtkWindow *win@ = window in which this is happening
55 * @GtkWidget *w@ = widget to activate, or null
56 *
57 * Returns: ---
58 *
59 * Use: Sets up @win@ so that a press of `escape' will activate
60 * @w@ or destroy @win@.
61 */
62
63static gboolean cancel_press(GtkWidget *w, GdkEventKey *ev, gpointer *p)
64{
65 if (ev->keyval == GDK_Escape) {
66 if (p)
67 gtk_widget_activate(GTK_WIDGET(p));
68 else
69 gtk_object_destroy(GTK_OBJECT(w));
70 return (1);
71 }
72 return (0);
73}
74
75void cancel(GtkWindow *win, GtkWidget *w)
76{
77 gtk_signal_connect(GTK_OBJECT(win), "key_press_event",
78 GTK_SIGNAL_FUNC(cancel_press), w);
79}
80
81/*----- That's all, folks -------------------------------------------------*/
8e774312 82
83#else
84 int mgLib_cancel = 0;
85#endif