Convert uses of XKeycodeToKeysym (deprecated) to XkbKeycodeToKeysym
[oweals/cde.git] / cde / programs / ttsnoop / sessionChooser_stubs.C.src
1 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
2 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company
3 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.
4 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
5 //%%  (c) Copyright 1993, 1994 Novell, Inc.
6 //%%  $XConsortium: sessionChooser_stubs.C.src /main/3 1995/11/06 17:13:45 rswiston $
7 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
8
9 /*
10  * File: sessionChooser_stubs.c
11  * Contains: Module callbacks and connection functions
12  *
13  * This file was generated by dtcodegen, from module sessionChooser
14  *
15  * Any text may be added between the DTB_USER_CODE_START and
16  * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
17  * are provided only as an aid.
18  *
19  *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
20  *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
21  *  ** DELETE THE GENERATED COMMENTS!                                 **
22  */
23
24 #include <stdio.h>
25 #include <Xm/Xm.h>
26 #include "dtb_utils.h"
27 #include "sessionChooser_ui.h"
28
29 /*
30  * Header files for cross-module connections
31  */
32 #include "ttsnoop_ui.h"
33
34
35 /**************************************************************************
36  *** DTB_USER_CODE_START
37  ***
38  *** All necessary header files have been included.
39  ***
40  *** Add include files, types, macros, externs, and user functions here.
41  ***/
42
43 #include <Xm/TextF.h>
44
45 #include <fstream>
46 #include <sstream>
47
48 #include "DtTt.h"
49
50 extern std::ofstream snoopStream;
51
52 void
53 _DtSessionChooserSet(
54         _DtSessionChooserAction choice,
55         void *                  entity
56 )
57 {
58         char *okString;
59         char *title;
60         char *valueLabel;
61         switch (choice) {
62             case _DtSessionChoosePattern:
63                 okString = "Add";
64                 title = "tt_pattern_session_add";
65                 break;
66             case _DtSessionChooseMessage:
67                 okString = "Set";
68                 title = "tt_message_session_set";
69                 break;
70             case _DtSessionChooseJoin:
71                 okString = "Join";
72                 title = "tt_session_join";
73                 break;
74             case _DtSessionChooseDtJoin:
75                 okString = "Join";
76                 title = "ttdt_session_join";
77                 break;
78             case _DtSessionChooseQuit:
79                 okString = "Quit";
80                 title = "tt_session_quit";
81                 break;
82             case _DtSessionChooseDefault:
83                 okString = "Set";
84                 title = "tt_default_session_set";
85                 break;
86             default:
87                 return;
88         }
89         DtbSessionChooserSessionChooserInfo instance =
90                 &dtb_session_chooser_session_chooser;
91         if (! instance->initialized) {
92                 dtb_session_chooser_session_chooser_initialize(
93                         instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
94         }
95         DtTtSetLabel( instance->sessionOkButton, okString );
96         XtVaSetValues( instance->sessionChooser, XmNtitle, title, NULL );
97         // Remember dialog mode, entity
98         XtVaSetValues( instance->sessionOkButton, XmNuserData, choice, NULL );
99         XtVaSetValues( instance->sessionCancelButton, XmNuserData, entity, NULL );
100         XmTextPosition last =
101                 XmTextFieldGetLastPosition( instance->sessionText );
102         Time when =
103                 XtLastTimestampProcessed( XtDisplay( instance->sessionText ));
104         XmTextFieldSetSelection( instance->sessionText, 0, last, when );
105         XtManageChild( instance->sessionChooser_shellform );
106 }
107
108 static Tt_message
109 snoopSessionMsg(
110         Tt_message      msg,
111         void *          clientData,
112         Tt_message      contract
113 )
114 {
115         DtTtCreated( DTTT_MESSAGE, msg );
116         snoopIt( "Ttdt_contract_cb", (void *) snoopSessionMsg, msg );
117         if (   (tt_message_class( msg ) == TT_REQUEST)
118             && (tt_message_state( msg ) == TT_SENT))
119         {
120                 // Let user fill in the answer
121                 Widget newWidget = DtTtMessageWidgetCreate(
122                                     dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
123                                     msg, DtTtMessageWidgetUpdate );
124                 if (! tt_is_err( tt_ptr_error( newWidget ) )) {
125                         XRaiseWindow( XtDisplay( newWidget ),
126                                       XtWindow( newWidget ));
127                 }
128         }
129         return 0;
130 }
131
132 /*** DTB_USER_CODE_END
133  ***
134  *** End of user code section
135  ***
136  **************************************************************************/
137
138
139
140 void 
141 sessionChooser_sessionCancelButton_CB1(
142     Widget widget,
143     XtPointer clientData,
144     XtPointer callData
145 )
146 {
147     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
148     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
149     
150     DtbSessionChooserSessionChooserInfo instance = (DtbSessionChooserSessionChooserInfo)clientData;
151     
152     if (!(instance->initialized))
153     {
154         dtb_session_chooser_session_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
155     }
156     XtUnmanageChild(instance->sessionChooser_shellform);
157     
158     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
159     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
160 }
161
162
163 void 
164 defaultSession(
165     Widget widget,
166     XtPointer clientData,
167     XtPointer callData
168 )
169 {
170     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
171     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
172     
173     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
174     DtbSessionChooserSessionChooserInfo instance =
175             (DtbSessionChooserSessionChooserInfo)clientData;
176     char *sess = tt_default_session();
177     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
178                                      "tt_default_session()", sess );
179     if (tt_is_err( status )) {
180             return;
181     }
182     XmTextFieldSetString( instance->sessionText, sess );
183     tt_free( sess );
184     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
185 }
186
187
188 void 
189 sessionOK(
190     Widget widget,
191     XtPointer clientData,
192     XtPointer callData
193 )
194 {
195     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
196     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
197     
198     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
199     DtbSessionChooserSessionChooserInfo instance =
200             (DtbSessionChooserSessionChooserInfo)clientData;
201     char *session = XmTextFieldGetString( instance->sessionText );
202     if ((session != 0) && (session[0] == '\0')) {
203             XtFree( session );
204             session = 0;
205     }
206     XtPointer val;
207     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
208     _DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
209     XtVaGetValues( instance->sessionCancelButton, XmNuserData, &val, NULL );
210     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
211     switch (choice) {
212             Tt_status status;
213             Tt_pattern *pats;
214         case _DtSessionChoosePattern:
215             _DtTtPatternUpdate( (Tt_pattern)val, choice, session );
216             break;
217         case _DtSessionChooseMessage:
218             _DtTtMessageUpdate( (Tt_message)val, choice, session );
219             break;
220         case _DtSessionChooseJoin:
221             status = tt_session_join( session );
222             DtTtSetLabel( label, "tt_session_join()", status );
223             break;
224         case _DtSessionChooseDtJoin:
225             pats = ttdt_session_join( session, snoopSessionMsg,
226                                 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, 0, 1 );
227             status = DtTtSetLabel( label, "ttdt_session_join()", pats );
228             if ((status == TT_OK) && (pats != 0)) {
229                     DtTtCreated( DTTT_DTSESSION, pats, session );
230             }
231             break;
232         case _DtSessionChooseQuit:
233             status = tt_session_quit( session );
234             DtTtSetLabel( label, "tt_session_quit()", status );
235             break;
236         case _DtSessionChooseDefault:
237             status = tt_default_session_set( session );
238             DtTtSetLabel( label, "tt_default_session_set()", status );
239             break;
240         default:
241             break;
242     }
243     if (session != 0) {
244             XtFree( session );
245     }
246     XtUnmanageChild(instance->sessionChooser_shellform);
247     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
248 }
249
250
251 void 
252 sessionHelp(
253     Widget widget,
254     XtPointer clientData,
255     XtPointer callData
256 )
257 {
258     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
259     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
260     
261     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
262     DtbSessionChooserSessionChooserInfo instance =
263             (DtbSessionChooserSessionChooserInfo)clientData;
264     XtPointer val;
265     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
266     _DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
267     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
268     switch (choice) {
269         case _DtSessionChoosePattern:
270             _DtMan( label, "tt_pattern_session_add" );
271             break;
272         case _DtSessionChooseMessage:
273             _DtMan( label, "tt_message_session_set" );
274             break;
275         case _DtSessionChooseJoin:
276             _DtMan( label, "tt_session_join" );
277             break;
278         case _DtSessionChooseDtJoin:
279             _DtMan( label, "ttdt_session_join" );
280             break;
281         case _DtSessionChooseQuit:
282             _DtMan( label, "tt_session_quit" );
283             break;
284         case _DtSessionChooseDefault:
285             _DtMan( label, "tt_default_session_set" );
286             break;
287         default:
288             break;
289     }
290     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
291 }
292
293
294 void 
295 xSession(
296     Widget widget,
297     XtPointer clientData,
298     XtPointer callData
299 )
300 {
301     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
302     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
303     
304     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
305     DtbSessionChooserSessionChooserInfo instance =
306             (DtbSessionChooserSessionChooserInfo)clientData;
307     char *sess = tt_X_session( getenv( "DISPLAY" ));
308     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
309                                 "tt_X_session( getenv( \"DISPLAY\" ))", sess );
310     if (tt_is_err( status )) {
311             return;
312     }
313     XmTextFieldSetString( instance->sessionText, sess );
314     tt_free( sess );
315     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
316 }
317
318
319 void 
320 initialSession(
321     Widget widget,
322     XtPointer clientData,
323     XtPointer callData
324 )
325 {
326     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
327     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
328     
329     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
330     DtbSessionChooserSessionChooserInfo instance =
331             (DtbSessionChooserSessionChooserInfo)clientData;
332     char *sess = tt_initial_session();
333     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
334                                      "tt_initial_session()", sess );
335     if (tt_is_err( status )) {
336             return;
337     }
338     XmTextFieldSetString( instance->sessionText, sess );
339     tt_free( sess );
340     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
341 }
342
343
344
345 /**************************************************************************
346  *** DTB_USER_CODE_START
347  ***
348  *** All automatically-generated data and functions have been defined.
349  ***
350  *** Add new functions here, or at the top of the file.
351  ***/
352
353 /*** DTB_USER_CODE_END
354  ***
355  *** End of user code section
356  ***
357  **************************************************************************/
358
359