#include <gtk/gtkstock.h>
#include <gtk/gtklabel.h>
#include <gtk/gtktogglebutton.h>
+#include <string.h>
#include "widgets/modest-global-settings-dialog.h"
#include "widgets/modest-global-settings-dialog-priv.h"
#include "modest-defs.h"
#include "modest-ui-constants.h"
#include "modest-tny-msg.h"
#include "modest-platform.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include "hildon2/modest-selector-picker.h"
+#include "modest-hildon-includes.h"
+#else
#include "widgets/modest-combo-box.h"
-#ifdef MODEST_PLATFORM_MAEMO
-#ifdef MODEST_HILDON_VERSION_0
+#endif
+#ifndef MODEST_TOOLKIT_GTK
+#if MODEST_HILDON_API == 0
#include <hildon-widgets/hildon-number-editor.h>
#else
#include <hildon/hildon-number-editor.h>
-#endif /*MODEST_HILDON_VERSION_0*/
+#endif /*MODEST_HILDON_API = 0*/
#endif
/* include other impl specific header files */
(GInstanceInitFunc) modest_global_settings_dialog_init,
NULL
};
+#ifdef MODEST_TOOLKIT_HILDON2
+ my_type = g_type_register_static (HILDON_TYPE_DIALOG,
+ "ModestGlobalSettingsDialog",
+ &my_info, 0);
+#else
my_type = g_type_register_static (GTK_TYPE_DIALOG,
"ModestGlobalSettingsDialog",
&my_info, 0);
+#endif
}
return my_type;
}
priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
priv->notebook = gtk_notebook_new ();
- priv->changed = FALSE;
+ priv->default_account_selector = NULL;
+ priv->accounts_list = NULL;
- /* Add the buttons: */
- gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
- gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
/* Connect to the dialog's response signal: */
g_signal_connect (G_OBJECT (self), "response", G_CALLBACK (on_response), self);
modest_pair_list_free (priv->connect_via_list);
modest_pair_list_free (priv->update_interval_list);
modest_pair_list_free (priv->msg_format_list);
+ modest_pair_list_free (priv->accounts_list);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
*list = g_slist_prepend (*list, pair);
}
-/*
- * Gets a list of pairs
- */
ModestPairList *
_modest_global_settings_dialog_get_connected_via (void)
{
GSList *list = NULL;
+ const gchar *message;
- add_to_modest_pair_list (MODEST_CONNECTED_VIA_WLAN,
- _("mcen_va_options_connectiontype_wlan"),
- &list);
+#ifndef MODEST_TOOLKIT_GTK
+ const gchar *env_var = getenv ("OSSO_PRODUCT_HARDWARE");
+ /* Check if WIMAX is available */
+ if (env_var && !strncmp (env_var, "RX-48", 5))
+ message = _("mcen_va_options_connectiontype_wlan_wimax");
+ else
+ message = _("mcen_va_options_connectiontype_wlan");
+#else
+ message = _("mcen_va_options_connectiontype_wlan");
+#endif
+ add_to_modest_pair_list (MODEST_CONNECTED_VIA_WLAN_OR_WIMAX, message, &list);
add_to_modest_pair_list (MODEST_CONNECTED_VIA_ANY,
_("mcen_va_options_connectiontype_all"),
&list);
error = NULL;
checked = FALSE;
}
+#ifdef MODEST_TOOLKIT_HILDON2
+ hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->auto_update), checked);
+#else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auto_update), checked);
+#endif
priv->initial_state.auto_update = checked;
/* Connected by */
if (error) {
g_error_free (error);
error = NULL;
- combo_id = MODEST_CONNECTED_VIA_WLAN;
+ combo_id = MODEST_CONNECTED_VIA_WLAN_OR_WIMAX;
}
+#ifdef MODEST_TOOLKIT_HILDON2
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->connect_via),
+ (gpointer) &combo_id);
+#else
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->connect_via),
(gpointer) &combo_id);
+#endif
priv->initial_state.connect_via = combo_id;
/* Emit toggled to update the visibility of connect_by caption */
+#ifndef MODEST_TOOLKIT_HILDON2
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (priv->auto_update));
+#endif
/* Update interval */
combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_INTERVAL, &error);
error = NULL;
combo_id = MODEST_UPDATE_INTERVAL_15_MIN;
}
+#ifdef MODEST_TOOLKIT_HILDON2
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->update_interval),
+ (gpointer) &combo_id);
+#else
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->update_interval),
(gpointer) &combo_id);
+#endif
priv->initial_state.update_interval = combo_id;
/* Size limit */
}
/* It's better to do this in the subclasses, but it's just one
line, so we'll leave it here for the moment */
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (priv->size_limit), value);
#else
gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit), value);
error = NULL;
checked = FALSE;
}
+#ifndef MODEST_TOOLKIT_HILDON2
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->play_sound), checked);
+#endif
priv->initial_state.play_sound = checked;
/* Msg format */
combo_id = MODEST_FILE_FORMAT_FORMATTED_TEXT;
}
combo_id = (checked) ? MODEST_FILE_FORMAT_FORMATTED_TEXT : MODEST_FILE_FORMAT_PLAIN_TEXT;
+#ifdef MODEST_TOOLKIT_HILDON2
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->msg_format),
+ (gpointer) &combo_id);
+#else
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->msg_format),
(gpointer) &combo_id);
+#endif
priv->initial_state.prefer_formatted_text = checked;
-
- /* Include reply */
- value = modest_conf_get_int (conf, MODEST_CONF_REPLY_TYPE, &error);
- if (error) {
- g_error_free (error);
- error = NULL;
- value = MODEST_TNY_MSG_REPLY_TYPE_QUOTE;
- }
- if (value == MODEST_TNY_MSG_REPLY_TYPE_QUOTE)
- checked = TRUE;
- else
- checked = FALSE;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->include_reply), checked);
- priv->initial_state.include_reply = checked;
}
static void
gint *id;
/* Get values from UI */
- state->auto_update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
+#ifdef MODEST_TOOLKIT_HILDON2
+ id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->connect_via));
+ state->auto_update = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auto_update));
+ state->default_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->default_account_selector));
+#else
id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->connect_via));
+ state->auto_update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
+ state->default_account = NULL;
+#endif
state->connect_via = *id;
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
state->size_limit = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->size_limit));
#else
state->size_limit = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->size_limit));
#endif
+
+#ifdef MODEST_TOOLKIT_HILDON2
+ id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->update_interval));
+#else
id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->update_interval));
+#endif
state->update_interval = *id;
+#ifdef MODEST_TOOLKIT_HILDON2
+ id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->msg_format));
+ state->play_sound = priv->initial_state.play_sound;
+#else
state->play_sound = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->play_sound));
id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->msg_format));
+#endif
state->prefer_formatted_text = (*id == MODEST_FILE_FORMAT_FORMATTED_TEXT) ? TRUE : FALSE;
- state->include_reply = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->include_reply));
}
gboolean
RETURN_FALSE_ON_ERROR(error);
modest_conf_set_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, current_state.prefer_formatted_text, NULL);
RETURN_FALSE_ON_ERROR(error);
- modest_conf_set_int (conf, MODEST_CONF_REPLY_TYPE,
- (current_state.include_reply) ? MODEST_TNY_MSG_REPLY_TYPE_QUOTE :
- MODEST_TNY_MSG_REPLY_TYPE_CITE, NULL);
- RETURN_FALSE_ON_ERROR(error);
+ if (current_state.default_account &&
+ (!priv->initial_state.default_account ||
+ strcmp (current_state.default_account, priv->initial_state.default_account)!= 0)) {
+ modest_account_mgr_set_default_account (modest_runtime_get_account_mgr (),
+ current_state.default_account);
+ }
/* Apply changes */
if (priv->initial_state.auto_update != current_state.auto_update ||
priv->initial_state.connect_via != current_state.connect_via ||
priv->initial_state.update_interval != current_state.update_interval) {
-
+
TnyAccountStore *account_store;
TnyDevice *device;
-
+
if (!current_state.auto_update) {
modest_platform_set_update_interval (0);
/* To avoid a new indentation level */
goto exit;
}
-
+
account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
device = tny_account_store_get_device (account_store);
-
+
if (tny_device_is_online (device)) {
/* If connected via any then set update interval */
if (current_state.connect_via == MODEST_CONNECTED_VIA_ANY) {
/* Disable autoupdate in offline mode */
modest_platform_set_update_interval (0);
}
- g_object_unref (device);
+ g_object_unref (device);
}
-
+
exit:
return TRUE;
}
initial_state.size_limit != current_state.size_limit ||
initial_state.play_sound != current_state.play_sound ||
initial_state.prefer_formatted_text != current_state.prefer_formatted_text ||
- initial_state.include_reply != current_state.include_reply)
+ (current_state.default_account &&
+ (!initial_state.default_account ||
+ strcmp (current_state.default_account, initial_state.default_account)!= 0)))
return TRUE;
else
return FALSE;
saved = _modest_global_settings_dialog_save_conf (MODEST_GLOBAL_SETTINGS_DIALOG (dialog));
if (saved) {
- modest_platform_run_information_dialog (GTK_WINDOW (user_data),
- _("mcen_ib_advsetup_settings_saved"));
+ modest_platform_information_banner (NULL, NULL,
+ _("mcen_ib_advsetup_settings_saved"));
} else {
- modest_platform_run_information_dialog (GTK_WINDOW (user_data),
- _("mail_ib_setting_failed"));
+ modest_platform_information_banner (NULL, NULL,
+ _("mail_ib_setting_failed"));
}
}
} else {
_("imum_nc_wizard_confirm_lose_changes"));
/* Do not close if the user Cancels */
if (response == GTK_RESPONSE_CANCEL)
- g_signal_stop_emission_by_name (dialog, "response");
+ g_signal_stop_emission_by_name (user_data, "response");
}
}
}