]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_notification.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_notification.m
1 ## Copyright (C) 2006 Søren Hauberg
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn  {Function File} zenity_notification(@var{text}, @var{icon})
18 ## Displays an icon with a text in the notification area.
19 ## The variable @var{text} sets the text in the notification area, and the
20 ## optional variable @var{icon} determines which icon to show.
21 ## @var{icon} can be either @code{info}, @code{warning}, @code{question},
22 ## and @code{error}.
23 ##
24 ## @seealso{zenity_calendar, zenity_list, zenity_progress, zenity_entry, zenity_message,
25 ## zenity_text_info, zenity_file_selection}
26 ## @end deftypefn
27
28 function zenity_notification(text, icon)
29   if (nargin == 0 || !ischar(text))
30     print_usage();
31   endif
32   
33   icon = "";
34   if (nargin > 1 && ischar(icon))
35     icon = sprintf('--window-icon="%s"', icon);
36   endif
37   
38   cmd = sprintf('zenity --notification --text="%s" %s', text, icon);
39   [status, output] = system(cmd);
40   if (status == -1)
41     error("zenity_notification: %s", output);
42   endif
43 endfunction