source: trunk/athena/bin/xquota/widgets.c @ 1816

Revision 1816, 21.1 KB checked in by kit, 35 years ago (diff)
Check to see of XtOpenDisplay returns NULL.
Line 
1/*
2 * xquota -  X window system quota display program.
3 *
4 * $Athena: widgets.c,v 1.3 89/03/28 16:43:36 kit Locked $
5 *
6 * Copyright 1989 Massachusetts Institute of Technology
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation for any purpose and without fee is hereby granted, provided
10 * that the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of M.I.T. not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission.  M.I.T. makes no representations about the
15 * suitability of this software for any purpose.  It is provided "as is"
16 * without express or implied warranty.
17 *
18 * Author:    Chris D. Peterson, MIT Project Athena
19 * Created:   March 5, 1989
20 */
21
22#if ( !defined(lint) && !defined(SABER))
23  static char rcs_version[] = "$Athena: widgets.c,v 1.3 89/03/28 16:43:36 kit Locked $";
24#endif
25
26#include <stdio.h>
27#include <X11/Intrinsic.h>
28#include <X11/StringDefs.h>
29
30#include <X11/AsciiText.h>
31#include <X11/Command.h>
32#include <X11/Label.h>
33#include <X11/Scroll.h>
34#include <X11/Shell.h>
35#include <X11/Paned.h>
36
37#include "xquota.h"
38
39static void CheckProc(), DoneProc(), QuitProc(), TopHelpProc();
40static void FlipColors(), TimeOutProc(), PopupHelpProc(), KillHelpProc();
41static void CreateButtonPane(), CreateQuotaDisplay();
42static void QuitAction(), PopInfoAction(), QuotaCheckAction();
43static void PrintHelpAction();
44static void LoadApplicationResources();
45static Widget CreateHelpWidget();
46static void ShowTopHelp(), ShowPopupHelp();
47
48extern Info info;                       /* external for action proc only. */
49
50#define Offset(field) (XtOffset(Info *, field))
51
52static XtResource quota_resources[] = {
53  {"warning", "Warning", XtRInt, sizeof(int),
54     Offset(warn), XtRImmediate, (caddr_t) DEFAULT_WARNING},
55  {"update", "Update", XtRInt, sizeof(int),
56     Offset(minutes), XtRImmediate, (caddr_t) DEFAULT_UPDATE},
57  {"numbers", "Numbers", XtRBoolean, sizeof(Boolean),
58     Offset(numbers), XtRImmediate, (caddr_t) TRUE},
59  {"spaceSaver", "SpaceSaver", XtRBoolean, sizeof(Boolean),
60     Offset(space_saver), XtRImmediate, (caddr_t) FALSE},
61  {"topHelpFile", "TopHelpFile", XtCString, sizeof(String),
62     Offset(top_help_file), XtRString, (caddr_t) TOP_HELP_FILE},
63  {"popupHelpFile", "PopupHelpFile", XtCString, sizeof(String),
64     Offset(popup_help_file), XtRString, (caddr_t) POPUP_HELP_FILE},
65};
66
67static XrmOptionDescRec quota_options[] = {
68{"-warning",    ".warning",    XrmoptionSepArg, (caddr_t) NULL},
69{"-update",     ".update",     XrmoptionSepArg, (caddr_t) NULL},
70{"-nonumbers",  ".numbers",    XrmoptionNoArg,  (caddr_t) "off"},
71{"-spacesaver", ".spaceSaver", XrmoptionNoArg,  (caddr_t) "on"},
72};
73
74static XtActionsRec actions[] = {
75  { "PopInfo", PopInfoAction },
76  { "QuotaCheck", QuotaCheckAction },
77  { "PrintHelp", PrintHelpAction },
78  { "Quit", QuitAction }
79};
80
81/*      Function Name: InitializeWorld
82 *      Description: Initializes everything for the quota check program.
83 *                   In preparation for createing widgets.
84 *      Arguments: info - the psuedo globals struct.
85 *                 argc, and argv - command line args.
86 *      Returns: the top level shell widget.
87 *
88 * NOTES: sets the applications context.
89 */
90
91Widget
92InitializeWorld(info, argc, argv)
93Info * info;
94int * argc;
95char ** argv;
96{
97  Widget shell;
98  Display * disp;
99
100  XtToolkitInitialize();
101  info->appcon = XtCreateApplicationContext();
102  disp = XtOpenDisplay(info->appcon, NULL, NULL, APP_CLASS, quota_options,
103                       XtNumber(quota_options), argc, argv);
104  if (disp == NULL)
105    XtAppError(info->appcon, "Xquota: Could not open the display.");
106
107  LoadApplicationResources(DEFAULTS_FILE, disp);
108  shell = XtAppCreateShell(NULL, APP_CLASS, applicationShellWidgetClass,
109                           disp, NULL, (Cardinal) 0);
110  XtGetApplicationResources(shell, (caddr_t) info,
111                            quota_resources, XtNumber(quota_resources),
112                            NULL, (Cardinal) 0);
113
114  XtAppAddActions(info->appcon, actions, XtNumber(actions));
115
116/*
117 * A few final checks.
118 */
119
120  info->flipped = FALSE;
121  info->timeout = NULL;
122  info->top_help = info->popup_help = NULL;
123
124  if (info->minutes < MIN_UPDATE) {
125    printf("The minimum update time is every %d minutes.\n", MIN_UPDATE);
126    info->minutes = MIN_UPDATE;
127  }
128   
129  return(shell);
130}
131
132/*      Function Name: CreateWidgets
133 *      Description: Creates all widgets that are decendants of the shell.
134 *      Arguments: shell - the shell widget that all these are decended from.
135 *                 info - structure with psuedo global info.
136 *      Returns: none.
137 */
138
139void
140CreateWidgets(shell, info)
141Widget shell;
142Info * info;
143{
144  Arg arglist[2];
145  Cardinal num_args;
146  Widget pane;
147
148  pane = XtCreateManagedWidget("topPane", panedWidgetClass, shell,
149                               NULL, (Cardinal) 0);
150 
151  if (info->numbers && !info->space_saver) {
152    info->quota_top = XtCreateManagedWidget("quota", labelWidgetClass, pane,
153                                        NULL, (Cardinal) 0);
154
155    info->used_top = XtCreateManagedWidget("used", labelWidgetClass, pane,
156                                       NULL, (Cardinal) 0);
157  }
158
159  num_args = 0;
160  XtSetArg( arglist[num_args], XtNtranslations,
161            XtParseTranslationTable("")); num_args++;
162  info->graph = XtCreateManagedWidget("graph", scrollbarWidgetClass, pane,
163                                      arglist, num_args);
164
165  if (!info->space_saver) {
166    Widget help;
167    num_args = 0;
168    XtSetArg( arglist[num_args], XtNskipAdjust, TRUE); num_args++;
169    help = XtCreateManagedWidget("help", commandWidgetClass, pane,
170                                 arglist, num_args);
171    XtAddCallback(help, XtNcallback, TopHelpProc, (caddr_t) info);
172  }
173
174  CreateInfoPopup(info);
175  ShowQuota(info);
176}
177
178/*      Function Name: CreateInfoPopup
179 *      Description: Creates the popup that will scream at you.
180 *      Arguments: info - the info structure.
181 *      Returns: none.
182 */
183
184void
185CreateInfoPopup(info)
186Info * info;
187{
188  Widget pane;
189  Arg arglist[5];
190  Cardinal num_args;
191  Dimension width, height;
192  Position x, y;
193  char buf[BUFSIZ], *string;
194
195  info->info_popup = XtCreatePopupShell("quotaInfo", transientShellWidgetClass,
196                                    info->graph, NULL, 0);
197
198  pane = XtCreateManagedWidget("infoPane", panedWidgetClass, info->info_popup,
199                               NULL, 0);
200
201  num_args = 0;
202  XtSetArg( arglist[num_args], XtNlabel, buf); num_args++; 
203
204  sprintf(buf, "%s - %s", VERSION, AUTHOR);
205  (void) XtCreateManagedWidget("version", labelWidgetClass, pane,
206                               arglist, num_args);
207
208  sprintf(buf, "Machine:  %s - Filesystem:  %s ", info->host, info->path);
209  (void) XtCreateManagedWidget("machine", labelWidgetClass, pane,
210                               arglist, num_args);
211
212  CreateQuotaDisplay(info, pane);
213
214  info->last_widget = XtCreateManagedWidget("last", labelWidgetClass, pane,
215                                            NULL, (Cardinal) 0);
216
217  string = XtMalloc( sizeof(char) * TEXT_BUFFER_LENGTH);
218  strcpy(string, SAFE_MESSAGE);
219
220  num_args = 0;
221  XtSetArg( arglist[num_args], XtNtextOptions, scrollVertical | wordBreak);
222  num_args++; 
223  XtSetArg( arglist[num_args], XtNeditType, XttextEdit); num_args++; 
224  XtSetArg( arglist[num_args], XtNlength, TEXT_BUFFER_LENGTH); num_args++; 
225  XtSetArg( arglist[num_args], XtNstring, string); num_args++; 
226  info->message_widget = XtCreateManagedWidget("message",
227                                               asciiStringWidgetClass, pane,
228                                               arglist, num_args);
229
230  CreateButtonPane(info, pane);
231  XtRealizeWidget(info->info_popup);
232
233  num_args = 0;
234  XtSetArg( arglist[num_args], XtNwidth, &width); num_args++;
235  XtSetArg( arglist[num_args], XtNheight, &height);num_args++;
236  XtGetValues(info->info_popup, arglist, num_args);
237 
238  x = (Position) (XtScreen(info->info_popup)->width - width)/2;
239  y = (Position) (XtScreen(info->info_popup)->height - height)/2;
240
241  num_args = 0;
242  XtSetArg( arglist[num_args], XtNx, x); num_args++; 
243  XtSetArg( arglist[num_args], XtNy, y); num_args++; 
244  XtSetValues(info->info_popup, arglist, num_args);
245}
246
247/*      Function Name: CreateQuotaDisplay
248 *      Description: Displays quota information.
249 *      Arguments: info - the info struct.
250 *                 parent - its parent.
251 *      Returns: none
252 */
253
254static void
255CreateQuotaDisplay(info, parent)
256Info * info;
257Widget parent;
258{
259  char buf[BUFSIZ];
260  Widget pane;
261  Arg arglist[10];
262  Cardinal num_args;
263
264  pane = XtCreateManagedWidget("quotaPane", panedWidgetClass, parent,
265                               NULL, (Cardinal) 0);
266
267  sprintf(buf, "%12s %10s %10s", "", "Kilobytes", "Files");
268  num_args = 0;
269  XtSetArg( arglist[num_args], XtNlabel, buf); num_args++; 
270  (void) XtCreateManagedWidget("Types", labelWidgetClass, pane,
271                               arglist, num_args);
272
273  info->hard_widget = XtCreateManagedWidget("hard", labelWidgetClass, pane,
274                                            NULL, (Cardinal) 0);
275  info->soft_widget = XtCreateManagedWidget("soft", labelWidgetClass, pane,
276                                            NULL, (Cardinal) 0);
277  info->used_widget = XtCreateManagedWidget("used", labelWidgetClass, pane,
278                                            NULL, (Cardinal) 0);
279}
280
281/*      Function Name: CreateButtonPane
282 *      Description: Create the pane with the command buttons in it.
283 *      Arguments: info - info struct.
284 *                 parent - parent widget.
285 *      Returns: none.
286 */
287
288static void
289CreateButtonPane(info, parent)
290Info * info;
291Widget parent;
292{
293  Widget hpane, check, help, done, quit;
294  Arg arglist[2];
295  Cardinal num_args;
296
297  num_args = 0;
298  XtSetArg( arglist[num_args], XtNorientation, XtorientHorizontal);
299  num_args++; 
300  XtSetArg( arglist[num_args], XtNskipAdjust, TRUE); num_args++; 
301  hpane = XtCreateManagedWidget("hPane", panedWidgetClass, parent,
302                                arglist, num_args);
303
304  done = XtCreateManagedWidget("done", commandWidgetClass, hpane,
305                               NULL, (Cardinal) 0);
306
307  help = XtCreateManagedWidget("help", commandWidgetClass, hpane,
308                               NULL, (Cardinal) 0);
309
310  check = XtCreateManagedWidget("check", commandWidgetClass, hpane,
311                               NULL, (Cardinal) 0);
312  num_args = 0;
313  XtSetArg( arglist[num_args], XtNmappedWhenManaged, FALSE); num_args++; 
314  (void) XtCreateManagedWidget("spacer", labelWidgetClass, hpane,
315                               arglist, num_args);
316  num_args = 0;
317  XtSetArg( arglist[num_args], XtNskipAdjust, TRUE); num_args++; 
318  quit = XtCreateManagedWidget("quit", commandWidgetClass, hpane,
319                               arglist, num_args);
320
321  XtAddCallback(help,  XtNcallback, PopupHelpProc, (caddr_t) info);
322  XtAddCallback(check, XtNcallback, CheckProc,     (caddr_t) info);
323  XtAddCallback(done,  XtNcallback, DoneProc,      (caddr_t) info);
324  XtAddCallback(quit,  XtNcallback, QuitProc,      (caddr_t) NULL);
325}
326
327/*      Function Name: CreateHelpWidget
328 *      Description: Creates a help widget.
329 *      Arguments: filename - name of file to load.
330 *                 parent - its parent widget.
331 *      Returns: the help widget we just created.
332 */
333
334static Widget
335CreateHelpWidget(filename, parent)
336String filename;
337Widget parent;
338{
339  Widget shell, pane, kill;
340  Arg arglist[4];
341  Cardinal num_args = 0;
342
343  shell = XtCreatePopupShell("help", topLevelShellWidgetClass,
344                             parent, NULL, 0);
345
346  pane = XtCreateManagedWidget("helpPane", panedWidgetClass, shell,
347                               arglist, num_args);
348
349  kill = XtCreateManagedWidget("killHelp", commandWidgetClass, pane,
350                               arglist, num_args);
351
352  XtAddCallback(kill, XtNcallback, KillHelpProc, (caddr_t) shell);
353 
354  num_args = 0;
355  XtSetArg( arglist[num_args], XtNtextOptions, scrollVertical | wordBreak ) ;
356  num_args++;
357  XtSetArg( arglist[num_args], XtNfile, filename ) ;
358  num_args++;
359  (void) XtCreateManagedWidget("text", asciiDiskWidgetClass, pane,
360                               arglist, num_args);
361  return(shell);
362}
363 
364/*      Function Name: ShowTopHelp
365 *      Description: Show the top help.
366 *      Arguments: info - the info struct.
367 *      Returns: none
368 */
369
370static void
371ShowTopHelp(info)
372Info * info;
373{
374  if (info->top_help == NULL)
375    info->top_help = CreateHelpWidget(info->top_help_file, info->graph);
376
377  XtPopup(info->top_help, XtGrabNone);
378}
379
380/*      Function Name: ShowPopupHelp
381 *      Description: Show the popup help.
382 *      Arguments: info - the info struct.
383 *      Returns: none.
384 */
385
386static void
387ShowPopupHelp(info)
388Info * info;
389{
390  if (info->popup_help == NULL)
391    info->popup_help = CreateHelpWidget(info->popup_help_file,
392                                        info->info_popup);
393
394  XtPopup(info->popup_help, XtGrabNone);
395}
396
397
398/************************************************************
399 *
400 *  Action Proceedures.
401 *
402 ************************************************************/
403
404/*      Function Name: PopInfoAction
405 *      Description: Pops information window.
406 *      Arguments: w - the widget that got the proceedure.    ** NOT USED **
407 *                 event - the event that caused the actions. ** NOT USED **
408 *                 params, num_params - args passed to proc. 
409 *      Returns: none.
410 */
411
412/* ARGSUSED */
413static void
414PopInfoAction(w, event, params, num_params)
415Widget w;
416XEvent * event;
417String * params;
418Cardinal * num_params;
419{
420  if (*num_params != 1) {
421    printf("PopInfo: number of parameters passed was not 1.\n");
422    return;
423  }
424  switch (params[0][0]) {
425  case 'U':
426  case 'u':
427    XtPopup(info.info_popup, XtGrabNone);
428    break;
429  case 'D':
430  case 'd':
431    XtPopdown(info.info_popup);
432    break;
433  default:
434    printf("PopInfo: specify either 'Up' or 'Down'.\n");
435    break;
436  }
437}
438
439/*      Function Name: QuitAction
440 *      Description: exits
441 *      Arguments: w - the widget that got the proceedure.    ** NOT USED **
442 *                 event - the event that caused the actions. ** NOT USED **
443 *                 params, num_params - args passed to proc.  ** NOT USED **
444 *      Returns: none.
445 */
446
447/* ARGSUSED */
448static void
449QuitAction(w, event, params, num_params)
450Widget w;
451XEvent * event;
452String * params;
453Cardinal * num_params;
454{
455  exit(0);
456}
457
458/*      Function Name: QuotaCheckAction
459 *      Description: checks the quota
460 *      Arguments: w - the widget that got the proceedure.    ** NOT USED **
461 *                 event - the event that caused the actions. ** NOT USED **
462 *                 params, num_params - args passed to proc.  ** NOT USED **
463 *      Returns: none.
464 */
465
466/* ARGSUSED */
467static void
468QuotaCheckAction(w, event, params, num_params)
469Widget w;
470XEvent * event;
471String * params;
472Cardinal * num_params;
473{
474  ShowQuota( &info);
475}
476
477/*      Function Name: PrintHelpAction
478 *      Description: Prints help.
479 *      Arguments: w - the widget that got the proceedure.    ** NOT USED **
480 *                 event - the event that caused the actions. ** NOT USED **
481 *                 params, num_params - args passed to proc.  ** NOT USED **
482 *      Returns: none.
483 */
484
485/* ARGSUSED */
486static void
487PrintHelpAction(w, event, params, num_params)
488Widget w;
489XEvent * event;
490String * params;
491Cardinal * num_params;
492{
493  if (*num_params != 1) {
494    printf("PrintHelp: number of parameters passed was not 1.\n");
495    return;
496  }
497  switch (params[0][0]) {
498  case 'T':
499  case 't':
500    ShowTopHelp( &info );
501    break;
502  case 'P':
503  case 'p':
504    ShowPopupHelp( &info );
505    break;
506  default:
507    printf("PrintHelp: specify either 'Top' or 'Popup'.\n");
508    break;
509  }
510}
511
512/************************************************************
513 *
514 *  Callback Proceedures.
515 *
516 ************************************************************/
517 
518/*      Function Name: CheckProc
519 *      Description: Checks the user's quota.
520 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
521 *                 info - a pointer the info structure.
522 *                 garbage - ** NOT USED **.
523 *      Returns: none.
524 */
525
526/* ARGSUSED */
527static void
528CheckProc(w, info_ptr, garbage)
529Widget w;
530caddr_t info_ptr, garbage;
531{
532  ShowQuota( (Info *) info_ptr);
533}
534 
535/*      Function Name: QuitProc
536 *      Description: exits
537 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
538 *                 junk, garbage - ** NOT USED **.
539 *      Returns: none.
540 */
541
542/* ARGSUSED */
543static void
544QuitProc(w, junk, garbage)
545Widget w;
546caddr_t junk, garbage;
547{
548  exit(0);
549}
550 
551/*      Function Name: DoneProc
552 *      Description: pops down info widget
553 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
554 *                 info - a pointer the info structure.
555 *                 garbage - ** NOT USED **.
556 *      Returns: none.
557 */
558
559/* ARGSUSED */
560 
561static void
562DoneProc(w, info_ptr, garbage)
563Widget w;
564caddr_t info_ptr, garbage;
565{
566  Info * info = (Info *) info_ptr;
567  XtPopdown(info->info_popup);
568}
569 
570/*      Function Name: TopHelpProc
571 *      Description: Print Top pane help info.
572 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
573 *                 info - a pointer the info structure.
574 *                 garbage - ** NOT USED **.
575 *      Returns: none.
576 */
577
578/* ARGSUSED */
579static void
580TopHelpProc(w, info_ptr, garbage)
581Widget w;
582caddr_t info_ptr, garbage;
583{
584  ShowTopHelp( (Info *) info_ptr);
585}
586   
587/*      Function Name: PopupHelpProc
588 *      Description: Print Top pane help info.
589 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
590 *                 info - a pointer the info structure.
591 *                 garbage - ** NOT USED **.
592 *      Returns: none.
593 */
594
595/* ARGSUSED */
596static void
597PopupHelpProc(w, info_ptr, garbage)
598Widget w;
599caddr_t info_ptr, garbage;
600{
601  ShowPopupHelp( (Info *) info_ptr);
602}
603
604/*      Function Name: KillHelpProc
605 *      Description: removes the help window.
606 *      Arguments: w - the widget that actived this proc. ** NOT USED **.
607 *                 help - a pointer the help shell.
608 *                 garbage - ** NOT USED **.
609 *      Returns: none.
610 */
611
612/* ARGSUSED */
613static void
614KillHelpProc(w, help, garbage)
615Widget w;
616caddr_t help, garbage;
617{
618  XtPopdown( (Widget) help);
619}
620 
621/************************************************************
622 *
623 *  Timeout proccedures.
624 *
625 ************************************************************/
626
627/*      Function Name: SetTimeout
628 *      Description: Sets the timeout for next quota check.
629 *      Arguments: info - the psuedo global structure.
630 *      Returns: none.
631 */
632
633#define MILLIES_PER_MINUTE 60000L
634
635void
636SetTimeOut(info)
637Info * info;
638{
639  long time;
640
641  if (info->timeout != NULL)    /* remove old timeout. */
642    XtRemoveTimeOut(info->timeout);
643
644  time = ((long) info->minutes ) * MILLIES_PER_MINUTE;
645  info->timeout = XtAppAddTimeOut(info->appcon, time,
646                                  TimeOutProc, (caddr_t) info);
647}
648
649/*      Function Name: TimeOutProc
650 *      Description: This proceedure gets called when the timer times out.
651 *      Arguments: info_ptr - pointer to info structure.
652 *                 id - id of timeout ** NOT USED **.
653 *      Returns: none
654 */
655
656/* ARGSUSED */
657static void
658TimeOutProc(info_ptr, id)
659caddr_t info_ptr;
660XtIntervalId *id;
661{
662  Info * info = (Info *) info_ptr;
663  info->timeout = NULL;
664  ShowQuota(info);
665
666
667/************************************************************
668 *
669 *  Widget Utility Functions.
670 *
671 ************************************************************/
672
673/*      Function Name: SetLabel
674 *      Description: Sets the label in a widget.
675 *      Arguments: w - the widget who's label we are changing.
676 *                 str - string to change it to.
677 *      Returns: none.
678 */
679
680void
681SetLabel(w, string)
682Widget w;
683char * string;
684{
685  Arg arglist[1];
686 
687  XtSetArg(arglist[0], XtNlabel, string);
688  XtSetValues(w, arglist, (Cardinal) 1);
689}
690
691/*      Function Name: FlipColors
692 *      Description: Swaps fg and bg colors.
693 *      Arguments: w - widget to flip.
694 *      Returns: none.
695 */
696
697static void
698FlipColors(w)
699Widget w;
700{
701  Arg arglist[2];
702  Pixel fg, bg;
703  Cardinal num_args;
704 
705  num_args = 0;
706  XtSetArg(arglist[num_args], XtNforeground, &fg); num_args++;
707  XtSetArg(arglist[num_args], XtNbackground, &bg); num_args++;
708  XtGetValues(w, arglist, num_args);
709 
710  num_args = 0;
711  XtSetArg(arglist[num_args], XtNforeground, bg); num_args++;
712  XtSetArg(arglist[num_args], XtNbackground, fg); num_args++;
713  XtSetValues(w, arglist, num_args);
714}
715 
716/*      Function Name: SetGraph
717 *      Description: Sets the quota graph.
718 *      Arguments: w - the graph widget.
719 *                 quota - quota in kilobytes.
720 *                 used - amount of space used in kilobytes.
721 *      Returns: none.
722 */
723
724void
725SetGraph(info, w, quota, used)
726Info * info;
727Widget w;
728int quota, used;
729{
730  float temp;
731
732  temp = ( (float) used ) / ( (float) quota);
733  if ( temp > 1.0 ) temp = 1.0;
734  XtScrollBarSetThumb( w, 1.0 - temp, temp );
735  temp *= 100;
736  if ( (((int) temp) >= info->warn && !info->flipped) ||
737       (((int) temp) < info->warn && info->flipped) ) {
738    FlipColors(w);
739    if (info->numbers && !info->space_saver)
740      FlipColors(info->used_top);
741    FlipColors(info->used_widget);
742    info->flipped = !info->flipped;
743  }
744}
745
746/*      Function Name: SetTextMessage
747 *      Description: Sets the text in the text widget to be "string".
748 *      Arguments: w - the text widget.
749 *                 string - string to show in text widget.
750 *      Returns: none.
751 */
752
753void
754SetTextMessage(w, string)
755Widget w;
756char * string;
757{
758  XtTextBlock t_block;
759
760  t_block.firstPos = 0;
761  t_block.length = strlen(string);
762  t_block.ptr = string;
763  t_block.format = FMT8BIT;
764
765  if (XtTextReplace(w, 0, TEXT_BUFFER_LENGTH, &t_block) != XawEditDone)
766    printf("Xquota Error: could not replace text string.\n");
767}
768
769/************************************************************
770 *
771 *  Get Alternate Application Resources.
772 *
773 *  Since I cannot write to /usr/lib/X11/app-defaults
774 *  I have to get my application resources from somewhere else.
775 *  Here is one method.
776 *
777 ************************************************************/
778
779/*      Function Name: LoadApplicationResources
780 *      Description: Loads in my own personal app-defaults file
781 *      Arguments: file - name of the defaults file.
782 *                 disp - the display.
783 *      Returns: none.
784 */
785
786static void
787LoadApplicationResources(file, disp)
788char * file;
789Display * disp;
790{
791  XrmDatabase my_database;
792
793  if (file == NULL || streq(file, "") ) return;
794
795  if ( (my_database = XrmGetFileDatabase(file)) == NULL ) {
796    printf("Could not open file %s to read resources.\n", file);
797    return;
798  }
799
800  XrmMergeDatabases(my_database, &(disp->db));
801}
Note: See TracBrowser for help on using the repository browser.