* Added an attribute sent to the msg edit window that specifies that the mail has...
[modest] / src / maemo / modest-msg-edit-window.c
index 6310ed6..c120bb0 100644 (file)
@@ -93,6 +93,7 @@ static void  send_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *edi
 static void  style_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
 static void  remove_attachment_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
 static void  zoom_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
+static void  paste_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor);
 static void  setup_insensitive_handlers (ModestMsgEditWindow *editor);
 static void  reset_modified (ModestMsgEditWindow *editor);
 
@@ -198,6 +199,7 @@ struct _ModestMsgEditWindowPrivate {
        gulong      system_clipboard_change_handler_id;
 
        TnyMsg      *draft_msg;
+       gboolean    sent;
 };
 
 #define MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
@@ -299,6 +301,7 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv->draft_msg = NULL;
        priv->clipboard_change_handler_id = 0;
        priv->system_clipboard_change_handler_id = 0;
+       priv->sent = FALSE;
 }
 
 
@@ -574,10 +577,22 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
 
        if (to)
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->to_field),  to);
-       if (cc)
+       if (cc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->cc_field),  cc);
-       if (bcc)
+               gtk_widget_set_no_show_all (priv->cc_caption, FALSE);
+               gtk_widget_show (priv->cc_caption);
+       } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_SHOW_CC, NULL)) {
+               gtk_widget_set_no_show_all (priv->cc_caption, FALSE);
+               gtk_widget_hide (priv->cc_caption);
+       }
+       if (bcc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->bcc_field), bcc);
+               gtk_widget_set_no_show_all (priv->cc_caption, FALSE);
+               gtk_widget_show (priv->bcc_caption);
+       } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_SHOW_BCC, NULL)) {
+               gtk_widget_set_no_show_all (priv->bcc_caption, FALSE);
+               gtk_widget_hide (priv->bcc_caption);
+       } 
        if (subject)
                gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
        modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW(self),
@@ -1951,11 +1966,13 @@ modest_msg_edit_window_show_cc (ModestMsgEditWindow *window,
                                gboolean show)
 {
        ModestMsgEditWindowPrivate *priv = NULL;
+       const gchar *recipients;
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
        gtk_widget_set_no_show_all (priv->cc_caption, TRUE);
-       if (show)
+       recipients = modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->cc_field));
+       if ((show) || ((recipients != NULL) && (recipients[0] != '\0')))
                gtk_widget_show (priv->cc_caption);
        else
                gtk_widget_hide (priv->cc_caption);
@@ -1967,11 +1984,13 @@ modest_msg_edit_window_show_bcc (ModestMsgEditWindow *window,
                                 gboolean show)
 {
        ModestMsgEditWindowPrivate *priv = NULL;
+       const gchar *recipients;
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
        gtk_widget_set_no_show_all (priv->bcc_caption, TRUE);
-       if (show)
+       recipients = modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->bcc_field));
+       if ((show) || ((recipients != NULL) && (recipients[0] != '\0')))
                gtk_widget_show (priv->bcc_caption);
        else
                gtk_widget_hide (priv->bcc_caption);
@@ -2348,6 +2367,9 @@ setup_insensitive_handlers (ModestMsgEditWindow *window)
        g_signal_connect (G_OBJECT (widget), "insensitive-press", G_CALLBACK (remove_attachment_insensitive_press), window);
        widget = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar/ViewMenu/ZoomMenu");
        g_signal_connect (G_OBJECT (widget), "insensitive-press", G_CALLBACK (zoom_insensitive_press), window);
+
+       widget = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar/EditMenu/PasteMenu");
+       g_signal_connect (G_OBJECT (widget), "insensitive-press", G_CALLBACK (paste_insensitive_press), window);
 }
 
 static void  
@@ -2706,14 +2728,37 @@ update_paste_dimming (ModestMsgEditWindow *window)
        ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
        GtkAction *action = NULL;
        GtkClipboard *clipboard = NULL;
+       GtkWidget *focused;
+       gboolean active;
+
+       focused = gtk_window_get_focus (GTK_WINDOW (window));
 
        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, gtk_clipboard_wait_is_text_available (clipboard));
+       gtk_action_set_sensitive (action, active);
 
 }
 
+static void  
+paste_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *editor)
+{
+       GtkWidget *focused = gtk_window_get_focus (GTK_WINDOW (editor));
+
+       if (MODEST_IS_ATTACHMENTS_VIEW (focused))
+               hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_unable_to_paste_here"));
+       else
+               hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ecoc_ib_edwin_nothing_to_paste"));
+               
+}
+
+
 static void
 modest_msg_edit_window_system_clipboard_owner_change (GtkClipboard *clipboard,
                                                      GdkEvent *event,
@@ -2775,3 +2820,22 @@ view_menu_activated (GtkAction *action,
 
        update_zoom_dimming (window);
 }
+
+gboolean 
+modest_msg_edit_window_get_sent (ModestMsgEditWindow *window)
+{
+       ModestMsgEditWindowPrivate *priv;
+
+       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
+       return priv->sent;
+}
+
+void 
+modest_msg_edit_window_set_sent (ModestMsgEditWindow *window, 
+                                gboolean sent)
+{
+       ModestMsgEditWindowPrivate *priv;
+
+       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
+       priv->sent = sent;
+}