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

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-memo-shell-view-actions.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-memo-shell-view-actions.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-actions.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 "libevolution-utils/e-alert-dialog.h"
  27 #include "e-memo-shell-view-private.h"
  28 
  29 static void
  30 action_gal_save_custom_view_cb (GtkAction *action,
  31                                 EMemoShellView *memo_shell_view)
  32 {
  33 	EMemoShellContent *memo_shell_content;
  34 	EShellView *shell_view;
  35 	GalViewInstance *view_instance;
  36 
  37 	/* All shell views respond to the activation of this action,
  38 	 * which is defined by EShellWindow.  But only the currently
  39 	 * active shell view proceeds with saving the custom view. */
  40 	shell_view = E_SHELL_VIEW (memo_shell_view);
  41 	if (!e_shell_view_is_active (shell_view))
  42 		return;
  43 
  44 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
  45 	view_instance = e_memo_shell_content_get_view_instance (memo_shell_content);
  46 	gal_view_instance_save_as (view_instance);
  47 }
  48 
  49 static void
  50 action_memo_delete_cb (GtkAction *action,
  51                        EMemoShellView *memo_shell_view)
  52 {
  53 	EMemoShellContent *memo_shell_content;
  54 	EMemoTable *memo_table;
  55 
  56 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
  57 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
  58 
  59 	e_selectable_delete_selection (E_SELECTABLE (memo_table));
  60 }
  61 
  62 static void
  63 action_memo_find_cb (GtkAction *action,
  64                      EMemoShellView *memo_shell_view)
  65 {
  66 	EMemoShellContent *memo_shell_content;
  67 	EPreviewPane *preview_pane;
  68 
  69 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
  70 	preview_pane = e_memo_shell_content_get_preview_pane (memo_shell_content);
  71 
  72 	e_preview_pane_show_search_bar (preview_pane);
  73 }
  74 
  75 static void
  76 action_memo_forward_cb (GtkAction *action,
  77                         EMemoShellView *memo_shell_view)
  78 {
  79 	EMemoShellContent *memo_shell_content;
  80 	EShell *shell;
  81 	EShellView *shell_view;
  82 	EShellWindow *shell_window;
  83 	ESourceRegistry *registry;
  84 	EMemoTable *memo_table;
  85 	ECalModelComponent *comp_data;
  86 	ECalComponent *comp;
  87 	icalcomponent *clone;
  88 	GSList *list;
  89 
  90 	shell_view = E_SHELL_VIEW (memo_shell_view);
  91 	shell_window = e_shell_view_get_shell_window (shell_view);
  92 	shell = e_shell_window_get_shell (shell_window);
  93 
  94 	registry = e_shell_get_registry (shell);
  95 
  96 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
  97 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
  98 
  99 	list = e_memo_table_get_selected (memo_table);
 100 	g_return_if_fail (list != NULL);
 101 	comp_data = list->data;
 102 	g_slist_free (list);
 103 
 104 	/* XXX We only forward the first selected memo. */
 105 	comp = e_cal_component_new ();
 106 	clone = icalcomponent_new_clone (comp_data->icalcomp);
 107 	e_cal_component_set_icalcomponent (comp, clone);
 108 
 109 	itip_send_comp (
 110 		registry, E_CAL_COMPONENT_METHOD_PUBLISH, comp,
 111 		comp_data->client, NULL, NULL, NULL, TRUE, FALSE);
 112 
 113 	g_object_unref (comp);
 114 }
 115 
 116 static void
 117 action_memo_list_copy_cb (GtkAction *action,
 118                           EMemoShellView *memo_shell_view)
 119 {
 120 	EMemoShellSidebar *memo_shell_sidebar;
 121 	EShell *shell;
 122 	EShellView *shell_view;
 123 	EShellWindow *shell_window;
 124 	ESourceRegistry *registry;
 125 	ESourceSelector *selector;
 126 	ESource *source;
 127 
 128 	shell_view = E_SHELL_VIEW (memo_shell_view);
 129 	shell_window = e_shell_view_get_shell_window (shell_view);
 130 	shell = e_shell_window_get_shell (shell_window);
 131 
 132 	registry = e_shell_get_registry (shell);
 133 
 134 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 135 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 136 	source = e_source_selector_ref_primary_selection (selector);
 137 	g_return_if_fail (source != NULL);
 138 
 139 	copy_source_dialog (
 140 		GTK_WINDOW (shell_window), registry,
 141 		source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
 142 
 143 	g_object_unref (source);
 144 }
 145 
 146 static void
 147 action_memo_list_delete_cb (GtkAction *action,
 148                             EMemoShellView *memo_shell_view)
 149 {
 150 	EMemoShellSidebar *memo_shell_sidebar;
 151 	EShellWindow *shell_window;
 152 	EShellView *shell_view;
 153 	ESource *source;
 154 	ESourceSelector *selector;
 155 	gint response;
 156 
 157 	shell_view = E_SHELL_VIEW (memo_shell_view);
 158 	shell_window = e_shell_view_get_shell_window (shell_view);
 159 
 160 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 161 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 162 
 163 	source = e_source_selector_ref_primary_selection (selector);
 164 	g_return_if_fail (source != NULL);
 165 
 166 	if (e_source_get_remote_deletable (source)) {
 167 		response = e_alert_run_dialog_for_args (
 168 			GTK_WINDOW (shell_window),
 169 			"calendar:prompt-delete-remote-memo-list",
 170 			e_source_get_display_name (source), NULL);
 171 
 172 		if (response == GTK_RESPONSE_YES)
 173 			e_shell_view_remote_delete_source (shell_view, source);
 174 
 175 	} else {
 176 		response = e_alert_run_dialog_for_args (
 177 			GTK_WINDOW (shell_window),
 178 			"calendar:prompt-delete-memo-list",
 179 			e_source_get_display_name (source), NULL);
 180 
 181 		if (response == GTK_RESPONSE_YES)
 182 			e_shell_view_remove_source (shell_view, source);
 183 	}
 184 
 185 	g_object_unref (source);
 186 }
 187 
 188 static void
 189 action_memo_list_new_cb (GtkAction *action,
 190                          EMemoShellView *memo_shell_view)
 191 {
 192 	EShell *shell;
 193 	EShellView *shell_view;
 194 	EShellWindow *shell_window;
 195 	ESourceRegistry *registry;
 196 	ECalClientSourceType source_type;
 197 	GtkWidget *config;
 198 	GtkWidget *dialog;
 199 	const gchar *icon_name;
 200 
 201 	shell_view = E_SHELL_VIEW (memo_shell_view);
 202 	shell_window = e_shell_view_get_shell_window (shell_view);
 203 	shell = e_shell_window_get_shell (shell_window);
 204 
 205 	registry = e_shell_get_registry (shell);
 206 	source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
 207 	config = e_cal_source_config_new (registry, NULL, source_type);
 208 
 209 	dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
 210 
 211 	gtk_window_set_transient_for (
 212 		GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
 213 
 214 	icon_name = gtk_action_get_icon_name (action);
 215 	gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
 216 
 217 	gtk_window_set_title (GTK_WINDOW (dialog), _("New Memo List"));
 218 
 219 	gtk_widget_show (dialog);
 220 }
 221 
 222 static void
 223 action_memo_list_print_cb (GtkAction *action,
 224                            EMemoShellView *memo_shell_view)
 225 {
 226 	EMemoShellContent *memo_shell_content;
 227 	EMemoTable *memo_table;
 228 
 229 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 230 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 231 
 232 	print_table (
 233 		E_TABLE (memo_table), _("Print Memos"), _("Memos"),
 234 		GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
 235 }
 236 
 237 static void
 238 action_memo_list_print_preview_cb (GtkAction *action,
 239                                    EMemoShellView *memo_shell_view)
 240 {
 241 	EMemoShellContent *memo_shell_content;
 242 	EMemoTable *memo_table;
 243 
 244 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 245 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 246 
 247 	print_table (
 248 		E_TABLE (memo_table), _("Print Memos"), _("Memos"),
 249 		GTK_PRINT_OPERATION_ACTION_PREVIEW);
 250 }
 251 
 252 static void
 253 action_memo_list_properties_cb (GtkAction *action,
 254                                 EMemoShellView *memo_shell_view)
 255 {
 256 	EShellView *shell_view;
 257 	EShellWindow *shell_window;
 258 	EMemoShellSidebar *memo_shell_sidebar;
 259 	ECalClientSourceType source_type;
 260 	ESource *source;
 261 	ESourceSelector *selector;
 262 	ESourceRegistry *registry;
 263 	GtkWidget *config;
 264 	GtkWidget *dialog;
 265 	const gchar *icon_name;
 266 
 267 	shell_view = E_SHELL_VIEW (memo_shell_view);
 268 	shell_window = e_shell_view_get_shell_window (shell_view);
 269 
 270 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 271 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 272 	source = e_source_selector_ref_primary_selection (selector);
 273 	g_return_if_fail (source != NULL);
 274 
 275 	source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
 276 	registry = e_source_selector_get_registry (selector);
 277 	config = e_cal_source_config_new (registry, source, source_type);
 278 
 279 	g_object_unref (source);
 280 
 281 	dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
 282 
 283 	gtk_window_set_transient_for (
 284 		GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
 285 
 286 	icon_name = gtk_action_get_icon_name (action);
 287 	gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
 288 
 289 	gtk_window_set_title (GTK_WINDOW (dialog), _("Memo List Properties"));
 290 
 291 	gtk_widget_show (dialog);
 292 }
 293 
 294 static void
 295 action_memo_list_refresh_cb (GtkAction *action,
 296                              EMemoShellView *memo_shell_view)
 297 {
 298 	EMemoShellContent *memo_shell_content;
 299 	EMemoShellSidebar *memo_shell_sidebar;
 300 	ESourceSelector *selector;
 301 	ECalClient *client;
 302 	ECalModel *model;
 303 	ESource *source;
 304 	GError *error = NULL;
 305 
 306 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 307 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 308 
 309 	model = e_memo_shell_content_get_memo_model (memo_shell_content);
 310 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 311 
 312 	source = e_source_selector_ref_primary_selection (selector);
 313 	g_return_if_fail (source != NULL);
 314 
 315 	client = e_cal_model_get_client_for_source (model, source);
 316 	if (client == NULL) {
 317 		g_object_unref (source);
 318 		return;
 319 	}
 320 
 321 	g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client)));
 322 
 323 	e_client_refresh_sync (E_CLIENT (client), NULL, &error);
 324 
 325 	if (error != NULL) {
 326 		g_warning (
 327 			"%s: Failed to refresh '%s', %s",
 328 			G_STRFUNC, e_source_get_display_name (source),
 329 			error->message);
 330 		g_error_free (error);
 331 	}
 332 
 333 	g_object_unref (source);
 334 }
 335 
 336 static void
 337 action_memo_list_rename_cb (GtkAction *action,
 338                             EMemoShellView *memo_shell_view)
 339 {
 340 	EMemoShellSidebar *memo_shell_sidebar;
 341 	ESourceSelector *selector;
 342 
 343 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 344 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 345 
 346 	e_source_selector_edit_primary_selection (selector);
 347 }
 348 
 349 static void
 350 action_memo_list_select_one_cb (GtkAction *action,
 351                                 EMemoShellView *memo_shell_view)
 352 {
 353 	EMemoShellSidebar *memo_shell_sidebar;
 354 	ESourceSelector *selector;
 355 	ESource *primary;
 356 
 357 	memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
 358 	selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 359 
 360 	primary = e_source_selector_ref_primary_selection (selector);
 361 	g_return_if_fail (primary != NULL);
 362 
 363 	e_source_selector_select_exclusive (selector, primary);
 364 
 365 	g_object_unref (primary);
 366 }
 367 
 368 static void
 369 action_memo_new_cb (GtkAction *action,
 370                     EMemoShellView *memo_shell_view)
 371 {
 372 	EShell *shell;
 373 	EShellView *shell_view;
 374 	EShellWindow *shell_window;
 375 	EMemoShellContent *memo_shell_content;
 376 	EMemoTable *memo_table;
 377 	ECalClient *client;
 378 	ECalComponent *comp;
 379 	CompEditor *editor;
 380 	GSList *list;
 381 
 382 	shell_view = E_SHELL_VIEW (memo_shell_view);
 383 	shell_window = e_shell_view_get_shell_window (shell_view);
 384 	shell = e_shell_window_get_shell (shell_window);
 385 
 386 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 387 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 388 
 389 	list = e_memo_table_get_selected (memo_table);
 390 	if (list == NULL) {
 391 		ECalModel *model;
 392 
 393 		model = e_memo_table_get_model (memo_table);
 394 		client = e_cal_model_get_default_client (model);
 395 	} else {
 396 		ECalModelComponent *comp_data;
 397 
 398 		comp_data = list->data;
 399 		client = comp_data->client;
 400 		g_slist_free (list);
 401 	}
 402 
 403 	g_return_if_fail (client != NULL);
 404 
 405 	comp = cal_comp_memo_new_with_defaults (client);
 406 	cal_comp_update_time_by_active_window (comp, shell);
 407 	editor = memo_editor_new (client, shell, COMP_EDITOR_NEW_ITEM);
 408 	comp_editor_edit_comp (editor, comp);
 409 
 410 	gtk_window_present (GTK_WINDOW (editor));
 411 
 412 	g_object_unref (comp);
 413 }
 414 
 415 static void
 416 action_memo_open_cb (GtkAction *action,
 417                      EMemoShellView *memo_shell_view)
 418 {
 419 	EMemoShellContent *memo_shell_content;
 420 	EMemoTable *memo_table;
 421 	ECalModelComponent *comp_data;
 422 	GSList *list;
 423 
 424 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 425 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 426 
 427 	list = e_memo_table_get_selected (memo_table);
 428 	g_return_if_fail (list != NULL);
 429 	comp_data = list->data;
 430 	g_slist_free (list);
 431 
 432 	/* XXX We only open the first selected memo. */
 433 	e_memo_shell_view_open_memo (memo_shell_view, comp_data);
 434 }
 435 
 436 static void
 437 action_memo_open_url_cb (GtkAction *action,
 438                          EMemoShellView *memo_shell_view)
 439 {
 440 	EShellView *shell_view;
 441 	EShellWindow *shell_window;
 442 	EMemoShellContent *memo_shell_content;
 443 	EMemoTable *memo_table;
 444 	ECalModelComponent *comp_data;
 445 	icalproperty *prop;
 446 	const gchar *uri;
 447 	GSList *list;
 448 
 449 	shell_view = E_SHELL_VIEW (memo_shell_view);
 450 	shell_window = e_shell_view_get_shell_window (shell_view);
 451 
 452 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 453 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 454 
 455 	list = e_memo_table_get_selected (memo_table);
 456 	g_return_if_fail (list != NULL);
 457 	comp_data = list->data;
 458 	g_slist_free (list);
 459 
 460 	/* XXX We only open the URI of the first selected memo. */
 461 	prop = icalcomponent_get_first_property (
 462 		comp_data->icalcomp, ICAL_URL_PROPERTY);
 463 	g_return_if_fail (prop != NULL);
 464 
 465 	uri = icalproperty_get_url (prop);
 466 	e_show_uri (GTK_WINDOW (shell_window), uri);
 467 }
 468 
 469 static void
 470 action_memo_preview_cb (GtkToggleAction *action,
 471                         EMemoShellView *memo_shell_view)
 472 {
 473 	EMemoShellContent *memo_shell_content;
 474 	gboolean visible;
 475 
 476 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 477 	visible = gtk_toggle_action_get_active (action);
 478 	e_memo_shell_content_set_preview_visible (memo_shell_content, visible);
 479 }
 480 
 481 static void
 482 action_memo_print_cb (GtkAction *action,
 483                       EMemoShellView *memo_shell_view)
 484 {
 485 	EMemoShellContent *memo_shell_content;
 486 	EMemoTable *memo_table;
 487 	ECalModelComponent *comp_data;
 488 	ECalComponent *comp;
 489 	ECalModel *model;
 490 	icalcomponent *clone;
 491 	GSList *list;
 492 
 493 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 494 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 495 	model = e_memo_table_get_model (memo_table);
 496 
 497 	list = e_memo_table_get_selected (memo_table);
 498 	g_return_if_fail (list != NULL);
 499 	comp_data = list->data;
 500 	g_slist_free (list);
 501 
 502 	/* XXX We only print the first selected memo. */
 503 	comp = e_cal_component_new ();
 504 	clone = icalcomponent_new_clone (comp_data->icalcomp);
 505 	e_cal_component_set_icalcomponent (comp, clone);
 506 
 507 	print_comp (
 508 		comp, comp_data->client,
 509 		e_cal_model_get_timezone (model),
 510 		e_cal_model_get_use_24_hour_format (model),
 511 		GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
 512 
 513 	g_object_unref (comp);
 514 }
 515 
 516 static void
 517 action_memo_save_as_cb (GtkAction *action,
 518                         EMemoShellView *memo_shell_view)
 519 {
 520 	EShell *shell;
 521 	EShellView *shell_view;
 522 	EShellWindow *shell_window;
 523 	EShellBackend *shell_backend;
 524 	EMemoShellContent *memo_shell_content;
 525 	EMemoTable *memo_table;
 526 	ECalModelComponent *comp_data;
 527 	EActivity *activity;
 528 	GSList *list;
 529 	GFile *file;
 530 	gchar *string;
 531 
 532 	shell_view = E_SHELL_VIEW (memo_shell_view);
 533 	shell_window = e_shell_view_get_shell_window (shell_view);
 534 	shell_backend = e_shell_view_get_shell_backend (shell_view);
 535 	shell = e_shell_window_get_shell (shell_window);
 536 
 537 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 538 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 539 
 540 	list = e_memo_table_get_selected (memo_table);
 541 	g_return_if_fail (list != NULL);
 542 	comp_data = list->data;
 543 	g_slist_free (list);
 544 
 545 	/* Translators: Default filename part saving a memo to a file when
 546 	 * no summary is filed, the '.ics' extension is concatenated to it. */
 547 	string = icalcomp_suggest_filename (comp_data->icalcomp, _("memo"));
 548 	file = e_shell_run_save_dialog (
 549 		shell, _("Save as iCalendar"), string,
 550 		"*.ics:text/calendar", NULL, NULL);
 551 	g_free (string);
 552 	if (file == NULL)
 553 		return;
 554 
 555 	/* XXX We only save the first selected memo. */
 556 	string = e_cal_client_get_component_as_string (
 557 		comp_data->client, comp_data->icalcomp);
 558 	if (string == NULL) {
 559 		g_warning ("Could not convert memo to a string");
 560 		g_object_unref (file);
 561 		return;
 562 	}
 563 
 564 	/* XXX No callback means errors are discarded. */
 565 	activity = e_file_replace_contents_async (
 566 		file, string, strlen (string), NULL, FALSE,
 567 		G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL);
 568 	e_shell_backend_add_activity (shell_backend, activity);
 569 
 570 	/* Free the string when the activity is finalized. */
 571 	g_object_set_data_full (
 572 		G_OBJECT (activity),
 573 		"file-content", string,
 574 		(GDestroyNotify) g_free);
 575 
 576 	g_object_unref (file);
 577 }
 578 
 579 static void
 580 action_memo_view_cb (GtkRadioAction *action,
 581                      GtkRadioAction *current,
 582                      EMemoShellView *memo_shell_view)
 583 {
 584 	EMemoShellContent *memo_shell_content;
 585 	GtkOrientable *orientable;
 586 	GtkOrientation orientation;
 587 
 588 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 589 	orientable = GTK_ORIENTABLE (memo_shell_content);
 590 
 591 	switch (gtk_radio_action_get_current_value (action)) {
 592 		case 0:
 593 			orientation = GTK_ORIENTATION_VERTICAL;
 594 			break;
 595 		case 1:
 596 			orientation = GTK_ORIENTATION_HORIZONTAL;
 597 			break;
 598 		default:
 599 			g_return_if_reached ();
 600 	}
 601 
 602 	gtk_orientable_set_orientation (orientable, orientation);
 603 }
 604 
 605 static GtkActionEntry memo_entries[] = {
 606 
 607 	{ "memo-delete",
 608 	  GTK_STOCK_DELETE,
 609 	  N_("_Delete Memo"),
 610 	  NULL,
 611 	  N_("Delete selected memos"),
 612 	  G_CALLBACK (action_memo_delete_cb) },
 613 
 614 	{ "memo-find",
 615 	  GTK_STOCK_FIND,
 616 	  N_("_Find in Memo..."),
 617 	  "<Shift><Control>f",
 618 	  N_("Search for text in the displayed memo"),
 619 	  G_CALLBACK (action_memo_find_cb) },
 620 
 621 	{ "memo-forward",
 622 	  "mail-forward",
 623 	  N_("_Forward as iCalendar..."),
 624 	  "<Control>f",
 625 	  NULL,  /* XXX Add a tooltip! */
 626 	  G_CALLBACK (action_memo_forward_cb) },
 627 
 628 	{ "memo-list-copy",
 629 	  GTK_STOCK_COPY,
 630 	  N_("_Copy..."),
 631 	  NULL,
 632 	  NULL,  /* XXX Add a tooltip! */
 633 	  G_CALLBACK (action_memo_list_copy_cb) },
 634 
 635 	{ "memo-list-delete",
 636 	  GTK_STOCK_DELETE,
 637 	  N_("D_elete Memo List"),
 638 	  NULL,
 639 	  N_("Delete the selected memo list"),
 640 	  G_CALLBACK (action_memo_list_delete_cb) },
 641 
 642 	{ "memo-list-new",
 643 	  "stock_notes",
 644 	  N_("_New Memo List"),
 645 	  NULL,
 646 	  N_("Create a new memo list"),
 647 	  G_CALLBACK (action_memo_list_new_cb) },
 648 
 649 	{ "memo-list-properties",
 650 	  GTK_STOCK_PROPERTIES,
 651 	  NULL,
 652 	  NULL,
 653 	  NULL,  /* XXX Add a tooltip! */
 654 	  G_CALLBACK (action_memo_list_properties_cb) },
 655 
 656 	{ "memo-list-refresh",
 657 	  GTK_STOCK_REFRESH,
 658 	  N_("Re_fresh"),
 659 	  NULL,
 660 	  N_("Refresh the selected memo list"),
 661 	  G_CALLBACK (action_memo_list_refresh_cb) },
 662 
 663 	{ "memo-list-rename",
 664 	  NULL,
 665 	  N_("_Rename..."),
 666 	  "F2",
 667 	  N_("Rename the selected memo list"),
 668 	  G_CALLBACK (action_memo_list_rename_cb) },
 669 
 670 	{ "memo-list-select-one",
 671 	  "stock_check-filled",
 672 	  N_("Show _Only This Memo List"),
 673 	  NULL,
 674 	  NULL,  /* XXX Add a tooltip! */
 675 	  G_CALLBACK (action_memo_list_select_one_cb) },
 676 
 677 	{ "memo-new",
 678 	  "stock_insert-note",
 679 	  N_("New _Memo"),
 680 	  NULL,
 681 	  N_("Create a new memo"),
 682 	  G_CALLBACK (action_memo_new_cb) },
 683 
 684 	{ "memo-open",
 685 	  GTK_STOCK_OPEN,
 686 	  N_("_Open Memo"),
 687 	  "<Control>o",
 688 	  N_("View the selected memo"),
 689 	  G_CALLBACK (action_memo_open_cb) },
 690 
 691 	{ "memo-open-url",
 692 	  "applications-internet",
 693 	  N_("Open _Web Page"),
 694 	  NULL,
 695 	  NULL,  /* XXX Add a tooltip! */
 696 	  G_CALLBACK (action_memo_open_url_cb) },
 697 
 698 	/*** Menus ***/
 699 
 700 	{ "memo-preview-menu",
 701 	  NULL,
 702 	  N_("_Preview"),
 703 	  NULL,
 704 	  NULL,
 705 	  NULL }
 706 };
 707 
 708 static EPopupActionEntry memo_popup_entries[] = {
 709 
 710 	{ "memo-list-popup-copy",
 711 	  NULL,
 712 	  "memo-list-copy" },
 713 
 714 	{ "memo-list-popup-delete",
 715 	  N_("_Delete"),
 716 	  "memo-list-delete" },
 717 
 718 	{ "memo-list-popup-properties",
 719 	  NULL,
 720 	  "memo-list-properties" },
 721 
 722 	{ "memo-list-popup-refresh",
 723 	  NULL,
 724 	  "memo-list-refresh" },
 725 
 726 	{ "memo-list-popup-rename",
 727 	  NULL,
 728 	  "memo-list-rename" },
 729 
 730 	{ "memo-list-popup-select-one",
 731 	  NULL,
 732 	  "memo-list-select-one" },
 733 
 734 	{ "memo-popup-forward",
 735 	  NULL,
 736 	  "memo-forward" },
 737 
 738 	{ "memo-popup-open",
 739 	  NULL,
 740 	  "memo-open" },
 741 
 742 	{ "memo-popup-open-url",
 743 	  NULL,
 744 	  "memo-open-url" }
 745 };
 746 
 747 static GtkToggleActionEntry memo_toggle_entries[] = {
 748 
 749 	{ "memo-preview",
 750 	  NULL,
 751 	  N_("Memo _Preview"),
 752 	  "<Control>m",
 753 	  N_("Show memo preview pane"),
 754 	  G_CALLBACK (action_memo_preview_cb),
 755 	  TRUE }
 756 };
 757 
 758 static GtkRadioActionEntry memo_view_entries[] = {
 759 
 760 	/* This action represents the initial active memo view.
 761 	 * It should not be visible in the UI, nor should it be
 762 	 * possible to switch to it from another shell view. */
 763 	{ "memo-view-initial",
 764 	  NULL,
 765 	  NULL,
 766 	  NULL,
 767 	  NULL,
 768 	  -1 },
 769 
 770 	{ "memo-view-classic",
 771 	  NULL,
 772 	  N_("_Classic View"),
 773 	  NULL,
 774 	  N_("Show memo preview below the memo list"),
 775 	  0 },
 776 
 777 	{ "memo-view-vertical",
 778 	  NULL,
 779 	  N_("_Vertical View"),
 780 	  NULL,
 781 	  N_("Show memo preview alongside the memo list"),
 782 	  1 }
 783 };
 784 
 785 static GtkRadioActionEntry memo_filter_entries[] = {
 786 
 787 	{ "memo-filter-any-category",
 788 	  NULL,
 789 	  N_("Any Category"),
 790 	  NULL,
 791 	  NULL,
 792 	  MEMO_FILTER_ANY_CATEGORY },
 793 
 794 	{ "memo-filter-unmatched",
 795 	  NULL,
 796 	  N_("Unmatched"),
 797 	  NULL,
 798 	  NULL,
 799 	  MEMO_FILTER_UNMATCHED }
 800 };
 801 
 802 static GtkRadioActionEntry memo_search_entries[] = {
 803 
 804 	{ "memo-search-advanced-hidden",
 805 	  NULL,
 806 	  N_("Advanced Search"),
 807 	  NULL,
 808 	  NULL,
 809 	  MEMO_SEARCH_ADVANCED },
 810 
 811 	{ "memo-search-any-field-contains",
 812 	  NULL,
 813 	  N_("Any field contains"),
 814 	  NULL,
 815 	  NULL,  /* XXX Add a tooltip! */
 816 	  MEMO_SEARCH_ANY_FIELD_CONTAINS },
 817 
 818 	{ "memo-search-description-contains",
 819 	  NULL,
 820 	  N_("Description contains"),
 821 	  NULL,
 822 	  NULL,  /* XXX Add a tooltip! */
 823 	  MEMO_SEARCH_DESCRIPTION_CONTAINS },
 824 
 825 	{ "memo-search-summary-contains",
 826 	  NULL,
 827 	  N_("Summary contains"),
 828 	  NULL,
 829 	  NULL,  /* XXX Add a tooltip! */
 830 	  MEMO_SEARCH_SUMMARY_CONTAINS }
 831 };
 832 
 833 static GtkActionEntry lockdown_printing_entries[] = {
 834 
 835 	{ "memo-list-print",
 836 	  GTK_STOCK_PRINT,
 837 	  NULL,
 838 	  "<Control>p",
 839 	  N_("Print the list of memos"),
 840 	  G_CALLBACK (action_memo_list_print_cb) },
 841 
 842 	{ "memo-list-print-preview",
 843 	  GTK_STOCK_PRINT_PREVIEW,
 844 	  NULL,
 845 	  NULL,
 846 	  N_("Preview the list of memos to be printed"),
 847 	  G_CALLBACK (action_memo_list_print_preview_cb) },
 848 
 849 	{ "memo-print",
 850 	  GTK_STOCK_PRINT,
 851 	  NULL,
 852 	  NULL,
 853 	  N_("Print the selected memo"),
 854 	  G_CALLBACK (action_memo_print_cb) }
 855 };
 856 
 857 static EPopupActionEntry lockdown_printing_popup_entries[] = {
 858 
 859 	{ "memo-popup-print",
 860 	  NULL,
 861 	  "memo-print" }
 862 };
 863 
 864 static GtkActionEntry lockdown_save_to_disk_entries[] = {
 865 
 866 	{ "memo-save-as",
 867 	  GTK_STOCK_SAVE_AS,
 868 	  N_("_Save as iCalendar..."),
 869 	  NULL,
 870 	  NULL,  /* XXX Add a tooltip! */
 871 	  G_CALLBACK (action_memo_save_as_cb) },
 872 };
 873 
 874 static EPopupActionEntry lockdown_save_to_disk_popup_entries[] = {
 875 
 876 	{ "memo-popup-save-as",
 877 	  NULL,
 878 	  "memo-save-as" }
 879 };
 880 
 881 void
 882 e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
 883 {
 884 	EMemoShellContent *memo_shell_content;
 885 	EShellView *shell_view;
 886 	EShellWindow *shell_window;
 887 	EShellSearchbar *searchbar;
 888 	EPreviewPane *preview_pane;
 889 	EWebView *web_view;
 890 	GtkActionGroup *action_group;
 891 	GSettings *memo_settings;
 892 	GtkAction *action;
 893 
 894 	shell_view = E_SHELL_VIEW (memo_shell_view);
 895 	shell_window = e_shell_view_get_shell_window (shell_view);
 896 
 897 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
 898 	searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
 899 	preview_pane = e_memo_shell_content_get_preview_pane (memo_shell_content);
 900 	web_view = e_preview_pane_get_web_view (preview_pane);
 901 
 902 	/* Memo Actions */
 903 	action_group = ACTION_GROUP (MEMOS);
 904 	gtk_action_group_add_actions (
 905 		action_group, memo_entries,
 906 		G_N_ELEMENTS (memo_entries), memo_shell_view);
 907 	e_action_group_add_popup_actions (
 908 		action_group, memo_popup_entries,
 909 		G_N_ELEMENTS (memo_popup_entries));
 910 	gtk_action_group_add_toggle_actions (
 911 		action_group, memo_toggle_entries,
 912 		G_N_ELEMENTS (memo_toggle_entries), memo_shell_view);
 913 	gtk_action_group_add_radio_actions (
 914 		action_group, memo_view_entries,
 915 		G_N_ELEMENTS (memo_view_entries), -1,
 916 		G_CALLBACK (action_memo_view_cb), memo_shell_view);
 917 	gtk_action_group_add_radio_actions (
 918 		action_group, memo_search_entries,
 919 		G_N_ELEMENTS (memo_search_entries),
 920 		-1, NULL, NULL);
 921 
 922 	/* Advanced Search Action */
 923 	action = ACTION (MEMO_SEARCH_ADVANCED_HIDDEN);
 924 	gtk_action_set_visible (action, FALSE);
 925 	e_shell_searchbar_set_search_option (
 926 		searchbar, GTK_RADIO_ACTION (action));
 927 
 928 	/* Lockdown Printing Actions */
 929 	action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
 930 	gtk_action_group_add_actions (
 931 		action_group, lockdown_printing_entries,
 932 		G_N_ELEMENTS (lockdown_printing_entries),
 933 		memo_shell_view);
 934 	e_action_group_add_popup_actions (
 935 		action_group, lockdown_printing_popup_entries,
 936 		G_N_ELEMENTS (lockdown_printing_popup_entries));
 937 
 938 	/* Lockdown Save-to-Disk Actions */
 939 	action_group = ACTION_GROUP (LOCKDOWN_SAVE_TO_DISK);
 940 	gtk_action_group_add_actions (
 941 		action_group, lockdown_save_to_disk_entries,
 942 		G_N_ELEMENTS (lockdown_save_to_disk_entries),
 943 		memo_shell_view);
 944 	e_action_group_add_popup_actions (
 945 		action_group, lockdown_save_to_disk_popup_entries,
 946 		G_N_ELEMENTS (lockdown_save_to_disk_popup_entries));
 947 
 948 	/* Bind GObject properties to settings keys. */
 949 
 950 	memo_settings = g_settings_new ("org.gnome.evolution.calendar");
 951 
 952 	g_settings_bind (
 953 		memo_settings, "show-memo-preview",
 954 		ACTION (MEMO_PREVIEW), "active",
 955 		G_SETTINGS_BIND_DEFAULT);
 956 
 957 	g_settings_bind (
 958 		memo_settings, "memo-layout",
 959 		ACTION (MEMO_VIEW_VERTICAL), "current-value",
 960 		G_SETTINGS_BIND_DEFAULT);
 961 
 962 	g_object_unref (memo_settings);
 963 
 964 	/* Fine tuning. */
 965 
 966 	g_signal_connect (
 967 		ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
 968 		G_CALLBACK (action_gal_save_custom_view_cb), memo_shell_view);
 969 
 970 	g_object_bind_property (
 971 		ACTION (MEMO_PREVIEW), "active",
 972 		ACTION (MEMO_VIEW_CLASSIC), "sensitive",
 973 		G_BINDING_SYNC_CREATE);
 974 
 975 	g_object_bind_property (
 976 		ACTION (MEMO_PREVIEW), "active",
 977 		ACTION (MEMO_VIEW_VERTICAL), "sensitive",
 978 		G_BINDING_SYNC_CREATE);
 979 
 980 	e_web_view_set_open_proxy (web_view, ACTION (MEMO_OPEN));
 981 	e_web_view_set_print_proxy (web_view, ACTION (MEMO_PRINT));
 982 	e_web_view_set_save_as_proxy (web_view, ACTION (MEMO_SAVE_AS));
 983 }
 984 
 985 void
 986 e_memo_shell_view_update_search_filter (EMemoShellView *memo_shell_view)
 987 {
 988 	EMemoShellContent *memo_shell_content;
 989 	EShellView *shell_view;
 990 	EShellWindow *shell_window;
 991 	EShellSearchbar *searchbar;
 992 	EActionComboBox *combo_box;
 993 	GtkActionGroup *action_group;
 994 	GtkRadioAction *radio_action;
 995 	GList *list, *iter;
 996 	GSList *group;
 997 	gint ii;
 998 
 999 	shell_view = E_SHELL_VIEW (memo_shell_view);
1000 	shell_window = e_shell_view_get_shell_window (shell_view);
1001 
1002 	action_group = ACTION_GROUP (MEMOS_FILTER);
1003 	e_action_group_remove_all_actions (action_group);
1004 
1005 	/* Add the standard filter actions.  No callback is needed
1006 	 * because changes in the EActionComboBox are detected and
1007 	 * handled by EShellSearchbar. */
1008 	gtk_action_group_add_radio_actions (
1009 		action_group, memo_filter_entries,
1010 		G_N_ELEMENTS (memo_filter_entries),
1011 		MEMO_FILTER_ANY_CATEGORY, NULL, NULL);
1012 
1013 	/* Retrieve the radio group from an action we just added. */
1014 	list = gtk_action_group_list_actions (action_group);
1015 	radio_action = GTK_RADIO_ACTION (list->data);
1016 	group = gtk_radio_action_get_group (radio_action);
1017 	g_list_free (list);
1018 
1019 	/* Build the category actions. */
1020 
1021 	list = e_util_get_searchable_categories ();
1022 	for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
1023 		const gchar *category_name = iter->data;
1024 		const gchar *filename;
1025 		GtkAction *action;
1026 		gchar *action_name;
1027 
1028 		action_name = g_strdup_printf (
1029 			"memo-filter-category-%d", ii);
1030 		radio_action = gtk_radio_action_new (
1031 			action_name, category_name, NULL, NULL, ii);
1032 		g_free (action_name);
1033 
1034 		/* Convert the category icon file to a themed icon name. */
1035 		filename = e_categories_get_icon_file_for (category_name);
1036 		if (filename != NULL && *filename != '\0') {
1037 			gchar *basename;
1038 			gchar *cp;
1039 
1040 			basename = g_path_get_basename (filename);
1041 
1042 			/* Lose the file extension. */
1043 			if ((cp = strrchr (basename, '.')) != NULL)
1044 				*cp = '\0';
1045 
1046 			g_object_set (
1047 				radio_action, "icon-name", basename, NULL);
1048 
1049 			g_free (basename);
1050 		}
1051 
1052 		gtk_radio_action_set_group (radio_action, group);
1053 		group = gtk_radio_action_get_group (radio_action);
1054 
1055 		/* The action group takes ownership of the action. */
1056 		action = GTK_ACTION (radio_action);
1057 		gtk_action_group_add_action (action_group, action);
1058 		g_object_unref (radio_action);
1059 	}
1060 	g_list_free (list);
1061 
1062 	memo_shell_content = memo_shell_view->priv->memo_shell_content;
1063 	searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
1064 	combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
1065 
1066 	e_shell_view_block_execute_search (shell_view);
1067 
1068 	/* Use any action in the group; doesn't matter which. */
1069 	e_action_combo_box_set_action (combo_box, radio_action);
1070 
1071 	ii = MEMO_FILTER_UNMATCHED;
1072 	e_action_combo_box_add_separator_after (combo_box, ii);
1073 
1074 	e_shell_view_unblock_execute_search (shell_view);
1075 }