Bladeren bron

Added Gtk Tray UI (thanks padfoot)

Added active/inactive icons
Jezra 10 jaren geleden
bovenliggende
commit
5575072b9b
5 gewijzigde bestanden met toevoegingen van 161 en 30 verwijderingen
  1. 100
    0
      GtkTrayUI.py
  2. 61
    30
      assets/blather.svg
  3. BIN
      assets/blather_inactive.png
  4. BIN
      assets/blathersrc.png
  5. BIN
      data/icon_inactive.png

+ 100
- 0
GtkTrayUI.py Bestand weergeven

@@ -0,0 +1,100 @@
1
+import sys
2
+import gobject
3
+
4
+import pygtk
5
+import gtk
6
+
7
+class UI(gobject.GObject):
8
+	__gsignals__ = {
9
+		'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
10
+	}
11
+
12
+	def __init__(self,args, continuous):
13
+		gobject.GObject.__init__(self)
14
+		self.continuous = continuous
15
+
16
+		self.statusicon = gtk.StatusIcon()
17
+		self.statusicon.set_title("Blather")
18
+		self.statusicon.set_name("Blather")
19
+		self.statusicon.set_tooltip_text("Blather - Idle")
20
+		self.statusicon.set_has_tooltip(True)
21
+		self.statusicon.connect("activate", self.continuous_toggle)
22
+		self.statusicon.connect("popup-menu", self.popup_menu)
23
+
24
+		self.menu = gtk.Menu()
25
+		self.menu_listen = gtk.MenuItem('Listen')
26
+		self.menu_continuous = gtk.CheckMenuItem('Continuous')
27
+		self.menu_quit = gtk.MenuItem('Quit')
28
+		self.menu.append(self.menu_listen)
29
+		self.menu.append(self.menu_continuous)
30
+		self.menu.append(self.menu_quit)
31
+		self.menu_listen.connect("activate", self.toggle_listen)
32
+		self.menu_continuous.connect("toggled", self.toggle_continuous)
33
+		self.menu_quit.connect("activate", self.quit)
34
+		self.menu.show_all()
35
+
36
+	def continuous_toggle(self, item):
37
+		checked = self.menu_continuous.get_active()
38
+		self.menu_continuous.set_active(not checked)
39
+
40
+	def toggle_continuous(self, item):
41
+		checked = self.menu_continuous.get_active()
42
+		self.menu_listen.set_sensitive(not checked)
43
+		if checked:
44
+			self.menu_listen.set_label("Listen")
45
+			self.emit('command', "continuous_listen")
46
+			self.statusicon.set_tooltip_text("Blather - Listening")
47
+			self.set_icon_active()
48
+		else:
49
+			self.set_icon_inactive()
50
+			self.statusicon.set_tooltip_text("Blather - Idle")
51
+			self.emit('command', "continuous_stop")
52
+
53
+	def toggle_listen(self, item):
54
+		val = self.menu_listen.get_label()
55
+		if val == "Listen":
56
+			self.emit("command", "listen")
57
+			self.menu_listen.set_label("Stop")
58
+			self.statusicon.set_tooltip_text("Blather - Listening")
59
+		else:
60
+			self.icon_inactive()
61
+			self.menu_listen.set_label("Listen")
62
+			self.emit("command", "stop")
63
+			self.statusicon.set_tooltip_text("Blather - Idle")
64
+
65
+	def popup_menu(self, item, button, time):
66
+		self.menu.popup(None, None, gtk.status_icon_position_menu, button, time, item)
67
+
68
+	def run(self):
69
+		#set the icon
70
+		self.set_icon_inactive()
71
+		if self.continuous:
72
+			self.menu_continuous.set_active(True)
73
+			self.set_icon_active()
74
+		else:
75
+			self.menu_continuous.set_active(False)
76
+		self.statusicon.set_visible(True)
77
+
78
+	def quit(self, item):
79
+		self.statusicon.set_visible(False)
80
+		self.emit("command", "quit")
81
+
82
+	def finished(self, text):
83
+		print text
84
+		if not self.menu_continuous.get_active():
85
+			self.menu_listen.set_label("Listen")
86
+			self.statusicon.set_from_icon_name("blather_stopped")
87
+			self.statusicon.set_tooltip_text("Blather - Idle")
88
+
89
+	def set_icon_active_asset(self, i):
90
+		self.icon_active = i
91
+
92
+	def set_icon_inactive_asset(self, i):
93
+		self.icon_inactive = i
94
+
95
+	def set_icon_active(self):
96
+		self.statusicon.set_from_file( self.icon_active )
97
+
98
+	def set_icon_inactive(self):
99
+		self.statusicon.set_from_file( self.icon_inactive )
100
+

+ 61
- 30
assets/blather.svg Bestand weergeven

@@ -14,7 +14,10 @@
14 14
    id="svg2"
15 15
    version="1.1"
16 16
    inkscape:version="0.48.4 r9939"
17
-   sodipodi:docname="blather.svg">
17
+   sodipodi:docname="blather.svg"
18
+   inkscape:export-filename="/storage/projects/blather/assets/blathersrc.png"
19
+   inkscape:export-xdpi="90"
20
+   inkscape:export-ydpi="90">
18 21
   <defs
19 22
      id="defs4" />
20 23
   <sodipodi:namedview
@@ -25,13 +28,13 @@
25 28
      inkscape:pageopacity="0.0"
26 29
      inkscape:pageshadow="2"
27 30
      inkscape:zoom="0.7"
28
-     inkscape:cx="-78.309837"
29
-     inkscape:cy="530.52381"
31
+     inkscape:cx="-332.59555"
32
+     inkscape:cy="359.09524"
30 33
      inkscape:document-units="px"
31
-     inkscape:current-layer="layer1"
34
+     inkscape:current-layer="g3014"
32 35
      showgrid="false"
33 36
      inkscape:window-width="1366"
34
-     inkscape:window-height="747"
37
+     inkscape:window-height="748"
35 38
      inkscape:window-x="0"
36 39
      inkscape:window-y="0"
37 40
      inkscape:window-maximized="1" />
@@ -43,7 +46,7 @@
43 46
         <dc:format>image/svg+xml</dc:format>
44 47
         <dc:type
45 48
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
46
-        <dc:title />
49
+        <dc:title></dc:title>
47 50
       </cc:Work>
48 51
     </rdf:RDF>
49 52
   </metadata>
@@ -51,35 +54,63 @@
51 54
      inkscape:groupmode="layer"
52 55
      id="layer2"
53 56
      inkscape:label="Layer"
54
-     style="display:inline">
55
-    <path
56
-       id="path3825"
57
-       style="fill:#00ff00;fill-rule:evenodd;stroke:none;stroke-width:15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
58
-       d="m 279.41428,362.8165 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 c 18.94346,-18.85561 30.21875,-42.50576 30.21875,-68.21875 l -0.0312,-2.125 C 422.164,411.42867 358.02781,362.8165 279.41433,362.8165 z"
59
-       inkscape:connector-curvature="0" />
60
-  </g>
57
+     style="display:inline" />
61 58
   <g
62 59
      inkscape:label="Layer 1"
63 60
      inkscape:groupmode="layer"
64 61
      id="layer1"
65 62
      style="display:inline">
66
-    <path
67
-       style="fill:#00ff00;fill-rule:evenodd;stroke:#008900;stroke-width:15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
68
-       d="m 279.41428,362.8165 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 c 18.94346,-18.8556 30.21875,-42.50576 30.21875,-68.21875 l -0.0312,-2.125 C 422.164,411.42867 358.02781,362.8165 279.41433,362.8165 z"
69
-       inkscape:connector-curvature="0"
70
-       id="path2992" />
71
-    <text
72
-       xml:space="preserve"
73
-       style="font-size:130.46780396px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#008900;stroke-width:5.77600002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans"
74
-       x="185.41168"
75
-       y="617.89215"
76
-       id="text3762"
77
-       sodipodi:linespacing="125%"
78
-       transform="scale(1.1228826,0.89056506)"><tspan
79
-         sodipodi:role="line"
80
-         id="tspan3764"
81
-         x="185.41168"
63
+    <g
64
+       id="g3021">
65
+      <path
66
+         inkscape:connector-curvature="0"
67
+         d="m 279.41428,362.8165 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 c 18.94346,-18.85561 30.21875,-42.50576 30.21875,-68.21875 l -0.0312,-2.125 C 422.164,411.42867 358.02781,362.8165 279.41433,362.8165 z"
68
+         style="display:inline;fill:#00ff00;fill-rule:evenodd;stroke:none;stroke-width:15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
69
+         id="path3825" />
70
+      <path
71
+         id="path2992"
72
+         inkscape:connector-curvature="0"
73
+         d="m 279.41428,362.8165 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 c 18.94346,-18.8556 30.21875,-42.50576 30.21875,-68.21875 l -0.0312,-2.125 C 422.164,411.42867 358.02781,362.8165 279.41433,362.8165 z"
74
+         style="fill:#00ff00;fill-rule:evenodd;stroke:#008900;stroke-width:15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
75
+      <text
76
+         transform="scale(1.1228826,0.89056506)"
77
+         sodipodi:linespacing="125%"
78
+         id="text3762"
82 79
          y="617.89215"
83
-         style="font-size:234.84202576px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#ffffff;fill-opacity:1;stroke:#008900;stroke-width:5.77600002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono Bold">B</tspan></text>
80
+         x="185.41168"
81
+         style="font-size:130.46780396px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#008900;stroke-width:5.77600002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans"
82
+         xml:space="preserve"><tspan
83
+           style="font-size:234.84202576px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#ffffff;fill-opacity:1;stroke:#008900;stroke-width:5.77600002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono Bold"
84
+           y="617.89215"
85
+           x="185.41168"
86
+           id="tspan3764"
87
+           sodipodi:role="line">B</tspan></text>
88
+    </g>
89
+    <g
90
+       id="g3014">
91
+      <path
92
+         inkscape:connector-curvature="0"
93
+         d="m 272.85715,656.65236 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 C 405.86311,817.453 417.1384,793.80285 417.1384,768.08986 l -0.0312,-2.125 c -1.50033,-60.70033 -65.63652,-109.3125 -144.25,-109.3125 z"
94
+         style="fill:#00ff00;fill-rule:evenodd;stroke:none;display:inline"
95
+         id="path3825-8" />
96
+      <path
97
+         id="path2992-8"
98
+         inkscape:connector-curvature="0"
99
+         d="m 272.85715,656.65236 c -79.6868,0 -144.28125,49.8972 -144.28125,111.4375 0,61.5403 64.59445,111.40625 144.28125,111.40625 17.09362,0 33.50236,-2.28624 48.71875,-6.5 l 72.71875,32.21875 -7.375,-68.90625 c 18.94346,-18.8556 30.21875,-42.50576 30.21875,-68.21875 l -0.0312,-2.125 c -1.50033,-60.70033 -65.63652,-109.3125 -144.25,-109.3125 z"
100
+         style="fill:#888888;fill-rule:evenodd;stroke:#666666;stroke-width:15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;fill-opacity:1" />
101
+      <text
102
+         transform="scale(1.1228826,0.89056506)"
103
+         sodipodi:linespacing="125%"
104
+         id="text3762-3"
105
+         y="947.83533"
106
+         x="179.57214"
107
+         style="font-size:130.46780395999999769px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#dadada;fill-opacity:1;stroke:#666666;stroke-width:5.77600001999999968;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;font-family:Sans"
108
+         xml:space="preserve"><tspan
109
+           style="font-size:234.84202576000001272px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#dadada;fill-opacity:1;stroke:#666666;stroke-width:5.77600001999999968;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono Bold"
110
+           y="947.83533"
111
+           x="179.57214"
112
+           id="tspan3764-6"
113
+           sodipodi:role="line">B</tspan></text>
114
+    </g>
84 115
   </g>
85 116
 </svg>

BIN
assets/blather_inactive.png Bestand weergeven


BIN
assets/blathersrc.png Bestand weergeven


BIN
data/icon_inactive.png Bestand weergeven


Laden…
Annuleren
Opslaan