]> wagner.pp.ru Git - oss/fubar.git/commitdiff
fixed encoding issues in some plugin master
authorVictor Wagner <vitus@wagner.pp.ru>
Tue, 9 Oct 2012 04:26:41 +0000 (08:26 +0400)
committerVictor Wagner <vitus@wagner.pp.ru>
Tue, 9 Oct 2012 04:26:41 +0000 (08:26 +0400)
fubar.tcl
plugins/clock
plugins/phone_vcf

index 1b18c103563dc20366154ea97e8628f141df0ec1..6d3a2fc8a16a292a84286ec42061e41525ddf0eb 100755 (executable)
--- a/fubar.tcl
+++ b/fubar.tcl
@@ -1,6 +1,6 @@
 #!/usr/bin/wish
 
-package require Tclx
+catch {package require Tclx}
 set noFvwm [catch {package require Fvwm}]
 set CONFIGDIR "~/.fubar"
 set LIBRARYDIR [file dirname [info script]]
index 20e6b243f1bf65703918c00a09df66f398d00ac1..02608f838d64adc005eb6e6740a402662ec5a46e 100644 (file)
@@ -8,29 +8,29 @@ option add *Calendar.Canvas.BoldFont -*-times-bold-r-normal--12-*-*-*-*-*-iso106
 option add *Calendar.Canvas.DateFont -*-times-medium-r-normal--12-*-*-*-*-iso10646-1 widgetDefault
 namespace eval clock {
 array set monthNames { 
-1 {ÑÎ×ÁÒÑ ÑÎ×ÁÒØ}
-2 {ÆÅ×ÒÁÌÑ ÆÅ×ÒÁÌØ}
-3 {ÍÁÒÔÁ ÍÁÒÔ}
-4 {ÁÐÒÅÌÑ ÁÐÒÅÌØ}
-5 {ÍÁÑ ÍÁÊ}
-6 {ÉÀÎÑ ÉÀÎØ}
-7 {ÉÀÌÑ ÉÀÌØ}
-8 {Á×ÇÕÓÔÁ Á×ÇÕÓÔ}
-9 {ÓÅÎÔÑÂÒÑ ÓÅÎÔÑÂÒØ}
-10 {ÏËÔÑÂÒÑ ÏËÔÑÂÒØ}
-11 {ÎÏÑÂÒÑ ÎÏÑÂÒØ}
-12 {ÄÅËÁÂÒÑ ÄÅËÁÂÒØ}
+1 {\u044f\u043d\u0432\u0430\u0440\u044f \u044f\u043d\u0432\u0430\u0440\u044c}
+2 {\u0444\u0435\u0432\u0440\u0430\u043b\u044f \u0444\u0435\u0432\u0440\u0430\u043b\u044c}
+3 {\u043c\u0430\u0440\u0442\u0430 \u043c\u0430\u0440\u0442}
+4 {\u0430\u043f\u0440\u0435\u043b\u044f \u0430\u043f\u0440\u0435\u043b\u044c}
+5 {\u043c\u0430\u044f \u043c\u0430\u0439}
+6 {\u0438\u044e\u043d\u044f \u0438\u044e\u043d\u044c}
+7 {\u0438\u044e\u043b\u044f \u0438\u044e\u043b\u044c}
+8 {\u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0430\u0432\u0433\u0443\u0441\u0442}
+9 {\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c}
+10 {\u043e\u043a\u0442\u044f\u0431\u0440\u044f \u043e\u043a\u0442\u044f\u0431\u0440\u044c}
+11 {\u043d\u043e\u044f\u0431\u0440\u044f \u043d\u043e\u044f\u0431\u0440\u044c}
+12 {\u0434\u0435\u043a\u0430\u0431\u0440\u044f \u0434\u0435\u043a\u0430\u0431\u0440\u044c}
 }
 array set weekday {
-0 {×ÏÓËÒÅÓÅÎØÅ red}
-1 {ÐÏÎÅÄÅÌØÎÉË black}
-2 {×ÔÏÒÎÉË black}
-3 {ÓÒÅÄÁ  black}
-4 {ÞÅÔ×ÅÒÇ black}
-5 {ÐÑÔÎÉÃÁ black}
-6 {ÓÕÂÂÏÔÁ red}
+0 {\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435 red}
+1 {\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a black}
+2 {\u0432\u0442\u043e\u0440\u043d\u0438\u043a black}
+3 {\u0441\u0440\u0435\u0434\u0430  black}
+4 {\u0447\u0435\u0442\u0432\u0435\u0440\u0433 black}
+5 {\u043f\u044f\u0442\u043d\u0438\u0446\u0430 black}
+6 {\u0441\u0443\u0431\u0431\u043e\u0442\u0430 red}
 }
-set weekDayAbbr {÷Ó ðΠ÷Ô óÒ þÔ ðÔ óÂ}
+set weekDayAbbr {\u0412\u0441 \u041f\u043d \u0412\u0442 \u0421\u0440 \u0427\u0442 \u041f\u0442 \u0421\u0431}
 proc currentMonth {} {
        eval fill_calendar [clock format [clock seconds] -format "%m %Y"]
 }         
index cd0f27abef457a996fb11c4340a9d2d80cbdabaa..f60262445da648834c62311b39e1668e5364f261 100644 (file)
@@ -1,6 +1,11 @@
 #!/usr/bin/wish 
 # Fubar plug-in to handle phonebook
-package require Img
+if [catch {package require Img} msg] {
+       puts stderr "Failed to load IMG package: $msg"
+       set noImg 1
+} else {
+       set noImg 0
+}
 if {![file exists ~/.phonebook.vcf]} {
        error "Phonebook file $env(HOME)/.phonebook.vcf not found"
 }      
@@ -32,12 +37,14 @@ namespace eval phonebook {
                                set list [split $field ";"]
                                if {[llength $list>1]} {
                                        set field [lindex $list 0]
+                                       if {$field != "N" && $field != "FN" } {
                                                foreach opt [lrange $list 1 end] {
                                                        if {[string match CHARSET=* $opt]||
                                                                [string match ENCODING=* $opt]||
                                                                        $opt eq "PREF"} continue
                                                        lappend field $opt
                                                }       
+                                       }       
                                }       
                                if {$field eq "END"} {
                                        assemble_record cur_record
@@ -68,9 +75,18 @@ namespace eval phonebook {
        proc assemble_record  {var} {
                upvar $var record
                variable phones
-               set index $record(N)
+               if {[info exists record(FN)]} {
+                       set index $record(FN)
+               } elseif {[info exists record(N)]} {
+                       set index $record(N)
+               } elseif {[info exists record(NICKNAME)]} {
+                       set index $record(NICKNAME)
+               }
                if [info exists record(ORG)] { append index ",$record(ORG)"}
                if [info exists record(TITLE)] { append index ",$record(TITLE)"}
+               if {![info exists index]} {
+                       after idle "error \"record [array get record] has no name\""
+               }
                set phones($index) [array get record]
        }       
 
@@ -94,9 +110,9 @@ namespace eval phonebook {
                        bind $w.list <Key> [list ::phonebook::keyEvent $w.search.pattern %k %s %A %K]
                        scrollbar $w.y -orient vert -command "$w.list yview"
                        frame $w.record
-                       foreach {name title} {name "éÍÑ" org "ïÒÇÁÎÉÚÁÃÉÑ" title "ú×ÁÎÉÅ"
-                               telcell "ôÅÌ. íÏÂ" telwork "ôÅÌ.òÁÂ." telhome "ôÅÌ.äÏÍ." telother
-                                       "ðÒÏÞÅÅ" fax "æÁËÓ" email "E-Mail"} {
+                       foreach {name title} {name "Name" org "Organization" title "Title"
+                               telcell "Tel. Cell" telwork "Tel. Work" telhome "Tel.  Home" telother
+                                       "Other" fax "Fax" email "E-Mail"} {
                                                label $w.record.l$name -text $title -anchor e
                                                        label $w.record.$name -anchor w
                                                        grid $w.record.l$name $w.record.$name -sticky news
@@ -129,8 +145,9 @@ namespace eval phonebook {
                } else {
                        array set record {}
                        if {[info exists current]} {unset current}
-               }       
-               $w.record.name configure -text $record(N);
+               }
+
+               $w.record.name configure -text $index
                set_if_exists $w.record.org record(ORG)
                set_if_exists $w.record.title record(TITLE)
                set_if_exists $w.record.telcell "record(TEL CELL)"
@@ -144,12 +161,18 @@ namespace eval phonebook {
                } else {
                        $w.record.mail configure -state disabled
                }       
+               set hasImage 0
                if {[llength [set img_index [lindex [array names record PHOTO*] 0]]]} {
                        if {![regexp {TYPE=([^[:space:]]+)} $img_index msg fmt]} {
                                set fmt JPEG
                        }       
+                       if {!$::noImg || $fmt eq "GIF" || $fmt eq "PPM"} {
                        $w.record.image configure -image [image create photo -format $fmt -data $record($img_index)]
-               } else {
+                       set hasImage 1
+                       }
+                       
+               } 
+               if {!$hasImage} {
                        $w.record.image configure -image ""
                }
        }