Mercurial > pidgin.yaz
diff src/savedstatuses.c @ 12690:d03afaccd41c
[gaim-migrate @ 15033]
Make the popular status docklet menu items actually do something.
Strip html and newlines from the titles of saved-statuses when
displaying them in the docklet menu.
Add a 'gaim_savedstatus_find_by_creation_time()' function. Sadrul:
you'll probably want to use this when you add popular statuses to
the status box.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 03 Jan 2006 05:23:01 +0000 |
parents | 473c23442a36 |
children | 10ef9171ca87 |
line wrap: on
line diff
--- a/src/savedstatuses.c Tue Jan 03 04:44:08 2006 +0000 +++ b/src/savedstatuses.c Tue Jan 03 05:23:01 2006 +0000 @@ -788,6 +788,22 @@ return NULL; } +GaimSavedStatus * +gaim_savedstatus_find_by_creation_time(time_t creation_time) +{ + GList *iter; + GaimSavedStatus *status; + + for (iter = saved_statuses; iter != NULL; iter = iter->next) + { + status = (GaimSavedStatus *)iter->data; + if (status->creation_time == creation_time) + return status; + } + + return NULL; +} + gboolean gaim_savedstatus_is_transient(const GaimSavedStatus *saved_status) { @@ -799,35 +815,40 @@ const char * gaim_savedstatus_get_title(const GaimSavedStatus *saved_status) { + const char *message; + g_return_val_if_fail(saved_status != NULL, NULL); - /* If transient then make up a title on the fly */ - if (saved_status->title == NULL) - { - const char *message = gaim_savedstatus_get_message(saved_status); + /* If we have a title then return it */ + if (saved_status->title != NULL) + return saved_status->title; + + /* Otherwise, this is a transient status and we make up a title on the fly */ + message = gaim_savedstatus_get_message(saved_status); - if (message == NULL) - { - GaimStatusPrimitive primitive; - primitive = gaim_savedstatus_get_type(saved_status); - return gaim_primitive_get_id_from_type(primitive); - } - else + if (message == NULL) + { + GaimStatusPrimitive primitive; + primitive = gaim_savedstatus_get_type(saved_status); + return gaim_primitive_get_id_from_type(primitive); + } + else + { + char *stripped; + static char buf[64]; + stripped = gaim_markup_strip_html(message); + gaim_util_chrreplace(stripped, '\n', ' '); + strncpy(buf, stripped, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + if ((strlen(stripped) + 1) > sizeof(buf)) { - static char buf[64]; - strncpy(buf, message, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - if ((strlen(message) + 1) > sizeof(buf)) - { - /* Truncate and ellipsize */ - char *tmp = g_utf8_find_prev_char(buf, &buf[sizeof(buf) - 4]); - strcpy(tmp, "..."); - } - return buf; + /* Truncate and ellipsize */ + char *tmp = g_utf8_find_prev_char(buf, &buf[sizeof(buf) - 4]); + strcpy(tmp, "..."); } + g_free(stripped); + return buf; } - - return saved_status->title; } GaimStatusPrimitive