GIMP Script-fu

Check-in [b40273f5f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed some translations changes that were missed.
Timelines: family | ancestors | sg-calendar
Files: files | file ages | folders
SHA1:b40273f5f8642e6243eeed5183cf85e98f773372
User & Date: saul 2015-04-03 07:41:38
Context
2015-04-03
07:41
Fixed some translations changes that were missed. Leaf check-in: b40273f5f8 user: saul tags: sg-calendar
06:54
Refactored translations to allow for (Catalan) day abbreviations. check-in: ceb3cb755c user: saul tags: sg-calendar
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sg-calendar.scm.

375
376
377
378
379
380
381
382

383
384
385
386
387
388
389
390
...
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
...
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
...
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
...
762
763
764
765
766
767
768
769
770
771

772
773
774
775
776
777
778
                                          ((caddr (list-ref sg-calendar-translations lang)))
                                          (else
                                             (map (lambda (x) 
                                                    (substring x 
                                                               0 
                                                               (min (+ letters-in-day 1)
                                                                    (string-length x))))
                                                  (list-ref sg-calendar-weekdays lang))))))

         )         
    (gimp-context-push)
    (gimp-image-undo-group-start image)
    (set! orig-sel (car (gimp-selection-save image)))
    (set! buffer (car (gimp-edit-named-copy drawable "buffer")))
    (set! bg-layer (car (gimp-edit-named-paste drawable buffer FALSE)))
    (gimp-floating-sel-to-layer bg-layer)
    (gimp-buffer-delete buffer)
................................................................................
           (extents '()) )
      (when (< h (+ h-sel (* h-sel padding 0.01))) ; shrink month height to make room for banner
        (set! h-sel (- h (* h padding 0.009))) ; increase vertical padding a bit
        (set! w-sel h-sel) ; re-calculate horizontal layout
        )
      (set! month-fontsize (apply min (map (lambda (text) 
                                               (sg-calendar-calc-fontsize text text-font 100 w-sel (- h h-sel)) )
                                           (list-ref sg-calendar-months lang) )))
      (set! y (+ (cadr (gimp-text-get-extents-fontname (car (list-ref sg-calendar-months lang)) 
                                                       month-fontsize 
                                                       PIXELS 
                                                       text-font ))
                 2) )
      (set! y-offsets (if (> num-rows 1)
                        (map truncate (algebraic-prog y (- height h-sel) num-rows))
                        (list y) ))
................................................................................
          (set! temp-layer (car (gimp-image-get-active-layer image)))
          (gimp-buffer-delete buffer)
          (let ((month (modulo (+ start-month month-index) 12)))
            (script-fu-sg-calendar image temp-layer lang month year sunday? 
                                   letters-in-day layout text-font number-font 
                                   fontsize% justify? border border-color gravity)
            (gimp-image-remove-layer image temp-layer)
            (set! extents (gimp-text-get-extents-fontname (list-ref (list-ref sg-calendar-months lang) month) 
                                                          month-fontsize 
                                                          PIXELS 
                                                          text-font ))
            (set! temp-layer (car (gimp-text-fontname image -1 
                                                      (+ x (/ (- w-sel (car extents)) 2))
                                                      (- y (cadr extents) (/ (cadddr extents) -2))
                                                      (list-ref (list-ref sg-calendar-months lang) month) 
                                                      0 TRUE 
                                                      month-fontsize PIXELS text-font ))))
          (set! x-offsets (cdr x-offsets))
          (set! month-index (succ month-index)) )
        (set! y-offsets (cdr y-offsets)) ) )
    ;; Now, transfer the rendered layers to original image
    (gimp-selection-none image)
................................................................................
  "Saul Goode"
  "Saul Goode"
  "10/26/09, updated Jan 2012"
  "RGB*,GRAY*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable"  0
  SF-OPTION "Language" sg-calendar-languages
  SF-OPTION "Month" (car sg-calendar-months)
  SF-ADJUSTMENT "Year" '( 2013 1753 2050 1 10 0 1 )
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 
  SF-FONT "Number font" "Sans" 
  SF-ADJUSTMENT "Font Size (% of maximum)" '( 100 0 100 1 10 0 1)
................................................................................
  "Saul Goode"
  "Saul Goode"
  "Dec 2010, updated Jan 2012"
  "RGB*,GRAY*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable"  0
  SF-OPTION "Language" sg-calendar-languages
  SF-ADJUSTMENT "Year" '( 2013 1753 2050 1 10 0 1 )
  SF-OPTION "Start Month" (car sg-calendar-months)
  SF-OPTION "End Month" (cons (car (last (car sg-calendar-months))) (butlast (car sg-calendar-months)))

  SF-ADJUSTMENT "Columns" '( 4 1 12 1 10 0 1 )
  SF-ADJUSTMENT "Padding" '( 10 0 80 1 10 0 1 )
 
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 







|
>
|







 







|
|







 







|






|







 







|







 







|
|
|
>







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
...
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
...
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
...
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
...
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
                                          ((caddr (list-ref sg-calendar-translations lang)))
                                          (else
                                             (map (lambda (x) 
                                                    (substring x 
                                                               0 
                                                               (min (+ letters-in-day 1)
                                                                    (string-length x))))
                                                  (cadr (list-ref sg-calendar-translations
                                                                  lang)))))))
         )
    (gimp-context-push)
    (gimp-image-undo-group-start image)
    (set! orig-sel (car (gimp-selection-save image)))
    (set! buffer (car (gimp-edit-named-copy drawable "buffer")))
    (set! bg-layer (car (gimp-edit-named-paste drawable buffer FALSE)))
    (gimp-floating-sel-to-layer bg-layer)
    (gimp-buffer-delete buffer)
................................................................................
           (extents '()) )
      (when (< h (+ h-sel (* h-sel padding 0.01))) ; shrink month height to make room for banner
        (set! h-sel (- h (* h padding 0.009))) ; increase vertical padding a bit
        (set! w-sel h-sel) ; re-calculate horizontal layout
        )
      (set! month-fontsize (apply min (map (lambda (text) 
                                               (sg-calendar-calc-fontsize text text-font 100 w-sel (- h h-sel)) )
                                           (car (list-ref sg-calendar-translations lang)) )))
      (set! y (+ (cadr (gimp-text-get-extents-fontname (caar (list-ref sg-calendar-translations lang))
                                                       month-fontsize 
                                                       PIXELS 
                                                       text-font ))
                 2) )
      (set! y-offsets (if (> num-rows 1)
                        (map truncate (algebraic-prog y (- height h-sel) num-rows))
                        (list y) ))
................................................................................
          (set! temp-layer (car (gimp-image-get-active-layer image)))
          (gimp-buffer-delete buffer)
          (let ((month (modulo (+ start-month month-index) 12)))
            (script-fu-sg-calendar image temp-layer lang month year sunday? 
                                   letters-in-day layout text-font number-font 
                                   fontsize% justify? border border-color gravity)
            (gimp-image-remove-layer image temp-layer)
            (set! extents (gimp-text-get-extents-fontname (list-ref (car (list-ref sg-calendar-translations lang)) month) 
                                                          month-fontsize 
                                                          PIXELS 
                                                          text-font ))
            (set! temp-layer (car (gimp-text-fontname image -1 
                                                      (+ x (/ (- w-sel (car extents)) 2))
                                                      (- y (cadr extents) (/ (cadddr extents) -2))
                                                      (list-ref (car (list-ref sg-calendar-translations lang)) month)
                                                      0 TRUE 
                                                      month-fontsize PIXELS text-font ))))
          (set! x-offsets (cdr x-offsets))
          (set! month-index (succ month-index)) )
        (set! y-offsets (cdr y-offsets)) ) )
    ;; Now, transfer the rendered layers to original image
    (gimp-selection-none image)
................................................................................
  "Saul Goode"
  "Saul Goode"
  "10/26/09, updated Jan 2012"
  "RGB*,GRAY*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable"  0
  SF-OPTION "Language" sg-calendar-languages
  SF-OPTION "Month" (caar sg-calendar-translations)
  SF-ADJUSTMENT "Year" '( 2013 1753 2050 1 10 0 1 )
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 
  SF-FONT "Number font" "Sans" 
  SF-ADJUSTMENT "Font Size (% of maximum)" '( 100 0 100 1 10 0 1)
................................................................................
  "Saul Goode"
  "Saul Goode"
  "Dec 2010, updated Jan 2012"
  "RGB*,GRAY*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable"  0
  SF-OPTION "Language" sg-calendar-languages
  SF-ADJUSTMENT "Year" '( 2015 1753 2050 1 10 0 1 )
  SF-OPTION "Start Month" (caar sg-calendar-translations)
  SF-OPTION "End Month" (cons (car (last (caar sg-calendar-translations))) 
                              (butlast (caar sg-calendar-translations)))
  SF-ADJUSTMENT "Columns" '( 4 1 12 1 10 0 1 )
  SF-ADJUSTMENT "Padding" '( 10 0 80 1 10 0 1 )
 
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 

Changes to sg-platonic-calendar.scm.

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
...
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
           (y/m-ratio (cond  
	                      ((= 4 ym-layout) 0.35)
	                      ((= 5 ym-layout) 0.60)
	                      (else 0.50) ))
           (month-size 0)
           (year-size 0)
           (banner-height 0)
           (banners (map (lambda (x) (list-ref (list-ref sg-calendar-months lang)
                                          (string->number (car (gimp-vectors-get-name x))) ))
                         pents )) )
      ; Render first month so that size banner and footer can be determined.
      (gimp-image-add-layer month-image month-layer 0)
      (gimp-drawable-fill month-layer TRANSPARENT-FILL)
      (gimp-layer-set-offsets month-layer 0 (- (car (gimp-image-height month-image))
                                               (car (gimp-drawable-height month-layer)) ))
      (set! date-layer (car (script-fu-sg-calendar month-image 
................................................................................
        (gimp-drawable-set-name floated month-name)
        
        (set! pents (cdr pents))
        (set! banners (cdr banners))
        (unless (null? pents)
          (set! pent (car pents))
          (set! month (string->number (car (gimp-vectors-get-name pent))))
          (set! month-name (list-ref (list-ref sg-calendar-months lang) month ))
          (set! xya (pent-ref pent 0))
          (gimp-image-delete month-image)
          (set! month-image (car (gimp-image-new edge-length (ceiling (/ (* edge-length 7) 6)) RGB)))
          (set! month-layer (car (gimp-layer-new month-image 
                                                 edge-length edge-length 
                                                 RGBA-IMAGE "tmp" 100 NORMAL-MODE )))
		      (gimp-image-add-layer month-image month-layer 0)
................................................................................
  "Saul Goode"
  "updated Jan 2012"
  ""
  SF-ADJUSTMENT "Edge length" '(400 100 1500 1 10 0 1)
  SF-OPTION "Banner format" '("Year at bottom" "Year then Month (horiz)" "Month then Year(horiz)"
                               "Year over Month equal size" "Large Month under Year" "Small Month under Year" )
  SF-OPTION "Language" sg-calendar-languages
  SF-ADJUSTMENT "Year" '( 2013 1753 2050 1 10 0 1 )
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 
  SF-FONT "Number font" "Sans" 
  SF-ADJUSTMENT "Font Size (% of maximum)" '( 85 0 100 1 10 0 1)
  SF-TOGGLE "Right Justify" TRUE







|
|







 







|







 







|







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
...
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
           (y/m-ratio (cond  
	                      ((= 4 ym-layout) 0.35)
	                      ((= 5 ym-layout) 0.60)
	                      (else 0.50) ))
           (month-size 0)
           (year-size 0)
           (banner-height 0)
           (banners (map (lambda (x) (list-ref (car (list-ref sg-calendar-translations lang))
                                               (string->number (car (gimp-vectors-get-name x))) ))
                         pents )) )
      ; Render first month so that size banner and footer can be determined.
      (gimp-image-add-layer month-image month-layer 0)
      (gimp-drawable-fill month-layer TRANSPARENT-FILL)
      (gimp-layer-set-offsets month-layer 0 (- (car (gimp-image-height month-image))
                                               (car (gimp-drawable-height month-layer)) ))
      (set! date-layer (car (script-fu-sg-calendar month-image 
................................................................................
        (gimp-drawable-set-name floated month-name)
        
        (set! pents (cdr pents))
        (set! banners (cdr banners))
        (unless (null? pents)
          (set! pent (car pents))
          (set! month (string->number (car (gimp-vectors-get-name pent))))
          (set! month-name (list-ref (car (list-ref sg-calendar-translations lang)) month ))
          (set! xya (pent-ref pent 0))
          (gimp-image-delete month-image)
          (set! month-image (car (gimp-image-new edge-length (ceiling (/ (* edge-length 7) 6)) RGB)))
          (set! month-layer (car (gimp-layer-new month-image 
                                                 edge-length edge-length 
                                                 RGBA-IMAGE "tmp" 100 NORMAL-MODE )))
		      (gimp-image-add-layer month-image month-layer 0)
................................................................................
  "Saul Goode"
  "updated Jan 2012"
  ""
  SF-ADJUSTMENT "Edge length" '(400 100 1500 1 10 0 1)
  SF-OPTION "Banner format" '("Year at bottom" "Year then Month (horiz)" "Month then Year(horiz)"
                               "Year over Month equal size" "Large Month under Year" "Small Month under Year" )
  SF-OPTION "Language" sg-calendar-languages
  SF-ADJUSTMENT "Year" '( 2015 1753 2050 1 10 0 1 )
  SF-TOGGLE "Sunday first" TRUE
  SF-OPTION "Day format" '("S M T ..." "Su Mo Tu ..." "Sun Mon Tue ...")
  SF-OPTION "Layout" '( "Allow 6-week span" "Force 6-week span" "Wrap Week 6 to Week 1" "Wrap Week 6 to Week 5")
  SF-FONT "Text font" "Sans" 
  SF-FONT "Number font" "Sans" 
  SF-ADJUSTMENT "Font Size (% of maximum)" '( 85 0 100 1 10 0 1)
  SF-TOGGLE "Right Justify" TRUE