summaryrefslogtreecommitdiff
blob: 227e2ac04b4f35db5aa3f585e5c68fe0a55c5501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
From ea37ea940dfbcc4e6bcf8327194857a7b306a278 Mon Sep 17 00:00:00 2001
From: Peter Bloomfield
Date: Sat, 7 Jul 2018 14:44:26 -0400
Subject: [PATCH] Use g_debug() instead of conditional compilation

* libbalsa/html.c (lbh_navigation_policy_decision),
  (lbh_new_window_policy_decision), (lbh_response_policy_decision),
  (lbh_resource_notify_response_cb), (lbh_web_process_crashed_cb),
  (lbh_cid_cb), (libbalsa_html_new): Use g_debug() instead of
  conditionally compiled printing.
---
 libbalsa/html.c | 52 ++++++++++++++++++++++++-------------------------
 2 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/libbalsa/html.c b/libbalsa/html.c
index 17f62789e..1e5e2f500 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -44,6 +44,11 @@
 #include <string.h>
 #include <glib/gi18n.h>
 
+#ifdef G_LOG_DOMAIN
+#  undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "html"
+
 #ifdef HAVE_HTML_WIDGET
 
 /*
@@ -141,13 +146,6 @@ html2text(gchar ** text, gsize len)
  * Experimental support for WebKit2.
  */
 
-#define DEBUG_WEBKIT2 FALSE
-#if DEBUG_WEBKIT2
-#define d(x) x
-#else
-#define d(x)
-#endif
-
 /* WebKitContextMenuItem uses GtkAction, which is deprecated.
  * We don't use it, but it breaks the git-tree build, so we just mangle
  * it: */
@@ -280,10 +278,10 @@ lbh_navigation_policy_decision(WebKitPolicyDecision * decision,
 
     switch (navigation_type) {
     case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED:
-        d(g_print("%s clicked %s\n", __func__, uri));
+        g_debug("%s clicked %s", __func__, uri);
         (*info->clicked_cb) (uri);
     default:
-        d(g_print("%s uri %s, type %d, ignored\n", __func__, uri, navigation_type));
+        g_debug("%s uri %s, type %d, ignored", __func__, uri, navigation_type);
         webkit_policy_decision_ignore(decision);
     }
 }
@@ -305,13 +303,13 @@ lbh_new_window_policy_decision(WebKitPolicyDecision * decision,
             (navigation_action)) {
     case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED:
         request = webkit_navigation_action_get_request(navigation_action);
-        d(g_print("%s clicked %s\n", __func__,
-                  webkit_uri_request_get_uri(request)));
+        g_debug("%s clicked %s", __func__,
+                webkit_uri_request_get_uri(request));
         (*info->clicked_cb) (webkit_uri_request_get_uri(request));
     default:
-        d(g_print("%s type %d, ignored\n", __func__,
-                  webkit_navigation_action_get_navigation_type
-                  (navigation_action)));
+        g_debug("%s type %d, ignored", __func__,
+                webkit_navigation_action_get_navigation_type
+                (navigation_action));
 
         webkit_policy_decision_ignore(decision);
     }
@@ -321,10 +319,10 @@ static void
 lbh_response_policy_decision(WebKitPolicyDecision * decision,
                              gpointer               data)
 {
-    d(g_print("%s uri %s, ignored\n", __func__,
-              webkit_uri_request_get_uri
-              (webkit_response_policy_decision_get_request
-               (WEBKIT_RESPONSE_POLICY_DECISION(decision)))));
+    g_debug("%s uri %s, ignored", __func__,
+            webkit_uri_request_get_uri
+            (webkit_response_policy_decision_get_request
+             (WEBKIT_RESPONSE_POLICY_DECISION(decision))));
     webkit_policy_decision_ignore(decision);
 }
 
@@ -453,20 +451,20 @@ lbh_resource_notify_response_cb(WebKitWebResource * resource,
 
     response = webkit_web_resource_get_response(resource);
     mime_type = webkit_uri_response_get_mime_type(response);
-    d(g_print("%s mime-type %s\n", __func__, mime_type));
+    g_debug("%s mime-type %s", __func__, mime_type);
     if (g_ascii_strncasecmp(mime_type, "image/", 6) != 0)
         return;
 
     if (info->info_bar) {
-        d(g_print("%s %s destroy info_bar\n", __func__,
-                  webkit_web_resource_get_uri(resource)));
+        g_debug("%s %s destroy info_bar", __func__,
+                webkit_web_resource_get_uri(resource));
         /* web_view is loading an image from its cache, so we do not
          * need to ask the user for permission to download */
         gtk_widget_destroy(info->info_bar);
         info->info_bar = NULL;
     } else {
-        d(g_print("%s %s null info_bar\n", __func__,
-                  webkit_web_resource_get_uri(resource)));
+        g_debug("%s %s null info_bar", __func__,
+                webkit_web_resource_get_uri(resource));
     }
 }
 
@@ -493,7 +491,7 @@ static gboolean
 lbh_web_process_crashed_cb(WebKitWebView * web_view,
                            gpointer        data)
 {
-    d(g_print("%s\n", __func__));
+    g_debug("%s", __func__);
     return FALSE;
 }
 
@@ -509,7 +507,7 @@ lbh_cid_cb(WebKitURISchemeRequest * request,
     LibBalsaMessageBody *body;
 
     path = webkit_uri_scheme_request_get_path(request);
-    d(g_print("%s path %s\n", __func__, path));
+    g_debug("%s path %s", __func__, path);
 
     if ((body =
          libbalsa_message_get_part_by_id(info->body->message, path))) {
@@ -616,7 +614,7 @@ libbalsa_html_new(LibBalsaMessageBody * body,
         webkit_web_context_register_uri_scheme(context, "cid", lbh_cid_cb,
                                                &info, NULL);
         have_registered_cid = TRUE;
-        d(g_print("%s registered cid: scheme\n", __func__));
+        g_debug("%s registered cid: scheme", __func__);
     }
 
     settings = webkit_web_view_get_settings(web_view);
@@ -647,7 +645,7 @@ libbalsa_html_new(LibBalsaMessageBody * body,
     if (g_regex_match_simple(src_regex, text, G_REGEX_CASELESS, 0)) {
         info->info_bar = lbh_info_bar(info);
         gtk_box_pack_start(GTK_BOX(vbox), info->info_bar, FALSE, FALSE, 0);
-        d(g_print("%s shows info_bar\n", __func__));
+        g_debug("%s shows info_bar", __func__);
     }
 
     webkit_web_view_load_html(web_view, text, NULL);
-- 
2.17.1