No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-config-activity-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-config-activity-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-config-activity-page.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 "e-mail-config-activity-page.h"
20
21 #include <camel/camel.h>
22
23 #include <libevolution-utils/e-alert-sink.h>
24 #include <libevolution-utils/e-alert-dialog.h>
25 #include <misc/e-activity-bar.h>
26 #include <misc/e-alert-bar.h>
27
28 #define E_MAIL_CONFIG_ACTIVITY_PAGE_GET_PRIVATE(obj) \
29 (G_TYPE_INSTANCE_GET_PRIVATE \
30 ((obj), E_TYPE_MAIL_CONFIG_ACTIVITY_PAGE, EMailConfigActivityPagePrivate))
31
32 struct _EMailConfigActivityPagePrivate {
33 GtkWidget *activity_bar; /* not referenced */
34 GtkWidget *alert_bar; /* not referenced */
35 };
36
37 /* Forward Declarations */
38 static void e_mail_config_activity_page_alert_sink_init
39 (EAlertSinkInterface *interface);
40
41 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
42 EMailConfigActivityPage,
43 e_mail_config_activity_page,
44 GTK_TYPE_BOX,
45 G_IMPLEMENT_INTERFACE (
46 E_TYPE_ALERT_SINK,
47 e_mail_config_activity_page_alert_sink_init))
48
49 static void
50 mail_config_activity_page_constructed (GObject *object)
51 {
52 EMailConfigActivityPage *page;
53 GtkWidget *frame;
54 GtkWidget *widget;
55
56 page = E_MAIL_CONFIG_ACTIVITY_PAGE (object);
57
58 /* Chain up to parent's constructed() method. */
59 G_OBJECT_CLASS (e_mail_config_activity_page_parent_class)->
60 constructed (object);
61
62 gtk_orientable_set_orientation (
63 GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
64
65 /* Does not matter what order the EActivityBar and EAlertBar are
66 * packed. They should never both be visible at the same time. */
67
68 frame = gtk_frame_new (NULL);
69 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
70 gtk_box_pack_end (GTK_BOX (page), frame, FALSE, FALSE, 0);
71 /* Visibility is bound to the EActivityBar. */
72
73 widget = e_activity_bar_new ();
74 gtk_container_add (GTK_CONTAINER (frame), widget);
75 page->priv->activity_bar = widget; /* do not reference */
76 /* EActivityBar controls its own visibility. */
77
78 g_object_bind_property (
79 widget, "visible",
80 frame, "visible",
81 G_BINDING_SYNC_CREATE);
82
83 frame = gtk_frame_new (NULL);
84 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
85 gtk_box_pack_end (GTK_BOX (page), frame, FALSE, FALSE, 0);
86 /* Visibility is bound to the EAlertBar. */
87
88 widget = e_alert_bar_new ();
89 gtk_container_add (GTK_CONTAINER (frame), widget);
90 page->priv->alert_bar = widget; /* do not reference */
91 /* EAlertBar controls its own visibility. */
92
93 g_object_bind_property (
94 widget, "visible",
95 frame, "visible",
96 G_BINDING_SYNC_CREATE);
97 }
98
99 static void
100 mail_config_activity_page_submit_alert (EAlertSink *alert_sink,
101 EAlert *alert)
102 {
103 EMailConfigActivityPagePrivate *priv;
104 EAlertBar *alert_bar;
105 GtkWidget *dialog;
106 gpointer parent;
107
108 priv = E_MAIL_CONFIG_ACTIVITY_PAGE_GET_PRIVATE (alert_sink);
109
110 parent = gtk_widget_get_toplevel (GTK_WIDGET (alert_sink));
111 parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
112
113 switch (e_alert_get_message_type (alert)) {
114 case GTK_MESSAGE_INFO:
115 case GTK_MESSAGE_WARNING:
116 case GTK_MESSAGE_ERROR:
117 alert_bar = E_ALERT_BAR (priv->alert_bar);
118 e_alert_bar_add_alert (alert_bar, alert);
119 break;
120
121 default:
122 dialog = e_alert_dialog_new (parent, alert);
123 gtk_dialog_run (GTK_DIALOG (dialog));
124 gtk_widget_destroy (dialog);
125 break;
126 }
127 }
128
129 static void
130 e_mail_config_activity_page_class_init (EMailConfigActivityPageClass *class)
131 {
132 GObjectClass *object_class;
133
134 g_type_class_add_private (
135 class, sizeof (EMailConfigActivityPagePrivate));
136
137 object_class = G_OBJECT_CLASS (class);
138 object_class->constructed = mail_config_activity_page_constructed;
139 }
140
141 static void
142 e_mail_config_activity_page_alert_sink_init (EAlertSinkInterface *interface)
143 {
144 interface->submit_alert = mail_config_activity_page_submit_alert;
145 }
146
147 static void
148 e_mail_config_activity_page_init (EMailConfigActivityPage *page)
149 {
150 page->priv = E_MAIL_CONFIG_ACTIVITY_PAGE_GET_PRIVATE (page);
151 }
152
153 EActivity *
154 e_mail_config_activity_page_new_activity (EMailConfigActivityPage *page)
155 {
156 EActivity *activity;
157 EActivityBar *activity_bar;
158 GCancellable *cancellable;
159
160 g_return_val_if_fail (E_IS_MAIL_CONFIG_ACTIVITY_PAGE (page), NULL);
161
162 /* Clear any previous alerts. */
163 e_alert_bar_clear (E_ALERT_BAR (page->priv->alert_bar));
164
165 activity = e_activity_new ();
166
167 e_activity_set_alert_sink (activity, E_ALERT_SINK (page));
168
169 cancellable = camel_operation_new ();
170 e_activity_set_cancellable (activity, cancellable);
171 g_object_unref (cancellable);
172
173 activity_bar = E_ACTIVITY_BAR (page->priv->activity_bar);
174 e_activity_bar_set_activity (activity_bar, activity);
175
176 return activity;
177 }