[Tkabber-dev] r497 - in trunk/plugins/notes: . doc ifaces

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Oct 11 01:48:58 MSD 2011


Author: Totktonada
Date: 2011-10-11 01:48:58 +0400 (Tue, 11 Oct 2011)
New Revision: 497

Added:
   trunk/plugins/notes/.gitignore
   trunk/plugins/notes/gui_actions.tcl
Modified:
   trunk/plugins/notes/
   trunk/plugins/notes/doc/TODO
   trunk/plugins/notes/ifaces/gui.tcl
   trunk/plugins/notes/notes.tcl
Log:
Notes plugin:

1. Update TODO.
2. Add .gitignore file.
3. Add action ?\194?\171Copy selection to new note?\194?\187.



Property changes on: trunk/plugins/notes
___________________________________________________________________
Added: svn:ignore
   + Changes.txt


Added: trunk/plugins/notes/.gitignore
===================================================================
--- trunk/plugins/notes/.gitignore	                        (rev 0)
+++ trunk/plugins/notes/.gitignore	2011-10-10 21:48:58 UTC (rev 497)
@@ -0,0 +1,3 @@
+.*.swp
+.vim
+Changes.txt

Modified: trunk/plugins/notes/doc/TODO
===================================================================
--- trunk/plugins/notes/doc/TODO	2011-10-05 19:38:48 UTC (rev 496)
+++ trunk/plugins/notes/doc/TODO	2011-10-10 21:48:58 UTC (rev 497)
@@ -139,3 +139,7 @@
 Изменения из строки для ввода тегов по Enter'у надо добавлять в промежуточную
 переменную, чтобы при экспорте и прочей обработке обрабатывалось именно то, что
 в lbox.
+
+======================
+
+Проверить: несколько пробелов между тегами.

Added: trunk/plugins/notes/gui_actions.tcl
===================================================================
--- trunk/plugins/notes/gui_actions.tcl	                        (rev 0)
+++ trunk/plugins/notes/gui_actions.tcl	2011-10-10 21:48:58 UTC (rev 497)
@@ -0,0 +1,41 @@
+namespace eval gui_actions {
+# TODO: need here, or only in ::plugins::notes?
+#    package require msgcat
+}
+
+proc gui_actions::load {} {
+    hook::add chat_win_popup_menu_hook [namespace current]::selection_popup 90
+}
+
+proc gui_actions::unload {} {
+    hook::remove chat_win_popup_menu_hook [namespace current]::selection_popup 90
+}
+
+proc gui_actions::selection_popup {m W X Y x y} {
+    if {[expr [lempty [$W tag ranges sel]] || \
+        [expr [llength [plugins::notes::connections]] == 0]]} {
+        set state disabled
+    } else {
+        set state normal
+    }
+
+    $m add command -label [::msgcat::mc "Copy selection to new note"] \
+        -command [list [namespace current]::CopySelection $W] \
+        -state $state
+}
+
+proc gui_actions::CopySelection {cw} {
+    if {$cw == "."} {
+        set cw [get_chatwin]
+        if {$cw == ""} return
+    }
+
+    set sel [$cw tag ranges sel]
+    if {$sel == ""} return
+
+    set text [$cw get [lindex $sel 0] [lindex $sel 1]]
+
+#    ::plugins::notes::set_note end end $new_note # Add note immediately.
+    ::plugins::notes::ifaces::gui::edit_note end \
+        -text $text
+}

Modified: trunk/plugins/notes/ifaces/gui.tcl
===================================================================
--- trunk/plugins/notes/ifaces/gui.tcl	2011-10-05 19:38:48 UTC (rev 496)
+++ trunk/plugins/notes/ifaces/gui.tcl	2011-10-10 21:48:58 UTC (rev 497)
@@ -208,6 +208,19 @@
         set title ""
         set tags_str ""
         set text ""
+
+        foreach {key value} $args {
+            switch -- $key {
+                -title -
+                -text -
+                -tags_str {
+                    set [string range $key 1 end] $value
+                }
+                -tags {
+                    set tags_str [join $value " "]
+                }
+            }
+        }
     } else {
         set source_note [::plugins::notes::get_note $idx [get_filter_tags]]
         ::xmpp::private::notes::split $source_note title -> text tags_str
@@ -272,6 +285,10 @@
 proc ifaces::gui::get_filter_tags {} {
     set tags .notes.tools.tags
 
+    if {![winfo exists .notes]} {
+        return {}
+    }
+
     return [split [string trim [$tags get] " "] " "]
 }
 

Modified: trunk/plugins/notes/notes.tcl
===================================================================
--- trunk/plugins/notes/notes.tcl	2011-10-05 19:38:48 UTC (rev 496)
+++ trunk/plugins/notes/notes.tcl	2011-10-10 21:48:58 UTC (rev 497)
@@ -34,6 +34,8 @@
     }
 
     source [file join $scriptdir ie.tcl]
+    source [file join $scriptdir gui_actions.tcl]
+    eval gui_actions::load
 
     hook::add disconnected_hook [namespace current]::disconnected
     hook::add connected_hook [namespace current]::connected
@@ -44,6 +46,8 @@
 proc notes::unload {} {
     variable scriptdir
 
+    eval gui_actions::unload
+
 # TODO: think about create list of ifaces on load (in notes::load) and unload them by this list
     set ifaces_dir [file join $scriptdir ifaces]
     foreach iface_file [glob -nocomplain -directory "$ifaces_dir" "*.tcl"] {



More information about the Tkabber-dev mailing list