[Tkabber-dev] r498 - in trunk/plugins/hidetabs: . msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Oct 11 11:39:39 MSD 2011


Author: ancestor
Date: 2011-10-11 11:39:39 +0400 (Tue, 11 Oct 2011)
New Revision: 498

Modified:
   trunk/plugins/hidetabs/hidetabs.tcl
   trunk/plugins/hidetabs/msgs/ru.msg
Log:
1) Added all last updates to hidetabs.tcl from rejjin's mercurial repo. See https://bitbucket.org/rejjin/hidetabs for details.

Modified: trunk/plugins/hidetabs/hidetabs.tcl
===================================================================
--- trunk/plugins/hidetabs/hidetabs.tcl	2011-10-10 21:48:58 UTC (rev 497)
+++ trunk/plugins/hidetabs/hidetabs.tcl	2011-10-11 07:39:39 UTC (rev 498)
@@ -26,6 +26,7 @@
 	set self(fr) .nb
 	set self(state) 1
 	set self(menu-fr) .menu_tabbar
+	set self(tabsmenu) .tabsmenu
 	
 	set config(nonecolor) ""
 	set config(unread_msg_color) ""
@@ -75,6 +76,16 @@
 		-group hidetabs -type boolean \
 		-command [namespace current]::show_unread
 		
+	custom::defvar config(show_current_tab) 1 \
+		[mc "Show title of active tab."] \
+		-group hidetabs -type boolean \
+		-command [namespace current]::show_ctab
+		
+	custom::defvar config(hide_ctab_unread) 0 \
+		[mc "Hide labels when tabbar hidden."] \
+		-group hidetabs -type boolean \
+		-command [namespace current]::hide_labels_process
+		
 	custom::defvar config(key_nb_toggle) "<Key-F5>" \
 		[mc "Key for toggle tabbar."] \
 		-group hidetabs -type string \
@@ -85,21 +96,65 @@
 		-group hidetabs -type string \
 		-command [list [namespace current]::change_bindkey $config(key_menu_toggle)]
 	
-	image create photo none-type \
+	image create photo hidetabs/none-type \
 		-file [file join $cdir pixmaps none-type.gif]
-	
 
 	hook::add finload_hook [namespace current]::load
 	hook::add systray_menu_hook [namespace current]::systray_menu 20
 }
 
 proc hidetabs::systray_menu { m } {
+	variable self
+	$m configure -postcommand [list [namespace current]::generate_menu $m]
+	$m insert end command -label [mc "Dismiss all tabs"] \
+		-command [namespace current]::dismiss_all
 	menu $m.hidetabs -title [mc "Tabs"] -tearoff 0 \
 		-postcommand [list [namespace current]::pcm_menu $m.hidetabs]
 	$m add cascade -label [mc "Tabs"] -menu $m.hidetabs
 	$m add separator
 }
 
+proc hidetabs::hide_labels_process {args} {
+	variable config
+	variable self
+	
+	if { $self(state) && $config(hide_ctab_unread)} { 
+		delete_unread
+		delete_ctab
+	}
+}
+
+proc hidetabs::generate_menu { m } {
+	variable self
+	
+	if { [info exist self(idx-menu)] && $self(idx-menu) > 0} {
+	$m delete 0 $self(idx-menu)
+	}
+	
+	set self(idx-menu) 0
+	foreach ind [get_tabs_data] {
+		lassign $ind tab color tabtitle number_msg personal_msg cmd icon c_tab
+
+		if {$number_msg > 0} { 
+			append tabtitle " ($number_msg)" 
+			if {[string equal $tab $c_tab]} { 
+			set tabtitle "\[ $tabtitle \]" 
+			}
+			$m insert $self(idx-menu) command -label $tabtitle -command $cmd \
+			-image $icon -compound left -foreground $color
+			incr self(idx-menu)
+		}
+	}
+	if {$self(idx-menu) > 0} {
+	incr self(idx-menu)
+	$m insert $self(idx-menu) separator
+	}
+	set l 0
+	foreach ind [get_tabs_data] {
+	incr l
+	}
+}
+
 proc hidetabs::load {} {
 	variable config
 	
@@ -109,6 +164,7 @@
 		-tearoff 0 -title [mc "Tabs"] 
 	
 	show_unread
+	show_ctab
 	
 	bind . $config(key_nb_toggle) [namespace current]::toggle_tabbar
 	bind . $config(key_menu_toggle) [list [namespace current]::menu_key 0 toggle]
@@ -125,6 +181,7 @@
 	catch {destroy $m.list}
 	
 	delete_unread
+	delete_ctab
 	
 	bind . $config(key_nb_toggle) {}
 	bind . $config(key_menu_toggle) {}
@@ -135,6 +192,11 @@
 	catch { destroy $w.unreadl }
 }
 
+proc hidetabs::delete_ctab {} {
+	set w [.mainframe gettoolbar 0]
+	catch { destroy $w.ctab }
+}
+
 proc hidetabs::show_unread { args } {
 	variable config
 	
@@ -150,7 +212,12 @@
 	}
 	
 	label $w.unreadl
+	
+	if { [winfo exist $w.ctab] } {
+	pack $w.unreadl -side right -padx 3 -before $w.ctab
+	} else {
 	pack $w.unreadl -side right -padx 3
+	}
 	
 	if { $config(nonecolor) == "" } {
 	set config(nonecolor) [$w.unreadl cget -foreground]
@@ -159,11 +226,77 @@
 	bind $w.unreadl <1> [list [namespace current]::next_unread $w.unreadl]
 	bind $w.unreadl <3> [list [namespace current]::menu_key 0 toggle]
 	
-	unread_label_loop $w.unreadl
+	unread_label_loop $w
 }
 
+proc hidetabs::show_ctab { args } {
+	variable config
+	
+	set w [.mainframe gettoolbar 0]
+	
+	if { !$config(show_current_tab) } {
+		catch { destroy $w.ctab}
+		return
+	}
+	
+	if { [winfo exist $w.ctab] } {
+	return
+	}
+	
+	label $w.ctab
+	
+	if { [winfo exist $w.unreadl] } {
+	pack $w.ctab -side right -after $w.unreadl -padx 0
+	} else {
+	pack $w.ctab -side right -padx 0
+	}
+	
+	bind $w.ctab <1> [list [namespace current]::menu_ctab_show %W %X %Y]
+	bind $w.ctab <Any-Enter> [list [namespace current]::scroll init]
+	bind $w.ctab <Any-Leave> [list [namespace current]::scroll destroy]
+	
+	unread_label_loop $w
+}
+
+proc hidetabs::scroll { type } {
+	switch -- $type {
+		init {
+			bind . <<ScrollUp>> [list [namespace current]::open_tab next]
+			bind . <<ScrollDown>> [list [namespace current]::open_tab prev]
+		}
+		destroy {
+			bind . <<ScrollUp>> {}
+			bind . <<ScrollDown>> {}
+		}
+	}
+}
+
+proc hidetabs::open_tab { type } {
+	variable self
+	switch -- $type {
+		next {
+			ifacetk::tab_move $self(fr) +1
+		}
+		prev {
+			ifacetk::tab_move $self(fr) -1
+		}
+	}
+}
+
+proc hidetabs::menu_ctab_show {w x y} {
+	set m $w.menu
+
+	if { ![winfo exists $m] } {
+		menu $m -tearoff 0
+	}
+
+	pcm_menu $m
+	
+	tk_popup $m $x $y
+}
+
 proc hidetabs::next_unread { m } {
-	if { [string equal [$m cget -text] [mc "Messages: %s" n/a]] } {
+	if { [string equal [$m cget -text] "\[ [mc "Messages: %s" _] \]"] } {
 		menu_key 0 toggle
 		return
 	}
@@ -183,12 +316,31 @@
 }
 
 proc hidetabs::unread_label_loop { w } {
-	variable config
+	variable after_idle
 	
-	if { ![winfo exist $w] } {
+	if { [info exist after_idle] } {
+	after cancel $after_idle
+	}
+	
+	if { ![winfo exist $w.unreadl] && ![winfo exist $w.ctab] } {
 	return
 	}
 	
+	if { [winfo exist $w.unreadl] } {
+	update_unread_label $w
+	}
+	
+	if { [winfo exist $w.ctab] } {
+	update_ctab_label $w
+	}
+	
+	set after_idle [after idle "after 100 [list \
+	[namespace current]::unread_label_loop $w]"]
+}
+
+proc hidetabs::update_unread_label { w } {
+	variable config
+	
 	set unreaded 0
 	set color $config(nonecolor)
 	set pmsgs 0
@@ -218,19 +370,64 @@
 	}
 	
 	if { [string equal $unreaded "0"] } {
-		set unreaded n/a
+		set unreaded _
 	}
 	
 	set title [mc "Messages: %s" $unreaded]
-	$w configure -text $title -foreground $color -state normal
+	$w.unreadl configure -text "\[ $title \]" -foreground $color -state normal
 	
 	if { $ss && $config(auto_disable_label) } {
-		$w configure -state disabled
+		$w.unreadl configure -state disabled
 	}
+}
+
+proc hidetabs::update_ctab_label { w } {
+	$w.ctab configure -text "" -image ""
+	foreach ind [get_tabs_data] {
+		lassign $ind tab color tabtitle number_msg personal_msg cmd icon c_tab
+		if { [string equal $tab $c_tab] } {
+			$w.ctab configure -text "\[ $tabtitle \]" -foreground $color \
+			-image $icon -compound left
+			bind $w.ctab <3> [list [namespace current]::tab_menu %X %Y $c_tab]
+			bind $w.ctab <2> [list ifacetk::destroy_tab $c_tab]
+		}
+	}
+}
+
+proc hidetabs::tab_menu {x y page} {
+	variable self
+	global curmenutab
 	
-	after idle "after 500 [list [namespace current]::unread_label_loop $w]"
+    set curmenutab $page
+	
+	set m .hidetabsmenu
+	if { ![winfo exist $m]} {
+	$self(tabsmenu) clone $m
+	$m add separator
+	$m add command -label [mc "Dismiss all tabs"] \
+	-command [namespace current]::dismiss_all
+	}
+	
+	tk_popup $m $x $y
 }
 
+proc hidetabs::dismiss_all {} {
+	foreach chatid [::chat::opened] {
+		set winid [::chat::winid $chatid]
+		set page [ifacetk::nbpage $winid]
+		set color [lindex $::alert_colors 0]
+		.nb itemconfigure $page \
+				-foreground $color \
+				-activeforeground $color
+		set ::tabcolors($page) 0
+		set ::ifacetk::number_msg($chatid) 0
+		set ::ifacetk::personal_msg($chatid) 0
+		
+		ifacetk::update_chat_title $chatid
+		ifacetk::update_main_window_title
+	}
+}
+
 proc hidetabs::change_bindkey {old_key ns key c} {
 	variable config
 
@@ -270,10 +467,17 @@
 
 proc hidetabs::toggle_tabbar { args } {
 	variable self
+	variable config
 	
 	if { $self(state) } { 
 	grid forget $self(fr) 
+	show_unread
+	show_ctab
 	} else { 
+	if {$config(hide_ctab_unread)} {
+		delete_unread
+		delete_ctab
+	}
 	ifacetk::configure_tabs
 	}
 	
@@ -297,7 +501,6 @@
 		if {[info exist S] && $S} {
 			close_menu
 			aset 300 $full_s 0
-			array unset p_fm
 		} else {
 			show_menu
 			aset 100 $full_s 1
@@ -412,6 +615,7 @@
 	} 	
 
 	if { ! $process} {
+		array unset p_fm
 		set nb [llength $slv]
 		set tm [lindex $slv 0]
 		grid $tm
@@ -555,7 +759,7 @@
 	foreach tab [.nb pages] {
 		set cw [pack slaves [.nb getframe $tab]]
 		set chatid [::chat::winid_to_chatid $cw]
-		set icon none-type
+		set icon hidetabs/none-type
 		set number_msg 0; set personal_msg 0
 		
 		if { [string length $chatid] > 0 } {

Modified: trunk/plugins/hidetabs/msgs/ru.msg
===================================================================
--- trunk/plugins/hidetabs/msgs/ru.msg	2011-10-10 21:48:58 UTC (rev 497)
+++ trunk/plugins/hidetabs/msgs/ru.msg	2011-10-11 07:39:39 UTC (rev 498)
@@ -15,4 +15,7 @@
 ::msgcat::mcset ru "Key for toggle tabs menu." "Клавиша / комбинация для переключения окна."
 ::msgcat::mcset ru "Tabs" "Вкладки"
 ::msgcat::mcset ru "Messages: %s" "Сообщений: %s"
-::msgcat::mcset ru "Save last focus on button." "Запоминать последний выделенный таб."
\ No newline at end of file
+::msgcat::mcset ru "Save last focus on button." "Запоминать последний выделенный таб."
+::msgcat::mcset ru "Show title of active tab." "Показывать заголовок активного таба."
+::msgcat::mcset ru "Dismiss all tabs" "Пометить всё как прочитанное"
+::msgcat::mcset ru "Hide labels when tabbar hidden." "Прятать метки при скрытии таббара."
\ No newline at end of file



More information about the Tkabber-dev mailing list