evolution-3.6.4/modules/calendar/e-memo-shell-view.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-memo-shell-view.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-memo-shell-view.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
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-memo-shell-view.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  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 19  *
 20  */
 21 
 22 #ifdef HAVE_CONFIG_H
 23 #include <config.h>
 24 #endif
 25 
 26 #include "e-memo-shell-view-private.h"
 27 
 28 static gpointer parent_class;
 29 static GType memo_shell_view_type;
 30 
 31 static void
 32 memo_shell_view_dispose (GObject *object)
 33 {
 34 	e_memo_shell_view_private_dispose (E_MEMO_SHELL_VIEW (object));
 35 
 36 	/* Chain up to parent's dispose() method. */
 37 	G_OBJECT_CLASS (parent_class)->dispose (object);
 38 }
 39 
 40 static void
 41 memo_shell_view_finalize (GObject *object)
 42 {
 43 	e_memo_shell_view_private_finalize (E_MEMO_SHELL_VIEW (object));
 44 
 45 	/* Chain up to parent's finalize() method. */
 46 	G_OBJECT_CLASS (parent_class)->finalize (object);
 47 }
 48 
 49 static void
 50 memo_shell_view_constructed (GObject *object)
 51 {
 52 	/* Chain up to parent's constructed() method. */
 53 	G_OBJECT_CLASS (parent_class)->constructed (object);
 54 
 55 	e_memo_shell_view_private_constructed (E_MEMO_SHELL_VIEW (object));
 56 }
 57 
 58 static void
 59 memo_shell_view_execute_search (EShellView *shell_view)
 60 {
 61 	EMemoShellContent *memo_shell_content;
 62 	EShellWindow *shell_window;
 63 	EShellContent *shell_content;
 64 	EShellSearchbar *searchbar;
 65 	EActionComboBox *combo_box;
 66 	GtkRadioAction *action;
 67 	ECalComponentPreview *memo_preview;
 68 	EPreviewPane *preview_pane;
 69 	EMemoTable *memo_table;
 70 	EWebView *web_view;
 71 	ECalModel *model;
 72 	gchar *query;
 73 	gchar *temp;
 74 	gint value;
 75 
 76 	shell_content = e_shell_view_get_shell_content (shell_view);
 77 	shell_window = e_shell_view_get_shell_window (shell_view);
 78 
 79 	memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
 80 	searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
 81 
 82 	action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS));
 83 	value = gtk_radio_action_get_current_value (action);
 84 
 85 	if (value == MEMO_SEARCH_ADVANCED) {
 86 		query = e_shell_view_get_search_query (shell_view);
 87 
 88 		if (!query)
 89 			query = g_strdup ("");
 90 	} else {
 91 		const gchar *format;
 92 		const gchar *text;
 93 		GString *string;
 94 
 95 		text = e_shell_searchbar_get_search_text (searchbar);
 96 
 97 		if (text == NULL || *text == '\0') {
 98 			text = "";
 99 			value = MEMO_SEARCH_SUMMARY_CONTAINS;
100 		}
101 
102 		switch (value) {
103 			default:
104 				text = "";
105 				/* fall through */
106 
107 			case MEMO_SEARCH_SUMMARY_CONTAINS:
108 				format = "(contains? \"summary\" %s)";
109 				break;
110 
111 			case MEMO_SEARCH_DESCRIPTION_CONTAINS:
112 				format = "(contains? \"description\" %s)";
113 				break;
114 
115 			case MEMO_SEARCH_ANY_FIELD_CONTAINS:
116 				format = "(contains? \"any\" %s)";
117 				break;
118 		}
119 
120 		/* Build the query. */
121 		string = g_string_new ("");
122 		e_sexp_encode_string (string, text);
123 		query = g_strdup_printf (format, string->str);
124 		g_string_free (string, TRUE);
125 	}
126 
127 	/* Apply selected filter. */
128 	combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
129 	value = e_action_combo_box_get_current_value (combo_box);
130 	switch (value) {
131 		case MEMO_FILTER_ANY_CATEGORY:
132 			break;
133 
134 		case MEMO_FILTER_UNMATCHED:
135 			temp = g_strdup_printf (
136 				"(and (has-categories? #f) %s", query);
137 			g_free (query);
138 			query = temp;
139 			break;
140 
141 		default:
142 		{
143 			GList *categories;
144 			const gchar *category_name;
145 
146 			categories = e_util_get_searchable_categories ();
147 			category_name = g_list_nth_data (categories, value);
148 			g_list_free (categories);
149 
150 			temp = g_strdup_printf (
151 				"(and (has-categories? \"%s\") %s)",
152 				category_name, query);
153 			g_free (query);
154 			query = temp;
155 		}
156 	}
157 
158 	/* Submit the query. */
159 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
160 	model = e_memo_table_get_model (memo_table);
161 	e_cal_model_set_search_query (model, query);
162 	g_free (query);
163 
164 	preview_pane =
165 		e_memo_shell_content_get_preview_pane (memo_shell_content);
166 
167 	web_view = e_preview_pane_get_web_view (preview_pane);
168 	memo_preview = E_CAL_COMPONENT_PREVIEW (web_view);
169 	e_cal_component_preview_clear (memo_preview);
170 }
171 
172 static void
173 memo_shell_view_update_actions (EShellView *shell_view)
174 {
175 	EShellContent *shell_content;
176 	EShellSidebar *shell_sidebar;
177 	EShellWindow *shell_window;
178 	GtkAction *action;
179 	const gchar *label;
180 	gboolean sensitive;
181 	guint32 state;
182 
183 	/* Be descriptive. */
184 	gboolean any_memos_selected;
185 	gboolean has_primary_source;
186 	gboolean multiple_memos_selected;
187 	gboolean primary_source_is_writable;
188 	gboolean primary_source_is_removable;
189 	gboolean primary_source_is_remote_deletable;
190 	gboolean primary_source_in_collection;
191 	gboolean selection_has_url;
192 	gboolean single_memo_selected;
193 	gboolean sources_are_editable;
194 	gboolean refresh_supported;
195 
196 	/* Chain up to parent's update_actions() method. */
197 	E_SHELL_VIEW_CLASS (parent_class)->update_actions (shell_view);
198 
199 	shell_window = e_shell_view_get_shell_window (shell_view);
200 
201 	shell_content = e_shell_view_get_shell_content (shell_view);
202 	state = e_shell_content_check_state (shell_content);
203 
204 	single_memo_selected =
205 		(state & E_MEMO_SHELL_CONTENT_SELECTION_SINGLE);
206 	multiple_memos_selected =
207 		(state & E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE);
208 	sources_are_editable =
209 		(state & E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT);
210 	selection_has_url =
211 		(state & E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL);
212 
213 	shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
214 	state = e_shell_sidebar_check_state (shell_sidebar);
215 
216 	has_primary_source =
217 		(state & E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
218 	primary_source_is_writable =
219 		(state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE);
220 	primary_source_is_removable =
221 		(state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE);
222 	primary_source_is_remote_deletable =
223 		(state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE);
224 	primary_source_in_collection =
225 		(state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION);
226 	refresh_supported =
227 		(state & E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH);
228 
229 	any_memos_selected =
230 		(single_memo_selected || multiple_memos_selected);
231 
232 	action = ACTION (MEMO_DELETE);
233 	sensitive = any_memos_selected && sources_are_editable;
234 	gtk_action_set_sensitive (action, sensitive);
235 	if (multiple_memos_selected)
236 		label = _("Delete Memos");
237 	else
238 		label = _("Delete Memo");
239 	gtk_action_set_label (action, label);
240 
241 	action = ACTION (MEMO_FIND);
242 	sensitive = single_memo_selected;
243 	gtk_action_set_sensitive (action, sensitive);
244 
245 	action = ACTION (MEMO_FORWARD);
246 	sensitive = single_memo_selected;
247 	gtk_action_set_sensitive (action, sensitive);
248 
249 	action = ACTION (MEMO_LIST_COPY);
250 	sensitive = has_primary_source;
251 	gtk_action_set_sensitive (action, sensitive);
252 
253 	action = ACTION (MEMO_LIST_DELETE);
254 	sensitive =
255 		primary_source_is_removable ||
256 		primary_source_is_remote_deletable;
257 	gtk_action_set_sensitive (action, sensitive);
258 
259 	action = ACTION (MEMO_LIST_PROPERTIES);
260 	sensitive = primary_source_is_writable;
261 	gtk_action_set_sensitive (action, sensitive);
262 
263 	action = ACTION (MEMO_LIST_REFRESH);
264 	sensitive = refresh_supported;
265 	gtk_action_set_sensitive (action, sensitive);
266 
267 	action = ACTION (MEMO_LIST_RENAME);
268 	sensitive =
269 		primary_source_is_writable &&
270 		!primary_source_in_collection;
271 	gtk_action_set_sensitive (action, sensitive);
272 
273 	action = ACTION (MEMO_OPEN);
274 	sensitive = single_memo_selected;
275 	gtk_action_set_sensitive (action, sensitive);
276 
277 	action = ACTION (MEMO_OPEN_URL);
278 	sensitive = single_memo_selected && selection_has_url;
279 	gtk_action_set_sensitive (action, sensitive);
280 
281 	action = ACTION (MEMO_PRINT);
282 	sensitive = single_memo_selected;
283 	gtk_action_set_sensitive (action, sensitive);
284 
285 	action = ACTION (MEMO_SAVE_AS);
286 	sensitive = single_memo_selected;
287 	gtk_action_set_sensitive (action, sensitive);
288 }
289 
290 static void
291 memo_shell_view_class_init (EMemoShellViewClass *class,
292                             GTypeModule *type_module)
293 {
294 	GObjectClass *object_class;
295 	EShellViewClass *shell_view_class;
296 
297 	parent_class = g_type_class_peek_parent (class);
298 	g_type_class_add_private (class, sizeof (EMemoShellViewPrivate));
299 
300 	object_class = G_OBJECT_CLASS (class);
301 	object_class->dispose = memo_shell_view_dispose;
302 	object_class->finalize = memo_shell_view_finalize;
303 	object_class->constructed = memo_shell_view_constructed;
304 
305 	shell_view_class = E_SHELL_VIEW_CLASS (class);
306 	shell_view_class->label = _("Memos");
307 	shell_view_class->icon_name = "evolution-memos";
308 	shell_view_class->ui_definition = "evolution-memos.ui";
309 	shell_view_class->ui_manager_id = "org.gnome.evolution.memos";
310 	shell_view_class->search_options = "/memo-search-options";
311 	shell_view_class->search_rules = "memotypes.xml";
312 	shell_view_class->new_shell_content = e_memo_shell_content_new;
313 	shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new;
314 	shell_view_class->execute_search = memo_shell_view_execute_search;
315 	shell_view_class->update_actions = memo_shell_view_update_actions;
316 }
317 
318 static void
319 memo_shell_view_init (EMemoShellView *memo_shell_view,
320                       EShellViewClass *shell_view_class)
321 {
322 	memo_shell_view->priv =
323 		E_MEMO_SHELL_VIEW_GET_PRIVATE (memo_shell_view);
324 
325 	e_memo_shell_view_private_init (memo_shell_view, shell_view_class);
326 }
327 
328 GType
329 e_memo_shell_view_get_type (void)
330 {
331 	return memo_shell_view_type;
332 }
333 
334 void
335 e_memo_shell_view_register_type (GTypeModule *type_module)
336 {
337 	const GTypeInfo type_info = {
338 		sizeof (EMemoShellViewClass),
339 		(GBaseInitFunc) NULL,
340 		(GBaseFinalizeFunc) NULL,
341 		(GClassInitFunc) memo_shell_view_class_init,
342 		(GClassFinalizeFunc) NULL,
343 		type_module,
344 		sizeof (EMemoShellView),
345 		0,    /* n_preallocs */
346 		(GInstanceInitFunc) memo_shell_view_init,
347 		NULL  /* value_table */
348 	};
349 
350 	memo_shell_view_type = g_type_module_register_type (
351 		type_module, E_TYPE_SHELL_VIEW,
352 		"EMemoShellView", &type_info, 0);
353 }