Fix sensitivity of the main window's 'View/Message part/View as text' entry
authorwwp <wwp@free.fr>
Wed, 25 Apr 2018 13:48:12 +0000 (15:48 +0200)
committerwwp <wwp@free.fr>
Wed, 25 Apr 2018 13:48:12 +0000 (15:48 +0200)
according to the selected mime part.

src/mainwindow.c
src/mimeview.c

index 20bc40f9a2c6d0931b87a2fedcdcd8c732b5cb96..42de186e720ecf0859bf640e5ecd6d3d9b17a222 100644 (file)
@@ -3362,6 +3362,18 @@ do { \
        cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/CheckSignature", 
                                   mimepart_selected && mainwin->messageview->mimeview->signed_part);
 
+       sensitive = TRUE;
+       if (mimepart_selected) {
+               MimeInfo *partinfo = messageview_get_selected_mime_part(mainwin->messageview);
+
+               if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
+                                partinfo->type == MIMETYPE_IMAGE ||
+                                partinfo->type == MIMETYPE_MULTIPART)) {
+                       sensitive = FALSE;
+               }
+       }
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Part/AsText", sensitive);
+
        main_window_menu_callback_unblock(mainwin);
 }
 
index a00c72f6f55c5e376559bfbd0a0023563440fdab..9dd0f49a9c7e686d21754ee2cf2d03c8265b36a2 100644 (file)
@@ -1397,6 +1397,7 @@ static void mimeview_selected(GtkTreeSelection *selection, MimeView *mimeview)
        GtkTreeIter iter;
        GtkTreePath *path;
        MimeInfo *partinfo;
+       MainWindow *mainwin;
 
        selection = gtk_tree_view_get_selection(ctree);
        if (!gtk_tree_selection_get_selected(selection, &model, &iter))
@@ -1444,6 +1445,9 @@ static void mimeview_selected(GtkTreeSelection *selection, MimeView *mimeview)
                        break;
                }
        }
+       mainwin = mainwindow_get_mainwindow();
+       if (mainwin)
+               main_window_set_menu_sensitive(mainwin);
 
        if (mimeview->siginfo && privacy_auto_check_signatures(mimeview->siginfo)
        &&  privacy_mimeinfo_get_sig_status(mimeview->siginfo) == SIGNATURE_UNCHECKED) {
@@ -1499,6 +1503,8 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event,
                mimeview_launch(mimeview, partinfo);
                return TRUE;
        } else if (event->button == 3) {
+               MainWindow *mainwin = mainwindow_get_mainwindow();
+
                if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
                                 partinfo->type == MIMETYPE_IMAGE ||
                                 partinfo->type == MIMETYPE_MULTIPART))
@@ -1513,7 +1519,8 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event,
                else
 #endif
                        cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", TRUE);
-
+               if (mainwin)
+                       main_window_set_menu_sensitive(mainwin);
                g_object_set_data(G_OBJECT(mimeview->popupmenu),
                                  "pop_partinfo", partinfo);