Released version 3-2015061300
[notion.git] / contrib / statusbar / statusbar_act.lua
bloba4091e309b4bc49fb36068975dfc9d36804ab7fb
1 -- Authors: Tuomo Valkonen, Etan Reisner
2 -- License: LGPL, version 2.1 or later
3 -- Last Changed: 2007
4 --
5 -- statusbar_act.lua
6 --
7 -- Copyright (c) Tuomo Valkonen 2006.
8 -- Copyright (c) Etan Reisner 2007.
9 --
10 -- Ion is free software; you can redistribute it and/or modify it under
11 -- the terms of the GNU Lesser General Public License as published by
12 -- the Free Software Foundation; either version 2.1 of the License, or
13 -- (at your option) any later version.
16 local function notifyact()
17 local act = ioncore.activity_first()
18 local actcount = 0
20 if act then
21 mod_statusbar.inform('act_first', act:name())
22 mod_statusbar.inform('act_first_hint', 'activity')
23 local function count_act(reg)
24 actcount = actcount + 1
25 return true
26 end
27 ioncore.activity_i(count_act)
28 mod_statusbar.inform('act_n', tostring(actcount))
29 mod_statusbar.inform('act_n_hint', 'activity')
30 else
31 mod_statusbar.inform('act_first', '--')
32 mod_statusbar.inform('act_first_hint', 'normal')
33 mod_statusbar.inform('act_n', '0')
34 mod_statusbar.inform('act_n_hint', 'normal')
35 end
36 end
38 local function hookhandler(reg, how)
39 if how ~= "activity" then
40 return
41 end
43 ioncore.defer(function() notifyact() mod_statusbar.update() end)
44 end
46 ioncore.get_hook('region_notify_hook'):add(hookhandler)
48 notifyact()
49 mod_statusbar.inform('act_first_template', 'Mxxxxxxxxxxxxxx')
50 mod_statusbar.update(true)