11
11
# This program is distributed in the hope that it will be useful,
12
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
# GNU General Public License for more details.
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
24
except ImportError:
25
# I know, let's add an ugly hack!
26
# Don't totally bail when not using python2.4 or newer.
27
# FIXME: since we aren't using any new functionality of subprocess, we
28
# could just use the deprecated methods.
31
def Popen(cmd, close_fds, preexec_fn, stdin): return None
32
Popen = staticmethod(Popen)
25
# I know, let's add an ugly hack!
26
# Don't totally bail when not using python2.4 or newer.
27
# FIXME: since we aren't using any new functionality of subprocess, we
28
# could just use the deprecated methods.
31
def Popen(cmd, close_fds, preexec_fn, stdin): return None
32
Popen = staticmethod(Popen)
39
def _run_zenity(self):
40
# run zenity with stdout and stderr directed to /dev/null
42
null = open('/dev/null', 'w')
44
os.dup2(null.fileno(), sys.stdout.fileno())
45
os.dup2(null.fileno(), sys.stderr.fileno())
50
self.proc = subprocess.Popen(['zenity', '--notification',
54
stdin=subprocess.PIPE)
55
except (OSError, IOError):
61
self.proc.stdin.close()
62
status = self.proc.wait()
66
def _send_cmd(self, cmd):
67
if not self.proc: return
68
if isinstance(cmd, unicode):
69
cmd = cmd.encode('utf-8')
71
self.proc.stdin.write(cmd)
72
self.proc.stdin.flush()
73
except (IOError, OSError), err:
75
def set_icon(self, icon):
76
self._send_cmd('icon: %s\n' % icon)
78
def set_tooltip(self, tooltip):
79
self._send_cmd('tooltip: %s\n' % tooltip)
81
def set_visible(self, visible):
86
self._send_cmd('visible: %s\n' % visible)
39
def _run_zenity(self):
40
# run zenity with stdout and stderr directed to /dev/null
42
null = open('/dev/null', 'w')
44
os.dup2(null.fileno(), sys.stdout.fileno())
45
os.dup2(null.fileno(), sys.stderr.fileno())
50
self.proc = subprocess.Popen(['zenity', '--notification',
54
stdin=subprocess.PIPE)
55
except (OSError, IOError):
61
self.proc.stdin.close()
62
status = self.proc.wait()
66
def _send_cmd(self, cmd):
67
if not self.proc: return
68
if isinstance(cmd, unicode):
69
cmd = cmd.encode('utf-8')
71
self.proc.stdin.write(cmd)
72
self.proc.stdin.flush()
73
except (IOError, OSError), err:
75
def set_icon(self, icon):
76
self._send_cmd('icon: %s\n' % icon)
78
def set_tooltip(self, tooltip):
79
self._send_cmd('tooltip: %s\n' % tooltip)
81
def set_visible(self, visible):
86
self._send_cmd('visible: %s\n' % visible)