static void update_window_title (ModestMsgEditWindow *window);
static void update_dimmed (ModestMsgEditWindow *window);
static void update_paste_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,
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;
-
- 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);
+ 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 (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
ModestWindowPrivate *parent_priv;
ModestMsgEditWindowPrivate *priv;
GtkAction *action;
- gboolean has_selection;
- GtkWidget *focused;
GList *selected_attachments = NULL;
gint n_att_selected = 0;
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);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
gtk_action_set_sensitive (action, n_att_selected == 1);
+ 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);
}
static void
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)
{
ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (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);
+
+ dim = dim || (subject == NULL || subject[0] == '\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
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