diff options
| author | Bdale Garbee <bdale@gag.com> | 2014-06-26 12:55:21 -0600 |
|---|---|---|
| committer | Iain R. Learmonth <irl@fsfe.org> | 2015-05-03 18:29:34 +0100 |
| commit | 5e9167a4a78a45e58ae9969b41e70e9d77176376 (patch) | |
| tree | ebc0c218856d44b1c60b62ba20ec9cd1b90e4791 /chirpui/common.py | |
| parent | df2e8c36e9ce0a448c1ec9a9665644d95d3014c2 (diff) | |
| parent | c86187dcdf158df59977baee6c8d6385f964b69b (diff) | |
Imported Debian patch 0.4.0-1debian/0.4.0-1
Diffstat (limited to 'chirpui/common.py')
| -rw-r--r-- | chirpui/common.py | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/chirpui/common.py b/chirpui/common.py index adacaec..8511b8b 100644 --- a/chirpui/common.py +++ b/chirpui/common.py @@ -34,9 +34,11 @@ class Editor(gobject.GObject): root = None - def __init__(self): + def __init__(self, rthread): gobject.GObject.__init__(self) + self.read_only = False self._focused = False + self.rthread = rthread def is_focused(self): return self._focused @@ -56,6 +58,18 @@ class Editor(gobject.GObject): def hotkey(self, action): pass + def set_read_only(self, read_only): + self.read_only = read_only + + def get_read_only(self): + return self.read_only + + def prepare_close(self): + pass + + def other_editor_changed(self, editor): + pass + gobject.type_register(Editor) def DBG(*args): @@ -128,16 +142,26 @@ class RadioThread(threading.Thread, gobject.GObject): (gobject.TYPE_STRING,)), } - def __init__(self, radio): + def __init__(self, radio, parent=None): threading.Thread.__init__(self) gobject.GObject.__init__(self) self.__queue = {} + if parent: + self.__runlock = parent._get_run_lock() + self.status = lambda msg: parent.status(msg) + else: + self.__runlock = threading.Lock() + self.status = self._status + self.__counter = threading.Semaphore(0) - self.__enabled = True self.__lock = threading.Lock() - self.__runlock = threading.Lock() + + self.__enabled = True self.radio = radio + def _get_run_lock(self): + return self.__runlock + def _qlock(self): self.__lock.acquire() @@ -196,7 +220,7 @@ class RadioThread(threading.Thread, gobject.GObject): self.__counter.release() self.__enabled = False - def status(self, msg): + def _status(self, msg): jobs = 0 for i in dict(self.__queue): jobs += len(self.__queue[i]) @@ -224,14 +248,14 @@ class RadioThread(threading.Thread, gobject.GObject): DBG("Running job at priority %i" % i) break self._qunlock() - + if job: self.lock() self.status(job.desc) job.execute(self.radio) last_job_desc = job.desc self.unlock() - + print "RadioThread exiting" def log_exception(): @@ -389,3 +413,8 @@ def show_diff_blob(title, result): d.run() d.destroy() +def unpluralize(string): + if string.endswith("s"): + return string[:-1] + else: + return string |
