Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 15465:2399c5295a14
Avoid allocating and freeing the color string excessively.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 30 Jan 2007 15:45:55 +0000 |
parents | a415922e2882 |
children | 0d4890637238 883bf81c8d73 |
comparison
equal
deleted
inserted
replaced
15464:bb3bf2f88406 | 15465:2399c5295a14 |
---|---|
258 { | 258 { |
259 GaimConversation *conv = c->active_conv; | 259 GaimConversation *conv = c->active_conv; |
260 | 260 |
261 if (conv->features & GAIM_CONNECTION_HTML) | 261 if (conv->features & GAIM_CONNECTION_HTML) |
262 { | 262 { |
263 char *color; | 263 char color[8]; |
264 GdkColor fg_color, bg_color; | 264 GdkColor fg_color, bg_color; |
265 | 265 |
266 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) | 266 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
267 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); | 267 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
268 | 268 |
279 { | 279 { |
280 int size = gaim_prefs_get_int("/gaim/gtk/conversations/font_size"); | 280 int size = gaim_prefs_get_int("/gaim/gtk/conversations/font_size"); |
281 | 281 |
282 /* 3 is the default. */ | 282 /* 3 is the default. */ |
283 if (size != 3) | 283 if (size != 3) |
284 { | |
285 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), size); | 284 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), size); |
286 } | |
287 } | 285 } |
288 | 286 |
289 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) | 287 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
290 { | 288 { |
291 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | 289 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
292 &fg_color); | 290 &fg_color); |
293 color = g_strdup_printf("#%02x%02x%02x", | 291 g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
294 fg_color.red / 256, | 292 fg_color.red / 256, |
295 fg_color.green / 256, | 293 fg_color.green / 256, |
296 fg_color.blue / 256); | 294 fg_color.blue / 256); |
297 } | 295 } else |
298 else | 296 strcpy(color, ""); |
299 color = g_strdup(""); | |
300 | 297 |
301 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); | 298 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
302 g_free(color); | |
303 | 299 |
304 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && | 300 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
305 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) | 301 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
306 { | 302 { |
307 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | 303 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
308 &bg_color); | 304 &bg_color); |
309 color = g_strdup_printf("#%02x%02x%02x", | 305 g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
310 bg_color.red / 256, | 306 bg_color.red / 256, |
311 bg_color.green / 256, | 307 bg_color.green / 256, |
312 bg_color.blue / 256); | 308 bg_color.blue / 256); |
313 } | 309 } else |
314 else | 310 strcpy(color, ""); |
315 color = g_strdup(""); | |
316 | 311 |
317 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); | 312 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
318 g_free(color); | |
319 | |
320 | 313 |
321 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) | 314 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
322 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); | 315 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
323 else | 316 else |
324 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | 317 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); |