pidgin.next.minor: bb6e722f: Adding the patch to extend the blist the...

grim at pidgin.im grim at pidgin.im
Mon Jan 5 23:01:32 EST 2009


-----------------------------------------------------------------
Revision: bb6e722febbaba2cf01178b8e6ef9390451fdefd
Ancestor: 1e8b6403400015b82def768a98cd269fb8cc2cf2
Author: paul at aurich.com
Date: 2009-01-06T03:54:50
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/bb6e722febbaba2cf01178b8e6ef9390451fdefd

Modified files:
        pidgin/gtkblist-theme-loader.c pidgin/gtkblist-theme.c
        pidgin/gtkblist-theme.h pidgin/gtkblist.c

ChangeLog: 

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


-------------- next part --------------
============================================================
--- pidgin/gtkblist-theme-loader.c	a9e949d3632e87c160f4d1df3bea69c80977f865
+++ pidgin/gtkblist-theme-loader.c	c1362a579fd552065450b5161f311d0786cb7cd5
@@ -42,10 +42,10 @@ pidgin_blist_loader_build(const gchar *d
 	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 @@ pidgin_blist_loader_build(const gchar *d
 	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 @@ pidgin_blist_loader_build(const gchar *d
 	}
 
 	/* <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 @@ pidgin_blist_loader_build(const gchar *d
 		}
 	}
 
-	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 @@ pidgin_blist_loader_build(const gchar *d
 	}
 
 	/* <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 @@ pidgin_blist_loader_build(const gchar *d
 		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 @@ pidgin_blist_loader_build(const gchar *d
 		}
 	}
 	
-	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 @@ pidgin_blist_loader_build(const gchar *d
 	}
 
 	/* 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 @@ pidgin_blist_loader_build(const gchar *d
 			    "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;
 	}
============================================================
--- pidgin/gtkblist-theme.c	53bd3b6cddc0ab792bb5a2c47461fb4a37e7fcd9
+++ pidgin/gtkblist-theme.c	9fc4353d6f0be1524ff1c9621a7381ed2f0480d8
@@ -52,6 +52,7 @@ typedef struct {
 	FontColorPair *offline;
 	FontColorPair *idle;
 	FontColorPair *message;
+	FontColorPair *message_nick_said;
 
 	FontColorPair *status;
 
@@ -82,6 +83,7 @@ enum {
 	PROP_OFFLINE,
 	PROP_IDLE,
 	PROP_MESSAGE,
+	PROP_MESSAGE_NICK_SAID,
 	PROP_STATUS,
 };
 
@@ -161,6 +163,9 @@ pidgin_blist_theme_get_property(GObject 
 		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 @@ pidgin_blist_theme_set_property(GObject 
 		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 @@ pidgin_blist_theme_finalize (GObject *ob
 	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 @@ pidgin_blist_theme_class_init (PidginBli
 	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 *
 }
 
 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
 }
 
 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;
============================================================
--- pidgin/gtkblist-theme.h	366b6aa2766e60f6d56da44efcbae255b4796e99
+++ pidgin/gtkblist-theme.h	6896e8e9b667c1452758d567e7c6798e44b966cd
@@ -200,6 +200,14 @@ gdouble pidgin_blist_theme_get_opacity(P
  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_in
 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
============================================================
--- pidgin/gtkblist.c	7e088cc6e9f53526580c48856fc5839faa0f8e3c
+++ pidgin/gtkblist.c	1bee9e3249ec21b843832bffb7d59715890f2478
@@ -171,7 +171,8 @@ typedef enum {
 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 @@ written_msg_update_ui_cb(PurpleAccount *
 			!(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 @@ displayed_msg_update_ui_cb(PidginConvers
 	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 @@ static void pidgin_blist_update_chat(Pur
 	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 @@ static void pidgin_blist_update_chat(Pur
 		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 @@ static void pidgin_blist_update_chat(Pur
 
 		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);


More information about the Commits mailing list