From: <ev...@us...> - 2006-12-10 05:06:11
|
Revision: 17935 http://svn.sourceforge.net/gaim/?rev=17935&view=rev Author: evands Date: 2006-12-09 21:06:01 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Improved handling of GaimNotifyUserInfoEntry types; an enum now specifies them. Fixed gaim_notify_user_info_get_text() not to have newlines before and after the horizontal line for section breaks. Modified Paths: -------------- trunk/libgaim/notify.c trunk/libgaim/notify.h Modified: trunk/libgaim/notify.c =================================================================== --- trunk/libgaim/notify.c 2006-12-10 03:44:35 UTC (rev 17934) +++ trunk/libgaim/notify.c 2006-12-10 05:06:01 UTC (rev 17935) @@ -43,7 +43,7 @@ { char *label; char *value; - gboolean is_header; + GaimNotifyUserInfoEntryType type; }; struct _GaimNotifyUserInfo @@ -483,7 +483,7 @@ user_info_entry = g_new0(GaimNotifyUserInfoEntry, 1); user_info_entry->label = g_strdup(label); user_info_entry->value = g_strdup(value); - user_info_entry->is_header = FALSE; + user_info_entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_PAIR; return user_info_entry; } @@ -541,9 +541,12 @@ for (l = user_info->user_info_entries; l != NULL; l = l->next) { GaimNotifyUserInfoEntry *user_info_entry = l->data; - if (user_info_entry->is_header) + /* Add a newline before a section header */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) g_string_append(text, newline); + /* Handle the label/value pair itself */ + /* XXX Todo: Use a larger size for a section header? */ if (user_info_entry->label) g_string_append_printf(text, "<b>%s</b>", user_info_entry->label); if (user_info_entry->label && user_info_entry->value) @@ -551,11 +554,18 @@ if (user_info_entry->value) g_string_append(text, user_info_entry->value); - if (user_info_entry->is_header) - g_string_append(text, newline); + /* Display a section break as a horizontal line */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) + g_string_append(text, "<HR>"); - if (l->next) + /* Don't insert a new line before or after a section break; <HR> does that for us */ + if ((user_info_entry->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) && + (l->next && ((((GaimNotifyUserInfoEntry *)(l->next->data))->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)))) g_string_append(text, newline); + + /* Add an extra newline after a section header */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) + g_string_append(text, newline); } return g_string_free(text, FALSE); @@ -602,29 +612,27 @@ GaimNotifyUserInfoEntry *entry; entry = gaim_notify_user_info_entry_new(label, NULL); - entry->is_header = TRUE; + entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER; user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); } -/** - * Remove the last item which was added to user_info - * This is helpful for removing a section header if the section was empty. - */ void -gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) +gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) { - user_info->user_info_entries = g_list_remove(user_info->user_info_entries, - g_list_last(user_info->user_info_entries)->data); + GaimNotifyUserInfoEntry *entry; + + entry = gaim_notify_user_info_entry_new(NULL, NULL); + entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK; + + user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); } void -gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) +gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) { - /* This is for future expansion; section breaks should be marked as such so the UI - * can format them differently if desired. - */ - gaim_notify_user_info_add_pair(user_info, NULL, "<HR>"); + user_info->user_info_entries = g_list_remove(user_info->user_info_entries, + g_list_last(user_info->user_info_entries)->data); } void * Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-10 03:44:35 UTC (rev 17934) +++ trunk/libgaim/notify.h 2006-12-10 05:06:01 UTC (rev 17935) @@ -94,6 +94,15 @@ } GaimNotifySearchResults; +/** + * Types of GaimNotifyUserInfoEntry objects + */ +typedef enum +{ + GAIM_NOTIFY_USER_INFO_ENTRY_PAIR = 0, + GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK, + GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER +} GaimNotifyUserInfoEntryType; /** * Single column of a search result. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |