Skip to content

Commit

Permalink
first version of hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
logileifs committed Nov 5, 2017
1 parent 73ee390 commit 6a1769e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
29 changes: 27 additions & 2 deletions testindicator/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import GObject
from gi.repository import Keybinder
# from gi.repository import GLib

# zenipy is a wrapper for handy gtk dialogs
Expand Down Expand Up @@ -46,6 +47,30 @@ def __init__(self):
run=self.run_tests_in_background,
stop=self.cancel_test_run)
self.bg_thread = None
self.status = 'waiting'
self.setup_hotkeys()


def setup_hotkeys(self):
log.debug('setting up hotkeys')
Keybinder.init()
Keybinder.bind('<Super><Ctrl>T', self.keypress, 'run-request')
Keybinder.bind('<Super><Ctrl>E', self.keypress, 'quit-request')


def keypress(self, key, action):
log.debug('KEY %s, ACTION %s' % (key, action))
if action == 'run-request' and self.status != 'running':
log.debug('run tests now')
self.run_tests_in_background()
if action == 'quit-request':
log.debug('quit-request')
self.quit()


def set_status(self, status):
self.status = status
self.indicator.set_status(status)


def handle_change(self, evt=None):
Expand All @@ -57,7 +82,7 @@ def run_tests_in_background(self):
log.debug('running tests')
self.notifier.inform_unkown('Running tests')
self.indicator.indicate_unkown()
self.indicator.set_status('running')
self.set_status('running')
self.bg_thread = TestRunner(
callback=self.handle_result,
args=(cfg.full_cmd, cfg.work_dir)
Expand All @@ -72,7 +97,7 @@ def cancel_test_run(self):

def handle_result(self, result):
log.debug('handle_result %s' % result)
self.indicator.set_status('waiting')
self.set_status('waiting')
if result is None:
log.debug('indicate unkown status')
self.indicator.indicate_unkown()
Expand Down
6 changes: 3 additions & 3 deletions testindicator/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, **kwargs):
self.show_item.show()
self.menu.append(self.show_item)

self.run_now_item = gtk.MenuItem("Run now")
self.run_now_item = gtk.MenuItem('Run tests (CTRL+SUPER+T)')
self.run_now_item.connect('activate', self.run_or_stop)
self.run_now_item.set_sensitive(True)
self.run_now_item.show()
Expand All @@ -68,7 +68,7 @@ def __init__(self, **kwargs):
separator_item.show()
self.menu.append(separator_item)

self.item_quit = gtk.MenuItem('Quit')
self.item_quit = gtk.MenuItem('Exit (CTRL+SUPER+E)')
self.item_quit.connect('activate', self.on_quit)
self.menu.append(self.item_quit)
self.menu.show_all()
Expand Down Expand Up @@ -111,5 +111,5 @@ def set_status(self, status):
self.run_now_item.get_child().set_text('Stop execution')
#self.run_now_item.set_sensitive(False)
if self.status == 'waiting':
self.run_now_item.get_child().set_text('Run now')
self.run_now_item.get_child().set_text('Run tests (CTRL+SUPER+T)')
#self.run_now_item.set_sensitive(True)

0 comments on commit 6a1769e

Please sign in to comment.