Mercurial > pidgin
changeset 25898:dc2584ebaa1a
Adding the patch to extend the blist theme to allow coloring of chat nodes with unread messages mentioning your nick.
Parenthesized a bunch of truth statements in gtkblist-theme-loader to clarify what it is doing.
Also s/sucess/success/g (if anyone feels like it, there is also a variable named sucess in gtkprefs.c and a misspelled 'sucessful' in gtksourceundomanager.c).
Oh, and I guess I also tested that the patch works properly :)
refs #7760
committer: Gary Kramlich <grim@reaperworld.com>
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 06 Jan 2009 03:54:50 +0000 |
parents | 44ce467babaf |
children | 19cd8f986e4a |
files | pidgin/gtkblist-theme-loader.c pidgin/gtkblist-theme.c pidgin/gtkblist-theme.h pidgin/gtkblist.c |
diffstat | 4 files changed, 108 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist-theme-loader.c Tue Jan 06 03:52:31 2009 +0000 +++ b/pidgin/gtkblist-theme-loader.c Tue Jan 06 03:54:50 2009 +0000 @@ -42,10 +42,10 @@ xmlnode *root_node = NULL, *sub_node, *sub_sub_node; gchar *filename_full, *data; const gchar *temp; - gboolean sucess = TRUE; + gboolean success = TRUE; GdkColor *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *contact_color; GdkColor color; - FontColorPair *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *status; + FontColorPair *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *message_nick_said, *status; PidginBlistLayout *layout; PidginBlistTheme *theme; @@ -79,10 +79,11 @@ offline = g_new0(FontColorPair, 1); idle = g_new0(FontColorPair, 1); message = g_new0(FontColorPair, 1); + message_nick_said = g_new0(FontColorPair, 1); status = g_new0(FontColorPair, 1); /* <blist> */ - if ((sucess = (sub_node = xmlnode_get_child(root_node, "blist")) != NULL)) { + if ((success = (sub_node = xmlnode_get_child(root_node, "blist")) != NULL)) { if ((temp = xmlnode_get_attrib(sub_node, "color")) != NULL && gdk_color_parse(temp, bgcolor)) gdk_colormap_alloc_color(gdk_colormap_get_system(), bgcolor, FALSE, TRUE); else { @@ -92,8 +93,8 @@ } /* <groups> */ - if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL - && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL)) { + if ((success = (success && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL + && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL))) { expanded->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); @@ -110,7 +111,7 @@ } } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL))) { collapsed->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); @@ -127,8 +128,8 @@ } /* <buddys> */ - if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "buddys")) != NULL && - (sub_sub_node = xmlnode_get_child(sub_node, "placement")) != NULL)) { + if ((success = (success && (sub_node = xmlnode_get_child(root_node, "buddys")) != NULL && + (sub_sub_node = xmlnode_get_child(sub_node, "placement")) != NULL))) { layout->status_icon = (temp = xmlnode_get_attrib(sub_sub_node, "status_icon")) != NULL ? atoi(temp) : 0; layout->text = (temp = xmlnode_get_attrib(sub_sub_node, "name")) != NULL ? atoi(temp) : 1; @@ -138,7 +139,7 @@ layout->show_status = (temp = xmlnode_get_attrib(sub_sub_node, "status_icon")) != NULL ? atoi(temp) != 0 : 1; } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "background")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "background")) != NULL))) { if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), contact_color)) gdk_colormap_alloc_color(gdk_colormap_get_system(), contact_color, FALSE, TRUE); else { @@ -147,49 +148,56 @@ } } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "contact_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "contact_text")) != NULL))) { contact->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) contact->color = g_strdup(temp); else contact->color = g_strdup(DEFAULT_TEXT_COLOR); } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "online_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "online_text")) != NULL))) { online->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) online->color = g_strdup(temp); else online->color = g_strdup(DEFAULT_TEXT_COLOR); } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "away_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "away_text")) != NULL))) { away->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) away->color = g_strdup(temp); else away->color = g_strdup(DEFAULT_TEXT_COLOR); } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "offline_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "offline_text")) != NULL))) { offline->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) online->color = g_strdup(temp); else online->color = g_strdup(DEFAULT_TEXT_COLOR); } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "idle_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "idle_text")) != NULL))) { idle->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) idle->color = g_strdup(temp); else online->color = g_strdup(DEFAULT_TEXT_COLOR); } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_text")) != NULL))) { message->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) message->color = g_strdup(temp); else message->color = g_strdup(DEFAULT_TEXT_COLOR); } + + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_nick_said_text")) != NULL))) { + message_nick_said->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); + if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) + message_nick_said->color = g_strdup(temp); + else message_nick_said->color = g_strdup(DEFAULT_TEXT_COLOR); + } - if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "status_text")) != NULL)) { + if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "status_text")) != NULL))) { status->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) status->color = g_strdup(temp); @@ -197,7 +205,7 @@ } /* name is required for theme manager */ - sucess = sucess && xmlnode_get_attrib(root_node, "name") != NULL; + success = (success && xmlnode_get_attrib(root_node, "name") != NULL); /* the new theme */ theme = g_object_new(PIDGIN_TYPE_BLIST_THEME, @@ -220,13 +228,14 @@ "offline", offline, "idle", idle, "message", message, + "message_nick_said", message_nick_said, "status", status, NULL); xmlnode_free(root_node); g_free(data); /* malformed xml file - also frees all partial data*/ - if (!sucess) { + if (!success) { g_object_unref(theme); theme = NULL; }
--- a/pidgin/gtkblist-theme.c Tue Jan 06 03:52:31 2009 +0000 +++ b/pidgin/gtkblist-theme.c Tue Jan 06 03:54:50 2009 +0000 @@ -52,6 +52,7 @@ FontColorPair *offline; FontColorPair *idle; FontColorPair *message; + FontColorPair *message_nick_said; FontColorPair *status; @@ -82,6 +83,7 @@ PROP_OFFLINE, PROP_IDLE, PROP_MESSAGE, + PROP_MESSAGE_NICK_SAID, PROP_STATUS, }; @@ -161,6 +163,9 @@ case PROP_MESSAGE: g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_text_info(theme)); break; + case PROP_MESSAGE_NICK_SAID: + g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_nick_said_text_info(theme)); + break; case PROP_STATUS: g_value_set_pointer(value, pidgin_blist_theme_get_status_text_info(theme)); break; @@ -219,6 +224,9 @@ case PROP_MESSAGE: pidgin_blist_theme_set_unread_message_text_info(theme, g_value_get_pointer(value)); break; + case PROP_MESSAGE_NICK_SAID: + pidgin_blist_theme_set_unread_message_nick_said_text_info(theme, g_value_get_pointer(value)); + break; case PROP_STATUS: pidgin_blist_theme_set_status_text_info(theme, g_value_get_pointer(value)); break; @@ -247,6 +255,7 @@ free_font_and_color(priv->away); free_font_and_color(priv->offline); free_font_and_color(priv->message); + free_font_and_color(priv->message_nick_said); free_font_and_color(priv->status); g_free(priv); @@ -331,10 +340,15 @@ g_object_class_install_property(obj_class, PROP_IDLE, pspec); pspec = g_param_spec_pointer("message", "Message Text", - "The text information for when a buddy is has an unread message", + "The text information for when a buddy has an unread message", G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_MESSAGE, pspec); + pspec = g_param_spec_pointer("message_nick_said", "Message (Nick Said) Text", + "The text information for when a chat has an unread message that mentions your nick", + G_PARAM_READWRITE); + g_object_class_install_property(obj_class, PROP_MESSAGE_NICK_SAID, pspec); + pspec = g_param_spec_pointer("status", "Status Text", "The text information for a buddy's status", G_PARAM_READWRITE); @@ -540,6 +554,18 @@ } FontColorPair * +pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme) +{ + PidginBlistThemePrivate *priv; + + g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL); + + priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); + + return priv->message_nick_said; +} + +FontColorPair * pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -730,6 +756,19 @@ } void +pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, FontColorPair *pair) +{ + PidginBlistThemePrivate *priv; + + g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); + + priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); + + free_font_and_color(priv->message_nick_said); + priv->message_nick_said = pair; +} + +void pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, FontColorPair *pair) { PidginBlistThemePrivate *priv;
--- a/pidgin/gtkblist-theme.h Tue Jan 06 03:52:31 2009 +0000 +++ b/pidgin/gtkblist-theme.h Tue Jan 06 03:54:50 2009 +0000 @@ -200,6 +200,14 @@ FontColorPair *pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme); /** + * Returns the text font and color to be used for chats with unread messages + * that mention your nick. + * + * @returns a font and color pair + */ + FontColorPair *pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme); + +/** * Returns the text font and color to be used for a buddy's status message * * @returns a font and color pair @@ -300,13 +308,21 @@ void pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, FontColorPair *pair); /** - * Sets the text color and font to be used for buddies with an unread message + * Sets the text color and font to be used for buddies with unread messages * * @param pair the new text font at color pair */ void pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, FontColorPair *pair); /** + * Sets the text color and font to be used for a chat with unread messages + * that mention your nick + * + * @param pair the new text font at color pair + */ +void pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, FontColorPair *pair); + +/** * Sets the text color and font to be used for buddy status messages * * @param pair the new text font at color pair
--- a/pidgin/gtkblist.c Tue Jan 06 03:52:31 2009 +0000 +++ b/pidgin/gtkblist.c Tue Jan 06 03:54:50 2009 +0000 @@ -171,7 +171,8 @@ static void set_urgent(void); typedef enum { - PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE = 1 << 0, /* Whether there's pending message in a conversation */ + PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE = 1 << 0, /* Whether there's pending message in a conversation */ + PIDGIN_BLIST_CHAT_HAS_PENDING_MESSAGE_WITH_NICK = 1 << 1, /* Whether there's a pending message in a chat that mentions our nick */ } PidginBlistNodeFlags; typedef struct _pidgin_blist_node { @@ -4364,6 +4365,10 @@ !(flag & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))) return; ui->conv.flags |= PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE; + if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT + && (flag & PURPLE_MESSAGE_NICK)) + ui->conv.flags |= PIDGIN_BLIST_CHAT_HAS_PENDING_MESSAGE_WITH_NICK; + ui->conv.last_message = time(NULL); /* XXX: for lack of better data */ pidgin_blist_update(purple_get_blist(), node); } @@ -4374,7 +4379,8 @@ PidginBlistNode *ui = node->ui_data; if (ui->conv.conv != gtkconv->active_conv) return; - ui->conv.flags &= ~PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE; + ui->conv.flags &= ~(PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE | + PIDGIN_BLIST_CHAT_HAS_PENDING_MESSAGE_WITH_NICK); pidgin_blist_update(purple_get_blist(), node); } @@ -6402,7 +6408,8 @@ if(purple_account_is_connected(chat->account)) { GtkTreeIter iter; GdkPixbuf *status, *avatar, *emblem, *prpl_icon; - gchar *mark, *color, *font, *tmp; + const gchar *color, *font; + gchar *mark, *tmp; gboolean showicons = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); PidginBlistNode *ui; @@ -6412,14 +6419,17 @@ FontColorPair *pair; PidginBlistTheme *theme; gboolean selected = (gtkblist->selected_node == node); + gboolean nick_said = FALSE; if (!insert_node(list, node, &iter)) return; ui = node->ui_data; conv = ui->conv.conv; - hidden = (conv && (ui->conv.flags & PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE) && - pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv))); + if (conv && pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv))) { + hidden = (ui->conv.flags & PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE); + nick_said = (ui->conv.flags & PIDGIN_BLIST_CHAT_HAS_PENDING_MESSAGE_WITH_NICK); + } status = pidgin_blist_get_status_icon(node, biglist ? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL); @@ -6437,12 +6447,19 @@ if (theme == NULL) pair = NULL; + else if (nick_said) + pair = pidgin_blist_theme_get_unread_message_nick_said_text_info(theme); else if (hidden) pair = pidgin_blist_theme_get_unread_message_text_info(theme); else pair = pidgin_blist_theme_get_online_text_info(theme); - + + font = (pair == NULL || pair->font == NULL) ? "" : pair->font; - color = (selected || pair == NULL || pair->color == NULL) ? "black" : pair->color; + if (selected || pair == NULL || pair->color == NULL) + /* nick_said color is the same as gtkconv:tab-label-attention */ + color = (nick_said ? "#006aff" : "black"); + else + color = pair->color; tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>", font, color, hidden ? "bold" : "normal", mark);