aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/select-names/e-select-names-config.c
blob: 1792a8a061044a0af5994261e9fbf1b05cf3b56c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 * Authors :
 *  Damon Chaplin <damon@ximian.com>
 *  Rodrigo Moya <rodrigo@ximian.com>
 *
 * Copyright 2000, Ximian, Inc.
 * Copyright 2000, Ximian, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>

#include "e-select-names-config-keys.h"
#include "e-select-names-config.h"

static GConfClient *config = NULL;

static void
do_cleanup (void)
{
    g_object_unref (config);
    config = NULL;
}

static void
e_select_names_config_init (void)
{
    if (config)
        return;

    config = gconf_client_get_default ();
    g_atexit ((GVoidFunc) do_cleanup);

    gconf_client_add_dir (config, SELECT_NAMES_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
}

void
e_select_names_config_remove_notification (guint id)
{
    gconf_client_notify_remove (config, id);
}

/* The current list of completion books */
GSList *
e_select_names_config_get_completion_books (void)
{
    e_select_names_config_init ();
    
    return gconf_client_get_list (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, GCONF_VALUE_STRING, NULL);
}

void
e_select_names_config_set_completion_books (GSList *selected)
{
    e_select_names_config_init ();

    gconf_client_set_list (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, GCONF_VALUE_STRING, selected, NULL);
}

guint
e_select_names_config_add_notification_completion_books (GConfClientNotifyFunc func, gpointer data)
{
    guint id;

    e_select_names_config_init ();
    
    id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, func, data, NULL, NULL);
    
    return id;
}

char *
e_select_names_config_get_last_completion_book (void)
{
    e_select_names_config_init ();
    
    return gconf_client_get_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, NULL);
}

void
e_select_names_config_set_last_completion_book (const char *last_completion_book)
{
    e_select_names_config_init ();

    gconf_client_set_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, last_completion_book, NULL);
}

guint
e_select_names_config_add_notification_last_completion_book (GConfClientNotifyFunc func, gpointer data)
{
    guint id;

    e_select_names_config_init ();
    
    id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, func, data, NULL, NULL);
    
    return id;
}

gint
e_select_names_config_get_min_query_length (void)
{
    e_select_names_config_init ();

    return gconf_client_get_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, NULL);
}


void
e_select_names_config_set_min_query_length (gint day_end_hour)
{
    e_select_names_config_init ();

    gconf_client_set_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, day_end_hour, NULL);
}

guint 
e_select_names_config_add_notification_min_query_length (GConfClientNotifyFunc func, gpointer data)
{
    guint id;

    e_select_names_config_init ();
    
    id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, func, data, NULL, NULL);
    
    return id;  
}