-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)
-{
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- GtkAction *action = NULL;
- GtkClipboard *clipboard = NULL;
- ModestEmailClipboard *e_clipboard;
- GtkWidget *focused;
- gboolean active;
-
- focused = gtk_window_get_focus (GTK_WINDOW (window));
-
- e_clipboard = modest_runtime_get_email_clipboard ();
- if (!modest_email_clipboard_cleared (e_clipboard)) {
- active = TRUE;
- } else {
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- active = gtk_clipboard_wait_is_text_available (clipboard);
- }
-
- if (active) {
- if (MODEST_IS_ATTACHMENTS_VIEW (focused))
- active = FALSE;
- }
-
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/PasteMenu");
- gtk_action_set_sensitive (action, active);
-
-}
-
-static void
-update_select_all_dimming (ModestMsgEditWindow *window)
-{
- GtkWidget *focused;
- gboolean dimmed = FALSE;
- GtkAction *action;
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
-
- focused = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_ENTRY (focused)) {
- const gchar *current_text;
- current_text = gtk_entry_get_text (GTK_ENTRY (focused));
- dimmed = ((current_text == NULL) || (current_text[0] == '\0'));
- } else if (GTK_IS_TEXT_VIEW (focused)) {
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused));
- dimmed = (gtk_text_buffer_get_char_count (buffer) < 1);
- } else if (MODEST_IS_ATTACHMENTS_VIEW (focused)) {
- dimmed = FALSE;
- }
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/SelectAllMenu");
- gtk_action_set_sensitive (action, !dimmed);
-}
-
-static void
-update_zoom_dimming (ModestMsgEditWindow *window)
-{
- GtkWidget *focused;
- gboolean dimmed = FALSE;
- GtkAction *action;
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
-
- focused = gtk_window_get_focus (GTK_WINDOW (window));
- dimmed = ! WP_IS_TEXT_VIEW (focused);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ZoomMenu");
- gtk_action_set_sensitive (action, !dimmed);
-}
-
-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
-view_menu_activated (GtkAction *action,
- gpointer userdata)
-{
- ModestMsgEditWindow *window = MODEST_MSG_EDIT_WINDOW (userdata);
-
- update_zoom_dimming (window);
-}
-