]> git.0d.be Git - empathy.git/commitdiff
adium: split removing unread markers into two functions
authorJonny Lamb <jonnylamb@gnome.org>
Fri, 13 May 2011 10:25:06 +0000 (11:25 +0100)
committerJonny Lamb <jonnylamb@gnome.org>
Fri, 13 May 2011 14:25:14 +0000 (15:25 +0100)
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
libempathy-gtk/empathy-theme-adium.c

index c947c28974b45ee324dc3b64cb64c1c74c730d5f..1a213ff91c2dcacae028004c732806334290f218 100644 (file)
@@ -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);
        }
 }