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);
gpointer userdata);
static void text_buffer_delete_images_by_id (GtkTextBuffer *buffer, const gchar * image_id);
static void subject_field_changed (GtkEditable *editable, ModestMsgEditWindow *window);
+static void subject_field_insert_text (GtkEditable *editable,
+ gchar *new_text,
+ gint new_text_length,
+ gint *position,
+ ModestMsgEditWindow *window);
static void modest_msg_edit_window_color_button_change (ModestMsgEditWindow *window,
gpointer userdata);
static void modest_msg_edit_window_size_change (GtkCheckMenuItem *menu_item,
static void update_window_title (ModestMsgEditWindow *window);
static void update_dimmed (ModestMsgEditWindow *window);
static void update_paste_dimming (ModestMsgEditWindow *window);
+static void update_remove_attachment_dimming (ModestMsgEditWindow *window);
+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,
TnyMsg *draft_msg;
TnyMsg *outbox_msg;
+ gchar *msg_uid;
+
gboolean sent;
};
priv->draft_msg = NULL;
priv->outbox_msg = NULL;
+ priv->msg_uid = NULL;
priv->clipboard_change_handler_id = 0;
priv->sent = FALSE;
return transports;
}
+static gboolean attachment_view_focus_lost (
+ GtkWidget *widget,
+ GdkEventFocus *event,
+ ModestMsgEditWindow *window)
+{
+ g_return_val_if_fail(MODEST_IS_MSG_EDIT_WINDOW(window), FALSE);
+
+ update_remove_attachment_dimming(window);
+
+ return FALSE;
+}
+
void vadj_changed (GtkAdjustment *adj,
ModestMsgEditWindow *window)
{
gtk_container_add (GTK_CONTAINER (priv->add_attachment_button), attachment_icon);
gtk_box_pack_start (GTK_BOX (subject_box), priv->add_attachment_button, FALSE, FALSE, 0);
priv->attachments_view = modest_attachments_view_new (NULL);
+ g_signal_connect (G_OBJECT (priv->attachments_view), "focus-out-event",
+ G_CALLBACK (attachment_view_focus_lost), obj);
priv->header_box = gtk_vbox_new (FALSE, 0);
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);
"changed", G_CALLBACK (recpt_field_changed), obj);
recpt_field_changed (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->to_field)), MODEST_MSG_EDIT_WINDOW (obj));
g_signal_connect (G_OBJECT (priv->subject_field), "changed", G_CALLBACK (subject_field_changed), obj);
+ g_signal_connect (G_OBJECT (priv->subject_field), "insert-text", G_CALLBACK (subject_field_insert_text), obj);
g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_edit_window_find_toolbar_close), obj);
g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_edit_window_find_toolbar_search), obj);
g_object_unref (priv->outbox_msg);
priv->outbox_msg = NULL;
}
+ if (priv->msg_uid != NULL) {
+ g_free (priv->msg_uid);
+ priv->msg_uid = NULL;
+ }
/* This had to stay alive for as long as the combobox that used it: */
modest_pair_list_free (priv->from_field_protos);
text_buffer_can_undo (priv->text_buffer, FALSE, self);
text_buffer_can_redo (priv->text_buffer, FALSE, self);
+ if (priv->msg_uid) {
+ g_free (priv->msg_uid);
+ priv->msg_uid = NULL;
+ }
+
/* we should set a reference to the incoming message if it is a draft */
msg_folder = tny_msg_get_folder (msg);
if (msg_folder) {
priv->draft_msg = g_object_ref(msg);
if (type == TNY_FOLDER_TYPE_OUTBOX)
priv->outbox_msg = g_object_ref(msg);
+ priv->msg_uid = modest_tny_folder_get_header_unique_id (header);
}
g_object_unref (msg_folder);
}
parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (parent_priv->toolbar));
- /* should we hide the toolbar? */
- if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_SHOW_TOOLBAR, NULL))
- gtk_widget_hide (parent_priv->toolbar);
-
/* Font color placeholder */
placeholder = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/FontColor");
insert_index = gtk_toolbar_get_item_index(GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM(placeholder));
gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
gtk_toolbar_insert(GTK_TOOLBAR(parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index);
- g_signal_connect_swapped (G_OBJECT (priv->font_color_button), "notify::color", G_CALLBACK (modest_msg_edit_window_color_button_change), window);
+ g_signal_connect_swapped (G_OBJECT (priv->font_color_button),
+ "notify::color",
+ G_CALLBACK (modest_msg_edit_window_color_button_change),
+ window);
/* Font size and face placeholder */
placeholder = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/FontAttributes");
gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
+ /* Explicitelly show all the toolbar (a normal gtk_widget_show
+ will not show the tool items added to the placeholders) */
+ gtk_widget_show_all (parent_priv->toolbar);
+ /* Set the no show all *after* showing all items. We do not
+ want the toolbar to be shown with a show all because it
+ could go agains the gconf setting regarding showing or not
+ the toolbar of the editor window */
+ gtk_widget_set_no_show_all (parent_priv->toolbar, TRUE);
}
gtk_window_add_accel_group (GTK_WINDOW (obj),
gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
- /* Menubar */
+ /* Menubar. Update the state of some toggles */
parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
+ conf = modest_runtime_get_conf ();
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager,
+ "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL));
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager,
+ "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarFullScreenMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL));
+
hildon_window_set_menu (HILDON_WINDOW (obj), GTK_MENU (parent_priv->menubar));
/* Init window */
data->subject = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->subject_field)));
if (priv->draft_msg) {
data->draft_msg = g_object_ref (priv->draft_msg);
- }
- if (priv->outbox_msg) {
+ } else if (priv->outbox_msg) {
data->draft_msg = g_object_ref (priv->outbox_msg);
} else {
data->draft_msg = NULL;
}
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), buffer_format, FALSE);
-
+
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ActionsBold");
modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bold);
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),
}
void
-modest_msg_edit_window_toggle_fullscreen (ModestMsgEditWindow *window)
-{
- ModestWindowPrivate *parent_priv;
- GtkAction *fs_toggle_action;
- gboolean active;
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
-
- fs_toggle_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewToggleFullscreenMenu");
- active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (fs_toggle_action));
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (fs_toggle_action), !active);
-}
-
-void
modest_msg_edit_window_show_cc (ModestMsgEditWindow *window,
gboolean show)
{
gboolean show_toolbar)
{
ModestWindowPrivate *parent_priv;
+ const gchar *action_name;
+ GtkAction *action;
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- /* FIXME: we can not just use the code of
+ /* We can not just use the code of
modest_msg_edit_window_setup_toolbar because it has a
mixture of both initialization and creation code. */
-
if (show_toolbar)
gtk_widget_show (GTK_WIDGET (parent_priv->toolbar));
else
gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar));
+
+ /* Update also the actions (to update the toggles in the
+ menus), we have to do it manually because some other window
+ of the same time could have changed it (remember that the
+ toolbar fullscreen mode is shared by all the windows of the
+ same type */
+ if (modest_window_mgr_get_fullscreen_mode (modest_runtime_get_window_mgr ()))
+ action_name = "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarFullScreenMenu";
+ else
+ action_name = "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu";
+
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ show_toolbar);
+
}
void
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)
{
return FALSE;
}
- if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->to_field), add_to_addressbook))
+ if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->to_field), add_to_addressbook)) {
+ modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field));
return FALSE;
- if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->cc_field), add_to_addressbook))
+ }
+ if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->cc_field), add_to_addressbook)) {
+ modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->cc_field));
return FALSE;
- if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->bcc_field), add_to_addressbook))
+ }
+ if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->bcc_field), add_to_addressbook)) {
+ modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->bcc_field));
return FALSE;
+ }
- modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field));
+ if (!modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->cc_field)) &&
+ !modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->bcc_field)))
+ modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field));
return TRUE;
GdkEvent *event,
ModestMsgEditWindow *window)
{
- ModestWindowPrivate *parent_priv;
- ModestMsgEditWindowPrivate *priv;
- GtkAction *action;
- gboolean has_selection;
- GtkWidget *focused;
- GList *selected_attachments = NULL;
- gint n_att_selected = 0;
-
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
-
if (!GTK_WIDGET_VISIBLE (window))
return;
- has_selection = gtk_clipboard_wait_for_targets (clipboard, NULL, NULL);
- focused = gtk_window_get_focus (GTK_WINDOW (window));
-
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
- gtk_action_set_sensitive (action, (has_selection) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
- gtk_action_set_sensitive (action, (has_selection) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
-
- selected_attachments = modest_attachments_view_get_selection (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
- n_att_selected = g_list_length (selected_attachments);
- g_list_free (selected_attachments);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
- gtk_action_set_sensitive (action, n_att_selected == 1);
-
+ update_remove_attachment_dimming (window);
+ update_copy_cut_dimming (window);
update_paste_dimming (window);
}
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);
}
-gboolean
-message_is_empty (ModestMsgEditWindow *window)
-{
- ModestMsgEditWindowPrivate *priv = NULL;
+static void
+subject_field_insert_text (GtkEditable *editable,
+ gchar *new_text,
+ gint new_text_length,
+ gint *position,
+ ModestMsgEditWindow *window)
+{
+ GString *result = g_string_new ("");
+ gchar *current;
+ gint result_len = 0;
+
+ for (current = new_text; current != NULL && *current != '\0'; current = g_utf8_next_char (current)) {
+ gunichar c = g_utf8_get_char_validated (current, 8);
+ /* Invalid unichar, stop */
+ if (c == -1)
+ break;
+ /* a bullet */
+ if (c == 0x2022)
+ continue;
+ result = g_string_append_unichar (result, c);
+ result_len++;
+ }
- g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ if (MIN (result_len, 1000) != g_utf8_strlen (new_text, 1000)) {
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
+ if (result_len > 0)
+ {
+ /* Prevent endless recursion */
+ g_signal_handlers_block_by_func(G_OBJECT(editable), G_CALLBACK(subject_field_insert_text), window);
+ g_signal_emit_by_name (editable, "insert-text",
+ (gpointer) result->str, (gpointer) result->len,
+ (gpointer) position, (gpointer) window);
+ g_signal_handlers_unblock_by_func(G_OBJECT(editable), G_CALLBACK(subject_field_insert_text), 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;
+ g_string_free (result, TRUE);
}
-
+
void
modest_msg_edit_window_toggle_find_toolbar (ModestMsgEditWindow *window,
gboolean show)
gtk_toggle_action_set_active (toggle, FALSE);
}
+static void
+update_remove_attachment_dimming (ModestMsgEditWindow *window)
+{
+ ModestWindowPrivate *parent_priv;
+ ModestMsgEditWindowPrivate *priv;
+ GtkAction *action;
+ GList *selected_attachments = NULL;
+ gint n_att_selected = 0;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+
+ selected_attachments = modest_attachments_view_get_selection (
+ MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+ n_att_selected = g_list_length (selected_attachments);
+ g_list_free (selected_attachments);
+
+ action = gtk_ui_manager_get_action (
+ parent_priv->ui_manager,
+ "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
+ gtk_action_set_sensitive (action, n_att_selected == 1);
+}
+
+static void
+update_copy_cut_dimming (ModestMsgEditWindow *window)
+{
+ ModestWindowPrivate *parent_priv = NULL;
+ ModestMsgEditWindowPrivate *priv = NULL;
+ GtkClipboard *clipboard = NULL;
+ GtkAction *action = NULL;
+ gboolean has_selection = FALSE;
+ GtkWidget *focused = NULL;
+ gchar *selection = NULL;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ focused = gtk_window_get_focus (GTK_WINDOW (window));
+
+ has_selection = gtk_clipboard_wait_for_targets (clipboard, NULL, NULL);
+
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
+ gtk_action_set_sensitive (action, (has_selection) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
+ gtk_action_set_sensitive (action, (has_selection) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
+
+ if (selection != NULL)
+ g_free(selection);
+}
static void
update_paste_dimming (ModestMsgEditWindow *window)
}
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)
{
ModestMsgEditWindow *window = MODEST_MSG_EDIT_WINDOW (userdata);
update_select_all_dimming (window);
+ update_copy_cut_dimming (window);
update_paste_dimming (window);
}
static void
header = tny_msg_get_header (draft);
if (TNY_IS_HEADER (header))
modest_window_mgr_register_header (mgr, header);
+ if (priv->msg_uid) {
+ g_free (priv->msg_uid);
+ priv->msg_uid = NULL;
+ }
+ priv->msg_uid = modest_tny_folder_get_header_unique_id (header);
}
priv->draft_msg = draft;
gtk_widget_show_all (priv->attachments_caption);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
}
+
+const gchar*
+modest_msg_edit_window_get_message_uid (ModestMsgEditWindow *window)
+{
+ ModestMsgEditWindowPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), NULL);
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ return priv->msg_uid;
+}