diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-04-07 23:12:01 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-08 00:24:47 +0800 |
commit | b83a9cd5bb938e3ccb72eae8d5b6392961169258 (patch) | |
tree | b25c7f3e6bdca7a0f233b9d1f25c8c2bc188614b | |
parent | e0a85ffed4267836db33cd245e6704e6510a24c5 (diff) | |
download | gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar.gz gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar.bz2 gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar.lz gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar.xz gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.tar.zst gsoc2013-evolution-b83a9cd5bb938e3ccb72eae8d5b6392961169258.zip |
EWebView: Use a GQueue to track highlight strings.
This also removes an unused function e_web_view_get_highlights() which
was returning a GSList.
-rw-r--r-- | doc/reference/libeutil/libeutil-sections.txt | 1 | ||||
-rw-r--r-- | e-util/e-web-view.c | 43 | ||||
-rw-r--r-- | e-util/e-web-view.h | 1 |
3 files changed, 16 insertions, 29 deletions
diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt index 39812f56d0..238dc0cf5f 100644 --- a/doc/reference/libeutil/libeutil-sections.txt +++ b/doc/reference/libeutil/libeutil-sections.txt @@ -4549,7 +4549,6 @@ e_web_view_get_print_proxy e_web_view_set_print_proxy e_web_view_get_save_as_proxy e_web_view_set_save_as_proxy -e_web_view_get_highlights e_web_view_add_highlight e_web_view_clear_highlights e_web_view_get_action diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index 7c15b43a26..dd4f261326 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -58,7 +58,7 @@ struct _EWebViewPrivate { GdkPixbufAnimation *cursor_image; gchar *cursor_image_src; - GSList *highlights; + GQueue highlights; GtkAction *open_proxy; GtkAction *print_proxy; @@ -455,14 +455,16 @@ static void web_view_update_document_highlights (EWebView *web_view) { WebKitDOMDocument *document; - GSList *iter; + GList *head, *link; document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view)); - for (iter = web_view->priv->highlights; iter; iter = iter->next) { + head = g_queue_peek_head_link (&web_view->priv->highlights); + + for (link = head; link != NULL; link = g_list_next (link)) { WebKitDOMDocumentFragment *frag; WebKitDOMElement *span; - const gchar *text = iter->data; + const gchar *text = link->data; span = webkit_dom_document_create_element (document, "span", NULL); @@ -801,11 +803,6 @@ web_view_dispose (GObject *object) priv->cursor_image_src = NULL; } - if (priv->highlights != NULL) { - g_slist_free_full (priv->highlights, g_free); - priv->highlights = NULL; - } - if (priv->aliasing_settings != NULL) { g_signal_handlers_disconnect_matched ( priv->aliasing_settings, G_SIGNAL_MATCH_DATA, @@ -839,6 +836,9 @@ web_view_finalize (GObject *object) g_free (priv->selected_uri); + while (!g_queue_is_empty (&priv->highlights)) + g_free (g_queue_pop_head (&priv->highlights)); + /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_web_view_parent_class)->finalize (object); } @@ -1724,8 +1724,6 @@ e_web_view_init (EWebView *web_view) web_view->priv = E_WEB_VIEW_GET_PRIVATE (web_view); - web_view->priv->highlights = NULL; - g_signal_connect ( web_view, "create-plugin-widget", G_CALLBACK (web_view_create_plugin_widget_cb), NULL); @@ -2432,14 +2430,6 @@ e_web_view_set_save_as_proxy (EWebView *web_view, g_object_notify (G_OBJECT (web_view), "save-as-proxy"); } -GSList * -e_web_view_get_highlights (EWebView *web_view) -{ - g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL); - - return web_view->priv->highlights; -} - void e_web_view_add_highlight (EWebView *web_view, const gchar *highlight) @@ -2447,21 +2437,20 @@ e_web_view_add_highlight (EWebView *web_view, g_return_if_fail (E_IS_WEB_VIEW (web_view)); g_return_if_fail (highlight && *highlight); - web_view->priv->highlights = g_slist_append ( - web_view->priv->highlights, g_strdup (highlight)); + g_queue_push_tail ( + &web_view->priv->highlights, + g_strdup (highlight)); web_view_update_document_highlights (web_view); } -void e_web_view_clear_highlights (EWebView *web_view) +void +e_web_view_clear_highlights (EWebView *web_view) { g_return_if_fail (E_IS_WEB_VIEW (web_view)); - if (!web_view->priv->highlights) - return; - - g_slist_free_full (web_view->priv->highlights, g_free); - web_view->priv->highlights = NULL; + while (!g_queue_is_empty (&web_view->priv->highlights)) + g_free (g_queue_pop_head (&web_view->priv->highlights)); web_view_update_document_highlights (web_view); } diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h index f03be60014..6fdf6017e4 100644 --- a/e-util/e-web-view.h +++ b/e-util/e-web-view.h @@ -171,7 +171,6 @@ void e_web_view_set_print_proxy (EWebView *web_view, GtkAction * e_web_view_get_save_as_proxy (EWebView *web_view); void e_web_view_set_save_as_proxy (EWebView *web_view, GtkAction *save_as_proxy); -GSList * e_web_view_get_highlights (EWebView *web_view); void e_web_view_add_highlight (EWebView *web_view, const gchar *highlight); void e_web_view_clear_highlights (EWebView *web_view); |