[Tkabber-dev] r77 - in trunk/plugins: . pluginmanager

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Nov 26 16:18:33 MSK 2007


Author: archimed
Date: 2007-11-26 16:18:32 +0300 (Mon, 26 Nov 2007)
New Revision: 77

Added:
   trunk/plugins/pluginmanager/
   trunk/plugins/pluginmanager/pluginmanager.tcl
   trunk/plugins/pluginmanager/readme
   trunk/plugins/pluginmanager/version
Removed:
   trunk/plugins/floatinglog/
Log:
floatinglog moved to tkabber plugins trunk.
pluginmanager is a plugin for tkabber-pack only.

Added: trunk/plugins/pluginmanager/pluginmanager.tcl
===================================================================
--- trunk/plugins/pluginmanager/pluginmanager.tcl	                        (rev 0)
+++ trunk/plugins/pluginmanager/pluginmanager.tcl	2007-11-26 13:18:32 UTC (rev 77)
@@ -0,0 +1,87 @@
+package require msgcat
+
+namespace eval pluginmanager {
+    variable DirPluginsAll [file join [file dirname $::rootdir] Plugins]
+    variable PluginsAll [lsort [glob -type d -tails \
+	-directory $DirPluginsAll -nocomplain *]]
+    foreach plugin $PluginsAll {
+	variable $plugin 0
+    }
+    variable DirPluginsInstalled [file join $::configdir Plugins]
+    if {[file exists $DirPluginsInstalled] == 0} {
+        file mkdir $DirPluginsInstalled
+    }
+    variable PluginsInstalled
+    variable winname .plugin_manager
+
+    proc create_menu {} {
+	set menu [.mainframe getmenu plugins]
+	$menu add command \
+		-label [::msgcat::mc "Open plugin manager"] \
+		-command [namespace current]::open_window
+    }
+
+    hook::add finload_hook [namespace current]::create_menu
+
+    proc open_window {} {
+	variable PluginsAll
+	variable DirPluginsInstalled
+	variable PluginsInstalled [lsort [glob -type d -tails \
+		-directory $DirPluginsInstalled -nocomplain *]]
+	variable winname
+
+	if {[winfo exists $winname]} {
+	    return
+	}
+
+	add_win $winname -title [::msgcat::mc "Plugin manager"] \
+	    -tabtitle [::msgcat::mc "PluginManager"] \
+	    -raisecmd [list focus $winname.ok]
+	set sw [ScrolledWindow $winname.sw]
+	set t [text $winname.pluginlist -wrap word -background [$winname cget -background]]
+	$sw setwidget $t
+	
+	foreach plugin $PluginsAll {
+	    if { [lsearch -exact $PluginsInstalled $plugin] >= 0 } {
+		variable $plugin 1
+	    } else {
+		variable $plugin 0
+	    }
+	    set cb_$plugin [checkbutton $t.$plugin -cursor left_ptr\
+			-text [::msgcat::mc $plugin] \
+			-variable [namespace current]::$plugin]
+	    $t window create end -window [set cb_$plugin]
+	    bindscroll [set cb_$plugin] $t
+	    $t insert end "\n"
+	}
+	set apply_button [button $winname.apply \
+			-text [::msgcat::mc "Apply changes"] \
+			-command [namespace current]::installdelete] 
+	
+	pack $apply_button -pady 5
+	pack $sw -side top -expand no -fill x
+    }
+
+    proc installdelete {} {
+        variable DirPluginsAll
+	variable PluginsAll
+	variable DirPluginsInstalled
+	variable PluginsInstalled [lsort [glob -type d -tails \
+		-directory $DirPluginsInstalled -nocomplain *]]
+	variable winname
+	foreach plugin $PluginsAll {
+	    variable $plugin
+	    if { [set $plugin] } {
+		if { [lsearch -exact $PluginsInstalled $plugin] < 0 } {
+		    file copy -force [file join $DirPluginsAll $plugin] $DirPluginsInstalled
+		}
+	    } else {
+		if { [lsearch -exact $PluginsInstalled $plugin] >= 0 } {
+		    file delete -force [file join $DirPluginsInstalled $plugin]
+		}
+	    }
+	}
+	tk_messageBox -type ok -icon info -title [::msgcat::mc "Operation complite"] \
+		-message [::msgcat::mc "You need to restart Tkabber to apply changes"]
+    }
+}
\ No newline at end of file

Added: trunk/plugins/pluginmanager/readme
===================================================================
--- trunk/plugins/pluginmanager/readme	                        (rev 0)
+++ trunk/plugins/pluginmanager/readme	2007-11-26 13:18:32 UTC (rev 77)
@@ -0,0 +1 @@
+Pluginmanager is designed to use in tkabber-pack only.
\ No newline at end of file

Added: trunk/plugins/pluginmanager/version
===================================================================
--- trunk/plugins/pluginmanager/version	                        (rev 0)
+++ trunk/plugins/pluginmanager/version	2007-11-26 13:18:32 UTC (rev 77)
@@ -0,0 +1,2 @@
+2007-nov-26
+ver 0.1 - demonstration version
\ No newline at end of file



More information about the Tkabber-dev mailing list