Sun, 30 Mar 2025 22:26:33 -0500
Make Purple.Message:attributes writable
Originally the thought here was that we would just update this with formatting,
but protocols know the exact formatting for the message and should be able to
set it to exactly what it should be.
Testing Done:
Called in the turtles
Reviewed at https://reviews.imfreedom.org/r/3944/
| libpurple/purplemessage.c | file | annotate | diff | comparison | revisions | |
| libpurple/purplemessage.h | file | annotate | diff | comparison | revisions |
--- a/libpurple/purplemessage.c Fri Mar 28 01:20:13 2025 -0500 +++ b/libpurple/purplemessage.c Sun Mar 30 22:26:33 2025 -0500 @@ -156,6 +156,9 @@ case PROP_ACTION: purple_message_set_action(message, g_value_get_boolean(value)); break; + case PROP_ATTRIBUTES: + purple_message_set_attributes(message, g_value_get_boxed(value)); + break; case PROP_AUTHOR: purple_message_set_author(message, g_value_get_object(value)); break; @@ -272,7 +275,7 @@ properties[PROP_ATTRIBUTES] = g_param_spec_boxed( "attributes", NULL, NULL, PANGO_TYPE_ATTR_LIST, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); /** * PurpleMessage:author: @@ -487,6 +490,22 @@ return message->attributes; } +void +purple_message_set_attributes(PurpleMessage *message, + PangoAttrList *attributes) +{ + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_return_if_fail(attributes != NULL); + + if(!pango_attr_list_equal(message->attributes, attributes)) { + g_clear_pointer(&message->attributes, pango_attr_list_unref); + message->attributes = pango_attr_list_ref(attributes); + + g_object_notify_by_pspec(G_OBJECT(message), + properties[PROP_ATTRIBUTES]); + } +} + PurpleConversationMember * purple_message_get_author(PurpleMessage *message) { g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
--- a/libpurple/purplemessage.h Fri Mar 28 01:20:13 2025 -0500 +++ b/libpurple/purplemessage.h Sun Mar 30 22:26:33 2025 -0500 @@ -118,6 +118,17 @@ PangoAttrList *purple_message_get_attributes(PurpleMessage *message); /** + * purple_message_set_attributes: + * @attributes: (transfer none): the attributes + * + * Sets the formatting attributes of the message. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +void purple_message_set_attributes(PurpleMessage *message, PangoAttrList *attributes); + +/** * purple_message_get_author: * @message: The message. *