summaryrefslogtreecommitdiff
path: root/camel/camel-store-settings.c
blob: 884b8287ccc6b5b2ba332b381b1a56e11e39b6ee (plain)
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
/*
 * camel-store-settings.c
 *
 * This library is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation.
 *
 * This library 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 Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "camel-store-settings.h"

#define CAMEL_STORE_SETTINGS_GET_PRIVATE(obj) \
	(G_TYPE_INSTANCE_GET_PRIVATE \
	((obj), CAMEL_TYPE_STORE_SETTINGS, CamelStoreSettingsPrivate))

struct _CamelStoreSettingsPrivate {
	gboolean filter_inbox;
};

enum {
	PROP_0,
	PROP_FILTER_INBOX
};

G_DEFINE_TYPE (
	CamelStoreSettings,
	camel_store_settings,
	CAMEL_TYPE_SETTINGS)

static void
store_settings_set_property (GObject *object,
                             guint property_id,
                             const GValue *value,
                             GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_FILTER_INBOX:
			camel_store_settings_set_filter_inbox (
				CAMEL_STORE_SETTINGS (object),
				g_value_get_boolean (value));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
store_settings_get_property (GObject *object,
                             guint property_id,
                             GValue *value,
                             GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_FILTER_INBOX:
			g_value_set_boolean (
				value,
				camel_store_settings_get_filter_inbox (
				CAMEL_STORE_SETTINGS (object)));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
camel_store_settings_class_init (CamelStoreSettingsClass *class)
{
	GObjectClass *object_class;

	g_type_class_add_private (class, sizeof (CamelStoreSettingsPrivate));

	object_class = G_OBJECT_CLASS (class);
	object_class->set_property = store_settings_set_property;
	object_class->get_property = store_settings_get_property;

	g_object_class_install_property (
		object_class,
		PROP_FILTER_INBOX,
		g_param_spec_boolean (
			"filter-inbox",
			"Filter Inbox",
			"Whether to filter new messages in Inbox",
			TRUE,
			G_PARAM_READWRITE |
			G_PARAM_CONSTRUCT |
			G_PARAM_STATIC_STRINGS));
}

static void
camel_store_settings_init (CamelStoreSettings *settings)
{
	settings->priv = CAMEL_STORE_SETTINGS_GET_PRIVATE (settings);
}

/**
 * camel_store_settings_get_filter_inbox:
 * @settings: a #CamelStoreSettings
 *
 * Returns whether to automatically apply filters to newly arrived messages
 * in the store's Inbox folder (assuming it has an Inbox folder).
 *
 * Returns: whether to filter new messages in Inbox
 *
 * Since: 3.2
 **/
gboolean
camel_store_settings_get_filter_inbox (CamelStoreSettings *settings)
{
	g_return_val_if_fail (CAMEL_IS_STORE_SETTINGS (settings), FALSE);

	return settings->priv->filter_inbox;
}

/**
 * camel_store_settings_set_filter_inbox:
 * @settings: a #CamelStoreSettings
 * @filter_inbox: whether to filter new messages in Inbox
 *
 * Sets whether to automatically apply filters to newly arrived messages
 * in the store's Inbox folder (assuming it has an Inbox folder).
 *
 * Since: 3.2
 **/
void
camel_store_settings_set_filter_inbox (CamelStoreSettings *settings,
                                       gboolean filter_inbox)
{
	g_return_if_fail (CAMEL_IS_STORE_SETTINGS (settings));

	if (settings->priv->filter_inbox == filter_inbox)
		return;

	settings->priv->filter_inbox = filter_inbox;

	g_object_notify (G_OBJECT (settings), "filter-inbox");
}