Annotation of freem/src/mwapi_event.c, revision 1.2
1.1 snw 1: /*
2: * *
3: * * *
4: * * *
5: * ***************
6: * * * * *
7: * * MUMPS *
8: * * * * *
9: * ***************
10: * * *
11: * * *
12: * *
13: *
14: * mwapi_event.c
15: * mwapi event support
16: *
17: *
1.2 ! snw 18: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 19: * Copyright (C) 1998 MUG Deutschland
20: * Copyright (C) 2014, 2020, 2021 Coherent Logic Development LLC
21: *
22: *
23: * This file is part of FreeM.
24: *
25: * FreeM is free software: you can redistribute it and/or modify
26: * it under the terms of the GNU Affero Public License as published by
27: * the Free Software Foundation, either version 3 of the License, or
28: * (at your option) any later version.
29: *
30: * FreeM is distributed in the hope that it will be useful,
31: * but WITHOUT ANY WARRANTY; without even the implied warranty of
32: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33: * GNU Affero Public License for more details.
34: *
35: * You should have received a copy of the GNU Affero Public License
36: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
37: *
38: **/
39: #include "config.h"
40:
41: #if defined(HAVE_MWAPI_MOTIF)
42:
43: #include <stdlib.h>
44: #include <Xm/Xm.h>
45: #include "mpsdef0.h"
46: #include "mwapi_event.h"
47: #include "mwapi_window.h"
48:
49: short evt_sync_enabled = FALSE;
50: mwapi_event_queue_entry *mwapi_event_queue_head;
51:
52: mwapi_event *mwapi_event_new(char *evclass, char *window_name, Widget *window)
53: {
54: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
55: NULLPTRCHK(e,"mwapi_event_new");
56:
57: e->evclass = evclass;
58: e->window_name = window_name;
59: e->window = window;
60:
61: stcnv_m2c (e->window_name);
62:
63: return e;
64: }
65:
66: void mwapi_wire_event(mwapi_event *e, char *entryref)
67: {
68:
69: char m_gtk_ev[100];
70:
71: if (strcmp (e->evclass, "CLOSE") == 0) strcpy (m_gtk_ev, "destroy");
72:
73: e->entryref = (char *) malloc (strlen (entryref) * sizeof (char));
74: NULLPTRCHK(e->entryref,"mwapi_wire_event");
75:
76: strcpy (e->entryref, entryref);
77:
78: //g_signal_connect (e->window, m_gtk_ev, G_CALLBACK(mwapi_enqueue_event), (gpointer) e);
79:
80: }
81:
82: void mwapi_enqueue_event(Widget *widget, void *data)
83: {
84: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
85: NULLPTRCHK(e,"mwapi_enqueue_event");
86:
87: mwapi_event_queue_entry *t = (mwapi_event_queue_entry *) malloc (sizeof (mwapi_event_queue_entry));
88: NULLPTRCHK(t,"mwapi_enqueue_event");
89:
90: e = (mwapi_event *) data;
91:
92: //printf ("mwapi_enqueue_event(): evclass = '%s' window_name = '%s' entryref = '%s'\r\n\r\n", e->evclass, e->window_name, e->entryref);
93:
94: t->e = e;
95: t->next = mwapi_event_queue_head;
96: mwapi_event_queue_head = t;
97:
98: return;
99: }
100:
101: int mwapi_dequeue_events(char *result)
102: {
103:
104: mwapi_event_queue_entry *t;
105: int i = 0;
106:
107: for (t = mwapi_event_queue_head; t != NULL; t = t->next) {
108:
109: strcat (result, t->e->entryref);
110: strcat (result, ",");
111: i++;
112:
113: }
114:
115: // TODO: delete events
116: mwapi_event_queue_head = NULL;
117:
118: /* chop off the final comma */
119: result[strlen (result) - 1] = '\0';
120:
121: return i;
122:
123: }
124:
125: void mwapi_on_merge_complete(char *window_name)
126: {
127: mwapi_window *t;
128:
129: if (stcmp (window_name, "\201") == 0) {
130: /* we're merging to the global directly; no specified subscript */
131: /* we'll do a loop here */
132: }
133: else {
134: /* merging to a specific window */
135: t = mwapi_win_get (window_name);
136: mwapi_win_show (t);
137: }
138:
139: }
140:
141: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>