static void handle_urgent(PidginWindow *purplewin, gboolean set) { g_return_if_fail(purplewin != NULL); g_return_if_fail(purplewin->window != NULL); pidgin_set_urgent(GTK_WINDOW(purplewin->window), set); }
static void * pidgin_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls) { GtkWidget *dialog = NULL; char *notification; PurpleAccount *account; PidginNotifyMailData *data = NULL, *data2; gboolean new_data; /* Don't bother updating if there aren't new emails and we don't have any displayed currently */ if (count == 0 && mail_dialog == NULL) return NULL; account = purple_connection_get_account(gc); dialog = pidgin_get_mail_dialog(); /* This creates mail_dialog if necessary */ mail_dialog->total_count += count; if (detailed) { while (count--) { char *to_text = NULL; char *from_text = NULL; char *subject_text = NULL; char *tmp; gboolean first = TRUE; if (tos != NULL) { tmp = g_markup_escape_text(*tos, -1); to_text = g_strdup_printf("<b>%s</b>: %s\n", _("Account"), tmp); g_free(tmp); first = FALSE; tos++; } if (froms != NULL) { tmp = g_markup_escape_text(*froms, -1); from_text = g_strdup_printf("%s<b>%s</b>: %s\n", first ? "<br>" : "", _("Sender"), tmp); g_free(tmp); first = FALSE; froms++; } if (subjects != NULL) { tmp = g_markup_escape_text(*subjects, -1); subject_text = g_strdup_printf("%s<b>%s</b>: %s", first ? "<br>" : "", _("Subject"), tmp); g_free(tmp); first = FALSE; subjects++; } #define SAFE(x) ((x) ? (x) : "") notification = g_strdup_printf("%s%s%s", SAFE(to_text), SAFE(from_text), SAFE(subject_text)); #undef SAFE g_free(to_text); g_free(from_text); g_free(subject_text); /* If we don't keep track of this, will leak "data" for each of the notifications except the last */ data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, 0, FALSE, &new_data); if (new_data) { if (data) data->purple_has_handle = FALSE; data = data2; } g_free(notification); if (urls != NULL) urls++; } } else { if (count > 0) { notification = g_strdup_printf(ngettext("%s has %d new message.", "%s has %d new messages.", (int)count), *tos, (int)count); data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, count, FALSE, &new_data); if (new_data) { if (data) data->purple_has_handle = FALSE; data = data2; } g_free(notification); } else { GtkTreeIter iter; /* Clear out all mails for the account */ pidgin_notify_add_mail(mail_dialog->treemodel, account, NULL, NULL, 0, TRUE, NULL); if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mail_dialog->treemodel), &iter)) { /* There is no API to clear the headline specifically */ /* This will trigger reset_mail_dialog() */ pidgin_blist_set_headline(NULL, NULL, NULL, NULL, NULL); return NULL; } } } if (!GTK_WIDGET_VISIBLE(dialog)) { GdkPixbuf *pixbuf = gtk_widget_render_icon(dialog, PIDGIN_STOCK_DIALOG_MAIL, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), NULL); char *label_text = g_strdup_printf(ngettext("<b>%d new email.</b>", "<b>%d new emails.</b>", mail_dialog->total_count), mail_dialog->total_count); mail_dialog->in_use = TRUE; /* So that _set_headline doesn't accidentally remove the notifications when replacing an old notification. */ pidgin_blist_set_headline(label_text, pixbuf, G_CALLBACK(gtk_widget_show_all), dialog, (GDestroyNotify)reset_mail_dialog); mail_dialog->in_use = FALSE; g_free(label_text); if (pixbuf) g_object_unref(pixbuf); } else if (!GTK_WIDGET_HAS_FOCUS(dialog)) pidgin_set_urgent(GTK_WINDOW(dialog), TRUE); return data; }
static int mail_window_focus_cb(GtkWidget *widget, GdkEventFocus *focus, gpointer null) { pidgin_set_urgent(GTK_WINDOW(widget), FALSE); return 0; }