From: Paul Mangan Date: Sun, 1 Jul 2001 19:27:01 +0000 (+0000) Subject: colour message instead of mark it X-Git-Tag: VERSION_0_5_0~32 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=bdcd9dc77e9ba49329dd63bebad191f327f90fdf colour message instead of mark it --- diff --git a/AUTHORS b/AUTHORS index 9850a8008..c66bed4a9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -66,4 +66,4 @@ contributors (beside the above; based on Changelog) Wakai Rodrigo Dias Arruda Senra Fabio Junior Beneditto - + Satoshi Nagayasu diff --git a/ChangeLog.claws b/ChangeLog.claws index d299b9431..d6caa3a78 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/src/mainwindow.c b/src/mainwindow.c index 6ce2ca04c..b5a19fbee 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -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 _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL}, {N_("/_Summary/_Sort/---"), NULL, NULL, 0, ""}, {N_("/_Summary/_Sort/_Attract by subject"), NULL, attract_by_subject_cb, 0, NULL}, diff --git a/src/procmsg.h b/src/procmsg.h index 8b8866c2c..7dbc1340e 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -45,6 +45,16 @@ typedef enum 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, @@ -60,6 +70,7 @@ typedef enum MSG_DELETED | \ MSG_REPLIED | \ MSG_FORWARDED | \ + MSG_LABEL | \ 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_GET_LABEL(msg) (msg & MSG_LABEL) + #define WRITE_CACHE_DATA_INT(n, fp) \ fwrite(&n, sizeof(n), 1, fp) diff --git a/src/summaryview.c b/src/summaryview.c index dcdf73fe6..923961085 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -266,6 +266,8 @@ static void summary_from_clicked (GtkWidget *button, 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, @@ -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_label (GtkCList *clist, + gconstpointer ptr1, + gconstpointer ptr2); 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_("/_Label"), NULL, NULL, 0, ""}, + {N_("/_Label/None"), NULL, summary_set_label, MSG_LABEL_NONE, NULL}, + {N_("/_Label/---"), NULL, NULL, 0, ""}, + {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, ""}, {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} }; +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; @@ -467,6 +571,11 @@ SummaryView *summary_create(void) "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); @@ -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, "/Label", TRUE); + 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_LABEL: + cmp_func = (GtkCListCompareFunc)summary_cmp_by_label; + break; 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); + + if ( MSG_GET_LABEL(msginfo->flags) ) + summary_set_label_color(ctree, node, (msginfo->flags & MSG_LABEL)); /* 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); + 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) @@ -3437,6 +3557,12 @@ static void summary_subject_clicked(GtkWidget *button, 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); @@ -3578,6 +3704,15 @@ static gint summary_cmp_by_subject(GtkCList *clist, 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) { diff --git a/src/summaryview.h b/src/summaryview.h index 72cfa2f49..1ec837214 100644 --- a/src/summaryview.h +++ b/src/summaryview.h @@ -60,7 +60,8 @@ typedef enum SORT_BY_DATE, SORT_BY_FROM, SORT_BY_SUBJECT, - SORT_BY_SCORE + SORT_BY_SCORE, + SORT_BY_LABEL } 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_set_label (SummaryView *summaryview, guint labelcolor, GtkWidget *widget); +void summary_set_label_color (GtkCTree *ctree, GtkCTreeNode *node, guint labelcolor); #endif /* __SUMMARY_H__ */