Updated Hungarian translation
[evolution.git] / mail / e-mail-config-provider-page.c
blob4f923ae90bb9278847d5b108a0d6ed130b189e87
1 /*
2 * e-mail-config-provider-page.c
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "e-mail-config-provider-page.h"
20 #include <config.h>
21 #include <string.h>
22 #include <glib/gi18n-lib.h>
24 #include <libebackend/libebackend.h>
26 #define E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE(obj) \
27 (G_TYPE_INSTANCE_GET_PRIVATE \
28 ((obj), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE, EMailConfigProviderPagePrivate))
30 #define STANDARD_MARGIN 12
31 #define DEPENDENCY_MARGIN 24
33 struct _EMailConfigProviderPagePrivate {
34 EMailConfigServiceBackend *backend;
35 gboolean is_empty;
38 enum {
39 PROP_0,
40 PROP_BACKEND
43 /* Forward Declarations */
44 static void e_mail_config_provider_page_interface_init
45 (EMailConfigPageInterface *iface);
47 G_DEFINE_TYPE_WITH_CODE (
48 EMailConfigProviderPage,
49 e_mail_config_provider_page,
50 E_TYPE_MAIL_CONFIG_ACTIVITY_PAGE,
51 G_IMPLEMENT_INTERFACE (
52 E_TYPE_EXTENSIBLE, NULL)
53 G_IMPLEMENT_INTERFACE (
54 E_TYPE_MAIL_CONFIG_PAGE,
55 e_mail_config_provider_page_interface_init))
57 static void
58 mail_config_provider_page_handle_dependency (EMailConfigProviderPage *page,
59 CamelProviderConfEntry *entry,
60 GtkWidget *widget)
62 EMailConfigServiceBackend *backend;
63 CamelSettings *settings;
64 GBindingFlags binding_flags = G_BINDING_SYNC_CREATE;
65 const gchar *depname = entry->depname;
66 gint margin;
68 if (depname == NULL)
69 return;
71 if (*depname == '!') {
72 binding_flags |= G_BINDING_INVERT_BOOLEAN;
73 depname++;
76 backend = e_mail_config_provider_page_get_backend (page);
77 settings = e_mail_config_service_backend_get_settings (backend);
79 g_object_bind_property (
80 settings, depname,
81 widget, "sensitive",
82 binding_flags);
84 /* Further indent the widget to show its dependency. */
85 margin = gtk_widget_get_margin_left (widget);
86 gtk_widget_set_margin_left (widget, margin + DEPENDENCY_MARGIN);
89 static void
90 mail_config_provider_page_add_section (EMailConfigProviderPage *page,
91 CamelProviderConfEntry *entry)
93 EMailConfigServiceBackend *backend;
94 CamelProvider *provider;
95 GtkWidget *widget;
96 gchar *markup;
98 g_return_if_fail (entry->text != NULL);
100 backend = e_mail_config_provider_page_get_backend (page);
101 provider = e_mail_config_service_backend_get_provider (backend);
103 markup = g_markup_printf_escaped ("<b>%s</b>", entry->text);
105 widget = gtk_label_new (markup);
106 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
107 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
108 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
109 gtk_widget_show (widget);
111 /* Skip the top margin if this is the first entry. */
112 if (entry != provider->extra_conf)
113 gtk_widget_set_margin_top (widget, 6);
115 g_free (markup);
118 static void
119 mail_config_provider_page_add_checkbox (EMailConfigProviderPage *page,
120 CamelProviderConfEntry *entry)
122 EMailConfigServiceBackend *backend;
123 CamelSettings *settings;
124 GtkWidget *widget;
126 g_return_if_fail (entry->text != NULL);
128 backend = e_mail_config_provider_page_get_backend (page);
129 settings = e_mail_config_service_backend_get_settings (backend);
131 widget = gtk_check_button_new_with_mnemonic (entry->text);
132 gtk_widget_set_margin_left (widget, STANDARD_MARGIN);
133 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
134 gtk_widget_show (widget);
136 g_object_bind_property (
137 settings, entry->name,
138 widget, "active",
139 G_BINDING_BIDIRECTIONAL |
140 G_BINDING_SYNC_CREATE);
142 mail_config_provider_page_handle_dependency (page, entry, widget);
145 static void
146 mail_config_provider_page_add_checkspin (EMailConfigProviderPage *page,
147 CamelProviderConfEntry *entry)
149 EMailConfigServiceBackend *backend;
150 CamelSettings *settings;
151 GObjectClass *class;
152 GParamSpec *pspec;
153 GParamSpec *use_pspec;
154 GtkAdjustment *adjustment;
155 GtkWidget *hbox, *spin;
156 GtkWidget *prefix;
157 gchar *use_property_name;
158 gchar *pre, *post;
160 g_return_if_fail (entry->text != NULL);
162 backend = e_mail_config_provider_page_get_backend (page);
163 settings = e_mail_config_service_backend_get_settings (backend);
165 /* The entry->name property (e.g. "foo") should be numeric for the
166 * spin button. If a "use" boolean property exists (e.g. "use-foo")
167 * then a checkbox is also shown. */
169 class = G_OBJECT_GET_CLASS (settings);
170 pspec = g_object_class_find_property (class, entry->name);
171 g_return_if_fail (pspec != NULL);
173 use_property_name = g_strconcat ("use-", entry->name, NULL);
174 use_pspec = g_object_class_find_property (class, use_property_name);
175 if (use_pspec != NULL && use_pspec->value_type != G_TYPE_BOOLEAN)
176 use_pspec = NULL;
177 g_free (use_property_name);
179 /* Make sure we can convert to and from doubles. */
180 g_return_if_fail (
181 g_value_type_transformable (
182 pspec->value_type, G_TYPE_DOUBLE));
183 g_return_if_fail (
184 g_value_type_transformable (
185 G_TYPE_DOUBLE, pspec->value_type));
187 if (G_IS_PARAM_SPEC_CHAR (pspec)) {
188 GParamSpecChar *pspec_char;
189 pspec_char = G_PARAM_SPEC_CHAR (pspec);
190 adjustment = gtk_adjustment_new (
191 (gdouble) pspec_char->default_value,
192 (gdouble) pspec_char->minimum,
193 (gdouble) pspec_char->maximum,
194 1.0, 1.0, 0.0);
196 } else if (G_IS_PARAM_SPEC_UCHAR (pspec)) {
197 GParamSpecUChar *pspec_uchar;
198 pspec_uchar = G_PARAM_SPEC_UCHAR (pspec);
199 adjustment = gtk_adjustment_new (
200 (gdouble) pspec_uchar->default_value,
201 (gdouble) pspec_uchar->minimum,
202 (gdouble) pspec_uchar->maximum,
203 1.0, 1.0, 0.0);
205 } else if (G_IS_PARAM_SPEC_INT (pspec)) {
206 GParamSpecInt *pspec_int;
207 pspec_int = G_PARAM_SPEC_INT (pspec);
208 adjustment = gtk_adjustment_new (
209 (gdouble) pspec_int->default_value,
210 (gdouble) pspec_int->minimum,
211 (gdouble) pspec_int->maximum,
212 1.0, 1.0, 0.0);
214 } else if (G_IS_PARAM_SPEC_UINT (pspec)) {
215 GParamSpecUInt *pspec_uint;
216 pspec_uint = G_PARAM_SPEC_UINT (pspec);
217 adjustment = gtk_adjustment_new (
218 (gdouble) pspec_uint->default_value,
219 (gdouble) pspec_uint->minimum,
220 (gdouble) pspec_uint->maximum,
221 1.0, 1.0, 0.0);
223 } else if (G_IS_PARAM_SPEC_LONG (pspec)) {
224 GParamSpecLong *pspec_long;
225 pspec_long = G_PARAM_SPEC_LONG (pspec);
226 adjustment = gtk_adjustment_new (
227 (gdouble) pspec_long->default_value,
228 (gdouble) pspec_long->minimum,
229 (gdouble) pspec_long->maximum,
230 1.0, 1.0, 0.0);
232 } else if (G_IS_PARAM_SPEC_ULONG (pspec)) {
233 GParamSpecULong *pspec_ulong;
234 pspec_ulong = G_PARAM_SPEC_ULONG (pspec);
235 adjustment = gtk_adjustment_new (
236 (gdouble) pspec_ulong->default_value,
237 (gdouble) pspec_ulong->minimum,
238 (gdouble) pspec_ulong->maximum,
239 1.0, 1.0, 0.0);
241 } else if (G_IS_PARAM_SPEC_FLOAT (pspec)) {
242 GParamSpecFloat *pspec_float;
243 pspec_float = G_PARAM_SPEC_FLOAT (pspec);
244 adjustment = gtk_adjustment_new (
245 (gdouble) pspec_float->default_value,
246 (gdouble) pspec_float->minimum,
247 (gdouble) pspec_float->maximum,
248 1.0, 1.0, 0.0);
250 } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) {
251 GParamSpecDouble *pspec_double;
252 pspec_double = G_PARAM_SPEC_DOUBLE (pspec);
253 adjustment = gtk_adjustment_new (
254 (gdouble) pspec_double->default_value,
255 (gdouble) pspec_double->minimum,
256 (gdouble) pspec_double->maximum,
257 1.0, 1.0, 0.0);
259 } else
260 g_return_if_reached ();
262 pre = g_alloca (strlen (entry->text) + 1);
263 strcpy (pre, entry->text);
264 post = strstr (pre, "%s");
265 if (post != NULL) {
266 *post = '\0';
267 post += 2;
270 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
271 gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
272 gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
273 gtk_widget_show (hbox);
275 if (use_pspec != NULL) {
276 prefix = gtk_check_button_new_with_mnemonic (pre);
278 g_object_bind_property (
279 settings, use_pspec->name,
280 prefix, "active",
281 G_BINDING_BIDIRECTIONAL |
282 G_BINDING_SYNC_CREATE);
283 } else {
284 prefix = gtk_label_new_with_mnemonic (pre);
286 gtk_box_pack_start (GTK_BOX (hbox), prefix, FALSE, TRUE, 0);
287 gtk_widget_show (prefix);
289 spin = gtk_spin_button_new (adjustment, 1.0, 0);
290 gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
291 gtk_widget_show (spin);
293 g_object_bind_property (
294 settings, entry->name,
295 spin, "value",
296 G_BINDING_BIDIRECTIONAL |
297 G_BINDING_SYNC_CREATE);
299 if (use_pspec != NULL)
300 g_object_bind_property (
301 prefix, "active",
302 spin, "sensitive",
303 G_BINDING_SYNC_CREATE);
305 if (post != NULL) {
306 GtkWidget *label = gtk_label_new_with_mnemonic (post);
307 gtk_label_set_mnemonic_widget (GTK_LABEL (label), prefix);
308 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
309 gtk_widget_show (label);
312 mail_config_provider_page_handle_dependency (page, entry, hbox);
315 static void
316 mail_config_provider_page_add_entry (EMailConfigProviderPage *page,
317 CamelProviderConfEntry *entry)
319 EMailConfigServiceBackend *backend;
320 CamelSettings *settings;
321 GtkWidget *hbox;
322 GtkWidget *input;
323 GtkWidget *label;
325 g_return_if_fail (entry->text != NULL);
327 backend = e_mail_config_provider_page_get_backend (page);
328 settings = e_mail_config_service_backend_get_settings (backend);
330 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
331 gtk_box_set_spacing (GTK_BOX (hbox), 6);
332 gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
333 gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
334 gtk_widget_show (hbox);
336 label = gtk_label_new_with_mnemonic (entry->text);
337 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
338 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
339 gtk_widget_show (label);
341 input = gtk_entry_new ();
342 gtk_label_set_mnemonic_widget (GTK_LABEL (label), input);
343 gtk_box_pack_start (GTK_BOX (hbox), input, TRUE, TRUE, 0);
344 gtk_widget_show (input);
346 e_binding_bind_object_text_property (
347 settings, entry->name,
348 input, "text",
349 G_BINDING_BIDIRECTIONAL |
350 G_BINDING_SYNC_CREATE);
352 g_object_bind_property (
353 input, "sensitive",
354 label, "sensitive",
355 G_BINDING_SYNC_CREATE);
357 mail_config_provider_page_handle_dependency (page, entry, hbox);
360 static void
361 mail_config_provider_page_add_options (EMailConfigProviderPage *page,
362 CamelProviderConfEntry *entry)
364 EMailConfigServiceBackend *backend;
365 CamelProvider *provider;
366 CamelSettings *settings;
367 GtkCellRenderer *renderer;
368 GtkListStore *store;
369 GtkWidget *hbox;
370 GtkWidget *combo;
371 GtkWidget *label;
372 gchar **tokens;
373 guint length, ii;
375 /* The 'value' string is of the format:
377 * 'nick0:caption0:nick1:caption1:...nickN:captionN'
379 * where 'nick' is the nickname a GEnumValue and 'caption'
380 * is the localized combo box item displayed to the user. */
382 g_return_if_fail (entry->text != NULL);
383 g_return_if_fail (entry->value != NULL);
385 backend = e_mail_config_provider_page_get_backend (page);
386 provider = e_mail_config_service_backend_get_provider (backend);
387 settings = e_mail_config_service_backend_get_settings (backend);
389 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
390 gtk_box_set_spacing (GTK_BOX (hbox), 6);
391 gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
392 gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
393 gtk_widget_show (hbox);
395 label = gtk_label_new_with_mnemonic (entry->text);
396 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
397 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
398 gtk_widget_show (label);
400 /* 0: 'nick', 1: caption */
401 store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
403 tokens = g_strsplit (entry->value, ":", -1);
404 length = g_strv_length (tokens);
406 /* Take the strings two at a time. */
407 for (ii = 0; ii + 1 < length; ii += 2) {
408 GtkTreeIter iter;
409 const gchar *nick;
410 const gchar *caption;
412 nick = tokens[ii + 0];
413 caption = tokens[ii + 1];
415 /* Localize the caption. */
416 caption = dgettext (provider->translation_domain, caption);
418 gtk_list_store_append (store, &iter);
419 gtk_list_store_set (store, &iter, 0, nick, 1, caption, -1);
422 g_strfreev (tokens);
424 combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
425 gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 0);
426 gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
427 gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
428 gtk_widget_show (combo);
430 g_object_bind_property_full (
431 settings, entry->name,
432 combo, "active-id",
433 G_BINDING_BIDIRECTIONAL |
434 G_BINDING_SYNC_CREATE,
435 e_binding_transform_enum_value_to_nick,
436 e_binding_transform_enum_nick_to_value,
437 NULL, (GDestroyNotify) NULL);
439 renderer = gtk_cell_renderer_text_new ();
440 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
441 gtk_cell_layout_set_attributes (
442 GTK_CELL_LAYOUT (combo), renderer, "text", 1, NULL);
444 mail_config_provider_page_handle_dependency (page, entry, hbox);
447 static void
448 mail_config_provider_page_add_widgets (EMailConfigProviderPage *page)
450 EMailConfigServiceBackend *backend;
451 CamelProviderConfEntry *entries;
452 CamelProvider *provider;
453 GtkWidget *container;
454 GtkWidget *widget;
455 ESource *source;
456 ESourceExtension *extension;
457 gboolean first_section = TRUE;
458 const gchar *extension_name;
459 const gchar *text;
460 gchar *markup;
461 gint ii;
463 /* XXX We begin the page with our own section header and refresh
464 * interval setting, and then skip the CamelProvider's first
465 * CAMEL_PROVIDER_CONF_SECTION_START entry.
467 * This is all very brittle. I'm convinced that generating
468 * a user interface from an array of records like this is a
469 * bad idea. We already have EMailConfigServiceBackend for
470 * building provider-specific "Receving Email" and "Sending
471 * EMail" pages by hand. We should do similarly here. */
473 backend = e_mail_config_provider_page_get_backend (page);
474 source = e_mail_config_service_backend_get_source (backend);
475 provider = e_mail_config_service_backend_get_provider (backend);
476 g_return_if_fail (provider != NULL);
478 /* XXX I guess refresh options go in the mail account source,
479 * even if the source is part of a collection. I did not
480 * think about it too hard, so hopefully this is right. */
481 extension_name = E_SOURCE_EXTENSION_REFRESH;
482 extension = e_source_get_extension (source, extension_name);
484 text = _("Checking for New Mail");
485 markup = g_markup_printf_escaped ("<b>%s</b>", text);
486 widget = gtk_label_new (markup);
487 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
488 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
489 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
490 gtk_widget_show (widget);
491 g_free (markup);
493 widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
494 gtk_widget_set_margin_left (widget, STANDARD_MARGIN);
495 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
496 gtk_widget_show (widget);
498 container = widget;
500 text = _("Check for _new messages every");
501 widget = gtk_check_button_new_with_mnemonic (text);
502 gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
503 gtk_widget_show (widget);
505 g_object_bind_property (
506 extension, "enabled",
507 widget, "active",
508 G_BINDING_BIDIRECTIONAL |
509 G_BINDING_SYNC_CREATE);
511 widget = gtk_spin_button_new_with_range (1.0, 1440.0, 1.0);
512 gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
513 gtk_widget_show (widget);
515 g_object_bind_property (
516 extension, "enabled",
517 widget, "sensitive",
518 G_BINDING_SYNC_CREATE);
520 g_object_bind_property (
521 extension, "interval-minutes",
522 widget, "value",
523 G_BINDING_BIDIRECTIONAL |
524 G_BINDING_SYNC_CREATE);
526 widget = gtk_label_new (_("minutes"));
527 gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
528 gtk_widget_show (widget);
530 /* Note the "text" member of each CamelProviderConfEntry is
531 * already localized, so we can use it directly in widgets. */
533 entries = provider->extra_conf;
535 /* Loop until we see CAMEL_PROVIDER_CONF_END. */
536 for (ii = 0; entries[ii].type != CAMEL_PROVIDER_CONF_END; ii++) {
538 /* Skip entries with no name. */
539 if (entries[ii].name == NULL)
540 continue;
542 switch (entries[ii].type) {
543 case CAMEL_PROVIDER_CONF_SECTION_START:
544 /* Skip the first section start. */
545 if (first_section) {
546 first_section = FALSE;
547 continue;
549 mail_config_provider_page_add_section (
550 page, &entries[ii]);
551 break;
553 case CAMEL_PROVIDER_CONF_CHECKBOX:
554 mail_config_provider_page_add_checkbox (
555 page, &entries[ii]);
556 break;
558 case CAMEL_PROVIDER_CONF_CHECKSPIN:
559 mail_config_provider_page_add_checkspin (
560 page, &entries[ii]);
561 break;
563 case CAMEL_PROVIDER_CONF_ENTRY:
564 mail_config_provider_page_add_entry (
565 page, &entries[ii]);
566 break;
568 case CAMEL_PROVIDER_CONF_OPTIONS:
569 mail_config_provider_page_add_options (
570 page, &entries[ii]);
571 break;
573 default:
574 break; /* skip it */
579 static void
580 mail_config_provider_page_set_backend (EMailConfigProviderPage *page,
581 EMailConfigServiceBackend *backend)
583 g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
584 g_return_if_fail (page->priv->backend == NULL);
586 page->priv->backend = g_object_ref (backend);
589 static void
590 mail_config_provider_page_set_property (GObject *object,
591 guint property_id,
592 const GValue *value,
593 GParamSpec *pspec)
595 switch (property_id) {
596 case PROP_BACKEND:
597 mail_config_provider_page_set_backend (
598 E_MAIL_CONFIG_PROVIDER_PAGE (object),
599 g_value_get_object (value));
600 return;
603 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
606 static void
607 mail_config_provider_page_get_property (GObject *object,
608 guint property_id,
609 GValue *value,
610 GParamSpec *pspec)
612 switch (property_id) {
613 case PROP_BACKEND:
614 g_value_set_object (
615 value,
616 e_mail_config_provider_page_get_backend (
617 E_MAIL_CONFIG_PROVIDER_PAGE (object)));
618 return;
621 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
624 static void
625 mail_config_provider_page_dispose (GObject *object)
627 EMailConfigProviderPagePrivate *priv;
629 priv = E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE (object);
631 if (priv->backend != NULL) {
632 g_object_unref (priv->backend);
633 priv->backend = NULL;
636 /* Chain up parent's dispose() method. */
637 G_OBJECT_CLASS (e_mail_config_provider_page_parent_class)->
638 dispose (object);
641 static void
642 mail_config_provider_page_constructed (GObject *object)
644 EMailConfigProviderPage *page;
645 EMailConfigServiceBackend *backend;
646 CamelProvider *provider;
648 page = E_MAIL_CONFIG_PROVIDER_PAGE (object);
650 /* Chain up parent's constructed() method. */
651 G_OBJECT_CLASS (e_mail_config_provider_page_parent_class)->constructed (object);
653 gtk_box_set_spacing (GTK_BOX (object), 6);
655 gtk_orientable_set_orientation (
656 GTK_ORIENTABLE (object), GTK_ORIENTATION_VERTICAL);
658 backend = e_mail_config_provider_page_get_backend (page);
659 provider = e_mail_config_service_backend_get_provider (backend);
661 if (provider != NULL && provider->extra_conf != NULL)
662 mail_config_provider_page_add_widgets (page);
663 else
664 page->priv->is_empty = TRUE;
666 e_extensible_load_extensions (E_EXTENSIBLE (page));
669 static void
670 e_mail_config_provider_page_class_init (EMailConfigProviderPageClass *class)
672 GObjectClass *object_class;
674 g_type_class_add_private (class, sizeof (EMailConfigProviderPagePrivate));
676 object_class = G_OBJECT_CLASS (class);
677 object_class->set_property = mail_config_provider_page_set_property;
678 object_class->get_property = mail_config_provider_page_get_property;
679 object_class->dispose = mail_config_provider_page_dispose;
680 object_class->constructed = mail_config_provider_page_constructed;
682 g_object_class_install_property (
683 object_class,
684 PROP_BACKEND,
685 g_param_spec_object (
686 "backend",
687 "Backend",
688 "Service backend to generate options from",
689 E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
690 G_PARAM_READWRITE |
691 G_PARAM_CONSTRUCT_ONLY |
692 G_PARAM_STATIC_STRINGS));
695 static void
696 e_mail_config_provider_page_interface_init (EMailConfigPageInterface *iface)
698 iface->title = _("Receiving Options");
699 iface->sort_order = E_MAIL_CONFIG_PROVIDER_PAGE_SORT_ORDER;
702 static void
703 e_mail_config_provider_page_init (EMailConfigProviderPage *page)
705 page->priv = E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE (page);
708 EMailConfigPage *
709 e_mail_config_provider_page_new (EMailConfigServiceBackend *backend)
711 g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), NULL);
713 return g_object_new (
714 E_TYPE_MAIL_CONFIG_PROVIDER_PAGE,
715 "backend", backend, NULL);
718 gboolean
719 e_mail_config_provider_page_is_empty (EMailConfigProviderPage *page)
721 g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER_PAGE (page), TRUE);
723 return page->priv->is_empty;
726 EMailConfigServiceBackend *
727 e_mail_config_provider_page_get_backend (EMailConfigProviderPage *page)
729 g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER_PAGE (page), NULL);
731 return page->priv->backend;