| 1 |
# !NewsStats.py.Iconbar/py |
| 2 |
|
| 3 |
import wimp |
| 4 |
import MainW |
| 5 |
import Newsbase |
| 6 |
|
| 7 |
|
| 8 |
def init(): |
| 9 |
"Setup iconbar icon" |
| 10 |
global iconbar, window_info, menu_iconbar |
| 11 |
if Newsbase.active: |
| 12 |
iconbar = wimp.iconbar_icon('!newsstats', click, 1) |
| 13 |
else: |
| 14 |
iconbar = wimp.iconbar_icon('!newsstats2', click, 1) |
| 15 |
window_info = wimp.info_window() |
| 16 |
menu_iconbar = wimp.menu('iconbar', ('task', ('info', window_info), 'quit')) |
| 17 |
|
| 18 |
|
| 19 |
def click(buttons, x): |
| 20 |
"Handle click on iconbar" |
| 21 |
if buttons == 2: |
| 22 |
reopen = 1 |
| 23 |
while reopen: |
| 24 |
selection, reopen = menu_iconbar.menu(x - 64, 184) |
| 25 |
if selection is None: |
| 26 |
pass |
| 27 |
elif selection[0] == 0: |
| 28 |
window_info.open_as_menu() |
| 29 |
reopen = 0 |
| 30 |
elif selection[0] == 1: |
| 31 |
wimp.quit() |
| 32 |
elif MainW.analysing: |
| 33 |
MainW.window_status.open_centred(-1) |
| 34 |
else: |
| 35 |
if Newsbase.active: |
| 36 |
MainW.w.open_centred(-1) |
| 37 |
MainW.w.put_caret() |
| 38 |
else: |
| 39 |
wimp.warning(wimp.m['warning.newsbase.noreply']) |
| 40 |
|
| 41 |
|
| 42 |
def update(): |
| 43 |
if Newsbase.active: |
| 44 |
iconbar.change('!newsstats') |
| 45 |
else: |
| 46 |
iconbar.change('!newsstats2') |
| 47 |
MainW.w.close() |