Add -fpermissive to linux standard c++ option define in linux.cf
[oweals/cde.git] / cde / programs / dtprintinfo / UI / DtPrinterIcon.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: DtPrinterIcon.C /main/5 1998/07/24 16:13:14 mgreess $ */
24 #include "DtPrinterIcon.h"
25 #include "Button.h"
26 #include "DtMainW.h"
27 #include "Prompt.h"
28 #include "DtPrtProps.h"
29 #include "DtSetModList.h"
30 #include "DtFindD.h"
31 #include "DtDetailsLabel.h"
32 #include "Dt/Action.h"
33
34 #include <sys/stat.h>
35 #include <time.h>
36 #include <fcntl.h>
37 #include <unistd.h> // This is for the getuid function
38 #include <stdlib.h> // This is for the getenv function
39 #include <pwd.h>
40
41 #include "dtprintinfomsg.h"
42
43 const char *PROPS_PRINTER_ID = "PrinterPropsDE";
44 const char *PRINTER_ID = "PrinterDE";
45 const char *STATUS_FLAG = "Flag";
46 const char *PRINTER_ICON_FILE = "Fpprnt";
47 const char *PRINTERS_PERSONAL_DIR = ".dt/.Printers";
48
49 char DtPrinterIcon::homeDir[300] = "";
50
51 DtPrinterIcon::DtPrinterIcon(DtMainW *mainW, AnyUI *parent, Queue *que, 
52                              PrinterApplicationMode _app_mode)
53         : IconObj((char *) que->ObjectClassName(), parent,
54                   GetPrinterLabel(que->Name(), _app_mode),
55                   GetPrinterIcon(que->Name(), _app_mode))
56 {
57    app_mode = _app_mode;
58    queue = que;
59    status = NULL;
60    dnd = NULL;
61 #ifdef aix
62    _print_device_up = NULL;
63 #endif
64
65    // Return if initializing printers
66    if (app_mode == INITIALIZE_PRINTERS)
67       return;
68
69    char *buf = new char[300];
70    struct stat statbuff;
71    if (*homeDir == '\0')
72     {
73       struct passwd * pwInfo;
74       char *home = getenv("HOME");
75       if (home == NULL || strlen(home) == 0)
76        {
77          pwInfo = getpwuid(getuid());
78          home = pwInfo->pw_dir;
79        }
80       strcpy(homeDir, home);
81       sprintf(buf, "%s/%s", homeDir, PRINTERS_PERSONAL_DIR);
82       if (stat(buf, &statbuff) < 0)
83        {
84          sprintf(buf, "mkdir -p %s/%s", homeDir, PRINTERS_PERSONAL_DIR);
85          system(buf);
86        }
87       sprintf(buf, "%s/.dt/types", homeDir);
88       if (stat(buf, &statbuff) < 0)
89        {
90          sprintf(buf, "mkdir -p %s/.dt/types", homeDir);
91          system(buf);
92        }
93       DtDbReloadNotify(&DtPrinterIcon::ReloadNotifyCB, this);
94     }
95    sprintf(buf, "%s/%s/%s_Print", homeDir, PRINTERS_PERSONAL_DIR,
96            queue->Name());
97    if (stat(buf, &statbuff) < 0)
98     {
99       int fd = creat(buf, 0755);
100       close(fd);
101     }
102    else if (statbuff.st_mode != 0755)
103       chmod(buf, 0755);
104    mainw = mainW;
105    props = NULL;
106    container = NULL;
107    waitForChildren = false;
108    if (app_mode == PRINT_MANAGER)
109       expand = new Button(this, queue->DisplayName(), PUSH_BUTTON, OpenCloseCB,
110                           NULL, NULL, NULL, NULL, "Dtplus");
111    else
112       expand = NULL;
113
114    if (app_mode != CONFIG_PRINTERS)
115     {
116 #ifdef aix
117       n_devices = queue->NumberDevices();
118       _print_device_up = new boolean[n_devices];
119       int i;
120       for (i = 0; i < n_devices; i++)
121          _print_device_up[i] = true;
122 #else
123       queue->ReadAttributes();
124       _print_device_up = true;
125 #endif
126       _print_queue_up = true;
127       flag = new IconObj((char *)STATUS_FLAG, this, NULL, "DtFlag");
128       flag->Visible(false);
129       details_label = new DtDetailsLabel(this);
130       _previous_show_only_my_jobs = mainw->setPrefD->ShowOnlyMyJobs() ?
131                                     false : true;
132       ShowDetailsLabel(IconView(), false);
133     }
134    else
135     {
136       flag = NULL;
137       details_label = NULL;
138     }
139    dnd = new DtDND(this, DndCB);
140    mainw->RegisterPopup(this);
141    ApplicationData = NULL;
142    if (app_mode == SINGLE_PRINTER)
143     {
144       mainw->IconName((char *)Name());
145       char *iconFile = GetPrinterIcon(que->Name(), _app_mode);
146       char *s = new char [strlen(iconFile) + 6];
147       if (depth == 1)
148          sprintf(s, "%s.l.bm", iconFile);
149       else
150          sprintf(s, "%s.l.pm", iconFile);
151       mainw->IconFile(s);
152       if (!mainw->IconFile())
153        {
154          *(s + strlen(iconFile) + 1) = 'm';
155          mainw->IconFile(s);
156        }
157       delete [] s;
158     }
159    delete [] buf;
160 }
161
162 DtPrinterIcon::~DtPrinterIcon()
163 {
164    delete dnd;
165 #ifdef aix
166    delete _print_device_up;
167 #endif
168    delete status;
169 }
170
171 char *DtPrinterIcon::Description()
172 {
173    static char buf[200];
174
175    sprintf(buf, "%s_Print", queue->Name());
176    char *desc = DtActionDescription(buf);
177    return (desc ? desc : "");
178 }
179
180 void DtPrinterIcon::PrintQueueUp(boolean _flag)
181 {
182    if (app_mode == CONFIG_PRINTERS)
183       return;
184    if (props)
185       status[0]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
186    _print_queue_up = _flag;
187    ShowFlag();
188 }
189
190 #ifdef aix
191
192 void DtPrinterIcon::PrintDeviceUp(boolean _flag, int index)
193 {
194    if (app_mode == CONFIG_PRINTERS)
195       return;
196    if (index >= 0 && index < n_devices)
197     {
198       if (props)
199          status[index + 1]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
200       _print_device_up[index] = _flag;
201       ShowFlag();
202     }
203 }
204
205 boolean DtPrinterIcon::PrintDeviceUp(int index)
206 {
207    if (app_mode != CONFIG_PRINTERS)
208     {
209       if (index >= 0 && index < n_devices)
210          return _print_device_up[index];
211     }
212    return false;
213 }
214
215 #else
216
217 void DtPrinterIcon::PrintDeviceUp(boolean _flag)
218 {
219    if (app_mode == CONFIG_PRINTERS)
220       return;
221    if (props)
222       status[1]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
223    _print_device_up = _flag;
224    ShowFlag();
225 }
226
227 #endif
228
229 boolean DtPrinterIcon::SetName(char *_name)
230 {
231    IconObj::SetName(_name);
232    if (dnd)
233       dnd->UpdateRects();
234    return true;
235 }
236
237 boolean DtPrinterIcon::SetOpen(boolean _flag)
238 {
239    if (app_mode != CONFIG_PRINTERS)
240       IconObj::SetOpen(_flag);
241    return true;
242 }
243
244 DtPrinterContainer *DtPrinterIcon::CreateContainer()
245 {
246    if (!container)
247     {
248       container = new DtPrinterContainer((char *)Category(), this,
249                                          queue->DisplayName());
250       mainw->RegisterPopup(container);
251       container->dnd = new DtDND(container, DndCB);
252       container->ApplicationData = queue;
253       ApplicationData = container;
254     }
255    return container;
256 }
257
258 char *DtPrinterIcon::CreateActionFile()
259 {
260    static char filename[300];
261    FILE *fp;
262    struct stat statbuff;
263    boolean create_file;
264
265    char *buf = new char[300];
266    char *lang = getenv("LANG");
267    if (!(lang && *lang))
268       lang = "C";
269
270    if (app_mode == INITIALIZE_PRINTERS || app_mode == CONFIG_PRINTERS)
271     {
272       sprintf(filename, "/etc/dt/appconfig/types/%s", lang);
273       if (stat(filename, &statbuff) < 0)
274        {
275          sprintf(buf, "mkdir -p %s", filename);
276          system(buf);
277        }
278       sprintf(filename, "/etc/dt/appconfig/types/%s/%s.dt", lang,
279               queue->Name());
280       if (stat(filename, &statbuff) < 0 || statbuff.st_size == 0)
281          create_file = true;
282       else
283          create_file = false;
284     }
285    else
286     {
287       sprintf(buf, "%s/.dt/types/%s.dt", homeDir, queue->Name());
288       if (stat(buf, &statbuff) < 0 || statbuff.st_size == 0)
289        {
290          sprintf(buf, "/etc/dt/appconfig/types/%s/%s.dt", lang, queue->Name());
291          if (stat(buf, &statbuff) >= 0 && statbuff.st_size > 0)
292           {
293             sprintf(buf, "cp /etc/dt/appconfig/types/%s/%s.dt %s/.dt/types",
294                     lang, queue->Name(), homeDir);
295             system(buf);
296             create_file = false;
297           }
298          else
299             create_file = true;
300        }
301       else
302          create_file = false;
303       sprintf(filename, "%s/.dt/types/%s.dt", homeDir, queue->Name());
304     }
305    if (create_file)
306     {
307       if (fp = fopen(filename, "w"))
308        {
309          time_t secs;
310          time(&secs);
311          fprintf(fp, "################################################################\n\n");
312          fprintf(fp, "#   Actions and Datatypes for Printer \"%s\"\n\n", queue->Name());
313          fprintf(fp, "#   Common Desktop Environment 1.0\n\n");
314          fprintf(fp, "#   This file was created by the \"dtprintinfo\" program.\n\n");
315          strftime(buf, 300, "%c", localtime(&secs));
316          fprintf(fp, "#   Date of creation: %s\n\n", buf);
317          fprintf(fp, "################################################################\n\n");
318          fprintf(fp, "ACTION %s_Print\n", queue->Name());
319          fprintf(fp, "{\n");
320          fprintf(fp, "        ARG_TYPE                *\n");
321          fprintf(fp, "        LABEL                   %s\n", queue->Name());
322          fprintf(fp, "        ICON                    %s\n", PRINTER_ICON_FILE);
323          fprintf(fp, "        TYPE                    COMMAND\n");
324          fprintf(fp, "        WINDOW_TYPE             NO_STDIO\n");
325          fprintf(fp, "        EXEC_STRING             env LPDEST=%s \\\n", queue->Name());
326          fprintf(fp, "                          /usr/dt/bin/dtaction Print %%(File)Arg_1%%\n");
327          sprintf(buf, MESSAGE(DefaultDescriptionL), queue->Name());
328          fprintf(fp, "        DESCRIPTION             %s\n", buf);
329          fprintf(fp, "}\n\n");
330    
331          fprintf(fp, "ACTION %s_Print\n", queue->Name());
332          fprintf(fp, "{\n");
333          fprintf(fp, "        ARG_COUNT               0\n");
334          fprintf(fp, "        TYPE                    COMMAND\n");
335          fprintf(fp, "        WINDOW_TYPE             NO_STDIO\n");
336          fprintf(fp, "        EXEC_STRING             /usr/dt/bin/dtaction Dtprintinfo %s\n", queue->Name());
337          fprintf(fp, "}\n");
338          fflush(fp);
339          fclose(fp);
340          chmod(filename, 0644);
341        }
342     }
343    delete [] buf;
344    return filename;
345 }
346
347 void DtPrinterIcon::DndCB(BaseUI *obj, char **value, int * /*len*/,
348                           DNDProtocol dndProtocol)
349 {
350    DtPrinterIcon *printer;
351    if (obj->UIClass() == ICON)
352       printer = (DtPrinterIcon *)obj;
353    else
354       printer = (DtPrinterIcon *)obj->Parent();
355    DtActionArg ap[1];
356    char *old_LPDEST = NULL;
357    ap[0].argClass = DtACTION_FILE;
358
359    char *buf = new char[100];
360    switch (dndProtocol)
361    {
362    case FILENAME_TRANSFER: // Dropping an Object on a printer
363       ap[0].u.file.name = *value;
364       if (printer->PrintActionExists())
365          sprintf(buf, "%s_Print", printer->queue->Name());
366       else
367        {
368          if (old_LPDEST = STRDUP(getenv("LPDEST")))
369           {
370             sprintf(buf, "LPDEST=%s", printer->queue->Name());
371             putenv(buf);
372           }
373          strcpy(buf, "Print");
374        }
375
376       DtActionInvoke(((AnyUI *)printer->mainw->Parent())->BaseWidget(), buf, ap,
377                      1, NULL, NULL, NULL, True, NULL, NULL);
378       if (old_LPDEST)
379        {
380          sprintf(buf, "LPDEST=%s", old_LPDEST);
381          putenv(buf);
382          delete old_LPDEST;
383        }
384       break;
385    case CONVERT_DATA: // Dragging a printer to an object
386       if (printer->PrintActionExists())
387        {
388          struct stat statbuff;
389          *value = new char[strlen(homeDir) + strlen(PRINTERS_PERSONAL_DIR) +
390                            strlen(printer->queue->Name()) + 10];
391          sprintf(*value, "%s/%s/%s_Print", homeDir, PRINTERS_PERSONAL_DIR,
392                  printer->queue->Name());
393          if (stat(*value, &statbuff) < 0)
394           {
395             int fd = creat(*value, 0755);
396             close(fd);
397           }
398        }
399       else
400          *value = NULL;
401       break;
402    case DROP_ON_ROOT:
403       {
404       char *x = *value;
405       char *y = strchr(x, '\n');
406       *y++ = '\0';
407       char *filename = strchr(y, '\n');
408       *filename++ = '\0';
409       char *work_space = strchr(filename, '\n');
410       if (work_space)
411          *work_space++ = '\0';
412       }
413       break;
414    case TEXT_TRANSFER:
415       break;
416    case BUFFER_TRANSFER:
417       *value = new char[strlen(printer->queue->Name()) + 10];
418       sprintf(*value, "%s_Print", printer->queue->Name());
419       break;
420    case CONVERT_DELETE:
421       break;
422    case ANIMATE:
423       break;
424    }
425    delete [] buf;
426 }
427
428 boolean DtPrinterIcon::SetIcon(IconStyle style)
429 {
430    IconObj::SetIcon(style);
431    if (dnd)
432       dnd->UpdateRects();
433    ShowDetailsLabel(style, Visible());
434
435    return true;
436 }
437
438 boolean DtPrinterIcon::HandleHelpRequest()
439 {
440    mainw->DisplayHelp((char *)PRINTER_ID);
441    return true;
442 }
443
444 void DtPrinterIcon::UpdateExpand()
445 {
446    if (expand)
447     {
448       if (Open() == true)
449          expand->IconFile("Dtminus");
450       else
451          expand->IconFile("Dtplus");
452     }
453    ShowDetailsLabel(IconView(), true);
454 }
455
456 void DtPrinterIcon::Update()
457 {
458    char *cmd = new char[200];
459    sprintf(cmd, GET_QUEUE_STATUS, queue->Name());
460    Invoke *_thread = new Invoke(cmd);
461    PrintQueueUp(_thread->status ? false : true);
462    delete _thread;
463 #ifdef aix
464    int i;
465    for (i = 0; i < n_devices; i++)
466     {
467       sprintf(cmd, GET_DEVICE_STATUS, queue->Device(i));
468       _thread = new Invoke(cmd);
469       PrintDeviceUp(_thread->status ? false : true, i);
470       delete _thread;
471     }
472 #else
473 #ifdef sun
474    if (queue->IsRemote())
475       PrintDeviceUp(_print_queue_up);
476    else
477     {
478       sprintf(cmd, GET_DEVICE_STATUS, queue->Name());
479       _thread = new Invoke(cmd);
480       PrintDeviceUp(_thread->status ? false : true);
481       delete _thread;
482     }
483 #else
484    sprintf(cmd, GET_DEVICE_STATUS, queue->Name());
485    _thread = new Invoke(cmd);
486    PrintDeviceUp(_thread->status ? false : true);
487    delete _thread;
488 #endif
489 #endif
490    delete [] cmd;
491 }
492
493 void DtPrinterIcon::ShowFlag()
494 {
495    if (app_mode == CONFIG_PRINTERS)
496       return;
497
498    if (Visible() == false || mainw->setPrefD->ShowStatusFlags() == false)
499     {
500       flag->Visible(false);
501       return;
502     }
503    // Update problem flag's visiblity
504 #ifdef aix
505    boolean show_it;
506    if (_print_queue_up)
507     {
508       int i;
509       show_it = false;
510       for (i = 0; i < n_devices; i++)
511          if (_print_device_up[i] == false)
512           {
513             show_it = true;
514             break;
515           }
516     }
517    else
518       show_it = true;
519    flag->Visible(show_it);
520 #else
521    if (_print_queue_up && _print_device_up)
522       flag->Visible(false);
523    else
524       flag->Visible(true);
525 #endif
526 }
527
528 void DtPrinterIcon::NotifyVisiblity(BaseUI *obj)
529 {
530    if (app_mode == CONFIG_PRINTERS)
531       return;
532
533    if (obj == flag)
534     {
535       boolean show_it = Visible();
536       if (show_it)
537        {
538          if (mainw->setPrefD->ShowStatusFlags() == false)
539             show_it = false;
540          else
541           {
542 #ifdef aix
543             if (_print_queue_up)
544              {
545                show_it = false;
546                int i;
547                for (i = 0; i < n_devices; i++)
548                   if (_print_device_up[i] == false)
549                    {
550                      show_it = true;
551                      break;
552                    }
553              }
554             else
555                show_it = true;
556 #else
557             if (_print_queue_up && _print_device_up)
558                show_it = false;
559             else
560                show_it = true;
561 #endif
562           }
563        }
564       if (flag->Visible() != show_it)
565          flag->Visible(show_it);
566     }
567    else if (obj == details_label)
568     {
569       boolean show_it = Visible();
570       if (show_it)
571        {
572          if (container && IconView() == DETAILS && Open())
573           {
574             if (container->NumChildren() == 0 ||
575                 (container->Children()[0])->UIClass() == LABEL)
576                show_it = false;
577             else if (mainw->setPrefD->ShowDetailsLabel())
578              {
579                show_it = false;
580                int i;
581                BaseUI **children = container->Children();
582                for (i = 0; i < container->NumChildren(); i++)
583                   if (children[i]->Visible())
584                    {
585                      show_it = true;
586                      break;
587                    }
588              }
589             else
590                show_it = mainw->setPrefD->ShowDetailsLabel();
591           }
592          else
593             show_it = false;
594        }
595       if (details_label->Visible() != show_it)
596          details_label->Visible(show_it);
597     }
598 }
599
600 void DtPrinterIcon::ShowDetailsLabel(IconStyle style, boolean is_visible)
601 {
602    if (app_mode == CONFIG_PRINTERS)
603       return;
604
605    if (_previous_show_only_my_jobs != mainw->setPrefD->ShowOnlyMyJobs())
606     {
607       _previous_show_only_my_jobs = mainw->setPrefD->ShowOnlyMyJobs();
608       details_label->Update(_previous_show_only_my_jobs);
609     }
610    if (container && style == DETAILS && is_visible && Open())
611     {
612      if (container->NumChildren() == 0 ||
613           (container->Children()[0])->UIClass() == LABEL)
614          details_label->Visible(false);
615       else if (mainw->setPrefD->ShowDetailsLabel())
616        {
617          boolean show_it = false;
618          int i;
619          BaseUI **children = container->Children();
620          for (i = 0; i < container->NumChildren(); i++)
621             if (children[i]->Visible())
622              {
623                show_it = true;
624                break;
625              }
626          details_label->Visible(show_it);
627        }
628       else
629          details_label->Visible(false);
630     }
631    else
632       details_label->Visible(false);
633 }
634
635 boolean DtPrinterIcon::SetVisiblity(boolean _flag)
636 {
637    if (_flag)
638     {
639       IconObj::SetVisiblity(_flag);
640       Update();
641       if (container && Open())
642          container->Visible(true);
643       ShowDetailsLabel(IconView(), _flag);
644     }     
645    else
646     {
647       if (container)
648        {
649          container->Visible(false);
650          if (mainw->findD)
651           {
652             int i;
653             BaseUI **children = container->Children();
654             for (i = 0; i < container->NumChildren(); i++)
655                mainw->findD->DeleteJobFromList(children[i]);
656           }
657        }
658       IconObj::SetVisiblity(_flag);
659     }
660
661    if (dnd)
662       dnd->UpdateActivity(_flag);
663    return true;
664 }
665
666 void DtPrinterIcon::DisplayProps()
667 {
668    if (!props)
669     {
670       char *title = new char[200];
671       sprintf(title, MESSAGE(PrinterPropsTitleL), mainw->Name());
672       queue->ReadAttributes();
673       props = new DtPrtProps(mainw, title, this);
674       int n_matches = 0;
675       props->FindByName(MESSAGE(PrinterStatusL), 0, &n_matches,
676                         (BaseUI***)&status);
677       delete [] title;
678     }
679    props->Visible(true);
680 }
681
682 void DtPrinterIcon::ReloadNotifyCB(XtPointer data)
683 {
684    DtPrinterIcon *printer = (DtPrinterIcon *)data;
685    DtDbLoad();
686    int i, n_siblings = printer->NumSiblings();
687    BaseUI **siblings = printer->Siblings();
688
689    for (i = 0; i < n_siblings; i++)
690     {
691       printer = (DtPrinterIcon *)siblings[i];
692       char *iconName = GetPrinterLabel(printer->queue->Name(),
693                                        printer->app_mode);
694       char *iconFile = GetPrinterIcon(printer->queue->Name(),
695                                       printer->app_mode);
696
697       if (strcmp(iconName, printer->Name()))
698        {
699          printer->Name(iconName);
700          if (printer->PrinterAppMode() == SINGLE_PRINTER)
701             printer->mainw->IconName(iconName);
702          if (printer->PrinterAppMode() == PRINT_MANAGER)
703           {
704             if (printer->mainw->findD && printer->mainw->findD->Visible())
705                printer->mainw->findD->UpdatePrinter(printer);
706           }
707        }
708       if (strcmp(iconFile, printer->IconFile()))
709        {
710          printer->IconFile(iconFile);
711          if (printer->PrinterAppMode() == SINGLE_PRINTER &&
712              iconFile && *iconFile)
713           {
714             char *s = new char [strlen(iconFile) + 6];
715             if (depth == 1)
716                sprintf(s, "%s.l.bm", iconFile);
717             else
718                sprintf(s, "%s.l.pm", iconFile);
719             printer->mainw->IconFile(s);
720             delete [] s;
721           }
722        }
723       if (printer->props && printer->props->Visible())
724          printer->props->Reset();
725     }
726    if (printer->mainw->setModList && printer->mainw->setModList->Visible())
727       printer->mainw->setModList->Reset();
728 }
729
730 void DtPrinterIcon::OpenCloseCB(void *data) 
731 {
732    BaseUI *obj = ((BaseUI *)data)->Parent();
733    if (obj->Open())
734       obj->Open(false);
735    else
736       obj->Open(true);
737 }
738
739 boolean DtPrinterIcon::PrintActionExists()
740 {
741    boolean b;
742    char *buf = new char[60]; 
743    sprintf(buf, "%s_Print", queue->Name());
744    b =  (DtActionExists(buf) ? true : false);
745    delete [] buf;
746    return b;
747 }
748
749 char *DtPrinterIcon::GetPrinterIcon(const char *printer,
750                                     PrinterApplicationMode _app_mode)
751 {
752    static char buf[200];
753
754    sprintf(buf, "%s_Print", printer);
755    if (_app_mode != INITIALIZE_PRINTERS && DtActionExists(buf))
756     {
757       char *iconfile = DtActionIcon(buf);
758       if (iconfile)
759          strcpy(buf, iconfile);
760       else
761          strcpy(buf, PRINTER_ICON_FILE);
762     }
763    else
764       strcpy(buf, PRINTER_ICON_FILE);
765    return buf;
766 }
767
768 char *DtPrinterIcon::GetPrinterLabel(const char *printer,
769                                      PrinterApplicationMode _app_mode)
770 {
771    static char buf[200];
772
773    sprintf(buf, "%s_Print", printer);
774    if (_app_mode != INITIALIZE_PRINTERS && DtActionExists(buf))
775     {
776       char *label = DtActionLabel(buf);
777       if (label)
778          strcpy(buf, label);
779       else
780          strcpy(buf, printer);
781     }
782    else
783       strcpy(buf, printer);
784    return buf;
785 }