static void modest_msg_edit_window_finalize (GObject *obj);
static gboolean msg_body_focus (GtkWidget *focus, GdkEventFocus *event, gpointer userdata);
+static void body_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor);
static void recpt_field_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor);
static void send_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
static void style_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
static void update_copy_cut_dimming (ModestMsgEditWindow *window);
static void update_select_all_dimming (ModestMsgEditWindow *window);
static void update_zoom_dimming (ModestMsgEditWindow *window);
+static void update_send_dimming (ModestMsgEditWindow *window);
/* Find toolbar */
static void modest_msg_edit_window_find_toolbar_search (GtkWidget *widget,
G_CALLBACK (text_buffer_can_undo), obj);
g_signal_connect (G_OBJECT (priv->text_buffer), "can-redo",
G_CALLBACK (text_buffer_can_redo), obj);
+ g_signal_connect (G_OBJECT (priv->text_buffer), "changed",
+ G_CALLBACK (body_changed), obj);
g_signal_connect (G_OBJECT (obj), "window-state-event",
G_CALLBACK (modest_msg_edit_window_window_state_event),
NULL);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ActionsItalics");
modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->italic);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/BulletedListMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bullet);
+/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/BulletedListMenu"); */
+/* modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bullet); */
g_signal_handlers_block_by_func (G_OBJECT (priv->font_color_button),
G_CALLBACK (modest_msg_edit_window_color_button_change),
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/SelectFontMenu");
gtk_action_set_sensitive (action, rich_text && editor_focused);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/BulletedListMenu");
- gtk_action_set_sensitive (action, rich_text && editor_focused);
+/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/BulletedListMenu"); */
+/* gtk_action_set_sensitive (action, rich_text && editor_focused); */
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentMenu");
gtk_action_set_sensitive (action, rich_text && editor_focused);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentMenu/AlignmentLeftMenu");
}
}
+gboolean
+message_is_empty (ModestMsgEditWindow *window)
+{
+ ModestMsgEditWindowPrivate *priv = NULL;
+
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ /** TODO: Add wpeditor API to tell us if there is any _visible_ text,
+ * so we can ignore markup.
+ */
+ GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body));
+ gint count = 0;
+ if (buf)
+ count = gtk_text_buffer_get_char_count (buf);
+
+ return count == 0;
+}
+
static gboolean
msg_body_focus (GtkWidget *focus,
GdkEventFocus *event,
recpt_field_changed (GtkTextBuffer *buffer,
ModestMsgEditWindow *editor)
{
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (editor);
- ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor);
- GtkTextBuffer *to_buffer, *cc_buffer, *bcc_buffer;
- gboolean dim = FALSE;
- GtkAction *action;
+ update_send_dimming (editor);
+}
- to_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->to_field));
- cc_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->cc_field));
- bcc_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->bcc_field));
-
- dim = ((gtk_text_buffer_get_char_count (to_buffer) +
- gtk_text_buffer_get_char_count (cc_buffer) +
- gtk_text_buffer_get_char_count (bcc_buffer)) == 0);
-
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarSend");
- gtk_action_set_sensitive (action, !dim);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EmailMenu/SendMenu");
- gtk_action_set_sensitive (action, !dim);
+static void
+body_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor)
+{
+ update_send_dimming (editor);
}
static void
send_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor)
{
- hildon_banner_show_information (NULL, NULL, _("mcen_ib_add_recipients_first"));
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor);
+ const gchar *subject = gtk_entry_get_text (GTK_ENTRY (priv->subject_field));
+ if (message_is_empty(editor) || (subject == NULL || subject[0] == '\0')) {
+ hildon_banner_show_information (NULL, NULL, _("mcen_ib_subject_or_body_not_modified"));
+ } else {
+ hildon_banner_show_information (NULL, NULL, _("mcen_ib_add_recipients_first"));
+ }
}
static void
return FALSE;
}
+
+
+
gboolean
modest_msg_edit_window_check_names (ModestMsgEditWindow *window, gboolean add_to_addressbook)
{
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
update_window_title (window);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+ update_send_dimming (window);
}
static void
g_string_free (result, TRUE);
}
-gboolean
-message_is_empty (ModestMsgEditWindow *window)
-{
- ModestMsgEditWindowPrivate *priv = NULL;
-
- g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
- /** TODO: Add wpeditor API to tell us if there is any _visible_ text,
- * so we can ignore markup.
- */
- GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body));
- gint count = 0;
- if (buf)
- count = gtk_text_buffer_get_char_count (buf);
-
- return count == 0;
-}
-
void
modest_msg_edit_window_toggle_find_toolbar (ModestMsgEditWindow *window,
gboolean show)
}
static void
+update_send_dimming (ModestMsgEditWindow *window)
+{
+ ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ GtkTextBuffer *to_buffer, *cc_buffer, *bcc_buffer;
+ const gchar *subject;
+ gboolean dim = FALSE;
+ GtkAction *action;
+
+ to_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->to_field));
+ cc_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->cc_field));
+ bcc_buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->bcc_field));
+ subject = gtk_entry_get_text (GTK_ENTRY (priv->subject_field));
+
+ dim = ((gtk_text_buffer_get_char_count (to_buffer) +
+ gtk_text_buffer_get_char_count (cc_buffer) +
+ gtk_text_buffer_get_char_count (bcc_buffer)) == 0)
+ || (subject == NULL || subject[0] == '\0')
+ || message_is_empty(window);
+
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarSend");
+ gtk_action_set_sensitive (action, !dim);
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EmailMenu/SendMenu");
+ gtk_action_set_sensitive (action, !dim);
+}
+
+static void
edit_menu_activated (GtkAction *action,
gpointer userdata)
{