/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2018 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static GList *folderview_list = NULL;
-static GtkStyle *normal_style;
-static GtkStyle *normal_color_style;
static GtkStyle *bold_style;
-static GtkStyle *bold_color_style;
-static GtkStyle *bold_tgtfold_style;
static GdkPixbuf *inboxxpm;
static GdkPixbuf *inboxhrmxpm;
static void folderview_processing_cb(GtkAction *action, gpointer data);
static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row,
GdkEventButton *event);
+static void folderview_header_set_displayed_columns_cb(GtkAction *gaction,
+ gpointer data);
+static gboolean folderview_header_button_pressed(GtkWidget *widget,
+ GdkEvent *_event,
+ gpointer user_data);
GHashTable *folderview_popups;
};
+static GtkActionEntry folderview_header_popup_entries[] =
+{
+ {"FolderViewHeaderPopup", NULL, "FolderViewHeaderPopup", NULL, NULL, NULL },
+ {"FolderViewHeaderPopup/SetDisplayedColumns", NULL, N_("Set Displayed columns"), NULL, NULL, G_CALLBACK(folderview_header_set_displayed_columns_cb) }
+};
+
GtkTargetEntry folderview_drag_types[] =
{
{"claws-mail/internal", GTK_TARGET_SAME_APP, TARGET_DUMMY},
gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree),
col_pos[F_COL_TOTAL],
GTK_JUSTIFY_RIGHT);
- gtk_cmctree_set_line_style(GTK_CMCTREE(ctree), GTK_CMCTREE_LINES_NONE);
gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree),
GTK_CMCTREE_EXPANDER_TRIANGLE);
prefs_common.folder_col_size[i]);
gtk_cmclist_set_column_visibility
(GTK_CMCLIST(ctree), i, col_state[i].visible);
+
+ g_signal_connect(G_OBJECT(GTK_CMCLIST(ctree)->column[i].button),
+ "button-press-event",
+ G_CALLBACK(folderview_header_button_pressed),
+ folderview);
}
g_signal_connect(G_OBJECT(ctree), "key_press_event",
folderview_select(folderview,item);
}
-FolderView *folderview_create(void)
+FolderView *folderview_create(MainWindow *mainwin)
{
FolderView *folderview;
GtkWidget *scrolledwin;
folderview->popups = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_foreach(folderview_popups, create_action_groups, folderview);
+ gtk_action_group_add_actions(mainwin->action_group,
+ folderview_header_popup_entries,
+ G_N_ELEMENTS(folderview_header_popup_entries),
+ (gpointer)folderview);
+
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus", "FolderViewHeaderPopup", "FolderViewHeaderPopup", GTK_UI_MANAGER_MENU)
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/FolderViewHeaderPopup", "SetDisplayedColumns", "FolderViewHeaderPopup/SetDisplayedColumns", GTK_UI_MANAGER_MENUITEM)
+
+ folderview->headerpopupmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
+ gtk_ui_manager_get_widget(mainwin->ui_manager,
+ "/Menus/FolderViewHeaderPopup") ));
+
folderview->ctree = ctree;
folderview->folder_update_callback_id =
return folderview;
}
-void folderview_init(FolderView *folderview)
+static void folderview_set_fonts(FolderView *folderview)
{
+ PangoFontDescription *font_desc;
GtkWidget *ctree = folderview->ctree;
- GdkColor gdk_color;
- PangoFontDescription *normal_font;
+ font_desc = pango_font_description_from_string(NORMAL_FONT);
+ if (font_desc) {
+ gtk_widget_modify_font(ctree, font_desc);
+ pango_font_description_free(font_desc);
+ }
+
+ if (!bold_style) {
+ bold_style = gtk_style_copy(gtk_widget_get_style(ctree));
+
+ if (prefs_common.derive_from_normal_font || !BOLD_FONT) {
+ font_desc = pango_font_description_from_string(NORMAL_FONT);
+ if (font_desc) {
+ pango_font_description_free(bold_style->font_desc);
+ bold_style->font_desc = font_desc;
+ }
+ pango_font_description_set_weight
+ (bold_style->font_desc, PANGO_WEIGHT_BOLD);
+ } else {
+ font_desc = pango_font_description_from_string(BOLD_FONT);
+ if (font_desc) {
+ pango_font_description_free(bold_style->font_desc);
+ bold_style->font_desc = font_desc;
+ }
+ }
+ }
+}
+
+void folderview_init(FolderView *folderview)
+{
stock_pixbuf_gdk(STOCK_PIXMAP_INBOX_CLOSE, &inboxxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_INBOX_CLOSE_HRM, &inboxhrmxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_INBOX_OPEN, &inboxopenxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_DIR_SUBS_CLOSE_MARK, &m_foldersubsxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_DIR_NOSELECT_CLOSE_MARK, &m_foldernoselectxpm);
- normal_font = pango_font_description_from_string(NORMAL_FONT);
- if (normal_font) {
- gtk_widget_modify_font(ctree, normal_font);
- pango_font_description_free(normal_font);
- }
- gtk_cmclist_set_row_height(GTK_CMCLIST(ctree), 0);
-
- if (!normal_style) {
- PangoFontDescription *font_desc;
- normal_style = gtk_style_copy(gtk_widget_get_style(ctree));
- font_desc = pango_font_description_from_string(NORMAL_FONT);
- if (font_desc) {
- if (normal_style->font_desc)
- pango_font_description_free
- (normal_style->font_desc);
- normal_style->font_desc = font_desc;
- }
- gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW], &gdk_color);
- normal_color_style = gtk_style_copy(normal_style);
- normal_color_style->text[GTK_STATE_NORMAL] = gdk_color;
- }
-
- if (!bold_style) {
- gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW], &gdk_color);
- bold_style = gtk_style_copy(gtk_widget_get_style(ctree));
- if (prefs_common.derive_from_normal_font || !BOLD_FONT) {
- PangoFontDescription *font_desc;
- font_desc = pango_font_description_from_string(NORMAL_FONT);
- if (font_desc) {
- pango_font_description_free(bold_style->font_desc);
- bold_style->font_desc = font_desc;
- }
- pango_font_description_set_weight
- (bold_style->font_desc, PANGO_WEIGHT_BOLD);
- } else {
- PangoFontDescription *font_desc;
- font_desc = pango_font_description_from_string(BOLD_FONT);
- if (font_desc) {
- if (bold_style->font_desc)
- pango_font_description_free
- (bold_style->font_desc);
- bold_style->font_desc = font_desc;
- }
- }
- bold_color_style = gtk_style_copy(bold_style);
- bold_color_style->text[GTK_STATE_NORMAL] = gdk_color;
-
- bold_tgtfold_style = gtk_style_copy(bold_style);
- bold_tgtfold_style->text[GTK_STATE_NORMAL] = folderview->color_op;
- }
+ folderview_set_fonts(folderview);
}
static gboolean folderview_defer_set(gpointer data)
if (read) {
if (recursive)
- folderutils_mark_all_read_recursive(item);
+ folderutils_mark_all_read_recursive(item, TRUE);
else
- folderutils_mark_all_read(item);
+ folderutils_mark_all_read(item, TRUE);
} else {
if (recursive)
- folderutils_mark_all_unread_recursive(item);
+ folderutils_mark_all_read_recursive(item, FALSE);
else
- folderutils_mark_all_unread(item);
+ folderutils_mark_all_read(item, FALSE);
}
if (folderview->summaryview->folder_item != item && !recursive)
summary_unlock(folderview->summaryview);
static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
{
GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
- GtkStyle *style = NULL;
- GtkStyle *color_style = NULL;
+ GtkStyle *style = NULL, *prev_style;
FolderItem *item;
GdkPixbuf *xpm, *openxpm;
static GdkPixbuf *searchicon;
gboolean use_bold, use_color;
gint *col_pos = folderview->col_pos;
SpecialFolderItemType stype;
+ GdkColor gdk_color;
item = gtk_cmctree_node_get_row_data(ctree, node);
cm_return_if_fail(item != NULL);
gtk_cmctree_node_set_foreground(ctree, node, NULL);
if (use_bold) {
- GdkColor gdk_color;
-
- if (item->prefs->color > 0 && !use_color) {
+ style = bold_style;
+ if (use_color) {
+ gtk_cmctree_node_set_foreground(ctree, node, &folderview->color_new);
+ } else if (item->op_count > 0) {
+ gtk_cmctree_node_set_foreground(ctree, node, &folderview->color_op);
+ } else if (item->prefs->color != 0) {
gtkut_convert_int_to_gdk_color(item->prefs->color, &gdk_color);
- color_style = gtk_style_copy(bold_style);
- color_style->text[GTK_STATE_NORMAL] = gdk_color;
- style = color_style;
- } else if (use_color) {
- style = bold_color_style;
- } else
- style = bold_style;
- if (item->op_count > 0) {
- style = bold_tgtfold_style;
+ gtk_cmctree_node_set_foreground(ctree, node, &gdk_color);
}
} else if (use_color) {
- style = normal_color_style;
- gtk_cmctree_node_set_foreground(ctree, node,
- &folderview->color_new);
+ gtk_cmctree_node_set_foreground(ctree, node, &folderview->color_new);
} else if (item->op_count > 0) {
- style = bold_tgtfold_style;
- } else if (item->prefs->color > 0) {
- GdkColor gdk_color;
+ gtk_cmctree_node_set_foreground(ctree, node, &folderview->color_op);
+ } else if (item->prefs->color != 0) {
gtkut_convert_int_to_gdk_color(item->prefs->color, &gdk_color);
- color_style = gtk_style_copy(normal_style);
- color_style->text[GTK_STATE_NORMAL] = gdk_color;
- style = color_style;
- } else {
- style = normal_style;
+ gtk_cmctree_node_set_foreground(ctree, node, &gdk_color);
}
gtk_cmctree_node_set_row_style(ctree, node, style);
+ prev_style = gtk_cmctree_node_get_row_style(ctree, node);
+ if (prev_style) {
+ GtkStyle *ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
+
+ style = gtk_style_copy(prev_style);
+ style->text[GTK_STATE_NORMAL] = ctree_style->text[GTK_STATE_NORMAL];
+ style->text[GTK_STATE_SELECTED] = ctree_style->text[GTK_STATE_SELECTED];
+ gtk_cmctree_node_set_row_style(ctree, node, style);
+ g_object_unref(style);
+ }
+
if ((node = gtkut_ctree_find_collapsed_parent(ctree, node)) != NULL)
folderview_update_node(folderview, node);
}
gint prev_row = -1, row = -1, column = -1;
if (!event) return FALSE;
+ if (event->window != clist->clist_window) return FALSE;
if (event->button == 1 || event->button == 2) {
if (!gtk_sctree_is_hot_spot (GTK_SCTREE(clist), event->x, event->y))
break;
case GDK_KEY_Left:
if (folderview->selected) {
- if (GTK_CMCTREE_ROW(folderview->selected)->expanded) {
+ /* If the folder is expanded and can be collapsed, do that... */
+ if (GTK_CMCTREE_ROW(folderview->selected)->expanded &&
+ GTK_CMCTREE_ROW(folderview->selected)->children != NULL) {
gtk_cmctree_collapse(GTK_CMCTREE(folderview->ctree),
folderview->selected);
} else {
+ /* ...otherwise, move cursor to its parent node. */
if ((item = gtk_cmctree_node_get_row_data(GTK_CMCTREE(folderview->ctree),
folderview->selected))) {
if ((node = gtk_cmctree_find_by_row_data(GTK_CMCTREE(folderview->ctree),
FALSE, FALSE);
gtk_cmctree_expand(ctree, parent_node);
gtk_cmctree_node_set_row_data(ctree, node, item);
- if (normal_style)
- gtk_cmctree_node_set_row_style(ctree, node, normal_style);
folderview_sort_folders(folderview, parent_node, item->folder);
hookdata.item = item;
void folderview_set_target_folder_color(gint color_op)
{
- gint firstone = 1;
GList *list;
FolderView *folderview;
for (list = folderview_list; list != NULL; list = list->next) {
folderview = (FolderView *)list->data;
gtkut_convert_int_to_gdk_color(color_op, &folderview->color_op);
- if (firstone) {
- bold_tgtfold_style->text[GTK_STATE_NORMAL] =
- folderview->color_op;
- firstone = 0;
- }
}
}
GTK_SCROLLED_WINDOW(folderview->scrolledwin));
gint height = gtk_adjustment_get_value(pos);
+ gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW],
+ &folderview->color_new);
+ gtkut_convert_int_to_gdk_color(prefs_common.color[COL_TGT_FOLDER],
+ &folderview->color_op);
+
if (!last_smallfont || strcmp(last_smallfont, SMALL_FONT) ||
!last_normalfont || strcmp(last_normalfont, NORMAL_FONT) ||
!last_boldfont || strcmp(last_boldfont, BOLD_FONT) ||
s = NULL; \
}
- STYLE_FREE(normal_style);
- STYLE_FREE(normal_color_style);
STYLE_FREE(bold_style);
- STYLE_FREE(bold_color_style);
- STYLE_FREE(bold_tgtfold_style);
#undef STYLE_FREE
- folderview_init(folderview);
+ folderview_set_fonts(folderview);
+
gtk_cmclist_freeze(GTK_CMCLIST(folderview->ctree));
folderview_column_set_titles(folderview);
folderview_set_all();
g_slist_free(msglist);
gtk_drag_finish(drag_context, TRUE, FALSE, time);
} else {
- gtk_drag_finish(drag_context, FALSE, FALSE, time);
+ gtk_drag_finish(drag_context, FALSE, FALSE, time);
}
- list_free_strings(list);
- g_list_free(list);
+ list_free_strings_full(list);
}
static void folderview_drag_received_cb(GtkWidget *widget,
src_item && src_item != item && FOLDER_CLASS(item->folder)->copy_msg != NULL)) {
return;
}
- if (item && src_item) {
- switch (gdk_drag_context_get_selected_action(drag_context)) {
- case GDK_ACTION_COPY:
+
+ switch (gdk_drag_context_get_selected_action(drag_context)) {
+ case GDK_ACTION_COPY:
+ summary_copy_selected_to(folderview->summaryview, item);
+ gtk_drag_finish(drag_context, TRUE, FALSE, time);
+ break;
+ case GDK_ACTION_MOVE:
+ case GDK_ACTION_DEFAULT:
+ default:
+ if (FOLDER_CLASS(src_item->folder)->remove_msg == NULL)
summary_copy_selected_to(folderview->summaryview, item);
- gtk_drag_finish(drag_context, TRUE, FALSE, time);
- break;
- case GDK_ACTION_MOVE:
- case GDK_ACTION_DEFAULT:
- default:
- if (FOLDER_CLASS(src_item->folder)->remove_msg == NULL)
- summary_copy_selected_to(folderview->summaryview, item);
- else
- summary_move_selected_to(folderview->summaryview, item);
- gtk_drag_finish(drag_context, TRUE, TRUE, time);
- }
- } else
- gtk_drag_finish(drag_context, FALSE, FALSE, time);
+ else
+ summary_move_selected_to(folderview->summaryview, item);
+ gtk_drag_finish(drag_context, TRUE, TRUE, time);
+ }
} else {
/* comes from folderview */
char *source;
if (folderview)
gtk_widget_grab_focus(folderview->ctree);
}
+
+static void folderview_header_set_displayed_columns_cb(GtkAction *gaction,
+ gpointer data)
+{
+ prefs_folder_column_open();
+}
+
+static gboolean folderview_header_button_pressed(GtkWidget *widget,
+ GdkEvent *_event,
+ gpointer user_data)
+{
+ GdkEventButton *event = (GdkEventButton *)_event;
+ FolderView *folderview = (FolderView *)user_data;
+
+ cm_return_val_if_fail(folderview != NULL, FALSE);
+
+ /* Only handle single button presses. */
+ if (event->type == GDK_2BUTTON_PRESS ||
+ event->type == GDK_3BUTTON_PRESS)
+ return FALSE;
+
+ /* Handle right-click for context menu */
+ if (event->button == 3) {
+ gtk_menu_popup(GTK_MENU(folderview->headerpopupmenu),
+ NULL, NULL, NULL, NULL, 3, event->time);
+ return TRUE;
+ }
+
+ return FALSE;
+}