source: trunk/third/evolution/shell/e-shell-config-autocompletion.c @ 18142

Revision 18142, 3.5 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18141, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2/* e-shell-config-autocompletion.c - Configuration page for addressbook autocompletion.
3 *
4 * Copyright (C) 2002 Ximian, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
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 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authors: Chris Lahey <clahey@ximian.com>
21 *          Chris Toshok <toshok@ximian.com>
22 */
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif
27
28
29#include "e-shell-config-autocompletion.h"
30
31#include "e-folder-list.h"
32
33#include "Evolution.h"
34
35#include <bonobo-conf/Bonobo_Config.h>
36#include <bonobo/bonobo-exception.h>
37
38#include <libgnome/gnome-i18n.h>
39#include <gtk/gtkwidget.h>
40
41
42typedef struct {
43        EvolutionConfigControl *config_control;
44
45        GtkWidget *control_widget;
46
47        Bonobo_ConfigDatabase db;
48        EvolutionShellClient *shell_client;
49} EvolutionAutocompletionConfig;
50
51static void
52folder_list_changed_callback (EFolderList *efl,
53                              EvolutionAutocompletionConfig *ac)
54{
55        evolution_config_control_changed (ac->config_control);
56}
57
58static void
59config_control_destroy_callback (EvolutionConfigControl *config_control,
60                                 EvolutionAutocompletionConfig *ac)
61{
62        bonobo_object_unref (BONOBO_OBJECT (ac->shell_client));
63        g_free (ac);
64}
65
66
67static void
68config_control_apply_callback (EvolutionConfigControl *config_control,
69                               EvolutionAutocompletionConfig *ac)
70{
71        char *xml;
72        CORBA_Environment ev;
73
74        CORBA_exception_init (&ev);
75
76        xml = e_folder_list_get_xml (E_FOLDER_LIST (ac->control_widget));
77        bonobo_config_set_string (ac->db, "/Addressbook/Completion/uris", xml, &ev);
78        g_free (xml);
79
80        CORBA_exception_free (&ev);
81}
82
83GtkWidget *
84e_shell_config_autocompletion_create_widget (EShell *shell, EvolutionConfigControl *config_control)
85{
86        GNOME_Evolution_Shell shell_dup;
87        EvolutionAutocompletionConfig *ac;
88        char *xml;
89        CORBA_Environment ev;
90        static const char *possible_types[] = { "contacts/*", NULL };
91
92        ac = g_new0 (EvolutionAutocompletionConfig, 1);
93        ac->db = e_shell_get_config_db (shell);
94
95        CORBA_exception_init (&ev);
96
97        shell_dup = CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (shell)), &ev);
98        ac->shell_client = evolution_shell_client_new (shell_dup);
99
100        xml = bonobo_config_get_string (ac->db, "/Addressbook/Completion/uris", &ev);
101
102        ac->control_widget = e_folder_list_new (ac->shell_client, xml);
103        g_free (xml);
104
105        gtk_object_set (GTK_OBJECT (ac->control_widget),
106                        "title", _("Extra Completion folders"),
107                        "possible_types", possible_types,
108                        NULL);
109
110        gtk_widget_show (ac->control_widget);
111
112        ac->config_control = config_control;
113
114        gtk_signal_connect (GTK_OBJECT (ac->control_widget), "changed",
115                            GTK_SIGNAL_FUNC (folder_list_changed_callback), ac);
116        gtk_signal_connect (GTK_OBJECT (ac->config_control), "apply",
117                            GTK_SIGNAL_FUNC (config_control_apply_callback), ac);
118        gtk_signal_connect (GTK_OBJECT (ac->config_control), "destroy",
119                            GTK_SIGNAL_FUNC (config_control_destroy_callback), ac);
120
121        CORBA_exception_free (&ev);
122
123        return ac->control_widget;
124}
125
Note: See TracBrowser for help on using the repository browser.