[Tkabber-dev] r782 - in trunk/tkabber: . plugins/richtext

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Nov 4 21:06:33 MSK 2006


Author: sergei
Date: 2006-11-04 21:06:29 +0300 (Sat, 04 Nov 2006)
New Revision: 782

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/richtext/emoticons.tcl
Log:
	* plugins/richtext/emoticons.tcl: Fixed processing of 'None'
	  emoticon theme (theme without images at all).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-11-04 11:43:05 UTC (rev 781)
+++ trunk/tkabber/ChangeLog	2006-11-04 18:06:29 UTC (rev 782)
@@ -1,5 +1,8 @@
 2006-11-04  Sergei Golovan  <sgolovan at nes.ru>
 
+	* plugins/richtext/emoticons.tcl: Fixed processing of 'None'
+	  emoticon theme (theme without images at all).
+
 	* plugins/richtext/urls.tcl, chats.tcl: Fixed URL highlighting
 	  when mouse pointer is over the URL (thanks to Konstantin
 	  Khomoutov).

Modified: trunk/tkabber/plugins/richtext/emoticons.tcl
===================================================================
--- trunk/tkabber/plugins/richtext/emoticons.tcl	2006-11-04 11:43:05 UTC (rev 781)
+++ trunk/tkabber/plugins/richtext/emoticons.tcl	2006-11-04 18:06:29 UTC (rev 782)
@@ -30,12 +30,12 @@
     set options(no_theme) [::msgcat::mc "None"]
     set options(active_theme) $options(no_theme)
 	
-    custom::defvar options(theme) $options(no_theme) \
+    custom::defvar options(theme) "" \
 	[::msgcat::mc "Tkabber emoticons theme. To make new theme visible\
 		       for Tkabber put it to some subdirectory of\
 		       ~/.tkabber/emoticons"] \
 	-group Emoticons -type options \
-	-values [list {} $options(no_theme)] \
+	-values [list "" $options(no_theme)] \
 	-command [namespace current]::on_theme_changed
 
     custom::defvar options(match_whole_word) 1 \
@@ -122,7 +122,9 @@
     }
 
     # Load fresh images:
-    merge_dir $dir
+    if {$dir != ""} {
+	merge_dir $dir
+    }
 }
 
 # Merges a new set of emoticons, adding them to the existing set,
@@ -485,12 +487,8 @@
     foreach dir $dirs {
 	enumerate_theme [namespace current]::themes $dir
     }
-
-    variable themes
 }
 
-
-
 proc emoticons::enumerate_theme {varName dir} {
     set icondef_path [file join $dir icondef.xml]
 
@@ -508,8 +506,6 @@
     jlib::wrapper:free $parser
 }
 
-
-
 proc emoticons::get_theme_name {varName dir xmldata} {
     upvar #0 $varName themes
 
@@ -528,23 +524,16 @@
     return 0
 }
 
-
-
 proc emoticons::load_theme {theme} {
     variable themes
 
     if {![info exists themes($theme)]} {
-	error "No emoteicons theme: $theme"
+	load_dir ""
+    } else {
+	load_dir $themes($theme)
     }
-
-    set dir $themes($theme)
-    if {$dir == ""} return ;# handles None -> {} pair
-
-    load_dir $themes($theme)
 }
 
-
-
 # Gets called when options(theme) changes
 proc emoticons::on_theme_changed {args} {
     variable options
@@ -554,8 +543,6 @@
     }
 }
 
-
-
 # Gets called when the enabled/disabled state of emoticons subsystem changes
 proc emoticons::on_state_changed {args} {
     variable options
@@ -567,45 +554,50 @@
     }
 }
 
-
-
-proc emoticons::enable_subsystem {} {
+proc emoticons::find_themes {} {
     variable options
     variable themes
 
     array unset themes *
 
     enumerate_available_themes
-    
+
     set theme_names [lsort [array names themes]]
 
-    if {[llength $theme_names] > 0} {
-	set idx [lsearch -sorted $theme_names Default]
-	if {$idx > 0} {
-	    set theme_names [linsert [lreplace $theme_names $idx $idx] 0 Default]
-	}
+    set idx [lsearch -sorted $theme_names Default]
+    if {$idx > 0} {
+	set theme_names [linsert [lreplace $theme_names $idx $idx] 0 Default]
+    }
 
-	foreach theme $theme_names {
-	    lappend values $theme $theme
-	}
+    foreach theme $theme_names {
+	lappend values $theme $theme
+    }
 
-	set idx [lsearch -sorted $theme_names $options(theme)]
-	if {$idx < 0} {
-	    set idx [lsearch -sorted $theme_names Default]
-	    if {$idx < 0} { set idx 0 }
-	}
-	set options(theme) [lindex $theme_names $idx]
+    set values [linsert $values 0 "" $options(no_theme)]
+
+    set idx [lsearch -sorted $theme_names $options(theme)]
+    if {$idx >= 0} {
+	set theme [lindex $theme_names $idx]
     } else {
-	set options(theme) $options(no_theme)
-	set values [list {} $options(no_theme)]
+	set idx [lsearch -sorted $theme_names Default]
+	if {$idx >= 0} {
+	    set theme [lindex $theme_names $idx]
+	} else {
+	    set theme ""
+	}
     }
 
     ::custom::configvar [namespace current]::options(theme) -values $values
+    set options(theme) $theme
+}
 
+proc emoticons::enable_subsystem {} {
+    find_themes
     ::richtext::entity_state emoticon 1
 }
 
 proc emoticons::disable_subsystem {} {
+    find_themes
     ::richtext::entity_state emoticon 0
 }
 



More information about the Tkabber-dev mailing list