~ubuntu-branches/ubuntu/karmic/fsviewer/karmic

« back to all changes in this revision

Viewing changes to src/FSUtils.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Gurin
  • Date: 2004-08-12 16:13:27 UTC
  • mfrom: (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040812161327-4b2uq9v4gmxpgp9t
Tags: 0.2.5-6
* Fix ICONDIR problem  (closes: #261880)
* Fix FTBFS problems with patched api changes and dependency on libwraster-dev (closes: #280283)
* Implemented work around for BadWindow error (re: #288605)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <osreldate.h>
33
33
#include <sys/conf.h>
34
34
#include <sys/dkstat.h>
35
 
#include <sys/rlist.h>
 
35
/* #include <sys/rlist.h> */
36
36
#include <sys/sysctl.h>
37
37
#include <sys/time.h>
38
38
#include <sys/vmmeter.h>
47
47
#include <utmp.h>
48
48
#endif /*__SunOS__*/
49
49
 
50
 
#include "config.h"
 
50
/* #include "config.h" */
51
51
#include "files.h"
52
52
#include "filebrowser.h"
53
53
#include "FSFileButton.h"
155
155
    if ((info->haveUname == True))
156
156
        snprintf(buf, MAX_LEN, "%s", info->uts.machine); 
157
157
    else
158
 
        snprintf(buf, MAX_LEN, "Unavailable");
 
158
        snprintf(buf, MAX_LEN, _("Unavailable"));
159
159
 
160
160
    return wstrdup(buf);
161
161
}
167
167
    if ((info->haveUname == True))
168
168
        snprintf(buf, MAX_LEN, "%s %s", info->uts.sysname, info->uts.release);
169
169
    else
170
 
        snprintf(buf, MAX_LEN, "Unavailable");
 
170
        snprintf(buf, MAX_LEN, _("Unavailable"));
171
171
 
172
172
    return wstrdup(buf);
173
173
}
313
313
    if(total > 0)
314
314
        snprintf(buf, MAX_LEN, "%s", formatk(total));
315
315
    else
316
 
        snprintf(buf, MAX_LEN, "%s", "Unavailable");
 
316
        snprintf(buf, MAX_LEN, "%s", _("Unavailable"));
317
317
 
318
318
    return wstrdup(buf);
319
319
 
327
327
    
328
328
    if (!f) 
329
329
    {
330
 
        wwarning("%s %d: Can't run df, %s\n", __FILE__, __LINE__, 
 
330
        wwarning(_("%s %d: Can't run df, %s\n"), __FILE__, __LINE__, 
331
331
                 strerror(errno));
332
332
        exit(1);
333
333
    }
424
424
    }
425
425
    
426
426
    /* Uncomment if you want the app to support GIF or JPEG icons */
427
 
     if(FSImageTypeIsSupported("GIF")) 
428
 
     { 
429
 
        sprintf(tmp, "%s.gif", name); 
430
 
        path = WMPathForResourceOfType(tmp, "gif"); 
431
 
     }
432
 
  
433
 
     if(FSImageTypeIsSupported("JPEG"))
434
 
     {
435
 
        sprintf(tmp, "%s.jpg", name);
436
 
        path = WMPathForResourceOfType(tmp, "jpg");
437
 
     } 
 
427
/*     if(FSImageTypeIsSupported("GIF")) */
 
428
/*     { */
 
429
/*      sprintf(tmp, "%s.gif", name); */
 
430
/*      path = WMPathForResourceOfType(tmp, "gif"); */
 
431
/*     } */
 
432
    
 
433
/*     if(FSImageTypeIsSupported("JPEG")) */
 
434
/*     { */
 
435
/*      sprintf(tmp, "%s.jpg", name); */
 
436
/*      path = WMPathForResourceOfType(tmp, "jpg"); */
 
437
/*     } */
438
438
        
439
439
    if(!path)
440
440
    {
486
486
        switch(*execStr) 
487
487
        {
488
488
        case 's':
489
 
            (void)va_arg(ap, int);
 
489
            (void)va_arg(ap, char *);
490
490
            
491
491
            buffer = (char *) wrealloc(buffer, initBufferSize+cnt+pathnameLen);
492
492
            str = buffer;
553
553
        {
554
554
            char s[0xff];
555
555
 
556
 
            sprintf(s, "Error changing to %s but it's not that serious!", 
 
556
            sprintf(s, _("Error changing to %s but it's not that serious!"), 
557
557
                    fileInfo->path);
558
 
            FSErrorDialog("Error File Operation", s);
 
558
            FSErrorDialog(_("Error File Operation"), s);
559
559
        }
560
560
 
561
561
        pathname = GetPathnameFromPathName(fileInfo->path, fileInfo->name);
613
613
                    char *result = NULL;
614
614
            
615
615
                    result = FSRunAppInputPanel(fsViewer, fileInfo, 
616
 
                                                "App Input Window");
 
616
                                                _("App Input Window"));
617
617
                    if(result)
618
618
                        execStr = FSParseExecString(pathname, result);
619
619
                }
629
629
                char *result = NULL;
630
630
                
631
631
                result = FSRunAppInputPanel(fsViewer, fileInfo, 
632
 
                                            "App Input Window");
 
632
                                            _("App Input Window"));
633
633
                if(result)
634
634
                    execStr = FSParseExecString(pathname, result);
635
635
            }
652
652
    RColor color;
653
653
    WMPixmap *pixmap;
654
654
 
655
 
    color.red = 0xae;
656
 
    color.green = 0xaa;
657
 
    color.blue = 0xae;
 
655
    color.red   = 0xae;
 
656
    color.green = 0xaa; /* aa ?*/
 
657
    color.blue  = 0xae;
658
658
    color.alpha = 0;
659
659
    if(imgName)
660
 
        pixmap = FSCreateBlendedPixmapFromFile(WMWidgetScreen(btn),
 
660
        pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(btn),
661
661
                                               imgName, &color);
662
662
    else
663
663
        pixmap = NULL;
664
664
 
665
665
    if (!pixmap)
666
666
    {
667
 
        wwarning("%s %d: Could not load icon file %s", 
 
667
        wwarning(_("%s %d: Could not load icon file %s"), 
668
668
                 __FILE__, __LINE__, imgName);
669
669
    }
670
670
    else
673
673
        WMReleasePixmap(pixmap);
674
674
    }
675
675
 
676
 
    color.red = 0xff;
 
676
    color.red   = 0xff;
677
677
    color.green = 0xff;
678
 
    color.blue = 0xff;
 
678
    color.blue  = 0xff;
679
679
    color.alpha = 0;
680
680
    if(imgName)
681
 
        pixmap = FSCreatePixmapWithBackingFromFile(WMWidgetScreen(btn),
682
 
                                                   imgName, &color);
 
681
/*      pixmap = FSCreatePixmapWithBackingFromFile(WMWidgetScreen(btn),
 
682
                                                   imgName, &color);*/
 
683
        pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(btn),
 
684
                                               imgName, &color);
683
685
    else
684
686
        pixmap = NULL;
685
687
 
686
688
    if (!pixmap)
687
689
    {
688
 
        wwarning("%s %d: Could not load icon file %s", 
 
690
        wwarning(_("%s %d: Could not load icon file %s"), 
689
691
                 __FILE__, __LINE__, imgName);
690
692
    }
691
693
    else
701
703
    RColor color;
702
704
    WMPixmap *pixmap;
703
705
 
704
 
    color.red = 0xae;
 
706
    color.red   = 0xae;
705
707
    color.green = 0xaa;
706
 
    color.blue = 0xae;
 
708
    color.blue  = 0xae;
707
709
    color.alpha = 0;
708
710
    pixmap = WMCreatePixmapFromXPMData(WMWidgetScreen(btn), data);
709
711
    if (!pixmap)
710
 
        wwarning("%s %d: Could not create Pixmap from Data",
 
712
        wwarning(_("%s %d: Could not create Pixmap from Data"),
711
713
                 __FILE__, __LINE__);
712
714
 
713
715
    WMSetButtonImage(btn, pixmap);
715
717
    if (pixmap)
716
718
        WMReleasePixmap(pixmap);
717
719
 
718
 
    color.red = 0xff;
 
720
    color.red   = 0xff;
719
721
    color.green = 0xff;
720
 
    color.blue = 0xff;
 
722
    color.blue  = 0xff;
721
723
    color.alpha = 0;
722
724
    pixmap = WMCreatePixmapFromXPMData(WMWidgetScreen(btn), data);
723
725
    if (!pixmap)
724
 
        wwarning("%s %d: Could not create Pixmap from Data",
 
726
        wwarning(_("%s %d: Could not create Pixmap from Data"),
725
727
                 __FILE__, __LINE__);
726
728
 
727
729
    WMSetButtonAltImage(btn, pixmap);
749
751
        {
750
752
            WMReleasePropList(WindowMakerDB);
751
753
            pathList = NULL;
752
 
            snprintf(mbuf, MAX_LEN, "Window Maker domain (%s) is corrupted!", 
 
754
            snprintf(mbuf, MAX_LEN, _("Window Maker domain (%s) is corrupted!"), 
753
755
                     path);
754
 
            WMRunAlertPanel(WMWidgetScreen(list), NULL, "Error", 
755
 
                            mbuf, "OK", NULL, NULL);
 
756
            WMRunAlertPanel(WMWidgetScreen(list), NULL, _("Error"), 
 
757
                            mbuf, _("OK"), NULL, NULL);
756
758
        }
757
759
    } 
758
760
    else 
759
761
    {
760
 
        snprintf(mbuf, MAX_LEN, "Could not load Window Maker defaults (%s)", 
 
762
        snprintf(mbuf, MAX_LEN, _("Could not load Window Maker defaults (%s)"), 
761
763
                 path);
762
 
        WMRunAlertPanel(WMWidgetScreen(list), NULL, "Error", 
763
 
                        mbuf, "OK", NULL, NULL);
 
764
        WMRunAlertPanel(WMWidgetScreen(list), NULL, _("Error"), 
 
765
                        mbuf, _("OK"), NULL, NULL);
764
766
    }
765
767
 
766
768
    pathList = WMGetFromPLDictionary(WindowMakerDB, WMCreatePLString("IconPath"));
837
839
{
838
840
    WMScreen *scr = FSGetFSViewerScreen(fsViewer);
839
841
 
840
 
    WMRunAlertPanel(scr, NULL, title, msg, "OK", 
 
842
    WMRunAlertPanel(scr, NULL, title, msg, _("OK"), 
841
843
                    NULL, NULL);
842
844
}
843
845
 
846
848
{
847
849
    WMScreen *scr = FSGetFSViewerScreen(fsViewer);
848
850
 
849
 
    return WMRunAlertPanel(scr, NULL, title, msg, "OK", 
850
 
                           "Cancel", NULL);
 
851
    return WMRunAlertPanel(scr, NULL, title, msg, _("OK"), 
 
852
                           _("Cancel"), NULL);
851
853
}
852
854
 
853
855
void
937
939
            return 1;
938
940
    };
939
941
}
940
 
 
 
942
/*
941
943
WMPixmap*
942
944
FSCreateBlendedPixmapFromFile(WMScreen *scr, char *fileName, RColor *color)
943
945
{
963
965
    if(!image)
964
966
        image = RGetImageFromXPMData(rContext, file_plain);
965
967
 
966
 
    color1.red = 0xaa;
967
 
    color1.green = 0xaa;
968
 
    color1.blue = 0xaa;
 
968
    color1.red   = 0xa3;
 
969
    color1.green = 0xa3;
 
970
    color1.blue  = 0xa3;
969
971
    color1.alpha = 255;
970
972
 
971
973
    RCombineImageWithColor(image, color);
972
974
 
973
 
    /* Resize the width to 64x64 pixels */
 
975
    / * Resize the width to 64x64 pixels * /
974
976
    clone = RMakeCenteredImage(image, 64, 64, &color1);
975
977
    pixmap = WMCreatePixmapFromRImage(scr, clone, 0);
976
978
 
977
 
    RDestroyImage(image);
978
 
    RDestroyImage(clone);
 
979
    RReleaseImage(image);
 
980
    RReleaseImage(clone);
979
981
 
980
982
    return pixmap;
981
983
}
 
984
*/
982
985
 
983
986
WMPixmap*
984
987
FSCreatePixmapWithBackingFromFile(WMScreen *scr, char *fileName, RColor *color)
1025
1028
      pixmap = WMCreatePixmapFromRImage(scr, clone, 0);
1026
1029
    }
1027
1030
 
1028
 
    RDestroyImage(clone);
1029
 
    RDestroyImage(image);
 
1031
    RReleaseImage(clone);
 
1032
    RReleaseImage(image);
1030
1033
 
1031
1034
    return pixmap;
1032
1035
}
1033
1036
 
 
1037
 
1034
1038
WMPixmap*
1035
1039
FSCreateBlurredPixmapFromFile(WMScreen *scr, char *fileName)
1036
1040
{
1056
1060
    if(!image)
1057
1061
        image = RGetImageFromXPMData(rContext, file_plain);
1058
1062
 
1059
 
    color.red = 0xff;
 
1063
    color.red =   0xff;
1060
1064
    color.green = 0xff;
1061
 
    color.blue = 0xff;
 
1065
    color.blue =  0xff;
1062
1066
    color.alpha = 200;
1063
1067
 
1064
1068
    RClearImage(image, &color);
1065
1069
    pixmap = WMCreatePixmapFromRImage(scr, image, 0);
1066
1070
 
1067
 
    RDestroyImage(image);
 
1071
    RReleaseImage(image);
1068
1072
 
1069
1073
    return pixmap;
1070
1074
}
1223
1227
    {
1224
1228
        char s[0xff];
1225
1229
        
1226
 
        sprintf(s, "Error changing to %s, \"%s\" cancelled.", path);
1227
 
        FSErrorDialog("Error File Operation", s);
 
1230
        sprintf(s, _("Error changing to %s, \"%s\" cancelled."), path);
 
1231
        FSErrorDialog(_("Error File Operation"), s);
1228
1232
        
1229
1233
        return 1;
1230
1234
    }
1231
1235
 
1232
 
    if(execCommand(execStr))
 
1236
    if (execCommand(execStr))
1233
1237
        return 0;
1234
1238
 
1235
1239
    return 1;