summary refs log tree commit diff
path: root/GtkUI.py
diff options
context:
space:
mode:
Diffstat (limited to 'GtkUI.py')
-rw-r--r--GtkUI.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/GtkUI.py b/GtkUI.py
index 720fb10..56a6252 100644
--- a/GtkUI.py
+++ b/GtkUI.py
@@ -11,7 +11,7 @@ class UI(gobject.GObject):
 	__gsignals__ = {
 		'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
 	}
-	
+
 	def __init__(self,args, continuous):
 		gobject.GObject.__init__(self)
 		self.continuous = continuous
@@ -21,7 +21,7 @@ class UI(gobject.GObject):
 		#give the window a name
 		self.window.set_title("BlatherGtk")
 		self.window.set_resizable(False)
-		
+
 		layout = gtk.VBox()
 		self.window.add(layout)
 		#make a listen/stop button
@@ -30,15 +30,24 @@ class UI(gobject.GObject):
 		#make a continuous button
 		self.ccheckbox = gtk.CheckButton("Continuous Listen")
 		layout.add(self.ccheckbox)
-		
-		#connect the buttonsc
+
+		#connect the buttons
 		self.lsbutton.connect("clicked",self.lsbutton_clicked)
 		self.ccheckbox.connect("clicked",self.ccheckbox_clicked)
-		
+
 		#add a label to the UI to display the last command
 		self.label = gtk.Label()
 		layout.add(self.label)
 
+		#create an accellerator group for this window
+		accel = gtk.AccelGroup()
+		#add the ctrl+q to quit
+		accel.connect_group(gtk.keysyms.q, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE, self.accel_quit )
+		#lock the group
+		accel.lock()
+		#add the group to the window
+		self.window.add_accel_group(accel)
+
 	def ccheckbox_clicked(self, widget):
 		checked = self.ccheckbox.get_active()
 		self.lsbutton.set_sensitive(not checked)
@@ -47,10 +56,10 @@ class UI(gobject.GObject):
 			self.emit('command', "continuous_listen")
 		else:
 			self.emit('command', "continuous_stop")
-	
+
 	def lsbutton_stopped(self):
 		self.lsbutton.set_label("Listen")
-		
+
 	def lsbutton_clicked(self, button):
 		val = self.lsbutton.get_label()
 		if val == "Listen":
@@ -61,25 +70,25 @@ class UI(gobject.GObject):
 		else:
 			self.lsbutton_stopped()
 			self.emit("command", "stop")
-			
+
 	def run(self):
 		self.window.show_all()
 		if self.continuous:
 			self.ccheckbox.set_active(True)
-	
-	def quit(self):
-		pass
-	
+
+	def accel_quit(self, accel_group, acceleratable, keyval, modifier):
+		self.emit("command", "quit")
+
 	def delete_event(self, x, y ):
 		self.emit("command", "quit")
-		
+
 	def finished(self, text):
 		print text
 		#if the continuous isn't pressed
 		if not self.ccheckbox.get_active():
 			self.lsbutton_stopped()
 		self.label.set_text(text)
-		
+
 	def set_icon(self, icon):
 		gtk.window_set_default_icon_from_file(icon)
-		
+