Mercurial > pidgin.yaz
diff libpurple/savedstatuses.c @ 18111:02f39842d28b
fixes #590 by allowing one to use the delete key to delete transient status,
also introduced signals to repopulate the status lists when the statuses
are added/deleted/modified
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 17 Jun 2007 18:03:03 +0000 |
parents | f2d8658b3a86 |
children | 09eb621782bc |
line wrap: on
line diff
--- a/libpurple/savedstatuses.c Sat Jun 16 04:06:16 2007 +0000 +++ b/libpurple/savedstatuses.c Sun Jun 17 18:03:03 2007 +0000 @@ -569,6 +569,9 @@ schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), "savedstatus-added", + status); + return status; } @@ -584,6 +587,9 @@ status->title = g_strdup(title); schedule_save(); + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -594,6 +600,8 @@ status->type = type; schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -608,6 +616,9 @@ status->message = g_strdup(message); schedule_save(); + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -637,6 +648,8 @@ substatus->message = g_strdup(message); schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", saved_status); } void @@ -660,6 +673,9 @@ return; } } + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", saved_status); } /* @@ -683,16 +699,12 @@ } } -gboolean -purple_savedstatus_delete(const char *title) +void +purple_savedstatus_delete_by_status(PurpleSavedStatus *status) { - PurpleSavedStatus *status; time_t creation_time, current, idleaway; - status = purple_savedstatus_find(title); - - if (status == NULL) - return FALSE; + g_return_if_fail(status != NULL); saved_statuses = g_list_remove(saved_statuses, status); creation_time = purple_savedstatus_get_creation_time(status); @@ -713,6 +725,25 @@ if (idleaway == creation_time) purple_prefs_set_int("/purple/savedstatus/idleaway", 0); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-deleted", status); +} + +gboolean +purple_savedstatus_delete(const char *title) +{ + PurpleSavedStatus *status; + + status = purple_savedstatus_find(title); + + if (status == NULL) + return FALSE; + + if (purple_savedstatus_get_current() == status) + return FALSE; + + purple_savedstatus_delete_by_status(status); + return TRUE; } @@ -1171,6 +1202,21 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_SAVEDSTATUS)); + purple_signal_register(handle, "savedstatus-added", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + + purple_signal_register(handle, "savedstatus-deleted", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + + purple_signal_register(handle, "savedstatus-modified", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + purple_signal_connect(purple_accounts_get_handle(), "account-removed", handle, PURPLE_CALLBACK(purple_savedstatus_unset_all_substatuses),