2007-04-30 Murray Cumming <murrayc@murrayc.com>
+ * src/widgets/modest-recpt-editor.c:
+ (modest_recpt_editor_on_key_press_event): Put an #ifdef around the
+ use of gtk_text_buffer_get_has_selection() (from GTK+ 2.10), and add a
+ TODO comment for this. This fixes the build.
+
+ * src/modest-ui-actions.c: Add do_send_receive(), though it might not
+ be the best place for it. This will in future update all auto-update accounts,
+ rather than just the current/default account, when that gconf key exists.
+ (modest_ui_actions_on_send_receive): Offer the settings dialog (or wizard)
+ if there are no accounts, before calling do_send_receive().
+ * src/modest-ui-actions.h: Specify the callback for the Send/Recieve menu item.
+
+ * src/gnome/modest-main-window.c: (on_online_toggle_toggled):
+ * src/maemo/modest-main-window-ui.h:
+ * src/maemo/modest-main-window.c: (on_connection_changed),
+ (sync_accounts_cb): Use do_send_receive() instead of calling the signal handler
+ directly, becaue the signal handler does more.
+
+2007-04-30 Murray Cumming <murrayc@murrayc.com>
+
* src/modest-account-mgr-helpers.c:
(modest_account_mgr_get_account_data): Add a more helpful error message, and comment,
for the case that the account does not exist.
device = modest_runtime_get_device ();
online = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->online_toggle));
- if (online)
+ if (online) {
+ /* TODO: Just attempt to go online, instead of forcing the online status: */
tny_device_force_online (device);
+ }
else
tny_device_force_offline (device);
}
{ "ToolsAccounts", NULL, N_("mcen_me_inbox_accounts"), NULL, NULL, G_CALLBACK(modest_ui_actions_on_accounts) },
{ "ToolsSMTPServers", NULL, N_("mcen_me_inbox_globalsmtpservers"), NULL, NULL, NULL },
{ "ToolsSendReceive", NULL, N_("mcen_me_inbox_sendandreceive") }, /* submenu */
- { "ToolsSendReceiveAll", NULL, N_("mcen_me_inbox_sendandreceive_all"), NULL, NULL, NULL },
+ { "ToolsSendReceiveAll", NULL, N_("mcen_me_inbox_sendandreceive_all"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_send_receive) },
{ "ToolsSendReceiveCancelSending", NULL, N_("mcen_me_outbox_cancelsend"), NULL, NULL, NULL },
{ "ToolsContacts", NULL, N_("mcen_me_inbox_open_addressbook"), NULL, NULL, NULL },
{ "ToolsAddToContacts", NULL, N_("mcen_me_viewer_addtocontacts"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_add_to_contacts) },
on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
{
/* When going online, do the equivalent of pressing the send/receive button,
- * as per the specification: */
+ * as per the specification:
+ * (without the check for >0 accounts, though that is not specified): */
if (online) {
- modest_ui_actions_on_send_receive (NULL /* action */, MODEST_WINDOW (self));
+ do_send_receive (MODEST_WINDOW (self));
}
}
G_CALLBACK(on_connection_changed), self);
}
-
+/** Idle handler, to send/receive at startup .*/
gboolean
sync_accounts_cb (ModestMainWindow *win)
{
- /* TODO: Only for auto-update accounts. */
- modest_ui_actions_on_send_receive (NULL, MODEST_WINDOW(win));
- return FALSE;
+ do_send_receive (MODEST_WINDOW(win));
+ return FALSE; /* Do not call this idle handler again. */
}
/* Set account store */
tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
- g_idle_add ((GSourceFunc)sync_accounts_cb, self);
- /* do send & receive when we are idle */
-
+ /* do send & receive when we are idle */
+ g_idle_add ((GSourceFunc)sync_accounts_cb, self);
return MODEST_WINDOW(self);
}
return TRUE;
}
}
-
-void
-modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
+
+static void
+do_send_receive_current_or_default (ModestWindow *win)
{
gchar *account_name;
-
g_message ("%s: online? %s", __FUNCTION__,
tny_device_is_online(modest_runtime_get_device()) ? "yes":"no");
}
/* Do not continue if no suitable connection is open: */
- if (!check_for_connection (account_name))
- return;
+ if (check_for_connection (account_name)) {
+ /* As per the UI spec,
+ * for POP accounts, we should receive,
+ * for IMAP we should synchronize everything, including receiving,
+ * for SMTP we should send,
+ * first receiving, then sending:
+ */
+ if (!action_receive(account_name))
+ g_printerr ("modest: failed to receive\n");
+ if (!action_send(account_name))
+ g_printerr ("modest: failed to send\n");
+
+ g_free (account_name);
+ }
+}
- /* As per the UI spec,
- * for POP accounts, we should receive,
- * for IMAP we should synchronize everything, including receiving,
- * for SMTP we should send,
- * first receiving, then sending:
- */
- if (!action_receive(account_name))
- g_printerr ("modest: failed to receive\n");
- if (!action_send(account_name))
- g_printerr ("modest: failed to send\n");
+
+static void
+do_send_receive_auto (ModestWindow *win)
+{
+ g_message ("%s: online? %s", __FUNCTION__,
+ tny_device_is_online(modest_runtime_get_device()) ? "yes":"no");
+
+ /* TODO: Delete the item->data strings as well as the list? */
+ GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
+ GSList *iter = account_names;
+ while (iter) {
+ const gchar * account_name = (const char*) iter->data;
+
+ /* Do not continue if no suitable connection is open: */
+ if (account_name && check_for_connection (account_name)) {
+ /* As per the UI spec,
+ * for POP accounts, we should receive,
+ * for IMAP we should synchronize everything, including receiving,
+ * for SMTP we should send,
+ * first receiving, then sending:
+ */
+ if (!action_receive(account_name))
+ g_printerr ("modest: failed to receive for account %s\n", account_name);
+ if (!action_send(account_name))
+ g_printerr ("modest: failed to send for account %s\n", account_name);
+ }
+ }
+
+ g_slist_free (account_names);
}
+void
+do_send_receive (ModestWindow *win)
+{
+ const gboolean auto_update = TRUE; /* TODO: Get gconf setting. */
+ if (auto_update)
+ do_send_receive_current_or_default (win);
+ else
+ do_send_receive_auto (win);
+}
+
+void
+modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
+{
+ /* Check that at least one account exists: */
+ GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
+ gboolean accounts_exist = account_names != NULL;
+ g_slist_free (account_names);
+
+ /* If not, allow the user to create an account before trying to send/receive. */
+ if (!accounts_exist) {
+ modest_ui_actions_on_accounts (NULL, win);
+ }
+
+ do_send_receive (win);
+}
+
+
void
void modest_ui_actions_on_insert_image (GtkAction *action,
ModestMsgEditWindow *window);
+/* TODO: Is there a better place for this? */
+void do_send_receive (ModestWindow *win);
+
void modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win);
void modest_ui_actions_on_new_folder (GtkAction *action,
#include <pango/pango-attributes.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
static GObjectClass *parent_class = NULL;
break;
case GDK_BackSpace:
{
+ #if GTK_CHECK_VERSION(2, 10, 0) /* gtk_text_buffer_get_has_selection is only available in GTK+ 2.10 */
if (gtk_text_buffer_get_has_selection (buffer)) {
gtk_text_buffer_delete_selection (buffer, TRUE, TRUE);
return TRUE;
}
+ #else
+ /* TODO: Alternative code. */
+ #endif
+
tag = prev_iter_has_recipient (&location);
if (tag != NULL) {
GtkTextIter iter_in_tag;