From 5080aa2351deb6abe0aa1cc442fd1175f2eaa70e Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 13 May 2011 11:25:06 +0100 Subject: [PATCH] adium: split removing unread markers into two functions Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-theme-adium.c | 60 ++++++++++++++++------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index c947c289..1a213ff9 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -569,32 +569,10 @@ theme_adium_append_event_escaped (EmpathyChatView *view, } static void -theme_adium_remove_focus_marks (EmpathyThemeAdium *theme) +theme_adium_remove_focus_marks (EmpathyThemeAdium *theme, + WebKitDOMNodeList *nodes) { - EmpathyThemeAdiumPriv *priv = GET_PRIV (theme); - WebKitDOMDocument *dom; - WebKitDOMNodeList *nodes; guint i; - GError *error = NULL; - - if (!priv->has_unread_message) - return; - - priv->has_unread_message = FALSE; - - dom = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (theme)); - if (dom == NULL) { - return; - } - - /* Get all nodes with focus class */ - nodes = webkit_dom_document_query_selector_all (dom, ".focus", &error); - if (nodes == NULL) { - DEBUG ("Error getting focus nodes: %s", - error ? error->message : "No error"); - g_clear_error (&error); - return; - } /* Remove focus and firstFocus class */ for (i = 0; i < webkit_dom_node_list_get_length (nodes); i++) { @@ -631,6 +609,36 @@ theme_adium_remove_focus_marks (EmpathyThemeAdium *theme) } } +static void +theme_adium_remove_all_focus_marks (EmpathyThemeAdium *theme) +{ + EmpathyThemeAdiumPriv *priv = GET_PRIV (theme); + WebKitDOMDocument *dom; + WebKitDOMNodeList *nodes; + GError *error = NULL; + + if (!priv->has_unread_message) + return; + + priv->has_unread_message = FALSE; + + dom = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (theme)); + if (dom == NULL) { + return; + } + + /* Get all nodes with focus class */ + nodes = webkit_dom_document_query_selector_all (dom, ".focus", &error); + if (nodes == NULL) { + DEBUG ("Error getting focus nodes: %s", + error ? error->message : "No error"); + g_clear_error (&error); + return; + } + + theme_adium_remove_focus_marks (theme, nodes); +} + static void theme_adium_append_message (EmpathyChatView *view, EmpathyMessage *msg) @@ -788,7 +796,7 @@ theme_adium_append_message (EmpathyChatView *view, } /* remove all the unread marks when we are sending a message */ - theme_adium_remove_focus_marks (theme); + theme_adium_remove_all_focus_marks (theme); } else { /* in */ if (is_backlog) { @@ -946,7 +954,7 @@ theme_adium_focus_toggled (EmpathyChatView *view, priv->has_focus = has_focus; if (!priv->has_focus) { - theme_adium_remove_focus_marks (self); + theme_adium_remove_all_focus_marks (self); } } -- 2.39.2