2 * GData plugin for Claws-Mail
3 * Claws Mail -- A GTK based, lightweight, and fast e-mail client
4 * Copyright (C) 2011-2018 Holger Berndt and the Claws Mail team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # include "claws-features.h"
27 #include <glib/gi18n.h>
30 #include "cm_gdata_prefs.h"
31 #include "gdata_plugin.h"
32 #include "cm_gdata_contacts.h"
34 #include "prefs_gtk.h"
43 GtkWidget
*entry_username
;
44 GtkWidget
*spin_max_num_results
;
45 GtkWidget
*spin_max_cache_age
;
48 CmGDataPrefs cm_gdata_config
;
49 CmGDataPage gdata_page
;
51 PrefParam cm_gdata_param
[] =
53 {"username", NULL
, &cm_gdata_config
.username
, P_STRING
,
54 &gdata_page
.entry_username
, prefs_set_data_from_entry
, prefs_set_entry
},
56 { "max_num_results", "1000", &cm_gdata_config
.max_num_results
, P_INT
,
57 &gdata_page
.spin_max_num_results
, prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
59 { "max_cache_age", "300", &cm_gdata_config
.max_cache_age
, P_INT
,
60 &gdata_page
.spin_max_cache_age
, prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
62 {"oauth2_refresh_token", NULL
, &cm_gdata_config
.oauth2_refresh_token
, P_PASSWORD
,
65 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
68 static void gdata_create_prefs_page(PrefsPage
*page
, GtkWindow
*window
, gpointer data
)
77 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
80 frame
= gtk_frame_new(_("Authentication"));
81 gtk_container_set_border_width(GTK_CONTAINER(frame
), 5);
82 gtk_box_pack_start(GTK_BOX(vbox
), frame
, FALSE
, FALSE
, 0);
85 table
= gtk_grid_new();
86 label
= gtk_label_new(_("Username:"));
87 gtk_label_set_xalign(GTK_LABEL(label
), 0.0);
88 gtk_grid_attach(GTK_GRID(table
), label
, 0, 0, 1, 1);
89 entry
= gtk_entry_new();
90 gtk_widget_set_size_request(entry
, 250, -1);
91 gtk_grid_attach(GTK_GRID(table
), entry
, 1, 0, 1, 1);
92 gtk_widget_set_hexpand(entry
, TRUE
);
93 gtk_widget_set_halign(entry
, GTK_ALIGN_FILL
);
94 gdata_page
.entry_username
= entry
;
95 gtk_container_add(GTK_CONTAINER(frame
), table
);
97 table
= gtk_grid_new();
98 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
99 label
= gtk_label_new(_("Polling interval (seconds):"));
100 gtk_grid_attach(GTK_GRID(table
), label
, 0, 0, 1, 1);
101 gtk_label_set_xalign(GTK_LABEL(label
), 0.0);
102 spinner
= gtk_spin_button_new_with_range(10, 10000, 10);
103 gtk_grid_attach(GTK_GRID(table
), spinner
, 1, 0, 1, 1);
104 gdata_page
.spin_max_cache_age
= spinner
;
106 label
= gtk_label_new(_("Maximum number of results:"));
107 gtk_grid_attach(GTK_GRID(table
), label
, 0, 1, 1, 1);
108 gtk_label_set_xalign(GTK_LABEL(label
), 0.0);
109 spinner
= gtk_spin_button_new_with_range(0, G_MAXINT
, 50);
110 gtk_grid_attach(GTK_GRID(table
), spinner
, 1, 1, 1, 1);
111 gdata_page
.spin_max_num_results
= spinner
;
113 gtk_widget_show_all(vbox
);
116 prefs_set_dialog(cm_gdata_param
);
119 static void gdata_destroy_prefs_page(PrefsPage
*page
)
123 static void gdata_save_prefs(PrefsPage
*page
)
125 int old_max_cache_age
= cm_gdata_config
.max_cache_age
;
127 if (!page
->page_open
)
130 prefs_set_data_from_dialog(cm_gdata_param
);
132 cm_gdata_update_contacts_cache();
133 if(old_max_cache_age
!= cm_gdata_config
.max_cache_age
)
134 cm_gdata_update_contacts_update_timer();
137 void cm_gdata_prefs_init(void)
139 static gchar
*path
[3];
141 path
[0] = _("Plugins");
142 path
[1] = _("GData");
145 gdata_page
.page
.path
= path
;
146 gdata_page
.page
.create_widget
= gdata_create_prefs_page
;
147 gdata_page
.page
.destroy_widget
= gdata_destroy_prefs_page
;
148 gdata_page
.page
.save_page
= gdata_save_prefs
;
149 gdata_page
.page
.weight
= 40.0;
150 prefs_gtk_register_page((PrefsPage
*) &gdata_page
);
153 void cm_gdata_prefs_done(void)
155 if(!claws_is_exiting()) {
156 prefs_gtk_unregister_page((PrefsPage
*) &gdata_page
);