comparison gtk/gtknotify.c @ 15324:e3ea20c6e73f

[gaim-migrate @ 18115] Add a destroy-notify function for the blist-headline. If you close a headline by clicking the cross, or if some headline is replaced by another one, this is not going to leak anymore. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 12 Jan 2007 22:17:32 +0000
parents bfc90a066604
children 1f33d20e973d
comparison
equal deleted inserted replaced
15323:99dcbb8c4557 15324:e3ea20c6e73f
153 g_free(dialog); 153 g_free(dialog);
154 mail_dialog = NULL; 154 mail_dialog = NULL;
155 } 155 }
156 156
157 static void 157 static void
158 reset_mail_dialog(GtkDialog *dialog)
159 {
160 gaim_debug_fatal("WRTF!!", "resetting mail dialog\n");
161 gtk_widget_destroy(mail_dialog->dialog);
162 g_free(mail_dialog);
163 mail_dialog = NULL;
164 }
165
166 static void
158 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data) 167 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data)
159 { 168 {
160 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); 169 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win);
161 } 170 }
162 171
310 char *url; 319 char *url;
311 void *handle; 320 void *handle;
312 }; 321 };
313 322
314 static void 323 static void
324 free_inbox(struct inbox_info *inbox)
325 {
326 g_free(inbox->url);
327 g_free(inbox);
328 }
329
330 static void
315 open_inbox_cb(struct inbox_info *inbox) 331 open_inbox_cb(struct inbox_info *inbox)
316 { 332 {
317 if (inbox->url) 333 if (inbox->url)
318 gaim_notify_uri(inbox->handle, inbox->url); 334 gaim_notify_uri(inbox->handle, inbox->url);
319 g_free(inbox->url); 335 free_inbox(inbox);
320 g_free(inbox);
321 } 336 }
322 337
323 338
324 static void * 339 static void *
325 gaim_gtk_notify_emails(GaimConnection *gc, size_t count, gboolean detailed, 340 gaim_gtk_notify_emails(GaimConnection *gc, size_t count, gboolean detailed,
346 count), (int)count); 361 count), (int)count);
347 362
348 inbox->handle = gc; 363 inbox->handle = gc;
349 inbox->url = urls ? g_strdup(urls[0]) : NULL; 364 inbox->url = urls ? g_strdup(urls[0]) : NULL;
350 gaim_gtk_blist_set_headline(label_text, 365 gaim_gtk_blist_set_headline(label_text,
351 pixbuf, G_CALLBACK(open_inbox_cb), inbox); 366 pixbuf, G_CALLBACK(open_inbox_cb), inbox,
367 (GDestroyNotify)free_inbox);
352 g_object_unref(pixbuf); 368 g_object_unref(pixbuf);
353 return NULL; 369 return NULL;
354 } 370 }
355 371
356 if (mail_dialog == NULL || !detailed) 372 if (mail_dialog == NULL || !detailed)
538 GTK_ICON_SIZE_BUTTON, NULL); 554 GTK_ICON_SIZE_BUTTON, NULL);
539 char *label_text = g_strdup_printf(ngettext("<b>You have %d new e-mail.</b>", 555 char *label_text = g_strdup_printf(ngettext("<b>You have %d new e-mail.</b>",
540 "<b>You have %d new e-mails.</b>", 556 "<b>You have %d new e-mails.</b>",
541 mail_dialog->total_count), mail_dialog->total_count); 557 mail_dialog->total_count), mail_dialog->total_count);
542 gaim_gtk_blist_set_headline(label_text, 558 gaim_gtk_blist_set_headline(label_text,
543 pixbuf, G_CALLBACK(gtk_widget_show_all), dialog); 559 pixbuf, G_CALLBACK(gtk_widget_show_all), dialog,
560 (GDestroyNotify)reset_mail_dialog);
544 g_object_unref(pixbuf); 561 g_object_unref(pixbuf);
545 } 562 }
546 563
547 return data; 564 return data;
548 } 565 }