#include <gtk/gtknotebook.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkhseparator.h>
#include "modest-runtime.h"
#include "widgets/modest-global-settings-dialog-priv.h"
#include "modest-selector-picker.h"
-#include "hildon/hildon-check-button.h"
#include "hildon/hildon-pannable-area.h"
#include "modest-maemo-global-settings-dialog.h"
#include "widgets/modest-ui-constants.h"
#include "modest-text-utils.h"
#include <tny-account-store.h>
+#include <modest-account-mgr-helpers.h>
#define MSG_SIZE_MAX_VAL 5000
static void on_auto_update_clicked (GtkButton *button,
gpointer user_data);
+static void update_sensitive (ModestGlobalSettingsDialog *dialog);
+static ModestPairList * get_accounts_list (void);
typedef struct _ModestMaemoGlobalSettingsDialogPrivate ModestMaemoGlobalSettingsDialogPrivate;
struct _ModestMaemoGlobalSettingsDialogPrivate {
ppriv->updating_page = create_updating_page (self);
/* Add the buttons: */
- gtk_dialog_add_button (GTK_DIALOG (self), _HL("wdgt_bd_save "), GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG (self), _HL("wdgt_bd_save"), GTK_RESPONSE_OK);
/* Set the default focusable widgets */
g_object_set_data (G_OBJECT(ppriv->updating_page), DEFAULT_FOCUS_WIDGET,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), ppriv->updating_page);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
-
- /* gtk_window_set_default_size (GTK_WINDOW (self), 700, 300); */
+ gtk_window_set_default_size (GTK_WINDOW (self), -1, 340);
/* Load current config */
_modest_global_settings_dialog_load_conf (MODEST_GLOBAL_SETTINGS_DIALOG (self));
+ /* force update of sensitiveness */
+ update_sensitive (MODEST_GLOBAL_SETTINGS_DIALOG (self));
/* Set first page */
hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_options_dialog",
create_updating_page (ModestMaemoGlobalSettingsDialog *self)
{
GtkWidget *vbox, *vbox_update, *vbox_limit, *label, *hbox;
- GtkSizeGroup *size_group;
+ GtkSizeGroup *title_size_group;
+ GtkSizeGroup *value_size_group;
ModestGlobalSettingsDialogPrivate *ppriv;
+ GtkWidget *pannable;
+ ModestMaemoGlobalSettingsDialogPrivate *priv;
+ priv = MODEST_MAEMO_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
- vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
+ vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
- vbox_update = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ vbox_update = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* Auto update */
- ppriv->auto_update = hildon_check_button_new (HILDON_SIZE_AUTO);
+ ppriv->auto_update = hildon_check_button_new (MODEST_EDITABLE_SIZE);
gtk_button_set_label (GTK_BUTTON (ppriv->auto_update), _("mcen_fi_options_autoupdate"));
+ gtk_button_set_alignment (GTK_BUTTON (ppriv->auto_update), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox_update), ppriv->auto_update, FALSE, FALSE, MODEST_MARGIN_HALF);
g_signal_connect (ppriv->auto_update, "clicked", G_CALLBACK (on_auto_update_clicked), self);
* that uses it, because the ModestSelectorPicker uses the ID opaquely,
* so it can't know how to manage its memory. */
ppriv->connect_via_list = _modest_global_settings_dialog_get_connected_via ();
- ppriv->connect_via = modest_selector_picker_new (ppriv->connect_via_list, g_int_equal);
- hildon_button_set_title (HILDON_BUTTON (ppriv->connect_via), _("mcen_fi_options_connectiontype"));
+ ppriv->connect_via = modest_selector_picker_new (MODEST_EDITABLE_SIZE,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+ ppriv->connect_via_list, g_int_equal);
+ modest_maemo_utils_set_vbutton_layout (title_size_group,
+ _("mcen_fi_options_connectiontype"),
+ ppriv->connect_via);
gtk_box_pack_start (GTK_BOX (vbox_update), ppriv->connect_via, FALSE, FALSE, MODEST_MARGIN_HALF);
/* Update interval */
* that uses it, because the ModestSelectorPicker uses the ID opaquely,
* so it can't know how to manage its memory. */
ppriv->update_interval_list = _modest_global_settings_dialog_get_update_interval ();
- ppriv->update_interval = modest_selector_picker_new (ppriv->update_interval_list, g_int_equal);
- hildon_button_set_title (HILDON_BUTTON (ppriv->update_interval), _("mcen_fi_options_updateinterval"));
+ ppriv->update_interval = modest_selector_picker_new (MODEST_EDITABLE_SIZE,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+ ppriv->update_interval_list, g_int_equal);
+ modest_maemo_utils_set_vbutton_layout (title_size_group,
+ _("mcen_fi_options_updateinterval"),
+ ppriv->update_interval);
gtk_box_pack_start (GTK_BOX (vbox_update), ppriv->update_interval, FALSE, FALSE, MODEST_MARGIN_HALF);
+ /* Default account selector */
+ ppriv->accounts_list = get_accounts_list ();
+ ppriv->default_account_selector = modest_selector_picker_new (MODEST_EDITABLE_SIZE,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+ ppriv->accounts_list,
+ g_str_equal);
+ if (ppriv->accounts_list == NULL) {
+ gtk_widget_set_sensitive (GTK_WIDGET (ppriv->default_account_selector), FALSE);
+ } else {
+ gchar *default_account;
+
+ default_account = modest_account_mgr_get_default_account (
+ modest_runtime_get_account_mgr ());
+ if (default_account) {
+ modest_selector_picker_set_active_id (
+ MODEST_SELECTOR_PICKER (ppriv->default_account_selector),
+ default_account);
+ g_free (default_account);
+ }
+ }
+ modest_maemo_utils_set_vbutton_layout (title_size_group,
+ _("mcen_ti_default_account"),
+ ppriv->default_account_selector);
+ gtk_box_pack_start (GTK_BOX (vbox_update), ppriv->default_account_selector,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+
/* Add to vbox */
gtk_box_pack_start (GTK_BOX (vbox), vbox_update, FALSE, FALSE, MODEST_MARGIN_HALF);
- /* Separator */
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, MODEST_MARGIN_HALF);
+ g_object_unref (title_size_group);
+ g_object_unref (value_size_group);
/* Limits */
- vbox_limit = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ vbox_limit = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* Size limit */
ppriv->size_limit = hildon_number_editor_new (MSG_SIZE_MIN_VAL, MSG_SIZE_MAX_VAL);
gtk_box_pack_start (GTK_BOX (vbox), vbox_limit, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show_all (vbox_limit);
- /* Separator */
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, MODEST_MARGIN_HALF);
-
/* Note: This ModestPairList* must exist for as long as the picker
* that uses it, because the ModestSelectorPicker uses the ID opaquely,
* so it can't know how to manage its memory. */
ppriv->msg_format_list = _modest_global_settings_dialog_get_msg_formats ();
- ppriv->msg_format = modest_selector_picker_new (ppriv->msg_format_list, g_int_equal);
- hildon_button_set_title (HILDON_BUTTON (ppriv->msg_format), _("mcen_fi_options_messageformat"));
+ ppriv->msg_format = modest_selector_picker_new (MODEST_EDITABLE_SIZE,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+ ppriv->msg_format_list, g_int_equal);
+ modest_maemo_utils_set_vbutton_layout (title_size_group,
+ _("mcen_fi_options_messageformat"),
+ ppriv->msg_format);
gtk_box_pack_start (GTK_BOX (vbox), ppriv->msg_format, FALSE, FALSE, MODEST_MARGIN_HALF);
- return vbox;
+ pannable = g_object_new (HILDON_TYPE_PANNABLE_AREA, "initial-hint", TRUE, NULL);
+
+ hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), vbox);
+ gtk_widget_show (vbox);
+ gtk_widget_show (pannable);
+
+ g_object_unref (title_size_group);
+ g_object_unref (value_size_group);
+
+ return pannable;
}
static void
-on_auto_update_clicked (GtkButton *button,
- gpointer user_data)
+update_sensitive (ModestGlobalSettingsDialog *dialog)
{
ModestGlobalSettingsDialogPrivate *ppriv;
- ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
+ g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (dialog));
+ ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
- if (hildon_check_button_get_active (button)) {
+ if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (ppriv->auto_update))) {
gtk_widget_set_sensitive (ppriv->connect_via, TRUE);
gtk_widget_set_sensitive (ppriv->update_interval, TRUE);
} else {
}
}
+static void
+on_auto_update_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (user_data));
+ update_sensitive ((ModestGlobalSettingsDialog *) user_data);
+}
static gboolean
on_range_error (HildonNumberEditor *editor,
HildonNumberEditorErrorType type,
return modest_platform_get_current_connection ();
}
+static ModestPairList *
+get_accounts_list (void)
+{
+ GSList *list = NULL;
+ GSList *cursor, *account_names;
+ ModestAccountMgr *account_mgr;
+
+ account_mgr = modest_runtime_get_account_mgr ();
+
+ cursor = account_names = modest_account_mgr_account_names (account_mgr, TRUE /*only enabled*/);
+ while (cursor) {
+ gchar *account_name;
+ ModestAccountSettings *settings;
+ ModestServerAccountSettings *store_settings;
+
+ account_name = (gchar*)cursor->data;
+
+ settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
+ if (!settings) {
+ g_printerr ("modest: failed to get account data for %s\n", account_name);
+ continue;
+ }
+ store_settings = modest_account_settings_get_store_settings (settings);
+
+ /* don't display accounts without stores */
+ if (modest_server_account_settings_get_account_name (store_settings) != NULL) {
+
+ if (modest_account_settings_get_enabled (settings)) {
+ ModestPair *pair;
+
+ pair = modest_pair_new (
+ g_strdup (account_name),
+ g_strdup (modest_account_settings_get_display_name (settings)),
+ FALSE);
+ list = g_slist_prepend (list, pair);
+ }
+ }
+
+ g_object_unref (store_settings);
+ g_object_unref (settings);
+ cursor = cursor->next;
+ }
+
+ return (ModestPairList *) g_slist_reverse (list);
+}