evolution-3.6.4/widgets/misc/test-mail-signatures.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found test-mail-signatures.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * test-mail-signatures.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  */
 18 
 19 #include <stdlib.h>
 20 
 21 #include <libedataserver/libedataserver.h>
 22 
 23 #include <libevolution-utils/e-alert-sink.h>
 24 #include <misc/e-mail-identity-combo-box.h>
 25 #include <misc/e-mail-signature-combo-box.h>
 26 #include <misc/e-mail-signature-manager.h>
 27 #include <misc/e-mail-signature-preview.h>
 28 
 29 static GCancellable *cancellable = NULL;
 30 
 31 static void
 32 signature_loaded_cb (EMailSignatureComboBox *combo_box,
 33                      GAsyncResult *result,
 34                      EWebView *web_view)
 35 {
 36 	gchar *contents = NULL;
 37 	gboolean is_html;
 38 	GError *error = NULL;
 39 
 40 	e_mail_signature_combo_box_load_selected_finish (
 41 		combo_box, result, &contents, NULL, &is_html, &error);
 42 
 43 	/* Ignore cancellations. */
 44 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
 45 		g_warn_if_fail (contents == NULL);
 46 		g_object_unref (web_view);
 47 		g_error_free (error);
 48 		return;
 49 
 50 	} else if (error != NULL) {
 51 		g_warn_if_fail (contents == NULL);
 52 		e_alert_submit (
 53 			E_ALERT_SINK (web_view),
 54 			"widgets:no-load-signature",
 55 			error->message, NULL);
 56 		g_object_unref (web_view);
 57 		g_error_free (error);
 58 		return;
 59 	}
 60 
 61 	if (contents == NULL)
 62 		e_web_view_clear (web_view);
 63 	else if (is_html)
 64 		e_web_view_load_string (web_view, contents);
 65 	else {
 66 		gchar *string;
 67 
 68 		string = g_markup_printf_escaped ("<pre>%s</pre>", contents);
 69 		e_web_view_load_string (web_view, string);
 70 		g_free (string);
 71 	}
 72 
 73 	g_free (contents);
 74 
 75 	g_object_unref (web_view);
 76 }
 77 
 78 static void
 79 signature_combo_changed_cb (EMailSignatureComboBox *combo_box,
 80                             EWebView *web_view)
 81 {
 82 	if (cancellable != NULL) {
 83 		g_cancellable_cancel (cancellable);
 84 		g_object_unref (cancellable);
 85 	}
 86 
 87 	cancellable = g_cancellable_new ();
 88 
 89 	e_mail_signature_combo_box_load_selected (
 90 		combo_box, G_PRIORITY_DEFAULT, cancellable,
 91 		(GAsyncReadyCallback) signature_loaded_cb,
 92 		g_object_ref (web_view));
 93 }
 94 
 95 gint
 96 main (gint argc,
 97       gchar **argv)
 98 {
 99 	ESourceRegistry *registry;
100 	GtkWidget *container;
101 	GtkWidget *widget;
102 	GtkWidget *vbox;
103 	GtkWidget *identity_combo;
104 	GtkWidget *signature_combo;
105 	GError *error = NULL;
106 
107 	gtk_init (&argc, &argv);
108 
109 	registry = e_source_registry_new_sync (NULL, &error);
110 
111 	if (error != NULL) {
112 		g_printerr ("%s\n", error->message);
113 		exit (EXIT_FAILURE);
114 	}
115 
116 	/* Construct the widgets. */
117 
118 	widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
119 	gtk_window_set_title (GTK_WINDOW (widget), "Mail Signatures");
120 	gtk_window_set_default_size (GTK_WINDOW (widget), 400, 400);
121 	gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
122 	gtk_widget_show (widget);
123 
124 	g_signal_connect (
125 		widget, "delete-event",
126 		G_CALLBACK (gtk_main_quit), NULL);
127 
128 	container = widget;
129 
130 	widget = gtk_vbox_new (FALSE, 12);
131 	gtk_container_add (GTK_CONTAINER (container), widget);
132 	gtk_widget_show (widget);
133 
134 	container = vbox = widget;
135 
136 	widget = gtk_label_new ("<b>EMailSignatureComboBox</b>");
137 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
138 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
139 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
140 	gtk_widget_show (widget);
141 
142 	widget = gtk_vbox_new (FALSE, 6);
143 	gtk_widget_set_margin_left (widget, 12);
144 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
145 	gtk_widget_show (widget);
146 
147 	container = widget;
148 
149 	widget = e_mail_signature_combo_box_new (registry);
150 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
151 	signature_combo = widget;
152 	gtk_widget_show (widget);
153 
154 	widget = e_mail_identity_combo_box_new (registry);
155 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
156 	identity_combo = widget;
157 	gtk_widget_show (widget);
158 
159 	widget = gtk_scrolled_window_new (NULL, NULL);
160 	gtk_scrolled_window_set_policy (
161 		GTK_SCROLLED_WINDOW (widget),
162 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
163 	gtk_scrolled_window_set_shadow_type (
164 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
165 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
166 	gtk_widget_show (widget);
167 
168 	container = widget;
169 
170 	widget = e_web_view_new ();
171 	gtk_container_add (GTK_CONTAINER (container), widget);
172 	gtk_widget_show (widget);
173 
174 	g_signal_connect (
175 		signature_combo, "changed",
176 		G_CALLBACK (signature_combo_changed_cb), widget);
177 
178 	container = vbox;
179 
180 	widget = gtk_label_new ("<b>EMailSignatureManager</b>");
181 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
182 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
183 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
184 	gtk_widget_show (widget);
185 
186 	widget = e_mail_signature_manager_new (registry);
187 	gtk_widget_set_margin_left (widget, 12);
188 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
189 	gtk_widget_show (widget);
190 
191 	g_object_bind_property (
192 		identity_combo, "active-id",
193 		signature_combo, "identity-uid",
194 		G_BINDING_SYNC_CREATE);
195 
196 	gtk_main ();
197 
198 	return 0;
199 }