]> andersk Git - moira.git/blob - clients/mmoira/stubs.c
*** empty log message ***
[moira.git] / clients / mmoira / stubs.c
1 /*
2 ** Stub functions
3 */
4
5 #include        <X11/StringDefs.h>
6 #include        <X11/Intrinsic.h>
7 #include        <X11/IntrinsicP.h>
8 #include        <X11/Core.h>
9 #include        <X11/CoreP.h>
10 #include        <X11/CompositeP.h>
11 #include        <X11/cursorfont.h>
12 #include        "data.h"
13 #include        <Xm/Text.h>
14
15 static char rcsid[] = "$Header$";
16
17 void    extra_help_callback();
18
19 static Widget   logwidget = NULL;
20
21 Widget
22 SetupLogWidget(parent)
23 Widget  parent;
24 {
25         Arg             wargs[10];
26         int             n;
27
28         if (logwidget)
29                 return (logwidget);
30         
31         n = 0;
32         XtSetArg(wargs[n], XmNeditMode, XmMULTI_LINE_EDIT);     n++;
33         XtSetArg(wargs[n], XmNeditable, False);                 n++;
34
35         logwidget = XmCreateScrolledText(       parent,
36                                                 "logwidget", 
37                                                 wargs, n);
38         XtManageChild(logwidget);
39
40         return (logwidget);
41 }
42
43 /*
44 ** PopupErrorMessage(text)
45 **
46 ** Given a char* pointing to an error message, possibly with imbedded
47 ** newlines, display the text in a popup window and put two buttons
48 ** at the bottom of the window, labelled "OK" and "Cancel."  Pop down
49 ** when one of the buttons is pressed.
50 **
51 ** Return 0 if "OK" is pressed, 1 for "Cancel."
52 */
53
54 Boolean
55 PopupErrorMessage(text, extrahelp)
56 char    *text;
57 char    *extrahelp;
58 {
59         static Widget           child;
60         Arg             wargs[10];
61         int             n;
62         static XmString        label;
63
64         if (label) {
65                 XtFree(label);
66                 XtDestroyWidget(child);
67         }
68
69
70         label = XmStringCreateLtoR( text, XmSTRING_DEFAULT_CHARSET);
71
72         n = 0;
73         XtSetArg(wargs[n], XmNmessageString, label);            n++;
74
75         child = (Widget) XmCreateErrorDialog(logwidget, "errormessage", wargs, n);
76         if (extrahelp) 
77                 XtAddCallback (child, XmNhelpCallback, extra_help_callback, extrahelp);
78         else
79                 XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_HELP_BUTTON));
80         XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_CANCEL_BUTTON));
81         XtManageChild(child);
82 }
83
84 /*
85 ** PopupHelpWindow(text)
86 **
87 ** Given a char* pointing to an help message, possibly with imbedded
88 ** newlines, display the text in a popup window and put a single button
89 ** at the bottom of the window, labelled "OK."  Pop down when the
90 ** the buttons is pressed.
91 */
92
93 void
94 PopupHelpWindow(text)
95 char    *text;
96 {
97         static Widget           child;
98         Arg             wargs[10];
99         int             n;
100
101         static XmString        label;
102         if (label) {
103                 XtFree(label);
104                 XtDestroyWidget(child);
105         }
106
107         label = XmStringCreateLtoR( text, XmSTRING_DEFAULT_CHARSET);
108
109         n = 0;
110         XtSetArg(wargs[n], XmNmessageString, label);            n++;
111
112         child = (Widget) XmCreateMessageDialog(logwidget, "helpmessage", wargs, n);
113         XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_CANCEL_BUTTON));
114         XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_HELP_BUTTON));
115
116         XtManageChild(child);
117 }
118
119 /*
120 ** Given a char* to a single line of text, append this line at the bottom
121 ** of the log window.  Return 0 of the append was sucessful, non-zero
122 ** for an error condition.
123 */
124
125 int
126 AppendToLog(text)
127 char    *text;
128 {
129         XmTextPosition  pos;
130         char            *string;
131
132         string = XmTextGetString(logwidget);
133         pos = strlen(string);
134         XtFree(string);
135
136         XmTextReplace(logwidget, pos, pos, text);
137         XmTextSetCursorPosition(logwidget, pos + strlen(text));
138 }
139
140 void
141 MakeWatchCursor(topW)
142 Widget  topW;
143 {
144         Cursor  mycursor;
145
146         if (!topW)
147                 return;
148
149         mycursor = XCreateFontCursor (XtDisplay(topW), XC_watch);
150         XDefineCursor(XtDisplay(topW), XtWindow(topW), mycursor);
151 }
152
153 void
154 MakeNormalCursor(topW)
155 Widget  topW;
156 {
157         if (!topW)
158                 return;
159
160         XUndefineCursor(XtDisplay(topW), XtWindow(topW));
161 }
162
163 /*
164 ** Move through the fields of the spec and make certain that the
165 ** form's widgets actually reflect the current values.
166 */
167
168 void
169 UpdateForm(spec)
170 EntryForm       *spec;
171 {
172         UserPrompt      **myinputlines = spec->inputlines;
173         UserPrompt      *current;
174         Arg             wargs[10];
175         int             n, kidcount;
176         Widget          kid;
177
178         for (   current = (*myinputlines);
179                 current; 
180                 myinputlines++, current = (*myinputlines)) {
181
182
183                 switch (current->type) {
184                 case FT_STRING:
185                         if (current->returnvalue.stringvalue) {
186                                 XmTextSetString (current->mywidget, current->returnvalue.stringvalue);
187                         }
188                         break;
189
190                 case FT_BOOLEAN:
191                         n = 0;
192                         XtSetArg(wargs[n], XmNset,
193                                  current->returnvalue.booleanvalue ? True : False);     n++;
194                         XtSetValues (current->mywidget, wargs, n);
195                         break;
196
197                 case FT_KEYWORD:
198                         kidcount = ((CompositeRec *)(current->mywidget))->
199                                         composite.num_children;
200
201                         while(kidcount--) {
202                                 n = 0;
203                                 kid = ((CompositeRec *)(current->mywidget))->
204                                         composite.children[kidcount];
205                                 if (current->returnvalue.stringvalue &&
206                                         (!strcmp (XtName(kid), current->returnvalue.stringvalue))) {
207                                         XtSetArg(wargs[n], XmNset, True);
208                                         n++;
209                                 }
210                                 else {
211                                         XtSetArg(wargs[n], XmNset, False);
212                                         n++;
213                                 }
214                                 XtSetValues (kid, wargs, n);
215                         }
216                         break;
217
218                 case FT_NUMBER:
219                         break;
220                 }
221                 n = 0;
222                 XtSetArg(wargs[n], XtNsensitive, !(current->insensitive));              n++;
223                 XtSetValues (current->mywidget, wargs, n);
224         }
225 }
226
227 void
228 extra_help_callback(w, client_data, call_data)
229 Widget  w;
230 char    *client_data;
231 XmAnyCallbackStruct     *call_data;
232 {
233         PopupHelpWindow(client_data);
234 }
This page took 0.058648 seconds and 5 git commands to generate.