Commit a3fa18f9 authored by Milan Crha's avatar Milan Crha
Browse files

Bug 235022 - Can't use evolution before you create a mail account

parent c7936218
......@@ -693,6 +693,11 @@
<_summary>Whether the To Do bar should show also completed tasks</_summary>
<_description>Stores whether the To Do bar should show also completed tasks.</_description>
</key>
<key name="show-startup-wizard" type="b">
<default>true</default>
<_summary>Show start up wizard</_summary>
<_description>Whether show start up wizard when there is no mail account configured.</_description>
</key>
<!-- The following keys are deprecated. -->
......
......@@ -500,7 +500,10 @@ build_message_headers (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
uid = e_composer_header_table_dup_identity_uid (table, &alias_name, &alias_address);
source = e_composer_header_table_ref_source (table, uid);
if (uid)
source = e_composer_header_table_ref_source (table, uid);
else
source = NULL;
/* Subject: */
subject = e_composer_header_table_get_subject (table);
......@@ -1097,10 +1100,14 @@ composer_build_message (EMsgComposer *composer,
store = e_attachment_view_get_store (view);
identity_uid = e_composer_header_table_dup_identity_uid (table, NULL, NULL);
source = e_composer_header_table_ref_source (table, identity_uid);
g_free (identity_uid);
if (identity_uid) {
source = e_composer_header_table_ref_source (table, identity_uid);
g_free (identity_uid);
g_return_if_fail (source != NULL);
g_warn_if_fail (source != NULL);
} else {
source = NULL;
}
/* Do all the non-blocking work here, and defer
* any blocking operations to a separate thread. */
......@@ -1177,21 +1184,35 @@ composer_build_message (EMsgComposer *composer,
priv->extra_hdr_values->pdata[i]);
}
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
mi = e_source_get_extension (source, extension_name);
organization = e_source_mail_identity_get_organization (mi);
/* Disposition-Notification-To */
if (flags & COMPOSER_FLAG_REQUEST_READ_RECEIPT) {
const gchar *mdn_address;
mdn_address = e_source_mail_identity_get_reply_to (mi);
if (mdn_address == NULL)
mdn_address = e_source_mail_identity_get_address (mi);
if (mdn_address != NULL)
camel_medium_add_header (
if (source) {
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
mi = e_source_get_extension (source, extension_name);
organization = e_source_mail_identity_get_organization (mi);
/* Disposition-Notification-To */
if (flags & COMPOSER_FLAG_REQUEST_READ_RECEIPT) {
const gchar *mdn_address;
mdn_address = e_source_mail_identity_get_reply_to (mi);
if (mdn_address == NULL)
mdn_address = e_source_mail_identity_get_address (mi);
if (mdn_address != NULL)
camel_medium_add_header (
CAMEL_MEDIUM (context->message),
"Disposition-Notification-To", mdn_address);
}
/* Organization */
if (organization != NULL && *organization != '\0') {
gchar *encoded_organization;
encoded_organization = camel_header_encode_string (
(const guchar *) organization);
camel_medium_set_header (
CAMEL_MEDIUM (context->message),
"Disposition-Notification-To", mdn_address);
"Organization", encoded_organization);
g_free (encoded_organization);
}
}
/* X-Priority */
......@@ -1200,18 +1221,6 @@ composer_build_message (EMsgComposer *composer,
CAMEL_MEDIUM (context->message),
"X-Priority", "1");
/* Organization */
if (organization != NULL && *organization != '\0') {
gchar *encoded_organization;
encoded_organization = camel_header_encode_string (
(const guchar *) organization);
camel_medium_set_header (
CAMEL_MEDIUM (context->message),
"Organization", encoded_organization);
g_free (encoded_organization);
}
/* Build the text/plain part. */
if (priv->mime_body) {
......@@ -5147,6 +5156,8 @@ e_msg_composer_get_from (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
uid = e_composer_header_table_dup_identity_uid (table, &alias_name, &alias_address);
if (!uid)
return NULL;
source = e_composer_header_table_ref_source (table, uid);
g_return_val_if_fail (source != NULL, NULL);
......
......@@ -30,6 +30,7 @@
struct _EMailConfigWelcomePagePrivate {
gchar *text;
GtkBox *main_box; /* not referenced */
};
enum {
......@@ -113,12 +114,16 @@ mail_config_welcome_page_constructed (GObject *object)
G_OBJECT_CLASS (e_mail_config_welcome_page_parent_class)->constructed (object);
main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_valign (GTK_WIDGET (main_box), GTK_ALIGN_CENTER);
gtk_widget_set_valign (GTK_WIDGET (main_box), GTK_ALIGN_FILL);
gtk_widget_set_vexpand (GTK_WIDGET (main_box), TRUE);
page->priv->main_box = GTK_BOX (main_box);
widget = gtk_label_new (NULL);
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (main_box), widget, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_box), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
e_binding_bind_object_text_property (
......@@ -203,3 +208,10 @@ e_mail_config_welcome_page_set_text (EMailConfigWelcomePage *page,
g_object_notify (G_OBJECT (page), "text");
}
GtkBox *
e_mail_config_welcome_page_get_main_box (EMailConfigWelcomePage *page)
{
g_return_val_if_fail (E_IS_MAIL_CONFIG_WELCOME_PAGE (page), NULL);
return page->priv->main_box;
}
......@@ -67,6 +67,8 @@ const gchar * e_mail_config_welcome_page_get_text
void e_mail_config_welcome_page_set_text
(EMailConfigWelcomePage *page,
const gchar *text);
GtkBox * e_mail_config_welcome_page_get_main_box
(EMailConfigWelcomePage *page);
G_END_DECLS
......
......@@ -445,32 +445,42 @@ composer_presend_check_identity (EMsgComposer *composer,
EMailSession *session)
{
EComposerHeaderTable *table;
EClientCache *client_cache;
ESourceRegistry *registry;
ESource *source;
ESource *source = NULL;
gchar *uid;
gboolean success = TRUE;
table = e_msg_composer_get_header_table (composer);
uid = e_composer_header_table_dup_identity_uid (table, NULL, NULL);
source = e_composer_header_table_ref_source (table, uid);
if (uid)
source = e_composer_header_table_ref_source (table, uid);
g_free (uid);
g_return_val_if_fail (source != NULL, FALSE);
client_cache = e_composer_header_table_ref_client_cache (table);
registry = e_client_cache_ref_registry (client_cache);
if (source) {
EClientCache *client_cache;
ESourceRegistry *registry;
if (!e_source_registry_check_enabled (registry, source)) {
e_alert_submit (
E_ALERT_SINK (composer),
"mail:send-no-account-enabled", NULL);
client_cache = e_composer_header_table_ref_client_cache (table);
registry = e_client_cache_ref_registry (client_cache);
success = e_source_registry_check_enabled (registry, source);
if (!success) {
e_alert_submit (
E_ALERT_SINK (e_msg_composer_get_editor (composer)),
"mail:send-no-account-enabled", NULL);
}
g_object_unref (client_cache);
g_object_unref (registry);
} else {
success = FALSE;
e_alert_submit (
E_ALERT_SINK (e_msg_composer_get_editor (composer)),
"mail:send-no-account", NULL);
}
g_object_unref (client_cache);
g_object_unref (registry);
g_object_unref (source);
g_clear_object (&source);
return success;
}
......
......@@ -443,6 +443,11 @@ An mbox account will be created to preserve the old mbox folders. You can delete
<_secondary xml:space="preserve">Please enable the account or send using another account.</_secondary>
</error>
<error id="send-no-account" type="warning">
<_primary>This message cannot be sent because there is no mail account configured</_primary>
<_secondary xml:space="preserve">There had not been found any active mail account to send the message. Create or enable one first, please.</_secondary>
</error>
<error id="no-delete-permission" type="warning">
<_primary>Mail Deletion Failed</_primary>
<_secondary xml:space="preserve">You do not have sufficient permissions to delete this mail.</_secondary>
......
......@@ -140,7 +140,9 @@ startup_assistant_constructed (GObject *object)
n_pages = gtk_assistant_get_n_pages (GTK_ASSISTANT (assistant));
for (ii = 0; ii < n_pages; ii++) {
GtkWidget *nth_page;
GtkWidget *nth_page, *checkbox;
GtkBox *main_box;
GSettings *settings;
nth_page = gtk_assistant_get_nth_page (
GTK_ASSISTANT (assistant), ii);
......@@ -156,6 +158,20 @@ startup_assistant_constructed (GObject *object)
_("Welcome to Evolution.\n\nThe next few screens will "
"allow Evolution to connect to your email accounts, "
"and to import files from other applications."));
settings = e_util_ref_settings ("org.gnome.evolution.mail");
main_box = e_mail_config_welcome_page_get_main_box (E_MAIL_CONFIG_WELCOME_PAGE (nth_page));
checkbox = gtk_check_button_new_with_mnemonic (_("Do not _show this wizard again"));
gtk_widget_show (checkbox);
g_settings_bind (settings, "show-startup-wizard",
checkbox, "active",
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
gtk_box_pack_end (main_box, checkbox, FALSE, FALSE, 4);
g_object_unref (settings);
}
}
......
......@@ -21,6 +21,7 @@
#include <libebackend/libebackend.h>
#include <shell/e-shell.h>
#include <shell/e-shell-window.h>
#include <mail/e-mail-backend.h>
#include <mail/e-mail-config-assistant.h>
......@@ -42,6 +43,8 @@ typedef struct _EStartupWizardClass EStartupWizardClass;
struct _EStartupWizard {
EExtension parent;
gboolean proceeded;
};
struct _EStartupWizardClass {
......@@ -57,13 +60,6 @@ GType e_startup_wizard_get_type (void);
G_DEFINE_DYNAMIC_TYPE (EStartupWizard, e_startup_wizard, E_TYPE_EXTENSION)
G_GNUC_NORETURN static void
startup_wizard_terminate (void)
{
gtk_main_quit ();
_exit (0);
}
static EShell *
startup_wizard_get_shell (EStartupWizard *extension)
{
......@@ -148,38 +144,28 @@ startup_wizard_have_mail_account (EStartupWizard *extension)
return have_account;
}
static void
startup_wizard_weak_ref_cb (gpointer data,
GObject *where_the_object_was)
{
gtk_main_quit ();
}
static void
startup_wizard_run (EStartupWizard *extension)
static gboolean
startup_wizard_run_idle_cb (gpointer user_data)
{
GtkWidget *window = NULL;
EStartupWizard *extension = user_data;
EShell *shell;
GtkWidget *window;
/* Accounts should now be loaded if there were any to load.
* Check, and proceed with the Evolution Setup Assistant. */
if (startup_wizard_have_mail_account (extension))
return;
return FALSE;
if (window == NULL) {
window = startup_wizard_new_assistant (extension);
g_signal_connect (
window, "cancel",
G_CALLBACK (startup_wizard_terminate), NULL);
}
shell = startup_wizard_get_shell (extension);
window = startup_wizard_new_assistant (extension);
g_object_weak_ref (
G_OBJECT (window),
startup_wizard_weak_ref_cb, NULL);
gtk_window_set_transient_for (GTK_WINDOW (window), e_shell_get_active_window (shell));
gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
gtk_widget_show (window);
gtk_main ();
return FALSE;
}
static void
......@@ -266,9 +252,45 @@ startup_wizard_load_accounts (EStartupWizard *extension)
/* Pop our GMainContext off the thread-default stack. */
g_main_context_pop_thread_default (context);
g_main_context_unref (context);
}
static void
startup_wizard_notify_active_view_cb (EShellWindow *shell_window,
GParamSpec *param,
EStartupWizard *extension)
{
if (extension->proceeded) {
g_signal_handlers_disconnect_by_data (shell_window, extension);
return;
}
if (g_strcmp0 ("mail", e_shell_window_get_active_view (shell_window)) == 0) {
g_signal_handlers_disconnect_by_data (shell_window, extension);
g_signal_handlers_disconnect_by_data (startup_wizard_get_shell (extension), extension);
extension->proceeded = TRUE;
/* Proceed with the Evolution Setup Assistant. */
startup_wizard_run (extension);
if (gtk_widget_get_realized (GTK_WIDGET (shell_window)))
startup_wizard_run_idle_cb (extension);
else
g_idle_add (startup_wizard_run_idle_cb, extension);
}
}
static void
startup_wizard_window_added_cb (EStartupWizard *extension,
GtkWindow *window,
EShell *shell)
{
if (extension->proceeded) {
g_signal_handlers_disconnect_by_data (shell, extension);
return;
}
if (E_IS_SHELL_WINDOW (window)) {
g_signal_connect (window, "notify::active-view",
G_CALLBACK (startup_wizard_notify_active_view_cb), extension);
}
}
static void
......@@ -276,6 +298,7 @@ startup_wizard_constructed (GObject *object)
{
EShell *shell;
EStartupWizard *extension;
GSettings *settings;
extension = E_STARTUP_WIZARD (object);
shell = startup_wizard_get_shell (extension);
......@@ -284,6 +307,16 @@ startup_wizard_constructed (GObject *object)
shell, "event::ready-to-start",
G_CALLBACK (startup_wizard_load_accounts), extension);
settings = e_util_ref_settings ("org.gnome.evolution.mail");
extension->proceeded = !g_settings_get_boolean (settings, "show-startup-wizard");
g_object_unref (settings);
if (!extension->proceeded) {
g_signal_connect_swapped (
shell, "window-added",
G_CALLBACK (startup_wizard_window_added_cb), extension);
}
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_startup_wizard_parent_class)->constructed (object);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment