add Lock/Unlock to summary view popup menu
[claws.git] / src / summaryview.c
index d48a0f54e9366829248921068ed2e74f0156a7d3..a2fae745bb9cb7686f4fd1f6b7172c25d5947155 100644 (file)
@@ -191,6 +191,8 @@ static void summary_mark_row                (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
 static void summary_lock_row           (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
+static void summary_unlock_row         (SummaryView            *summaryview,
+                                        GtkCTreeNode           *row);
 static void summary_mark_row_as_read   (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
 static void summary_mark_row_as_unread (SummaryView            *summaryview,
@@ -429,6 +431,8 @@ static GtkItemFactoryEntry summary_popup_entries[] =
        {N_("/_Mark/Mark all read"),    NULL, summary_mark_all_read, 0, NULL},
        {N_("/_Mark/Ignore thread"),    NULL, summary_ignore_thread, 0, NULL},
        {N_("/_Mark/Unignore thread"),  NULL, summary_unignore_thread, 0, NULL},
+       {N_("/_Mark/Lock"),             NULL, summary_msgs_lock, 0, NULL},
+       {N_("/_Mark/Unlock"),           NULL, summary_msgs_unlock, 0, NULL},
        {N_("/Color la_bel"),           NULL, NULL,             0, NULL},
 
        {N_("/---"),                    NULL, NULL,             0, "<Separator>"},
@@ -1286,6 +1290,8 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
        menu_set_sensitive(ifactory, "/Mark/Mark all read", TRUE);
        menu_set_sensitive(ifactory, "/Mark/Ignore thread",   TRUE);
        menu_set_sensitive(ifactory, "/Mark/Unignore thread", TRUE);
+       menu_set_sensitive(ifactory, "/Mark/Lock", TRUE);
+       menu_set_sensitive(ifactory, "/Mark/Unlock", TRUE);
 
        menu_set_sensitive(ifactory, "/Color label", TRUE);
 
@@ -2763,7 +2769,6 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
 
 static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
-       /* almost verbatim summary_mark_row(); may want a menu action? */
        gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
@@ -2786,6 +2791,21 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
        debug_print("Message %d is locked\n", msginfo->msgnum);
 }
 
+static void summary_unlock_row(SummaryView *summaryview, GtkCTreeNode *row)
+{
+       gboolean changed = FALSE;
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       MsgInfo *msginfo;
+
+       msginfo = gtk_ctree_node_get_row_data(ctree, row);
+       if (!MSG_IS_LOCKED(msginfo->flags))
+               return;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
+       procmsg_msginfo_unset_flags(msginfo, MSG_LOCKED, 0);
+       summary_set_row_marks(summaryview, row);
+       debug_print("Message %d is unlocked\n", msginfo->msgnum);
+}
+
 void summary_mark(SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
@@ -2837,6 +2857,34 @@ void summary_mark_as_read(SummaryView *summaryview)
        summary_status_show(summaryview);
 }
 
+void summary_msgs_lock(SummaryView *summaryview)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+
+       folder_item_update_freeze();
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               summary_lock_row(summaryview,
+                                        GTK_CTREE_NODE(cur->data));
+       folder_item_update_thaw();
+       
+       summary_status_show(summaryview);
+}
+
+void summary_msgs_unlock(SummaryView *summaryview)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+
+       folder_item_update_freeze();
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               summary_unlock_row(summaryview,
+                                  GTK_CTREE_NODE(cur->data));
+       folder_item_update_thaw();
+       
+       summary_status_show(summaryview);
+}
+
 void summary_mark_all_read(SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);