1 /* $Id: themes.c 2397 2007-01-17 17:46:35Z nick $
3 * Copyright (C) 1999 Dave Camp <dave@davec.dhs.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 gchar *theme_directories[] = {
34 #define NUM_THEME_DIRECTORIES 1
37 parse_theme_file (EyesPluginContent *eyes, FILE *theme_file)
39 gchar line_buf [512]; /* prolly overkill */
41 fgets (line_buf, 512, theme_file);
42 while (!feof (theme_file)) {
43 token = strtok (line_buf, "=");
44 if (strncmp (token, "wall-thickness",
45 strlen ("wall-thickness")) == 0)
47 token += strlen ("wall-thickness");
48 while (!isdigit (*token))
52 sscanf (token, "%d", &eyes->wall_thickness);
54 else if (strncmp (token, "num-eyes", strlen ("num-eyes")) == 0)
56 token += strlen ("num-eyes");
57 while (!isdigit (*token))
61 sscanf (token, "%d", &eyes->num_eyes);
63 else if (strncmp (token, "eye-pixmap", strlen ("eye-pixmap")) == 0)
65 token = strtok (NULL, "\"");
66 token = strtok (NULL, "\"");
67 if (eyes->eye_filename != NULL)
68 g_free (eyes->eye_filename);
69 eyes->eye_filename = g_strdup_printf ("%s%s",
73 else if (strncmp (token, "pupil-pixmap", strlen ("pupil-pixmap")) == 0)
75 token = strtok (NULL, "\"");
76 token = strtok (NULL, "\"");
77 if (eyes->pupil_filename != NULL)
78 g_free (eyes->pupil_filename);
80 = g_strdup_printf ("%s%s",
84 fgets (line_buf, 512, theme_file);
91 load_theme (EyesPluginContent *eyes,
92 const gchar *theme_dir)
97 eyes->theme_dir = g_strdup_printf ("%s/", theme_dir);
99 file_name = g_strdup_printf("%s%s",theme_dir,"/config");
100 theme_file = fopen (file_name, "r");
101 if (theme_file == NULL) {
102 g_error ("Unable to open theme file.");
105 parse_theme_file (eyes, theme_file);
108 eyes->theme_name = g_strdup (theme_dir);
111 g_object_unref (eyes->eye_image);
113 eyes->eye_image = gdk_pixbuf_new_from_file (eyes->eye_filename, NULL);
115 if (eyes->pupil_image)
116 g_object_unref (eyes->pupil_image);
118 eyes->pupil_image = gdk_pixbuf_new_from_file (eyes->pupil_filename, NULL);
120 eyes->eye_height = gdk_pixbuf_get_height (eyes->eye_image);
121 eyes->eye_width = gdk_pixbuf_get_width (eyes->eye_image);
122 eyes->pupil_height = gdk_pixbuf_get_height (eyes->pupil_image);
123 eyes->pupil_width = gdk_pixbuf_get_width (eyes->pupil_image);