No issues found
1 /*
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with the program; if not, see <http://www.gnu.org/licenses/>
15 *
16 *
17 * Authors:
18 * Rodrigo Moya <rodrigo@ximian.com>
19 *
20 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
21 *
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <glib/gi18n.h>
29 #include <libedataserverui/libedataserverui.h>
30
31 #include "select-source-dialog.h"
32
33 /**
34 * select_source_dialog
35 *
36 * Implements dialog for allowing user to select a destination source.
37 */
38 ESource *
39 select_source_dialog (GtkWindow *parent,
40 ESourceRegistry *registry,
41 ECalClientSourceType obj_type,
42 ESource *except_source)
43 {
44 GtkWidget *dialog;
45 ESource *selected_source = NULL;
46 const gchar *extension_name;
47 const gchar *icon_name;
48
49 g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
50
51 if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) {
52 extension_name = E_SOURCE_EXTENSION_CALENDAR;
53 icon_name = "x-office-calendar";
54 } else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS) {
55 extension_name = E_SOURCE_EXTENSION_TASK_LIST;
56 icon_name = "stock_todo";
57 } else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) {
58 extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
59 icon_name = "stock_journal";
60 } else
61 return NULL;
62
63 /* create the dialog */
64 dialog = e_source_selector_dialog_new (parent, registry, extension_name);
65
66 if (icon_name)
67 gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
68
69 if (except_source)
70 g_object_set_data (G_OBJECT (dialog), "except-source", except_source);
71
72 if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
73 goto exit;
74
75 selected_source = e_source_selector_dialog_peek_primary_selection (
76 E_SOURCE_SELECTOR_DIALOG (dialog));
77 if (selected_source != NULL)
78 g_object_ref (selected_source);
79
80 exit:
81 gtk_widget_destroy (dialog);
82
83 return selected_source;
84 }