1 /* grrobot - Ricochet Robot using GTK+ and Xr
3 * Copyright © 2003 Carl Worth
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of Carl Worth
10 * not be used in advertising or publicity pertaining to distribution
11 * of the software without specific, written prior permission.
12 * Carl Worth makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without express
14 * or implied warranty.
16 * CARL WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18 * NO EVENT SHALL CARL WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Author: Carl Worth <carl@theworths.org>
30 typedef struct grr_icon {
35 grr_icon_create (char *name)
39 icon = malloc (sizeof (grr_icon_t));
43 _grr_icon_init (icon, name);
49 _grr_icon_init (grr_icon_t *icon, char *name)
54 status = xsvg_create (&icon->xsvg);
56 return RR_STATUS_NO_MEMORY;
58 file = grr_icon_find_file (name);
61 status = xsvg_parse_file (icon->xsvg, file);
62 if (status == XSVG_STATUS_SUCCESS) {
64 return RR_STATUS_SUCCESS;
66 fprintf (stderr, "Error parsing SVG icon: %s\n", file);
70 buf = grr_icon_find_buffer (name);
71 status = xsvg_parse_buffer (icon->xsvg, buf, strlen (buf));
73 fprintf (stderr, "Error parsing built-in SVG icon for: %s\n", name);
74 return RR_STATUS_PARSE_ERROR;
77 return RR_STATUS_SUCCESS;
80 /* XXX: This could be made more interesting, (eg. search in ~/.grrobot
83 _grr_icon_find_file (char *name)
89 rr_string_sprintf_alloc (&file, "%s/%s", GRR_ICON_DIR, name);
93 err = stat (file, &stat_buf);
94 if (err == 0 && S_ISREG (state.st_mode))
99 extern char *GRR_ROBOT_BLUE_SVG;
100 extern char *GRR_ROBOT_GREEN_SVG;
101 extern char *GRR_ROBOT_RED_SVG;
102 extern char *GRR_ROBOT_YELLOW_SVG;
104 extern char *GRR_TARGET_BLUE_CIRCLE_SVG;
105 extern char *GRR_TARGET_GREEN_CIRCLE_SVG;
106 extern char *GRR_TARGET_RED_CIRCLE_SVG;
107 extern char *GRR_TARGET_YELLOW_CIRCLE_SVG;
109 extern char *GRR_TARGET_BLUE_OCTAGON_SVG;
110 extern char *GRR_TARGET_GREEN_OCTAGON_SVG;
111 extern char *GRR_TARGET_RED_OCTAGON_SVG;
112 extern char *GRR_TARGET_YELLOW_OCTAGON_SVG;
114 extern char *GRR_TARGET_BLUE_SQUARE_SVG;
115 extern char *GRR_TARGET_GREEN_SQUARE_SVG;
116 extern char *GRR_TARGET_RED_SQUARE_SVG;
117 extern char *GRR_TARGET_YELLOW_SQUARE_SVG;
119 extern char *GRR_TARGET_BLUE_TRIANGLE_SVG;
120 extern char *GRR_TARGET_GREEN_TRIANGLE_SVG;
121 extern char *GRR_TARGET_RED_TRIANGLE_SVG;
122 extern char *GRR_TARGET_YELLOW_TRIANGLE_SVG;
124 extern char *GRR_TARGET_WHIRL_SVG;