Browse Source

icon, dumbass

Jezra 10 years ago
parent
commit
bd290f0061
3 changed files with 24 additions and 5 deletions
  1. 17
    1
      Blather.py
  2. 3
    0
      GtkUI.py
  3. 4
    4
      QtUI.py

+ 17
- 1
Blather.py View File

@@ -49,6 +49,10 @@ class Blather:
49 49
 				
50 50
 			self.ui = UI(args,opts.continuous)
51 51
 			self.ui.connect("command", self.process_command)
52
+			#can we load the icon resource?
53
+			icon = self.load_resource("icon.png")
54
+			if icon:
55
+				self.ui.set_icon(icon)
52 56
 		
53 57
 		if self.opts.history:
54 58
 			self.history = []
@@ -129,7 +133,19 @@ class Blather:
129 133
 			self.recognizer.pause()
130 134
 		elif command == "quit":
131 135
 			self.quit()
132
-		
136
+	
137
+	def load_resource(self,string):
138
+		local_data = os.path.join(os.path.dirname(__file__), 'data')
139
+		paths = ["/usr/share/blather/","/usr/local/share/blather", local_data]
140
+		for path in paths:
141
+			resource = os.path.join(path, string)
142
+			if os.path.exists( resource ):
143
+				return resource
144
+		#if we get this far, no resource was found
145
+		return False
146
+    
147
+    
148
+    
133 149
 if __name__ == "__main__":
134 150
 	parser = OptionParser()
135 151
 	parser.add_option("-i", "--interface",  type="string", dest="interface",

+ 3
- 0
GtkUI.py View File

@@ -80,3 +80,6 @@ class UI(gobject.GObject):
80 80
 			self.lsbutton_stopped()
81 81
 		self.label.set_text(text)
82 82
 		
83
+	def set_icon(self, icon):
84
+		gtk.window_set_default_icon_from_file(icon)
85
+		

+ 4
- 4
QtUI.py View File

@@ -6,7 +6,7 @@ import gobject
6 6
 # Qt stuff
7 7
 from PySide.QtCore import Signal, Qt
8 8
 from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout
9
-from PySide.QtGui import QLabel, QPushButton, QCheckBox
9
+from PySide.QtGui import QLabel, QPushButton, QCheckBox, QIcon
10 10
 
11 11
 class UI(gobject.GObject):
12 12
 	__gsignals__ = {
@@ -76,9 +76,6 @@ class UI(gobject.GObject):
76 76
 		self.app.exec_()
77 77
 		self.emit("command", "quit")
78 78
 	
79
-	def quit(self):
80
-		pass
81
-		
82 79
 	def finished(self, text):
83 80
 		print text
84 81
 		#if the continuous isn't pressed
@@ -89,3 +86,6 @@ class UI(gobject.GObject):
89 86
 	def quit(self):
90 87
 		#sys.exit()
91 88
 		pass
89
+
90
+	def set_icon(self, icon):
91
+		self.window.setWindowIcon(QIcon(icon))       

Loading…
Cancel
Save