colour message instead of mark it
authorPaul Mangan <paul@claws-mail.org>
Sun, 1 Jul 2001 19:27:01 +0000 (19:27 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sun, 1 Jul 2001 19:27:01 +0000 (19:27 +0000)
AUTHORS
ChangeLog.claws
src/mainwindow.c
src/procmsg.h
src/summaryview.c
src/summaryview.h

diff --git a/AUTHORS b/AUTHORS
index 9850a80..c66bed4 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -66,4 +66,4 @@ contributors (beside the above; based on Changelog)
        Wakai
         Rodrigo Dias Arruda Senra
         Fabio Junior Beneditto
        Wakai
         Rodrigo Dias Arruda Senra
         Fabio Junior Beneditto
-
+       Satoshi Nagayasu
index d299b94..d6caa3a 100644 (file)
@@ -1,3 +1,12 @@
+2001-07-01 [paul]
+
+       * src/ mainwindow.c
+       * src/procmsg.h
+       * src/summaryview.[ch]
+               new right-click option: Label.
+               substitute for 'Mark-->Mark/Unmark', colours the line.
+               submitted by Satoshi Nagayasu
+
 2001-07-01 [christoph]
 
        * src/folderview.c
 2001-07-01 [christoph]
 
        * src/folderview.c
index 6ce2ca0..b5a19fb 100644 (file)
@@ -536,6 +536,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Summary/_Sort/Sort by _from"),   NULL, sort_summary_cb, SORT_BY_FROM, NULL},
        {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
        {N_("/_Summary/_Sort/Sort by sco_re"),  NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
        {N_("/_Summary/_Sort/Sort by _from"),   NULL, sort_summary_cb, SORT_BY_FROM, NULL},
        {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
        {N_("/_Summary/_Sort/Sort by sco_re"),  NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
+       {N_("/_Summary/_Sort/Sort by _label"),  NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
        {N_("/_Summary/_Sort/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Summary/_Sort/_Attract by subject"),
                                                NULL, attract_by_subject_cb, 0, NULL},
        {N_("/_Summary/_Sort/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Summary/_Sort/_Attract by subject"),
                                                NULL, attract_by_subject_cb, 0, NULL},
index 8b8866c..7dbc134 100644 (file)
@@ -45,6 +45,16 @@ typedef enum
        MSG_MOVE        = 1 << 16,
        MSG_COPY        = 1 << 17,
 
        MSG_MOVE        = 1 << 16,
        MSG_COPY        = 1 << 17,
 
+       MSG_LABEL         = 1 << 8 | 1 << 7 | 1 << 6,
+       MSG_LABEL_NONE    = 0 << 8 | 0 << 7 | 0 << 6,
+       MSG_LABEL_ORANGE  = 0 << 8 | 0 << 7 | 1 << 6,
+       MSG_LABEL_RED     = 0 << 8 | 1 << 7 | 0 << 6,
+       MSG_LABEL_PINK    = 0 << 8 | 1 << 7 | 1 << 6,
+       MSG_LABEL_SKYBLUE = 1 << 8 | 0 << 7 | 0 << 6,
+       MSG_LABEL_BLUE    = 1 << 8 | 0 << 7 | 1 << 6,
+       MSG_LABEL_GREEN   = 1 << 8 | 1 << 7 | 0 << 6,
+       MSG_LABEL_BROWN   = 1 << 8 | 1 << 7 | 1 << 6,
+
        MSG_QUEUED      = 1 << 25,
        MSG_DRAFT       = 1 << 26,
        MSG_ENCRYPTED   = 1 << 27,
        MSG_QUEUED      = 1 << 25,
        MSG_DRAFT       = 1 << 26,
        MSG_ENCRYPTED   = 1 << 27,
@@ -60,6 +70,7 @@ typedef enum
                                         MSG_DELETED   | \
                                         MSG_REPLIED   | \
                                         MSG_FORWARDED | \
                                         MSG_DELETED   | \
                                         MSG_REPLIED   | \
                                         MSG_FORWARDED | \
+                                         MSG_LABEL     | \
                                          MSG_REALLY_DELETED)
 #define MSG_CACHED_FLAG_MASK           (MSG_MIME)
 
                                          MSG_REALLY_DELETED)
 #define MSG_CACHED_FLAG_MASK           (MSG_MIME)
 
@@ -84,6 +95,8 @@ typedef enum
 #define MSG_IS_NEWS(msg)               ((msg & MSG_NEWS) != 0)
 #define MSG_IS_CACHED(msg)             ((msg & MSG_CACHED) != 0)
 
 #define MSG_IS_NEWS(msg)               ((msg & MSG_NEWS) != 0)
 #define MSG_IS_CACHED(msg)             ((msg & MSG_CACHED) != 0)
 
+#define MSG_GET_LABEL(msg)             (msg & MSG_LABEL)
+
 #define WRITE_CACHE_DATA_INT(n, fp) \
        fwrite(&n, sizeof(n), 1, fp)
 
 #define WRITE_CACHE_DATA_INT(n, fp) \
        fwrite(&n, sizeof(n), 1, fp)
 
index dcdf73f..9239610 100644 (file)
@@ -266,6 +266,8 @@ static void summary_from_clicked    (GtkWidget              *button,
                                         SummaryView            *summaryview);
 static void summary_subject_clicked    (GtkWidget              *button,
                                         SummaryView            *summaryview);
                                         SummaryView            *summaryview);
 static void summary_subject_clicked    (GtkWidget              *button,
                                         SummaryView            *summaryview);
+static void summary_mark_clicked       (GtkWidget              *button,
+                                        SummaryView            *summaryview);
 
 static void summary_start_drag         (GtkWidget        *widget, 
                                         int button,
 
 static void summary_start_drag         (GtkWidget        *widget, 
                                         int button,
@@ -298,6 +300,9 @@ static gint summary_cmp_by_subject  (GtkCList               *clist,
 static gint summary_cmp_by_score       (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
 static gint summary_cmp_by_score       (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
+static gint summary_cmp_by_label       (GtkCList               *clist,
+                                        gconstpointer           ptr1,
+                                        gconstpointer           ptr2);
 
 GtkTargetEntry summary_drag_types[1] =
 {
 
 GtkTargetEntry summary_drag_types[1] =
 {
@@ -317,6 +322,16 @@ static GtkItemFactoryEntry summary_popup_entries[] =
        {N_("/_Mark/Mark as unr_ead"),  NULL, summary_mark_as_unread, 0, NULL},
        {N_("/_Mark/Mark as rea_d"),
                                        NULL, summary_mark_as_read, 0, NULL},
        {N_("/_Mark/Mark as unr_ead"),  NULL, summary_mark_as_unread, 0, NULL},
        {N_("/_Mark/Mark as rea_d"),
                                        NULL, summary_mark_as_read, 0, NULL},
+       {N_("/_Label"),                 NULL, NULL, 0, "<Branch>"},
+       {N_("/_Label/None"),            NULL, summary_set_label, MSG_LABEL_NONE, NULL},
+       {N_("/_Label/---"),             NULL, NULL,             0, "<Separator>"},
+       {N_("/_Label/Orange"),          NULL, summary_set_label, MSG_LABEL_ORANGE, NULL},
+       {N_("/_Label/Red"),             NULL, summary_set_label, MSG_LABEL_RED, NULL},
+       {N_("/_Label/Pink"),            NULL, summary_set_label, MSG_LABEL_PINK, NULL},
+       {N_("/_Label/SkyBlue"),         NULL, summary_set_label, MSG_LABEL_SKYBLUE, NULL},
+       {N_("/_Label/Blue"),            NULL, summary_set_label, MSG_LABEL_BLUE, NULL},
+       {N_("/_Label/Green"),           NULL, summary_set_label, MSG_LABEL_GREEN, NULL},
+       {N_("/_Label/Brown"),           NULL, summary_set_label, MSG_LABEL_BROWN, NULL},
        {N_("/---"),                    NULL, NULL,             0, "<Separator>"},
        {N_("/_Reply"),                 NULL, summary_reply_cb, COMPOSE_REPLY, NULL},
        {N_("/Repl_y to sender"),       NULL, summary_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
        {N_("/---"),                    NULL, NULL,             0, "<Separator>"},
        {N_("/_Reply"),                 NULL, summary_reply_cb, COMPOSE_REPLY, NULL},
        {N_("/Repl_y to sender"),       NULL, summary_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
@@ -337,6 +352,95 @@ static GtkItemFactoryEntry summary_popup_entries[] =
        {N_("/Select _all"),            NULL, summary_select_all, 0, NULL}
 };
 
        {N_("/Select _all"),            NULL, summary_select_all, 0, NULL}
 };
 
+void summary_set_label_color(GtkCTree *ctree, GtkCTreeNode *node,
+                            guint labelcolor)
+{
+  GdkColor color;
+  GtkStyle *style, *prev_style, *ctree_style;
+  MsgInfo *msginfo;
+  
+  ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
+  
+  prev_style = gtk_ctree_node_get_row_style(ctree, node);
+  
+  if (!prev_style)
+    prev_style = ctree_style;
+  
+  style = gtk_style_copy(prev_style);
+  
+  switch (labelcolor) {
+  case MSG_LABEL_ORANGE:
+    color.red = 0xffff;
+    color.green = (0x99<<8);
+    color.blue = 0x0;
+    break;
+  case MSG_LABEL_RED:
+    color.red = 0xffff;
+    color.green = color.blue = 0x0;
+    break;
+  case MSG_LABEL_PINK:
+    color.red = 0xffff;
+    color.green = (0x66<<8);
+    color.blue = 0xffff;
+    break;
+  case MSG_LABEL_SKYBLUE:
+    color.red = 0x0;
+    color.green = (0xcc<<8);
+    color.blue = 0xffff;
+    break;
+  case MSG_LABEL_BLUE:
+    color.red = 0x0;
+    color.green = 0x0;
+    color.blue = 0xffff;
+    break;
+  case MSG_LABEL_GREEN:
+    color.red = 0x0;
+    color.green = (0x99<<8);
+    color.blue = 0x0;
+    break;
+  case MSG_LABEL_BROWN:
+    color.red = (0x66<<8);
+    color.green = (0x33<<8);
+    color.blue = (0x33<<8);
+    break;
+  case MSG_LABEL_NONE:
+  default:
+    labelcolor = MSG_LABEL_NONE;
+    color.red = ctree_style->fg[GTK_STATE_NORMAL].red;
+    color.green = ctree_style->fg[GTK_STATE_NORMAL].green;
+    color.blue = ctree_style->fg[GTK_STATE_NORMAL].blue;
+    style->fg[GTK_STATE_NORMAL] = color;
+
+    color.red = ctree_style->fg[GTK_STATE_SELECTED].red;
+    color.green = ctree_style->fg[GTK_STATE_SELECTED].green;
+    color.blue = ctree_style->fg[GTK_STATE_SELECTED].blue;
+    style->fg[GTK_STATE_SELECTED] = color;
+    gtk_ctree_node_set_row_style(ctree, node, style);
+    break;
+  }
+
+  msginfo = gtk_ctree_node_get_row_data(ctree, node);
+
+  MSG_UNSET_FLAGS(msginfo->flags, MSG_LABEL);
+  MSG_SET_FLAGS(msginfo->flags, labelcolor);
+
+  if ( style ) {
+    style->fg[GTK_STATE_NORMAL] = color;
+    style->fg[GTK_STATE_SELECTED] = color;
+    gtk_ctree_node_set_row_style(ctree, node, style);
+  }
+}
+
+void summary_set_label(SummaryView *summaryview, guint labelcolor, GtkWidget *widget)
+{
+  GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+  GtkCList *clist = GTK_CLIST(summaryview->ctree);
+  GList *cur;
+  
+  for (cur = clist->selection; cur != NULL; cur = cur->next)
+    summary_set_label_color(ctree, GTK_CTREE_NODE(cur->data), labelcolor);
+}
+
 SummaryView *summary_create(void)
 {
        SummaryView *summaryview;
 SummaryView *summary_create(void)
 {
        SummaryView *summaryview;
@@ -467,6 +571,11 @@ SummaryView *summary_create(void)
                 "clicked",
                 GTK_SIGNAL_FUNC(summary_subject_clicked),
                 summaryview);
                 "clicked",
                 GTK_SIGNAL_FUNC(summary_subject_clicked),
                 summaryview);
+       gtk_signal_connect
+               (GTK_OBJECT(GTK_CLIST(ctree)->column[S_COL_MARK].button),
+                "clicked",
+                GTK_SIGNAL_FUNC(summary_mark_clicked),
+                summaryview);
 
        /* create status label */
        hbox = gtk_hbox_new(FALSE, 0);
 
        /* create status label */
        hbox = gtk_hbox_new(FALSE, 0);
@@ -958,6 +1067,8 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
        menu_set_sensitive(ifactory, "/Mark/Mark as unread", TRUE);
        menu_set_sensitive(ifactory, "/Mark/Mark as read",   TRUE);
 
        menu_set_sensitive(ifactory, "/Mark/Mark as unread", TRUE);
        menu_set_sensitive(ifactory, "/Mark/Mark as read",   TRUE);
 
+       menu_set_sensitive(ifactory, "/Label", TRUE);
+
        menu_set_sensitive(ifactory, "/Select all", TRUE);
 
        if (summaryview->folder_item->folder->account)
        menu_set_sensitive(ifactory, "/Select all", TRUE);
 
        if (summaryview->folder_item->folder->account)
@@ -1460,6 +1571,9 @@ void summary_sort(SummaryView *summaryview, SummarySortType type)
        case SORT_BY_SCORE:
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_score;
                break;
        case SORT_BY_SCORE:
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_score;
                break;
+       case SORT_BY_LABEL:
+               cmp_func = (GtkCListCompareFunc)summary_cmp_by_label;
+               break;
        default:
                return;
        }
        default:
                return;
        }
@@ -1582,6 +1696,9 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                        GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo);
 
                        summary_set_marks_func(ctree, node, summaryview);
                        GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo);
 
                        summary_set_marks_func(ctree, node, summaryview);
+                       
+                       if ( MSG_GET_LABEL(msginfo->flags) )
+                         summary_set_label_color(ctree, node, (msginfo->flags & MSG_LABEL));
 
                        /* preserve previous node if the message is
                           duplicated */
 
                        /* preserve previous node if the message is
                           duplicated */
@@ -1642,6 +1759,9 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                        GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo);
                        summary_set_marks_func(ctree, node, summaryview);
 
                        GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo);
                        summary_set_marks_func(ctree, node, summaryview);
 
+                       if ( MSG_GET_LABEL(msginfo->flags) )
+                         summary_set_label_color(ctree, node, (msginfo->flags & MSG_LABEL));
+
                        if (msginfo->msgid && *msginfo->msgid &&
                            g_hash_table_lookup(msgid_table, msginfo->msgid)
                            == NULL)
                        if (msginfo->msgid && *msginfo->msgid &&
                            g_hash_table_lookup(msgid_table, msginfo->msgid)
                            == NULL)
@@ -3437,6 +3557,12 @@ static void summary_subject_clicked(GtkWidget *button,
        summary_sort(summaryview, SORT_BY_SUBJECT);
 }
 
        summary_sort(summaryview, SORT_BY_SUBJECT);
 }
 
+static void summary_mark_clicked(GtkWidget *button,
+                                SummaryView *summaryview)
+{
+       summary_sort(summaryview, SORT_BY_LABEL);
+}
+
 void summary_change_display_item(SummaryView *summaryview)
 {
        GtkCList *clist = GTK_CLIST(summaryview->ctree);
 void summary_change_display_item(SummaryView *summaryview)
 {
        GtkCList *clist = GTK_CLIST(summaryview->ctree);
@@ -3578,6 +3704,15 @@ static gint summary_cmp_by_subject(GtkCList *clist,
        return strcasecmp(msginfo1->subject, msginfo2->subject);
 }
 
        return strcasecmp(msginfo1->subject, msginfo2->subject);
 }
 
+static gint summary_cmp_by_label(GtkCList *clist,
+                                gconstpointer ptr1, gconstpointer ptr2)
+{
+       MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
+
+       return MSG_GET_LABEL(msginfo1->flags) - MSG_GET_LABEL(msginfo2->flags);
+}
+
 static gint summary_cmp_by_score(GtkCList *clist,
                                 gconstpointer ptr1, gconstpointer ptr2)
 {
 static gint summary_cmp_by_score(GtkCList *clist,
                                 gconstpointer ptr1, gconstpointer ptr2)
 {
index 72cfa2f..1ec8372 100644 (file)
@@ -60,7 +60,8 @@ typedef enum
        SORT_BY_DATE,
        SORT_BY_FROM,
        SORT_BY_SUBJECT,
        SORT_BY_DATE,
        SORT_BY_FROM,
        SORT_BY_SUBJECT,
-       SORT_BY_SCORE
+       SORT_BY_SCORE,
+       SORT_BY_LABEL
 } SummarySortType;
 
 typedef enum
 } SummarySortType;
 
 typedef enum
@@ -195,5 +196,7 @@ void summary_mark_as_unread   (SummaryView          *summaryview);
 void summary_mark_as_read        (SummaryView          *summaryview);
 void summary_select_all                  (SummaryView          *summaryview);
 void summary_unselect_all        (SummaryView          *summaryview);
 void summary_mark_as_read        (SummaryView          *summaryview);
 void summary_select_all                  (SummaryView          *summaryview);
 void summary_unselect_all        (SummaryView          *summaryview);
+void summary_set_label           (SummaryView          *summaryview, guint labelcolor, GtkWidget *widget);
+void summary_set_label_color     (GtkCTree *ctree, GtkCTreeNode *node, guint labelcolor);
 
 #endif /* __SUMMARY_H__ */
 
 #endif /* __SUMMARY_H__ */