Skip to content

Commit ba0b9a0

Browse files
author
naveedm9
committed
Added a blinking status icon when new messages arrive.
git-svn-id: http://vimchat.googlecode.com/svn/trunk@113 d1d492a2-f496-11dd-9d1d-173cc1d06e3c
1 parent 7d10513 commit ba0b9a0

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

plugin/vimchat.vim

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ except:
5959
pyotr_logging = False
6060

6161

62-
gtk_available = False
62+
gtk_enabled = False
6363
try:
6464
from gtk import StatusIcon
6565
import gtk
66-
gtk_available = True
66+
gtk_enabled = True
6767
except:
68-
gtk_available = False
68+
gtk_enabled = False
6969
#}}}
7070

7171
#{{{ VimChatScope
@@ -77,6 +77,7 @@ class VimChatScope:
7777
otr_fingerprints = 'fingerprints'
7878
buddyListBuffer = None
7979
rosterFile = '/tmp/vimChatRoster'
80+
statusIcon = None
8081

8182
#{{{ init
8283
def init(self):
@@ -111,14 +112,15 @@ class VimChatScope:
111112
pyotr_enabled = False
112113
pyotr_logging = False
113114

114-
# GTK StausIcon
115-
#self.status_icon = StatusIcon()
116-
#self.status_icon.set_from_stock(gtk.STOCK_HOME)
117-
#self.status_icon.set_tooltip("VimChat")
118-
#self.status_icon.set_visible(True)
119-
#gtk.main()
120-
115+
isStatusIcon = int(vim.eval('g:vimchat_statusicon'))
116+
if isStatusIcon == 1:
117+
gtk_enabled = True
118+
else:
119+
gtk_enabled = False
121120

121+
if gtk_enabled:
122+
self.statusIcon = self.StatusIcon()
123+
self.statusIcon.start()
122124

123125
#Get JID's/Passwords
124126
vimChatAccounts = vim.eval('g:vimchat_accounts')
@@ -687,6 +689,20 @@ class VimChatScope:
687689
return False
688690
#}}}
689691
#}}}
692+
#{{{ class StatusIcon
693+
class StatusIcon(threading.Thread):
694+
def run(self):
695+
# GTK StausIcon
696+
gtk.gdk.threads_init()
697+
self.status_icon = StatusIcon()
698+
self.status_icon.set_from_file(os.path.expanduser(
699+
'~/.vimchat/icon.gif'))
700+
self.status_icon.set_tooltip("VimChat")
701+
self.status_icon.set_visible(True)
702+
gtk.main()
703+
def blink(self, value):
704+
self.status_icon.set_blinking(value)
705+
#}}}
690706

691707
#CONNECTION FUNCTIONS
692708
#{{{ signOn
@@ -973,7 +989,7 @@ class VimChatScope:
973989
nnoremap <buffer> <silent> <Leader>ov :py VimChat.otrVerifyBuddy()<CR>
974990
nnoremap <buffer> <silent> <Leader>or :py VimChat.otrSmpRespond()<CR>
975991
nnoremap <buffer> <silent> <Leader>c :py VimChat.openGroupChat()<CR>
976-
au CursorMoved <buffer> set tabline&
992+
au CursorMoved <buffer> exe 'py VimChat.clearNotify()'
977993
"""
978994
vim.command(commands)
979995
#}}}
@@ -1130,8 +1146,16 @@ class VimChatScope:
11301146
n = pynotify.Notification(title, msg, type)
11311147
n.set_timeout(10000)
11321148
n.show()
1133-
#}}}
11341149

1150+
if gtk_enabled:
1151+
self.statusIcon.blink(True)
1152+
#}}}
1153+
#{{{
1154+
def clearNotify(self):
1155+
if gtk_enabled:
1156+
self.statusIcon.blink(False)
1157+
vim.command('au CursorMoved <buffer> set tabline&')
1158+
#}}}
11351159
#LOGGING
11361160
#{{{ log
11371161
def log(self, account, user, msg):

0 commit comments

Comments
 (0)