comparison src/themes.c @ 4630:5cdfd20daa07

[gaim-migrate @ 4921] Faceprint found these leaks. Anyone else want to find any? committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 01 Mar 2003 18:37:48 +0000
parents a8249a5250b6
children c4ca37f34130
comparison
equal deleted inserted replaced
4629:86fd0f6eaa1a 4630:5cdfd20daa07
68 struct smiley_theme *theme=NULL; 68 struct smiley_theme *theme=NULL;
69 struct smiley_list *list = NULL; 69 struct smiley_list *list = NULL;
70 GSList *lst = smiley_themes; 70 GSList *lst = smiley_themes;
71 char *dirname; 71 char *dirname;
72 gboolean old=FALSE; 72 gboolean old=FALSE;
73 73
74 while (lst) { 74 while (lst) {
75 struct smiley_theme *thm = lst->data; 75 struct smiley_theme *thm = lst->data;
76 if (!strcmp(thm->path, file)) { 76 if (!strcmp(thm->path, file)) {
77 theme = thm; 77 theme = thm;
78 old = TRUE; 78 old = TRUE;
79 break; 79 break;
80 } 80 }
81 lst = lst->next; 81 lst = lst->next;
82 } 82 }
83
84 if (!f)
85 return NULL;
83 if (!theme) { 86 if (!theme) {
84 theme = g_new0(struct smiley_theme, 1); 87 theme = g_new0(struct smiley_theme, 1);
85 theme->path = g_strdup(file); 88 theme->path = g_strdup(file);
86 } 89 }
87 if (!f) 90
88 return NULL;
89
90 dirname = g_path_get_dirname(file); 91 dirname = g_path_get_dirname(file);
91 if (load) { 92 if (load) {
92 if (current_smiley_theme) { 93 if (current_smiley_theme) {
93 GSList *already_freed = NULL; 94 GSList *already_freed = NULL;
94 struct smiley_list *wer = current_smiley_theme->list; 95 struct smiley_list *wer = current_smiley_theme->list;
111 current_smiley_theme->list = NULL; 112 current_smiley_theme->list = NULL;
112 g_slist_free(already_freed); 113 g_slist_free(already_freed);
113 } 114 }
114 current_smiley_theme = theme; 115 current_smiley_theme = theme;
115 } 116 }
116 117
117 118
118 while (!feof(f)) { 119 while (!feof(f)) {
119 if (!fgets(buf, sizeof(buf), f)) { 120 if (!fgets(buf, sizeof(buf), f)) {
120 break; 121 break;
121 } 122 }
122 123
123 if (buf[0] == '#' || buf[0] == '\0') 124 if (buf[0] == '#' || buf[0] == '\0')
124 continue; 125 continue;
125 126
126 i = buf; 127 i = buf;
127 while (isspace(*i)) 128 while (isspace(*i))
128 i++; 129 i++;
129 130
130 if (*i == '[' && strchr(i, ']') && load) { 131 if (*i == '[' && strchr(i, ']') && load) {
131 struct smiley_list *child = g_new0(struct smiley_list, 1); 132 struct smiley_list *child = g_new0(struct smiley_list, 1);
132 child->sml = g_strndup(i+1, (int)strchr(i, ']') - (int)i - 1); 133 child->sml = g_strndup(i+1, (int)strchr(i, ']') - (int)i - 1);
133 if (theme->list) 134 if (theme->list)
134 list->next = child; 135 list->next = child;
135 else 136 else
136 theme->list = child; 137 theme->list = child;
137 list = child; 138 list = child;
138 } else if (!g_strncasecmp(i, "Name=", strlen("Name="))) { 139 } else if (!g_strncasecmp(i, "Name=", strlen("Name="))) {
148 theme->author = g_strdup(i + strlen("Author=")); 149 theme->author = g_strdup(i + strlen("Author="));
149 theme->author[strlen(theme->author)-1] = 0; 150 theme->author[strlen(theme->author)-1] = 0;
150 } else if (load && list) { 151 } else if (load && list) {
151 gboolean hidden; 152 gboolean hidden;
152 char *sfile = NULL; 153 char *sfile = NULL;
153 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); 154
154
155 if (*i == '!' && *(i + 1) == ' ') { 155 if (*i == '!' && *(i + 1) == ' ') {
156 hidden = TRUE; 156 hidden = TRUE;
157 i = i + 2; 157 i = i + 2;
158 } 158 }
159 while (*i) { 159 while (*i) {
160 char l[64]; 160 char l[64];
161 int li = 0; 161 int li = 0;
162 while (!isspace(*i)) 162 while (!isspace(*i))
163 l[li++] = *(i++); 163 l[li++] = *(i++);
164 if (!sfile) { 164 if (!sfile) {
165 l[li] = 0; 165 l[li] = 0;
166 sfile = g_build_filename(dirname, l, NULL); 166 sfile = g_build_filename(dirname, l, NULL);
167 } else { 167 } else {
168 l[li] = 0; 168 l[li] = 0;
169 smiley = g_new0(GtkIMHtmlSmiley, 1); 169 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
170 smiley->file = sfile; 170 smiley->file = sfile;
171 smiley->smile = g_strdup(l); 171 smiley->smile = g_strdup(l);
172 list->smileys = g_slist_append(list->smileys, smiley); 172 list->smileys = g_slist_append(list->smileys, smiley);
173 } 173 }
174 while (isspace(*i)) 174 while (isspace(*i))
175 i++; 175 i++;
176 176
177 } 177 }
178 } 178 }
179 } 179 }
180 180
181 if (load) { 181 if (load) {
182 GList *cnv; 182 GList *cnv;
183 183
184 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { 184 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
185 struct gaim_conversation *conv = cnv->data; 185 struct gaim_conversation *conv = cnv->data;
186 186
187 if (GAIM_IS_GTK_CONVERSATION(conv)) 187 if (GAIM_IS_GTK_CONVERSATION(conv))
188 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); 188 smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml);
189 } 189 }
190 } 190 }
191 191