No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | gal-view-minicard.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | gal-view-minicard.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 *
3 * gal-view-minicard.c: An Minicard View
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with the program; if not, see <http://www.gnu.org/licenses/>
17 *
18 *
19 * Authors:
20 * Chris Lahey <clahey@ximian.com>
21 *
22 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
23 *
24 */
25
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29
30 #include <libxml/parser.h>
31 #include <libevolution-utils/e-xml-utils.h>
32
33 #include "gal-view-minicard.h"
34
35 G_DEFINE_TYPE (
36 GalViewMinicard,
37 gal_view_minicard,
38 GAL_TYPE_VIEW)
39
40 static void
41 view_minicard_column_width_changed (EAddressbookView *address_view,
42 gdouble width)
43 {
44 GalView *view;
45 GalViewInstance *view_instance;
46 GalViewMinicard *view_minicard;
47
48 view_instance = e_addressbook_view_get_view_instance (address_view);
49 view = gal_view_instance_get_current_view (view_instance);
50 view_minicard = GAL_VIEW_MINICARD (view);
51
52 if (view_minicard->column_width != width) {
53 view_minicard->column_width = width;
54 gal_view_changed (view);
55 }
56 }
57
58 static void
59 view_minicard_finalize (GObject *object)
60 {
61 GalViewMinicard *view = GAL_VIEW_MINICARD (object);
62
63 if (view->title != NULL) {
64 gal_view_minicard_detach (view);
65 g_free (view->title);
66 view->title = NULL;
67 }
68
69 /* Chain up to parent's finalize() method. */
70 G_OBJECT_CLASS (gal_view_minicard_parent_class)->finalize (object);
71 }
72
73 static void
74 view_minicard_load (GalView *view,
75 const gchar *filename)
76 {
77 GalViewMinicard *view_minicard;
78 xmlDoc *doc;
79 xmlNode *root;
80
81 view_minicard = GAL_VIEW_MINICARD (view);
82
83 doc = e_xml_parse_file (filename);
84 g_return_if_fail (doc != NULL);
85
86 root = xmlDocGetRootElement (doc);
87 view_minicard->column_width =
88 e_xml_get_double_prop_by_name_with_default (
89 root, (guchar *) "column_width", 225);
90 xmlFreeDoc (doc);
91 }
92
93 static void
94 view_minicard_save (GalView *view,
95 const gchar *filename)
96 {
97 GalViewMinicard *view_minicard;
98 xmlDoc *doc;
99 xmlNode *root;
100
101 view_minicard = GAL_VIEW_MINICARD (view);
102
103 doc = xmlNewDoc ((guchar *) "1.0");
104 root = xmlNewNode (NULL, (guchar *) "EMinicardViewState");
105 e_xml_set_double_prop_by_name (
106 root, (guchar *) "column_width",
107 view_minicard->column_width);
108 xmlDocSetRootElement (doc, root);
109 e_xml_save_file (filename, doc);
110 xmlFreeDoc (doc);
111 }
112
113 static const gchar *
114 view_minicard_get_title (GalView *view)
115 {
116 GalViewMinicard *view_minicard;
117
118 view_minicard = GAL_VIEW_MINICARD (view);
119
120 return view_minicard->title;
121 }
122
123 static void
124 view_minicard_set_title (GalView *view,
125 const gchar *title)
126 {
127 GalViewMinicard *view_minicard;
128
129 view_minicard = GAL_VIEW_MINICARD (view);
130
131 g_free (view_minicard->title);
132 view_minicard->title = g_strdup (title);
133 }
134
135 static const gchar *
136 view_minicard_get_type_code (GalView *view)
137 {
138 return "minicard";
139 }
140
141 static GalView *
142 view_minicard_clone (GalView *view)
143 {
144 GalViewMinicard *view_minicard;
145 GalViewMinicard *clone;
146
147 view_minicard = GAL_VIEW_MINICARD (view);
148
149 clone = g_object_new (GAL_TYPE_VIEW_MINICARD, NULL);
150 clone->column_width = view_minicard->column_width;
151 clone->title = g_strdup (view_minicard->title);
152
153 return GAL_VIEW (clone);
154 }
155
156 static void
157 gal_view_minicard_class_init (GalViewMinicardClass *class)
158 {
159 GObjectClass *object_class;
160 GalViewClass *gal_view_class;
161
162 object_class = G_OBJECT_CLASS (class);
163 object_class->dispose = view_minicard_finalize;
164
165 gal_view_class = GAL_VIEW_CLASS (class);
166 gal_view_class->edit = NULL;
167 gal_view_class->load = view_minicard_load;
168 gal_view_class->save = view_minicard_save;
169 gal_view_class->get_title = view_minicard_get_title;
170 gal_view_class->set_title = view_minicard_set_title;
171 gal_view_class->get_type_code = view_minicard_get_type_code;
172 gal_view_class->clone = view_minicard_clone;
173
174 }
175
176 static void
177 gal_view_minicard_init (GalViewMinicard *gvm)
178 {
179 gvm->title = NULL;
180 gvm->column_width = 225.0;
181
182 gvm->emvw = NULL;
183 gvm->emvw_column_width_changed_id = 0;
184 }
185
186 /**
187 * gal_view_minicard_new
188 * @title: The name of the new view.
189 *
190 * Returns a new GalViewMinicard. This is primarily for use by
191 * GalViewFactoryMinicard.
192 *
193 * Returns: The new GalViewMinicard.
194 */
195 GalView *
196 gal_view_minicard_new (const gchar *title)
197 {
198 return gal_view_minicard_construct (
199 g_object_new (GAL_TYPE_VIEW_MINICARD, NULL), title);
200 }
201
202 /**
203 * gal_view_minicard_construct
204 * @view: The view to construct.
205 * @title: The name of the new view.
206 *
207 * Constructs the GalViewMinicard. To be used by subclasses and
208 * language bindings.
209 *
210 * Returns: The GalViewMinicard.
211 */
212 GalView *
213 gal_view_minicard_construct (GalViewMinicard *view,
214 const gchar *title)
215 {
216 view->title = g_strdup (title);
217
218 return GAL_VIEW (view);
219 }
220
221 void
222 gal_view_minicard_attach (GalViewMinicard *view,
223 EAddressbookView *address_view)
224 {
225 GObject *object;
226
227 g_return_if_fail (GAL_IS_VIEW_MINICARD (view));
228 g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (address_view));
229
230 object = e_addressbook_view_get_view_object (address_view);
231 g_return_if_fail (E_IS_MINICARD_VIEW_WIDGET (object));
232
233 gal_view_minicard_detach (view);
234 view->emvw = g_object_ref (object);
235
236 g_object_set (view->emvw, "column-width", view->column_width, NULL);
237
238 view->emvw_column_width_changed_id =
239 g_signal_connect_swapped (
240 view->emvw, "column-width-changed",
241 G_CALLBACK (view_minicard_column_width_changed),
242 address_view);
243 }
244
245 void
246 gal_view_minicard_detach (GalViewMinicard *view)
247 {
248 g_return_if_fail (GAL_IS_VIEW_MINICARD (view));
249
250 if (view->emvw == NULL)
251 return;
252
253 if (view->emvw_column_width_changed_id > 0) {
254 g_signal_handler_disconnect (
255 view->emvw, view->emvw_column_width_changed_id);
256 view->emvw_column_width_changed_id = 0;
257 }
258
259 g_object_unref (view->emvw);
260 view->emvw = NULL;
261 }