diff options
-rw-r--r-- | QtUI.py | 115 | ||||
-rwxr-xr-x | blather.py (renamed from Blather.py) | 19 | ||||
-rw-r--r-- | gtktrayui.py (renamed from GtkTrayUI.py) | 28 | ||||
-rw-r--r-- | gtkui.py (renamed from GtkUI.py) | 6 | ||||
-rwxr-xr-x | recognizer.py (renamed from Recognizer.py) | 3 |
5 files changed, 34 insertions, 137 deletions
diff --git a/QtUI.py b/QtUI.py deleted file mode 100644 index 728ff80..0000000 --- a/QtUI.py +++ /dev/null @@ -1,115 +0,0 @@ -#This is part of Blather -# -- this code is licensed GPLv3 -# Copyright 2013 Jezra -import sys -import gobject -# Qt stuff -from PySide.QtCore import Signal, Qt -from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout -from PySide.QtGui import QLabel, QPushButton, QCheckBox, QIcon, QAction - -class UI(gobject.GObject): - __gsignals__ = { - 'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) - } - - def __init__(self,args,continuous): - self.continuous = continuous - gobject.GObject.__init__(self) - #start by making our app - self.app = QApplication(args) - #make a window - self.window = QMainWindow() - #give the window a name - self.window.setWindowTitle("BlatherQt") - self.window.setMaximumSize(400,200) - center = QWidget() - self.window.setCentralWidget(center) - - layout = QVBoxLayout() - center.setLayout(layout) - #make a listen/stop button - self.lsbutton = QPushButton("Listen") - layout.addWidget(self.lsbutton) - #make a continuous button - self.ccheckbox = QCheckBox("Continuous Listen") - layout.addWidget(self.ccheckbox) - - #connect the buttons - self.lsbutton.clicked.connect(self.lsbutton_clicked) - self.ccheckbox.clicked.connect(self.ccheckbox_clicked) - - #add a label to the UI to display the last command - self.label = QLabel() - layout.addWidget(self.label) - - #add the actions for quiting - quit_action = QAction(self.window) - quit_action.setShortcut('Ctrl+Q') - quit_action.triggered.connect(self.accel_quit) - self.window.addAction(quit_action) - - def accel_quit(self): - #emit the quit - self.emit("command", "quit") - - def ccheckbox_clicked(self): - checked = self.ccheckbox.isChecked() - if checked: - #disable lsbutton - self.lsbutton.setEnabled(False) - self.lsbutton_stopped() - self.emit('command', "continuous_listen") - self.set_icon_active() - else: - self.lsbutton.setEnabled(True) - self.emit('command', "continuous_stop") - self.set_icon_inactive() - - def lsbutton_stopped(self): - self.lsbutton.setText("Listen") - - def lsbutton_clicked(self): - val = self.lsbutton.text() - if val == "Listen": - self.emit("command", "listen") - self.lsbutton.setText("Stop") - #clear the label - self.label.setText("") - self.set_icon_active() - else: - self.lsbutton_stopped() - self.emit("command", "stop") - self.set_icon_inactive() - - def run(self): - self.set_icon_inactive() - self.window.show() - if self.continuous: - self.set_icon_active() - self.ccheckbox.setCheckState(Qt.Checked) - self.ccheckbox_clicked() - self.app.exec_() - self.emit("command", "quit") - - def finished(self, text): - #if the continuous isn't pressed - if not self.ccheckbox.isChecked(): - self.lsbutton_stopped() - self.label.setText(text) - - def set_icon(self, icon): - self.window.setWindowIcon(QIcon(icon)) - - def set_icon_active_asset(self, i): - self.icon_active = i - - def set_icon_inactive_asset(self, i): - self.icon_inactive = i - - def set_icon_active(self): - self.window.setWindowIcon(QIcon(self.icon_active)) - - def set_icon_inactive(self): - self.window.setWindowIcon(QIcon(self.icon_inactive)) - diff --git a/Blather.py b/blather.py index 1f59ee0..3853314 100755 --- a/Blather.py +++ b/blather.py @@ -1,7 +1,9 @@ #!/usr/bin/env python2 +# This is part of Kaylee # -- this code is licensed GPLv3 # Copyright 2013 Jezra +# Copyright 2015 Clayton G. Hobbs import sys import signal @@ -14,6 +16,8 @@ try: except: print "YAML is not supported. ~/.config/blather/options.yaml will not function" +from recognizer import Recognizer + # Where are the files? conf_dir = os.path.expanduser("~/.config/blather") lang_dir = os.path.join(conf_dir, "language") @@ -31,7 +35,6 @@ class Blather: def __init__(self, opts): # Import the recognizer so Gst doesn't clobber our -h - from Recognizer import Recognizer self.ui = None self.options = {} ui_continuous_listen = False @@ -51,23 +54,21 @@ class Blather: self.options[k] = v if self.options['interface'] != None: - if self.options['interface'] == "q": - from QtUI import UI - elif self.options['interface'] == "g": - from GtkUI import UI + if self.options['interface'] == "g": + from gtkui import UI elif self.options['interface'] == "gt": - from GtkTrayUI import UI + from gtktrayui import UI else: print "no GUI defined" sys.exit() self.ui = UI(args, self.options['continuous']) self.ui.connect("command", self.process_command) - #can we load the icon resource? + # Can we load the icon resource? icon = self.load_resource("icon.png") if icon: self.ui.set_icon_active_asset(icon) - #can we load the icon_inactive resource? + # Can we load the icon_inactive resource? icon_inactive = self.load_resource("icon_inactive.png") if icon_inactive: self.ui.set_icon_inactive_asset(icon_inactive) @@ -201,7 +202,7 @@ if __name__ == "__main__": parser = OptionParser() parser.add_option("-i", "--interface", type="string", dest="interface", action='store', - help="Interface to use (if any). 'q' for Qt, 'g' for GTK, 'gt' for GTK system tray icon") + help="Interface to use (if any). 'g' for GTK or 'gt' for GTK system tray icon") parser.add_option("-c", "--continuous", action="store_true", dest="continuous", default=False, diff --git a/GtkTrayUI.py b/gtktrayui.py index dda153d..cb66259 100644 --- a/GtkTrayUI.py +++ b/gtktrayui.py @@ -1,3 +1,8 @@ +# This is part of Kaylee +# -- this code is licensed GPLv3 +# Copyright 2013 Jezra +# Copyright 2015 Clayton G. Hobbs + import sys from gi.repository import GObject # Gtk @@ -7,15 +12,17 @@ class UI(GObject.GObject): __gsignals__ = { 'command' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)) } + idle_text = "Kaylee - Idle" + listening_text = "Kaylee - Listening" def __init__(self, args, continuous): GObject.GObject.__init__(self) self.continuous = continuous self.statusicon = Gtk.StatusIcon() - self.statusicon.set_title("Blather") - self.statusicon.set_name("Blather") - self.statusicon.set_tooltip_text("Blather - Idle") + self.statusicon.set_title("Kaylee") + self.statusicon.set_name("Kaylee") + self.statusicon.set_tooltip_text(self.idle_text) self.statusicon.set_has_tooltip(True) self.statusicon.connect("activate", self.continuous_toggle) self.statusicon.connect("popup-menu", self.popup_menu) @@ -42,24 +49,25 @@ class UI(GObject.GObject): if checked: self.menu_listen.set_label("Listen") self.emit('command', "continuous_listen") - self.statusicon.set_tooltip_text("Blather - Listening") + self.statusicon.set_tooltip_text(self.listening_text) self.set_icon_active() else: self.set_icon_inactive() - self.statusicon.set_tooltip_text("Blather - Idle") + self.statusicon.set_tooltip_text(self.idle_text) self.emit('command', "continuous_stop") def toggle_listen(self, item): val = self.menu_listen.get_label() if val == "Listen": + self.set_icon_active() self.emit("command", "listen") self.menu_listen.set_label("Stop") - self.statusicon.set_tooltip_text("Blather - Listening") + self.statusicon.set_tooltip_text(self.listening_text) else: - self.icon_inactive() + self.set_icon_inactive() self.menu_listen.set_label("Listen") self.emit("command", "stop") - self.statusicon.set_tooltip_text("Blather - Idle") + self.statusicon.set_tooltip_text(self.idle_text) def popup_menu(self, item, button, time): self.menu.popup(None, None, Gtk.StatusIcon.position_menu, item, button, time) @@ -81,8 +89,8 @@ class UI(GObject.GObject): def finished(self, text): if not self.menu_continuous.get_active(): self.menu_listen.set_label("Listen") - self.statusicon.set_from_icon_name("blather_stopped") - self.statusicon.set_tooltip_text("Blather - Idle") + self.set_icon_inactive() + self.statusicon.set_tooltip_text(self.idle_text) def set_icon_active_asset(self, i): self.icon_active = i diff --git a/GtkUI.py b/gtkui.py index 2e0fc17..7c3600d 100644 --- a/GtkUI.py +++ b/gtkui.py @@ -1,6 +1,8 @@ -# This is part of Blather +# This is part of Kaylee # -- this code is licensed GPLv3 # Copyright 2013 Jezra +# Copyright 2015 Clayton G. Hobbs + import sys from gi.repository import GObject # Gtk @@ -18,7 +20,7 @@ class UI(GObject.GObject): self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) self.window.connect("delete_event", self.delete_event) # Give the window a name - self.window.set_title("BlatherGtk") + self.window.set_title("Kaylee") self.window.set_resizable(False) layout = Gtk.VBox() diff --git a/Recognizer.py b/recognizer.py index e962ea3..038d4cf 100755 --- a/Recognizer.py +++ b/recognizer.py @@ -1,6 +1,7 @@ -# This is part of Blather +# This is part of Kaylee # -- this code is licensed GPLv3 # Copyright 2013 Jezra +# Copyright 2015 Clayton G. Hobbs import gi gi.require_version('Gst', '1.0') |