"Fossies" - the Fresh Open Source Software Archive

Member "evolution-mapi-3.46.1/src/configuration/e-mail-config-mapi-page.c" (2 Dec 2022, 8134 Bytes) of package /linux/misc/evolution-mapi-3.46.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "e-mail-config-mapi-page.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * e-mail-config-mapi-page.c
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Lesser General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) version 3.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12  * Lesser General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU Lesser General Public
   15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
   16  *
   17  */
   18 
   19 #include "evolution-mapi-config.h"
   20 
   21 #include <gtk/gtk.h>
   22 #include <glib/gi18n-lib.h>
   23 
   24 #include <mail/e-mail-config-page.h>
   25 #include <mail/e-mail-config-security-page.h>
   26 
   27 #include "e-mapi-config-utils.h"
   28 
   29 #include "e-mail-config-mapi-page.h"
   30 
   31 #define E_MAIL_CONFIG_MAPI_PAGE_SORT_ORDER \
   32     (E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER + 10)
   33 
   34 struct _EMailConfigMapiPagePrivate {
   35     ESource *account_source;
   36     ESourceRegistry *registry;
   37 };
   38 
   39 enum {
   40     PROP_0,
   41     PROP_ACCOUNT_SOURCE,
   42     PROP_SOURCE_REGISTRY
   43 };
   44 
   45 static void e_mail_config_mapi_page_interface_init (EMailConfigPageInterface *iface);
   46 
   47 G_DEFINE_DYNAMIC_TYPE_EXTENDED (EMailConfigMapiPage, e_mail_config_mapi_page, GTK_TYPE_SCROLLED_WINDOW, 0,
   48     G_ADD_PRIVATE_DYNAMIC (EMailConfigMapiPage)
   49     G_IMPLEMENT_INTERFACE_DYNAMIC (E_TYPE_MAIL_CONFIG_PAGE, e_mail_config_mapi_page_interface_init))
   50 
   51 static void
   52 folder_size_clicked_cb (GtkWidget *button,
   53             EMailConfigMapiPage *page)
   54 {
   55     ESource *source, *setting_source;
   56     ESourceCamel *camel_ext;
   57     ESourceRegistry *registry;
   58     CamelSettings *settings;
   59 
   60     g_return_if_fail (page != NULL);
   61 
   62     source = e_mail_config_mapi_page_get_account_source (page);
   63     registry = e_mail_config_mapi_page_get_source_registry (page);
   64 
   65     if (e_source_get_parent (source))
   66         setting_source = e_source_registry_ref_source (registry, e_source_get_parent (source));
   67     else
   68         setting_source = g_object_ref (source);
   69 
   70     camel_ext = e_source_get_extension (setting_source, e_source_camel_get_extension_name ("mapi"));
   71     settings = e_source_camel_get_settings (camel_ext);
   72 
   73     e_mapi_config_utils_run_folder_size_dialog (registry, source, CAMEL_MAPI_SETTINGS (settings));
   74 
   75     g_object_unref (setting_source);
   76 }
   77 
   78 static void
   79 mail_config_mapi_page_set_account_source (EMailConfigMapiPage *page,
   80                       ESource *account_source)
   81 {
   82     g_return_if_fail (E_IS_SOURCE (account_source));
   83     g_return_if_fail (page->priv->account_source == NULL);
   84 
   85     page->priv->account_source = g_object_ref (account_source);
   86 }
   87 
   88 static void
   89 mail_config_mapi_page_set_source_registry (EMailConfigMapiPage *page,
   90                        ESourceRegistry *registry)
   91 {
   92     g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
   93     g_return_if_fail (page->priv->registry == NULL);
   94 
   95     page->priv->registry = g_object_ref (registry);
   96 }
   97 
   98 static void
   99 mail_config_mapi_page_set_property (GObject *object,
  100                     guint property_id,
  101                     const GValue *value,
  102                     GParamSpec *pspec)
  103 {
  104     switch (property_id) {
  105         case PROP_ACCOUNT_SOURCE:
  106             mail_config_mapi_page_set_account_source (
  107                 E_MAIL_CONFIG_MAPI_PAGE (object),
  108                 g_value_get_object (value));
  109             return;
  110 
  111         case PROP_SOURCE_REGISTRY:
  112             mail_config_mapi_page_set_source_registry (
  113                 E_MAIL_CONFIG_MAPI_PAGE (object),
  114                 g_value_get_object (value));
  115             return;
  116     }
  117 
  118     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  119 }
  120 
  121 static void
  122 mail_config_mapi_page_get_property (GObject *object,
  123                     guint property_id,
  124                     GValue *value,
  125                     GParamSpec *pspec)
  126 {
  127     switch (property_id) {
  128         case PROP_ACCOUNT_SOURCE:
  129             g_value_set_object (
  130                 value,
  131                 e_mail_config_mapi_page_get_account_source (
  132                 E_MAIL_CONFIG_MAPI_PAGE (object)));
  133             return;
  134 
  135         case PROP_SOURCE_REGISTRY:
  136             g_value_set_object (
  137                 value,
  138                 e_mail_config_mapi_page_get_source_registry (
  139                 E_MAIL_CONFIG_MAPI_PAGE (object)));
  140             return;
  141     }
  142 
  143     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  144 }
  145 
  146 static void
  147 mail_config_mapi_page_dispose (GObject *object)
  148 {
  149     EMailConfigMapiPage *mapi_page = E_MAIL_CONFIG_MAPI_PAGE (object);
  150 
  151     g_clear_object (&mapi_page->priv->account_source);
  152     g_clear_object (&mapi_page->priv->registry);
  153 
  154     /* Chain up to parent's dispose() method. */
  155     G_OBJECT_CLASS (e_mail_config_mapi_page_parent_class)->dispose (object);
  156 }
  157 
  158 static void
  159 mail_config_mapi_page_constructed (GObject *object)
  160 {
  161     EMailConfigMapiPage *page = E_MAIL_CONFIG_MAPI_PAGE (object);
  162     GtkWidget *widget;
  163     GtkWidget *main_box;
  164     GtkGrid *content_grid;
  165     gchar *markup;
  166 
  167     /* Chain up to parent's constructed() method. */
  168     G_OBJECT_CLASS (e_mail_config_mapi_page_parent_class)->constructed (object);
  169 
  170     main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  171 
  172     content_grid = GTK_GRID (gtk_grid_new ());
  173     gtk_grid_set_row_spacing (content_grid, 6);
  174     gtk_grid_set_column_spacing (content_grid, 6);
  175     gtk_box_pack_start (GTK_BOX (main_box), GTK_WIDGET (content_grid), FALSE, FALSE, 0);
  176 
  177     markup = g_markup_printf_escaped ("<b>%s</b>", _("MAPI Settings"));
  178     widget = gtk_label_new (markup);
  179     gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
  180     gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
  181     gtk_grid_attach (content_grid, widget, 0, 0, 2, 1);
  182 
  183     widget = gtk_label_new (_("View the size of all Exchange folders"));
  184     gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
  185     gtk_grid_attach (content_grid, widget, 0, 1, 1, 1);
  186 
  187     widget = gtk_button_new_with_mnemonic (_("Folder _Size"));
  188     g_signal_connect (widget, "clicked", G_CALLBACK (folder_size_clicked_cb), page);
  189     gtk_grid_attach (content_grid, widget, 1, 1, 1, 1);
  190 
  191     gtk_widget_show_all (GTK_WIDGET (main_box));
  192 
  193     e_mail_config_page_set_content (E_MAIL_CONFIG_PAGE (page), main_box);
  194 }
  195 
  196 static void
  197 e_mail_config_mapi_page_class_init (EMailConfigMapiPageClass *class)
  198 {
  199     GObjectClass *object_class;
  200 
  201     object_class = G_OBJECT_CLASS (class);
  202     object_class->set_property = mail_config_mapi_page_set_property;
  203     object_class->get_property = mail_config_mapi_page_get_property;
  204     object_class->dispose = mail_config_mapi_page_dispose;
  205     object_class->constructed = mail_config_mapi_page_constructed;
  206 
  207     g_object_class_install_property (
  208         object_class,
  209         PROP_ACCOUNT_SOURCE,
  210         g_param_spec_object (
  211             "account-source",
  212             "Account Source",
  213             "Mail account source being edited",
  214             E_TYPE_SOURCE,
  215             G_PARAM_READWRITE |
  216             G_PARAM_CONSTRUCT_ONLY));
  217 
  218     g_object_class_install_property (
  219         object_class,
  220         PROP_SOURCE_REGISTRY,
  221         g_param_spec_object (
  222             "source-registry",
  223             "Source Registry",
  224             NULL,
  225             E_TYPE_SOURCE_REGISTRY,
  226             G_PARAM_READWRITE |
  227             G_PARAM_CONSTRUCT_ONLY));
  228 }
  229 
  230 static void
  231 e_mail_config_mapi_page_class_finalize (EMailConfigMapiPageClass *class)
  232 {
  233 }
  234 
  235 static void
  236 e_mail_config_mapi_page_interface_init (EMailConfigPageInterface *iface)
  237 {
  238     iface->title = _("MAPI Settings");
  239     iface->sort_order = E_MAIL_CONFIG_MAPI_PAGE_SORT_ORDER;
  240 }
  241 
  242 static void
  243 e_mail_config_mapi_page_init (EMailConfigMapiPage *page)
  244 {
  245     page->priv = e_mail_config_mapi_page_get_instance_private (page);
  246 }
  247 
  248 void
  249 e_mail_config_mapi_page_type_register (GTypeModule *type_module)
  250 {
  251     /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
  252      *     function, so we have to wrap it with a public function in
  253      *     order to register types from a separate compilation unit. */
  254     e_mail_config_mapi_page_register_type (type_module);
  255 }
  256 
  257 EMailConfigPage *
  258 e_mail_config_mapi_page_new (ESource *account_source,
  259                  ESourceRegistry *registry)
  260 {
  261     EMailConfigPage *page;
  262 
  263     g_return_val_if_fail (E_IS_SOURCE (account_source), NULL);
  264 
  265     page = g_object_new (E_TYPE_MAIL_CONFIG_MAPI_PAGE,
  266         "account-source", account_source,
  267         "source-registry", registry,
  268         NULL);
  269 
  270     return page;
  271 }
  272 
  273 ESource *
  274 e_mail_config_mapi_page_get_account_source (EMailConfigMapiPage *page)
  275 {
  276     g_return_val_if_fail (E_IS_MAIL_CONFIG_MAPI_PAGE (page), NULL);
  277 
  278     return page->priv->account_source;
  279 }
  280 
  281 ESourceRegistry *
  282 e_mail_config_mapi_page_get_source_registry (EMailConfigMapiPage *page)
  283 {
  284     g_return_val_if_fail (E_IS_MAIL_CONFIG_MAPI_PAGE (page), NULL);
  285 
  286     return page->priv->registry;
  287 }