[Tkabber-dev] r45 - in trunk/plugins: . np_file np_registry

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Sep 19 21:33:51 MSD 2007


Author: kostix
Date: 2007-09-19 21:33:51 +0400 (Wed, 19 Sep 2007)
New Revision: 45

Added:
   trunk/plugins/np_registry/
   trunk/plugins/np_registry/AUTHORS
   trunk/plugins/np_registry/INSTALL
   trunk/plugins/np_registry/np_registry.tcl
Modified:
   trunk/plugins/np_file/np_file.tcl
Log:
np_registry: Added skeleton for the new "now playing" plugin which reads
  Windows registry.
np_file/np_file.tcl: removed no longer needed [uprefs] proc.


Modified: trunk/plugins/np_file/np_file.tcl
===================================================================
--- trunk/plugins/np_file/np_file.tcl	2007-09-19 16:40:17 UTC (rev 44)
+++ trunk/plugins/np_file/np_file.tcl	2007-09-19 17:33:51 UTC (rev 45)
@@ -18,14 +18,6 @@
 		lset args 0 [uplevel 1 namespace current]::[lindex $args 0]
 	}
 
-	proc uprefs {} {
-		foreach v [uplevel 1 info locals] {
-			if {[string match &* $v]} {
-				uplevel 1 upvar 1 "\${$v} [string range $v 1 end]"
-			}
-		}
-	}
-
 	custom::defgroup "User Tune" \
 		[::msgcat::mc "Plugins for automatic gathering of\
 			information for User Tune personal eventing facility."] \

Added: trunk/plugins/np_registry/AUTHORS
===================================================================
--- trunk/plugins/np_registry/AUTHORS	                        (rev 0)
+++ trunk/plugins/np_registry/AUTHORS	2007-09-19 17:33:51 UTC (rev 45)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>


Property changes on: trunk/plugins/np_registry/AUTHORS
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/plugins/np_registry/INSTALL
===================================================================
--- trunk/plugins/np_registry/INSTALL	                        (rev 0)
+++ trunk/plugins/np_registry/INSTALL	2007-09-19 17:33:51 UTC (rev 45)
@@ -0,0 +1,11 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/np_registry/
+  ~/.tkabber/plugins/np_registry/np_registry.tcl
+
+Restart Tkabber, to get the plugin loaded.
+Visit the "Customize->Plugins->User Tune->Now Playing (Registry)"
+block of settings and adjust them to match your setup.
+
+Consult the README file for the details about using this plugin.


Property changes on: trunk/plugins/np_registry/INSTALL
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/plugins/np_registry/np_registry.tcl
===================================================================
--- trunk/plugins/np_registry/np_registry.tcl	                        (rev 0)
+++ trunk/plugins/np_registry/np_registry.tcl	2007-09-19 17:33:51 UTC (rev 45)
@@ -0,0 +1,89 @@
+# $Id$
+
+if {![string equal $tcl_platform(platform) windows]} return
+if {[catch {package require registry} err]} {
+	puts stderr "np_registry: plugin is disabled due to: $err"
+	return
+}
+
+namespace np_registry {
+	variable options
+	variable players
+	variable lastinfo
+
+	custom::defvar options(media_player) "" \
+		[::msgcat::mc "Media player that manages its now playing\
+			information in the system registry.\
+			Select \"None\" to disable this plugin."] \
+		-type options \
+		-values [list] \
+		-command [mycmd on_media_player_changed] \
+		-group NowPlayingRegistry
+}
+
+# Calling of this procedure does only have sense when done from
+# a np_file_enumerate_media_players hook.
+proc np_registry::add_media_player args {
+	variable options
+	variable players
+
+	foreach {opt val} $args {
+		switch -- $opt {
+			-tag    { set tag $val }
+			-name   { set name $val }
+			-parser { set parser $val }
+			default {
+				return -code error "Bad option \"$opt\":\
+					must be one of -tag, -name or -parser"
+			}
+		}
+	}
+
+	foreach v {tag name parser} {
+		if {![info exists $v]} {
+			return -code error "Required option missing: -$v"
+		}
+	}
+
+	if {$tag == ""} {
+		return -code error "Empty tag is reserved and cannot be used"
+	}
+
+	set options(name,$tag) $name
+	set options(parser,$tag) $parser
+
+	lappend players $tag $name
+}
+
+proc np_registry::enumerate_media_players {} {
+	variable options
+	variable players
+
+	foreach {tag name parser} [list \
+		wmp     "Windows Media Player"   [mycmd wmp_yield] \
+	] {
+		add_media_player -tag $tag -name $name -parser $parser
+	}
+
+	hook::run np_file_enumerate_media_players
+
+	custom::configvar [namespace current]::options(media_player) \
+		-values [concat [list "" [::msgcat::mc "None"]] $players]
+
+	unset players
+}
+
+proc np_registry::on_media_player_changed args {
+	variable lastinfo
+
+	array unset lastinfo *
+}
+
+#### Windows Media Player
+
+proc np_registry::wmp_yield {
+	set key {HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\CurrentMetadata}
+}
+
+np_registry::enumerate_media_players
+


Property changes on: trunk/plugins/np_registry/np_registry.tcl
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Tkabber-dev mailing list