[Tkabber-dev] r383 - in trunk/plugins: . themes themes/msgs themes/themes

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Sep 12 22:42:08 MSD 2010


Author: Rejjin
Date: 2010-09-12 22:42:08 +0400 (Sun, 12 Sep 2010)
New Revision: 383

Added:
   trunk/plugins/themes/
   trunk/plugins/themes/msgs/
   trunk/plugins/themes/msgs/ru.msg
   trunk/plugins/themes/themes.tcl
   trunk/plugins/themes/themes/
   trunk/plugins/themes/themes/Test.thm
Log:
Plugin to support color schemes for Tkabber. It contains only one test subject. To create your order, use the plugin - themes_editor

Added: trunk/plugins/themes/msgs/ru.msg
===================================================================
--- trunk/plugins/themes/msgs/ru.msg	                        (rev 0)
+++ trunk/plugins/themes/msgs/ru.msg	2010-09-12 18:42:08 UTC (rev 383)
@@ -0,0 +1,3 @@
+::msgcat::mcset ru "Color theme options" "Настройки цветовых схем"
+::msgcat::mcset ru "Tkabber color theme (Need restart)." "Цветовая схема Tkabber (Требуется перезапуск)."
+::msgcat::mcset ru "Theme %s with error!\n%s" "Тема %s содержит ошибку!\n%s"
\ No newline at end of file

Added: trunk/plugins/themes/themes/Test.thm
===================================================================
--- trunk/plugins/themes/themes/Test.thm	                        (rev 0)
+++ trunk/plugins/themes/themes/Test.thm	2010-09-12 18:42:08 UTC (rev 383)
@@ -0,0 +1,58 @@
+*activeBackground: #8f8f8f
+*activeBorderWidth: 2
+*activeForeground: #030303
+*background: #bfbfbf
+*borderWidth: 1
+*disabledForeground: #595959
+*foreground: #030303
+*highlightBackground: #a3a3a3
+*highlightColor: #a8a8a8
+*highlightThickness: 0
+*padX: 0
+*padY: 0
+*Button.relief: ridge
+*selectBackground: #9e9e9e
+*selectBorderWidth: 1
+*selectForeground: #fffaf0
+*input*relief: groove
+*ButtonBar*font: Tahoma 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: trunk/plugins/themes/themes.tcl
===================================================================
--- trunk/plugins/themes/themes.tcl	                        (rev 0)
+++ trunk/plugins/themes/themes.tcl	2010-09-12 18:42:08 UTC (rev 383)
@@ -0,0 +1,98 @@
+package require msgcat
+
+namespace eval themes {
+variable SCRIPT_DIR
+	
+	set SCRIPT_DIR [file dirname [info script]]
+	
+	::msgcat::mcload [file join $SCRIPT_DIR msgs]
+	
+	custom::defgroup Plugins [::msgcat::mc "Plugins options."] \
+	-group Tkabber	
+	
+    custom::defgroup Themes [::msgcat::mc "Color theme options"] \
+	-group Plugins	
+	
+	hook::add finload_hook [namespace current]::handle 
+		
+}
+
+proc themes::handle { } {
+variable TKABBER_THEME
+
+	set themes [get_themes_from_dir]
+	custom::defvar TKABBER_THEME Default \
+		[::msgcat::mc "Tkabber color theme (Need restart)."] -type options \
+		-values $themes -group Themes
+		
+	add_trace_to_tkabber_theme
+}
+
+proc themes::add_trace_to_tkabber_theme { } {
+variable TKABBER_THEME
+	trace add variable [namespace current]::TKABBER_THEME write \
+		[namespace current]::change_theme
+}
+		
+proc themes::change_theme { who work value } {
+variable TKABBER_THEME
+	save_theme $TKABBER_THEME
+}
+		
+proc themes::save_theme { theme } {
+variable SCRIPT_DIR
+
+	set cache [open [file join $SCRIPT_DIR theme] w]
+	puts $cache $theme
+	close $cache
+}
+
+proc themes::load_theme { } {
+variable SCRIPT_DIR
+	
+	set path [file join $SCRIPT_DIR theme]
+	
+	if { [file exist $path] == 0 } {
+		return Default
+	}
+	
+	set cache [open $path r]
+	gets $cache theme
+	close $cache
+	
+	return $theme
+}
+
+proc themes::get_themes_from_dir { } {
+variable SCRIPT_DIR
+
+	set themes { Default Default } 
+	set path [file join $SCRIPT_DIR themes] 
+	
+	foreach theme [glob -nocomplain -directory $path *.thm] {
+		lappend themes [file normalize $theme] \
+			[file tail [file rootname $theme]]
+	}
+	
+	return $themes
+}
+
+#########################################################
+proc themes::init_theme { } {
+	set theme [load_theme]
+		
+	if { $theme ne "Default" } {
+		if { [catch { option readfile $theme } out] } {
+			hook::add finload_hook {
+				tk_messageBox -icon warning \
+				-message [::msgcat::mc "Theme %s with error!\n%s" $theme $out]
+			}
+			save_theme Default
+		}
+	}
+}
+
+[namespace current]::themes::init_theme
+#########################################################
+
+



More information about the Tkabber-dev mailing list