[Commits] [SCM] claws branch, gtk3tree, updated. 4.0.0-96-g78512b55a
thorsten at claws-mail.org
thorsten at claws-mail.org
Wed Aug 18 12:56:08 UTC 2021
The branch, gtk3tree has been updated
via 78512b55a6c84369b795333a54665d6a268f4f17 (commit)
via 332a9b8958a333c368e432651339c9fb7deddb20 (commit)
via 2816d7dbdcd2c81fe1097dfecc6dc8208f3c9245 (commit)
via 5e237aee3c9075b0a68003cc753ecf74233747f7 (commit)
via b8e35947d41d3c8d3613ff2e6c61b641d194ce8b (commit)
from 16e168b4e872a1425e9e9ba5016d2e00cac0a980 (commit)
Summary of changes:
src/addr_compl.c | 7 +++++-
src/alertpanel.c | 13 +++++++---
src/common/defs.h | 4 +--
src/compose.c | 8 ++++--
src/folderview.c | 5 +++-
src/gtk/gtkutils.c | 19 +++++++++-----
src/gtk/prefswindow.c | 14 ++++++++---
src/headerview.c | 1 +
src/mainwindow.c | 12 +++++++--
src/messageview.c | 1 +
src/mimeview.c | 5 ++++
src/noticeview.c | 1 +
src/prefs_themes.c | 14 +++++++----
src/summaryview.c | 11 ++++++--
src/textview.c | 69 ++++++++++++++++++++++++++++++++++++---------------
src/wizard.c | 2 +-
16 files changed, 137 insertions(+), 49 deletions(-)
- Log -----------------------------------------------------------------
commit 78512b55a6c84369b795333a54665d6a268f4f17
Merge: 16e168b4e 332a9b895
Author: Thorsten Maerz <info at netztorte.de>
Date: Wed Aug 18 14:53:07 2021 +0200
Merge branch 'gtk3' into gtk3tree
diff --cc src/folderview.c
index dd7f72f0d,a3f549236..30fb0c3d0
--- a/src/folderview.c
+++ b/src/folderview.c
@@@ -217,555 -270,334 +217,557 @@@ GtkTargetEntry folderview_drag_types[]
{"text/uri-list", 0, TARGET_MAIL_URI_LIST}
};
-void folderview_initialize(void)
+static void folderview_update_row_iter(FolderView *folderview,
+ GtkTreeIter *iter, FolderItem *item);
+
+/* Sort function for the treeview, making sure that all special
+ * folders are on top. */
+static gint folderview_compare_func(GtkTreeModel *model, GtkTreeIter *a,
+ GtkTreeIter *b, gpointer context)
+{
+ gchar *str_a = NULL, *str_b = NULL;
+#ifdef G_OS_WIN32
+ gchar *str_a_dn = NULL, *str_b_dn = NULL;
+#endif /* G_OS_WIN32 */
+ gint val = 0;
+ FolderItem *item_a = NULL, *item_b = NULL;
+ GtkTreeIter parent;
+
+ gtk_tree_model_get(model, a, F_COL_FOLDERITEM, &item_a, -1);
+ gtk_tree_model_get(model, b, F_COL_FOLDERITEM, &item_b, -1);
+
+ /* no sort for root folder */
+ if (!gtk_tree_model_iter_parent(GTK_TREE_MODEL(model), &parent, a))
+ return 0;
+
+ /* if both a and b are special folders, sort them according to
+ * their types (which is in-order). Note that this assumes that
+ * there are no multiple folders of a special type. */
+ if (item_a->stype != F_NORMAL && item_b->stype != F_NORMAL)
+ return item_a->stype - item_b->stype;
+
+ /* if b is normal folder, and a is not, b is smaller (ends up
+ * lower in the list) */
+ if (item_a->stype != F_NORMAL && item_b->stype == F_NORMAL)
+ return item_b->stype - item_a->stype;
+
+ /* if b is special folder, and a is not, b is larger (ends up
+ * higher in the list) */
+ if (item_a->stype == F_NORMAL && item_b->stype != F_NORMAL)
+ return item_b->stype - item_a->stype;
+
+ /* XXX g_utf8_collate_key() comparisons may speed things
+ * up when having large lists of folders */
+ gtk_tree_model_get(model, a, F_COL_FOLDER, &str_a, -1);
+ gtk_tree_model_get(model, b, F_COL_FOLDER, &str_b, -1);
+
+ /* otherwise just compare the folder names */
+#ifdef G_OS_WIN32
+ str_a_dn = g_utf8_casefold(str_a, -1);
+ str_b_dn = g_utf8_casefold(str_b, -1);
+ g_free(str_a);
+ g_free(str_b);
+ str_a = str_a_dn;
+ str_b = str_b_dn;
+#endif /* G_OS_WIN32 */
+ val = g_utf8_collate(str_a, str_b);
+
+ g_free(str_a);
+ g_free(str_b);
+
+ return val;
+}
+
+/****************************
+ * Treeview signal handlers *
+ ****************************/
+static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
+ gpointer user_data)
{
- FolderViewPopup *fpopup;
+ FolderView *folderview = (FolderView *)user_data;
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ GtkTreeIter iter;
+ gboolean ret;
+ FolderItem *item;
+ gboolean is_expander;
- fpopup = g_new0(FolderViewPopup, 1);
+ debug_print("button-press: button %d\n", event->button);
- fpopup->klass = "common";
- fpopup->path = "<CommonFolder>";
- fpopup->entries = folderview_common_popup_entries;
- fpopup->n_entries = G_N_ELEMENTS(folderview_common_popup_entries);
- fpopup->set_sensitivity = NULL;
+ if (event->button == 2) {
+ /* Middle-click does nothing */
+ return TRUE;
+ }
- folderview_popups = g_hash_table_new(g_str_hash, g_str_equal);
- g_hash_table_insert(folderview_popups, "common", fpopup);
+ ret = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
+ event->x, event->y,
+ &path, &column, NULL, NULL);
+ if (!ret) {
+ debug_print("clicked empty space, ignoring\n");
+ gtk_tree_path_free(path);
+ return FALSE;
+ }
+
+ folderview->data_row_clicked = TRUE; /* don't save column-widths on button-release */
+ is_expander = gtkut_tree_is_expander_clicked(GTK_TREE_VIEW(widget),
+ path, column, event->x, event->y);
+
+ if (event->button == 1) { /* Left click */
+ gtk_tree_path_free(path);
+ if (is_expander)
+ return FALSE;
+
+ if (event->type == GDK_2BUTTON_PRESS) {
+ folderview_toggle_expansion(GTK_TREE_VIEW(widget));
+ return FALSE;
+ }
+ } else if (event->button == 3) { /* Right click */
+ debug_print("will show popup menu\n");
+
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), path, NULL, FALSE);
+ /* Find out which item the click was on */
+ GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
+ gtk_tree_model_get_iter(model, &iter, path);
+ gtk_tree_path_free(path);
+ gtk_tree_model_get(model, &iter,
+ F_COL_FOLDERITEM, &item, -1);
+
+ cm_return_val_if_fail(item != NULL, FALSE);
+
+ set_sens_and_popup_menu(folderview, item, event);
+
+ /* Do not even allow the cursor to move */
+ return TRUE;
+ }
+
+ return FALSE;
}
-static GtkActionGroup *create_action_group(FolderView *folderview, FolderViewPopup *fpopup)
+static gboolean button_release_cb(GtkWidget *widget, GdkEventButton *event,
+ gpointer user_data)
{
- FolderViewPopup *fpopup_common;
- GtkActionGroup *action_group;
-
- action_group = cm_menu_create_action_group(
- fpopup->path,
- fpopup->entries, fpopup->n_entries,
- (gpointer)folderview);
+ FolderView *folderview = (FolderView *)user_data;
+ gboolean data_row_clicked = folderview->data_row_clicked;
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ gint i;
- if (fpopup->toggle_entries)
- gtk_action_group_add_toggle_actions(action_group, fpopup->toggle_entries,
- fpopup->n_toggle_entries,
- (gpointer)folderview);
- if (fpopup->radio_entries)
- gtk_action_group_add_radio_actions(action_group, fpopup->radio_entries,
- fpopup->n_radio_entries, fpopup->radio_default,
- G_CALLBACK(fpopup->radio_callback),
- (gpointer)folderview);
+ /* TM: Workaround for missing "resize_column" signal
+ * Opposed to button-press, the button-release signal is fired for
+ * headers as well, but event->y gets the SAME values, when clicked on
+ * the headers, as if clicked on the first data row. To distiguish
+ * them, data_row_clicked is set in the button-press handler.
+ */
+ folderview->data_row_clicked = FALSE;
+ /* ignore clicks on and below data rows */
+ if (data_row_clicked || !gtk_tree_view_get_path_at_pos
+ (GTK_TREE_VIEW(widget),
+ event->x, event->y, &path, NULL, NULL, NULL))
+ return FALSE;
- fpopup_common = g_hash_table_lookup(folderview_popups, "common");
- if (fpopup_common != fpopup) {
- gtk_action_group_add_actions(action_group, fpopup_common->entries,
- fpopup_common->n_entries,
- (gpointer)folderview);
- if (fpopup_common->toggle_entries)
- gtk_action_group_add_toggle_actions(action_group, fpopup_common->toggle_entries,
- fpopup_common->n_toggle_entries,
- (gpointer)folderview);
- if (fpopup_common->radio_entries)
- gtk_action_group_add_radio_actions(action_group, fpopup_common->radio_entries,
- fpopup_common->n_radio_entries, fpopup_common->radio_default,
- G_CALLBACK(fpopup_common->radio_callback),
- (gpointer)folderview);
+ /* button released on header row: save column widths */
+ for (i = F_COL_FOLDER; i <= F_COL_TOTAL; i++) {
+ column = (GtkTreeViewColumn*)g_list_nth_data
+ (treeview_default_columns_ordered,
+ i - F_COL_FOLDER);
+ prefs_common.folder_col_size[i] =
+ gtk_tree_view_column_get_width(column);
}
-
- return action_group;
+ return FALSE;
}
-static void create_action_groups(gpointer key, gpointer value, gpointer data)
+
+static void folderview_toggle_expansion(GtkTreeView *treeview)
{
- FolderView *folderview = data;
- FolderViewPopup *fpopup = value;
- GtkActionGroup *group;
+ GtkTreePath *path;
- group = create_action_group(folderview, fpopup);
- g_hash_table_insert(folderview->popups, fpopup->klass, group);
+ gtk_tree_view_get_cursor(treeview, &path, NULL);
+ if (path) {
+ if (gtk_tree_view_row_expanded(treeview, path))
+ gtk_tree_view_collapse_row(treeview, path);
+ else
+ gtk_tree_view_expand_row(treeview,path, FALSE);
+ gtk_tree_path_free(path);
+ }
}
-static void folderview_column_set_titles(FolderView *folderview)
+void folderview_open_or_expand_selected(FolderView *folderview)
{
- GtkWidget *ctree = folderview->ctree;
- GtkWidget *label_folder;
- GtkWidget *label_new;
- GtkWidget *label_unread;
- GtkWidget *label_total;
- GtkWidget *hbox_folder;
- GtkWidget *hbox_new;
- GtkWidget *hbox_unread;
- GtkWidget *hbox_total;
- gint *col_pos = folderview->col_pos;
-
- debug_print("setting titles...\n");
- gtk_widget_realize(folderview->ctree);
- gtk_widget_show_all(folderview->scrolledwin);
-
- /* CLAWS: titles for "New" and "Unread" show new & unread pixmaps
- * instead text (text overflows making them unreadable and ugly) */
- stock_pixbuf_gdk(STOCK_PIXMAP_NEW, &newxpm);
- stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD, &unreadxpm);
- stock_pixbuf_gdk(STOCK_PIXMAP_READ, &readxpm);
-
- label_folder = gtk_label_new(_("Folder"));
- label_new = gtk_image_new_from_pixbuf(newxpm);
- label_unread = gtk_image_new_from_pixbuf(unreadxpm);
- label_total = gtk_image_new_from_pixbuf(readxpm);
-
- gtk_cmclist_column_titles_active(GTK_CMCLIST(ctree));
-
- hbox_folder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
- hbox_new = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
- hbox_unread = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
- hbox_total = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
-
- /* left justified */
- gtk_box_pack_start(GTK_BOX(hbox_folder), label_folder, TRUE, TRUE, 0);
- gtk_widget_set_halign(label_folder, GTK_ALIGN_START);
- gtk_box_pack_start(GTK_BOX(hbox_new), label_new, TRUE, TRUE, 0);
- gtk_widget_set_halign(label_new, GTK_ALIGN_END);
- gtk_box_pack_start(GTK_BOX(hbox_unread), label_unread, TRUE, TRUE, 0);
- gtk_widget_set_halign(label_unread, GTK_ALIGN_END);
- gtk_box_pack_start(GTK_BOX(hbox_total), label_total, TRUE, TRUE, 0);
- gtk_widget_set_halign(label_total, GTK_ALIGN_END);
-
- gtk_widget_show_all(hbox_folder);
- gtk_widget_show_all(hbox_new);
- gtk_widget_show_all(hbox_unread);
- gtk_widget_show_all(hbox_total);
-
-#ifdef GENERIC_UMPC
- gtk_widget_set_size_request(hbox_new, -1, 20);
- gtk_widget_set_size_request(hbox_unread, -1, 20);
- gtk_widget_set_size_request(hbox_total, -1, 20);
-#endif
+ GtkTreeView *treeview = GTK_TREE_VIEW(folderview->treeview);
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- gtk_cmclist_set_column_widget(GTK_CMCLIST(ctree),col_pos[F_COL_FOLDER],hbox_folder);
- gtk_cmclist_set_column_widget(GTK_CMCLIST(ctree),col_pos[F_COL_NEW],hbox_new);
- gtk_cmclist_set_column_widget(GTK_CMCLIST(ctree),col_pos[F_COL_UNREAD],hbox_unread);
- gtk_cmclist_set_column_widget(GTK_CMCLIST(ctree),col_pos[F_COL_TOTAL],hbox_total);
+ gtk_tree_view_get_cursor(treeview, &path, &column);
-#ifdef GENERIC_UMPC
- GTK_EVENTS_FLUSH();
-#endif
+ model = gtk_tree_view_get_model(treeview);
+ if (!gtk_tree_model_get_iter(model, &iter, path)) {
+ gtk_tree_path_free(path);
+ return;
+ }
- gtk_sctree_set_column_tooltip(GTK_SCTREE(ctree), col_pos[F_COL_NEW], _("New"));
- gtk_sctree_set_column_tooltip(GTK_SCTREE(ctree), col_pos[F_COL_UNREAD], _("Unread"));
- gtk_sctree_set_column_tooltip(GTK_SCTREE(ctree), col_pos[F_COL_TOTAL], _("Total"));
+ if (gtk_tree_model_iter_has_child(model, &iter)
+ && !gtk_tree_view_row_expanded(treeview, path))
+ gtk_tree_view_expand_row(treeview, path, FALSE);
+ else
+ row_activated_cb(treeview, path, column, (gpointer)folderview);
+
+ gtk_tree_path_free(path);
}
-static gboolean folderview_popup_menu(GtkWidget *widget, gpointer data)
+void folderview_collape_or_open_parent(FolderView *folderview)
{
- FolderView *folderview = (FolderView *)data;
- GdkEventButton event;
- if (folderview_get_selected_item(folderview) == NULL)
- return FALSE;
-
- event.button = 3;
- event.time = gtk_get_current_event_time();
-
- folderview_set_sens_and_popup_menu(folderview, -1,
- &event);
+ GtkTreeView *treeview = GTK_TREE_VIEW(folderview->treeview);
+ GtkTreePath *path, *parent_path;
- return TRUE;
-}
+ gtk_tree_view_get_cursor(treeview, &path, NULL);
+ /* if expanded: collapse current row */
+ if (gtk_tree_view_row_expanded(treeview, path)) {
+ gtk_tree_view_collapse_row(treeview, path);
+ gtk_tree_path_free(path);
+ return;
+ }
-static GtkWidget *folderview_ctree_create(FolderView *folderview)
-{
- GtkWidget *ctree;
- gint *col_pos;
- FolderColumnState *col_state;
- FolderColumnType type;
- gchar *titles[N_FOLDER_COLS];
- gint i;
- GtkWidget *scrolledwin = folderview->scrolledwin;
+ /* otherwise: open parent */
+ parent_path = gtkut_tree_path_get_parent(treeview, path);
+ if (parent_path) {
+ row_activated_cb(treeview, parent_path, NULL, (gpointer)folderview);
+ gtk_tree_path_free(parent_path);
+ gtk_tree_path_free(path);
+ return;
+ }
- debug_print("creating tree...\n");
- memset(titles, 0, sizeof(titles));
+}
- col_state = prefs_folder_column_get_config();
- memset(titles, 0, sizeof(titles));
+static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
+ FolderView *folderview)
+{
+ if (!event) return FALSE;
- col_pos = folderview->col_pos;
+ if (quicksearch_has_focus(folderview->summaryview->quicksearch))
+ return FALSE;
- for (i = 0; i < N_FOLDER_COLS; i++) {
- folderview->col_state[i] = col_state[i];
- type = col_state[i].type;
- col_pos[type] = i;
+ switch (event->keyval) {
+ case GDK_KEY_Right:
+ /* expand, if collapsed. otherwise open selected folder */
+ folderview_open_or_expand_selected(folderview);
+ break;
+ case GDK_KEY_Left:
+ /* collapse, if expanded. otherwise open parent folder */
+ folderview_collape_or_open_parent(folderview);
+ break;
+ default:
+ break;
}
- titles[col_pos[F_COL_FOLDER]] = _("Folder");
- titles[col_pos[F_COL_NEW]] = _("New");
- titles[col_pos[F_COL_UNREAD]] = _("Unread");
- /* TRANSLATORS: This in Number sign in American style */
- titles[col_pos[F_COL_TOTAL]] = _("#");
+ return FALSE;
+}
+
+static gboolean cursor_changed_cb(GtkTreeView *treeview, gpointer user_data)
+{
+ FolderView *folderview = (FolderView *)user_data;
- ctree = gtk_sctree_new_with_titles(N_FOLDER_COLS, col_pos[F_COL_FOLDER],
- titles);
+ debug_print("cursor-changed\n");
- gtk_widget_set_name(GTK_WIDGET(ctree), "folderview_sctree");
+ /* Only do something if some other signal handler has indicated that
+ * a selected folder should be opened. */
- if (prefs_common.show_col_headers == FALSE)
- gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree));
+ if (folderview->open_item != NULL)
+ folderview_unselect(folderview);
+ return FALSE;
+}
- gtk_cmclist_set_selection_mode(GTK_CMCLIST(ctree), GTK_SELECTION_BROWSE);
- gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree), col_pos[F_COL_NEW],
- GTK_JUSTIFY_RIGHT);
- gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree),
- col_pos[F_COL_UNREAD],
- GTK_JUSTIFY_RIGHT);
- gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree),
- col_pos[F_COL_TOTAL],
- GTK_JUSTIFY_RIGHT);
- gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree),
- GTK_CMCTREE_EXPANDER_TRIANGLE);
+static void row_expanded_collapsed_cb(GtkTreeView *treeview, GtkTreeIter *iter,
+ GtkTreePath *path, gpointer user_data)
+{
+ FolderView *folderview = (FolderView *)user_data;
+ gboolean expanded = gtk_tree_view_row_expanded(treeview, path);
+ GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+ FolderItem *item = NULL;
+ GtkTreeIter child;
+ GtkTreePath *cpath;
- gtk_sctree_set_stripes(GTK_SCTREE(ctree), prefs_common.use_stripes_in_summaries);
- gtk_sctree_set_recursive_expand(GTK_SCTREE(ctree), FALSE);
+ debug_print("row-expanded/collapsed\n");
- gtk_cmctree_set_indent(GTK_CMCTREE(ctree), CTREE_INDENT);
- gtk_cmclist_set_compare_func(GTK_CMCLIST(ctree), folderview_clist_compare);
+ gtk_tree_model_get(model, iter,
+ F_COL_FOLDERITEM, &item, -1);
- /* don't let title buttons take key focus */
- for (i = 0; i < N_FOLDER_COLS; i++) {
- gtk_widget_set_can_focus(GTK_CMCLIST(ctree)->column[i].button, FALSE);
- gtk_cmclist_set_column_width(GTK_CMCLIST(ctree), col_pos[i],
- prefs_common.folder_col_size[i]);
- gtk_cmclist_set_column_visibility
- (GTK_CMCLIST(ctree), i, col_state[i].visible);
+ if (item == NULL)
+ return;
- g_signal_connect(G_OBJECT(GTK_CMCLIST(ctree)->column[i].button),
- "button-press-event",
- G_CALLBACK(folderview_header_button_pressed),
- folderview);
+ /* Remember if the folderitem is expanded or not, as it gets saved
+ * into folderlist.xml. */
+ item->collapsed = !expanded;
+ debug_print("%s folder '%s'\n",
+ (expanded ? ">>> expanding" : "<<< collapsing"), item->path);
+
+ folderview_update_row_iter(folderview, iter, item);
+
+ /* GtkTreeView does not remember expanded state of child rows
+ * after their parent row gets collapsed, so we need to reexpand
+ * all children as needed. */
+ if (expanded && gtk_tree_model_iter_children(model, &child, iter)) {
+ do {
+ gtk_tree_model_get(model, &child,
+ F_COL_FOLDERITEM, &item, -1);
+ if (gtk_tree_model_iter_has_child(model, &child) &&
+ item != NULL && !item->collapsed) {
+ cpath = gtk_tree_model_get_path(model, &child);
+ gtk_tree_view_expand_row(treeview, cpath, FALSE);
+ gtk_tree_path_free(cpath);
+ }
+ } while (gtk_tree_model_iter_next(model, &child));
}
+}
- g_signal_connect(G_OBJECT(ctree), "key_press_event",
- G_CALLBACK(folderview_key_pressed),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "button_press_event",
- G_CALLBACK(folderview_button_pressed),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "popup-menu",
- G_CALLBACK(folderview_popup_menu), folderview);
- g_signal_connect(G_OBJECT(ctree), "button_release_event",
- G_CALLBACK(folderview_button_released),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "tree_select_row",
- G_CALLBACK(folderview_selected), folderview);
-#ifndef GENERIC_UMPC
- /* drag-n-dropping folders on maemo is impractical as this
- * opens the folder almost everytime */
- g_signal_connect(G_OBJECT(ctree), "start_drag",
- G_CALLBACK(folderview_start_drag), folderview);
-#endif
- g_signal_connect(G_OBJECT(ctree), "drag_data_get",
- G_CALLBACK(folderview_drag_data_get),
- folderview);
+static void row_activated_cb(GtkTreeView *treeview, GtkTreePath *path,
+ GtkTreeViewColumn *column, gpointer user_data)
+{
+ FolderView *folderview = (FolderView *)user_data;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+ FolderItem *item;
- g_signal_connect_after(G_OBJECT(ctree), "tree_expand",
- G_CALLBACK(folderview_tree_expanded),
- folderview);
- g_signal_connect_after(G_OBJECT(ctree), "tree_collapse",
- G_CALLBACK(folderview_tree_collapsed),
- folderview);
+ debug_print("row-activated\n");
- g_signal_connect(G_OBJECT(ctree), "resize_column",
- G_CALLBACK(folderview_col_resized),
- folderview);
+ if (folderview->open_path)
+ gtk_tree_path_free(folderview->open_path);
+ folderview->open_path = gtk_tree_path_copy(path);
+ gtk_tree_model_get_iter(model, &iter, path);
+ gtk_tree_model_get(model, &iter,
+ F_COL_FOLDERITEM, &item, -1);
- /* drop callback */
- gtk_drag_dest_set(ctree, GTK_DEST_DEFAULT_ALL & ~GTK_DEST_DEFAULT_HIGHLIGHT,
- folderview_drag_types, 2,
- GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_DEFAULT);
- g_signal_connect(G_OBJECT(ctree), "drag_motion",
- G_CALLBACK(folderview_drag_motion_cb),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "drag_leave",
- G_CALLBACK(folderview_drag_leave_cb),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "drag_data_received",
- G_CALLBACK(folderview_drag_received_cb),
- folderview);
- g_signal_connect(G_OBJECT(ctree), "drag_end",
- G_CALLBACK(folderview_drag_end_cb),
- folderview);
+ folderview_open(folderview, item);
+ folderview_update_row(folderview, item);
+
+ /* CLAWS: set compose button type: news folder items
+ * always have a news folder as parent */
+ if (item->folder)
+ toolbar_set_compose_button
+ (folderview->mainwin->toolbar,
+ FOLDER_TYPE(item->folder) == F_NEWS ?
+ COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
- gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
+ if (item->path)
+ debug_print("Folder %s is selected\n", item->path);
+
+ /* TM: Why expand, if there are no children?
+ if (!GTK_CMCTREE_ROW(row)->children)
+ gtk_cmctree_expand(ctree, row);
+ */
- return ctree;
+ /* ungrab the mouse event */
+ /* TM: disabled - grab_add was done by ctree
+ if (gtk_widget_has_grab(GTK_WIDGET(treeview))) {
+ gtk_grab_remove(GTK_WIDGET(treeview));
+ if (gdk_pointer_is_grabbed())
+ gdk_pointer_ungrab(GDK_CURRENT_TIME);
+ } */
}
-void folderview_set_column_order(FolderView *folderview)
+/***********************************
+ * End of treeview signal handlers *
+ ***********************************/
+
+static gboolean hook_folder_item_update(gpointer source,
+ gpointer data)
{
- GtkWidget *ctree = folderview->ctree;
- FolderItem *item = folderview_get_selected_item(folderview);
- FolderItem *sel_item = NULL, *op_item = NULL;
- GtkWidget *scrolledwin = folderview->scrolledwin;
+ FolderItemUpdateData *update_info = (FolderItemUpdateData *)source;
+ FolderView *folderview = (FolderView *)data;
- if (folderview->drag_timer_id != 0) {
- g_source_remove(folderview->drag_timer_id);
- folderview->drag_timer_id = 0;
- }
- if (folderview->deferred_refresh_id != 0) {
- g_source_remove(folderview->deferred_refresh_id);
- folderview->deferred_refresh_id = 0;
- }
- if (folderview->scroll_timeout_id != 0) {
- g_source_remove(folderview->scroll_timeout_id);
- folderview->scroll_timeout_id = 0;
+ debug_print("hook_folder_item_update\n");
+
+ cm_return_val_if_fail(update_info != NULL, TRUE);
+ cm_return_val_if_fail(update_info->item != NULL, TRUE);
+ cm_return_val_if_fail(folderview != NULL, FALSE);
+
+ if (update_info->update_flags & (F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_NAME)) {
+ folderview_update_row(folderview, update_info->item);
}
- if (folderview->postpone_select_id != 0) {
- g_source_remove(folderview->postpone_select_id);
- folderview->postpone_select_id = 0;
+
+ if ((update_info->update_flags & F_ITEM_UPDATE_CONTENT) &&
+ update_info->item == folderview->summaryview->folder_item) {
+ if (!quicksearch_has_sat_predicate(folderview->summaryview->quicksearch))
+ summary_show(folderview->summaryview, update_info->item, FALSE);
}
- if (folderview->selected)
- sel_item = folderview_get_selected_item(folderview);
- if (folderview->opened)
- op_item = folderview_get_opened_item(folderview);
+ return FALSE;
+}
+
+static gboolean hook_folder_update(gpointer source,
+ gpointer data)
+{
+ FolderUpdateData *hookdata = (FolderUpdateData *)source;
+ FolderView *folderview = (FolderView *)data;
- debug_print("recreating tree...\n");
- gtk_widget_destroy(folderview->ctree);
+ debug_print("hook_folder_update\n");
+ cm_return_val_if_fail(hookdata != NULL, FALSE);
+ cm_return_val_if_fail(folderview != NULL, FALSE);
- folderview->ctree = ctree = folderview_ctree_create(folderview);
- gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_CMCLIST(ctree)->hadjustment);
- gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_CMCLIST(ctree)->vadjustment);
- gtk_widget_show(ctree);
-
- if (sel_item)
- folderview->selected = gtk_cmctree_find_by_row_data(GTK_CMCTREE(ctree), NULL, sel_item);
- if (op_item)
- folderview->opened = gtk_cmctree_find_by_row_data(GTK_CMCTREE(ctree), NULL, op_item);
+ if (hookdata->update_flags & FOLDER_ADD_FOLDERITEM) {
+ debug_print("hook_folder_update ADD FOLDERITEM '%s'\n", hookdata->item->name);
+ folderview_add_folderitem(folderview, hookdata->item);
+ } else if (hookdata->update_flags & FOLDER_RENAME_FOLDERITEM) {
+ debug_print("hook_folder_update RENAME FOLDERITEM '%s'\n", hookdata->item->name);
+ folderview_update_row(folderview, hookdata->item);
+ } else if (hookdata->update_flags & FOLDER_REMOVE_FOLDERITEM) {
+ debug_print("hook_folder_update REMOVE FOLDERITEM '%s'\n", hookdata->item->name);
+ if (hookdata->item == folderview->open_item) {
+ debug_print("closing open item before removing it\n");
+ folderview_close_opened(folderview, FALSE);
+ }
+ folderview_remove_folderitem(folderview, hookdata->item);
+ } else if (hookdata->update_flags & FOLDER_MOVE_FOLDERITEM) {
+ debug_print("hook_folder_update MOVE FOLDERITEM '%s'\n", hookdata->item->name);
+ /* do nothing, it's done by the ADD and REMOVE) */
+ } else if (hookdata->update_flags &
+ (FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDER | FOLDER_REMOVE_FOLDER)) {
+ debug_print("hook_folder_update OTHER\n");
+ folderview_set(folderview);
+ }
- folderview_set(folderview);
- folderview_column_set_titles(folderview);
+ return FALSE;
+}
- folderview_select(folderview,item);
+/* Helper function for folderview_create()
+ * Sets up the treeview widget, minus connecting the signal handlers. */
+static GtkWidget *treeview_create_unconnected()
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer, *text_renderer;
+ GtkWidget *image;
+ GdkPixbuf *new_pixbuf;
+ GdkPixbuf *unread_pixbuf = NULL;
+ GdkPixbuf *total_pixbuf = NULL;
+
+ debug_print("treeview_create_unconnected\n");
+
+ stock_pixbuf_gdk(STOCK_PIXMAP_NEW, &new_pixbuf);
+ stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD, &unread_pixbuf);
+ stock_pixbuf_gdk(STOCK_PIXMAP_READ, &total_pixbuf);
+
+ GtkTreeStore *store = gtk_tree_store_new(N_FOLDER_COLS,
+ G_TYPE_POINTER, /* pointer to FolderItem */
+ PANGO_TYPE_FONT_DESCRIPTION, /* font */
+ GDK_TYPE_RGBA, /* text color */
+ GDK_TYPE_PIXBUF, /* icon */
+ G_TYPE_STRING, /* folder name */
+ G_TYPE_STRING, /* new */
+ G_TYPE_STRING, /* unread */
+ G_TYPE_STRING, /* total */
+ PANGO_TYPE_ALIGNMENT); /* alignment of the column text */
+ gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store),
+ F_COL_FOLDER, folderview_compare_func, NULL, NULL);
+
+ GtkWidget *treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ g_object_unref(store);
+
++ gtk_widget_set_name(GTK_WIDGET(treeview), "folderview_treeview");
++
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), TRUE);
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview),
+ prefs_common.use_stripes_in_summaries);
+ gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(treeview), TRUE);
+ gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), F_COL_FOLDER);
+
+ /* Icon */
+ column = gtk_tree_view_column_new();
+ renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_renderer_set_padding(renderer, 0, 0);
+ gtk_tree_view_column_pack_start(column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "pixbuf", F_COL_ICON,
+ NULL);
+
+ /* Folder name */
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_renderer_set_padding(renderer, 4, 0);
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "text", F_COL_FOLDER,
+ "font-desc", F_COL_FONT,
+ "foreground-rgba", F_COL_COLOR,
+ NULL);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_fixed_width(column, prefs_common.folder_col_size[F_COL_FOLDER]);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_expand(column, TRUE);
+ gtk_tree_view_column_set_title(column, _("Folder"));
+
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ treeview_default_columns_ordered = g_list_append
+ (treeview_default_columns_ordered, column);
+
+ /* New */
+ column = gtk_tree_view_column_new();
+ renderer = text_renderer = gtk_cell_renderer_text_new();
+ gtk_cell_renderer_set_padding(renderer, 0, 0);
+ gtk_cell_renderer_set_alignment(renderer, 1, 0);
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "text", F_COL_NEW,
+ "font-desc", F_COL_FONT,
+ "foreground-rgba", F_COL_COLOR,
+ NULL);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_fixed_width(column, prefs_common.folder_col_size[F_COL_NEW]);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_expand(column, FALSE);
+ image = gtk_image_new_from_pixbuf(new_pixbuf);
+ gtk_widget_show(image);
+ gtk_tree_view_column_set_widget(column, image);
+
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ treeview_default_columns_ordered = g_list_append
+ (treeview_default_columns_ordered, column);
+
+ /* Unread */
+ column = gtk_tree_view_column_new();
+ renderer = text_renderer;
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "text", F_COL_UNREAD,
+ "font-desc", F_COL_FONT,
+ "foreground-rgba", F_COL_COLOR,
+ NULL);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_fixed_width(column, prefs_common.folder_col_size[F_COL_UNREAD]);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_expand(column, FALSE);
+ image = gtk_image_new_from_pixbuf(unread_pixbuf);
+ gtk_widget_show(image);
+ gtk_tree_view_column_set_widget(column, image);
+
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ treeview_default_columns_ordered = g_list_append
+ (treeview_default_columns_ordered, column);
+
+ /* Total */
+ column = gtk_tree_view_column_new();
+ renderer = text_renderer;
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "text", F_COL_TOTAL,
+ "font-desc", F_COL_FONT,
+ "foreground-rgba", F_COL_COLOR,
+ NULL);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_fixed_width(column, prefs_common.folder_col_size[F_COL_TOTAL]);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_expand(column, FALSE);
+ image = gtk_image_new_from_pixbuf(total_pixbuf);
+ gtk_widget_show(image);
+ gtk_tree_view_column_set_widget(column, image);
+
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ treeview_default_columns_ordered = g_list_append
+ (treeview_default_columns_ordered, column);
+
+ return treeview;
}
FolderView *folderview_create(MainWindow *mainwin)
@@@ -777,23 -608,9 +779,24 @@@
debug_print("Creating folder view...\n");
folderview = g_new0(FolderView, 1);
+
+ folderview->mainwin = mainwin;
+ folderview->summaryview = mainwin->summaryview;
+
+ folderview->normal_font = NULL;
+ folderview->bold_font = NULL;
+
+ folderview->open_item = NULL;
+ folderview->menu_item = NULL;
+ folderview->open_path = gtk_tree_path_new_from_string("0");
+
+ folderview->data_row_clicked = FALSE;
+
+ folderview->popups = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_foreach(folderview_popups, create_action_groups, folderview);
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_set_name(GTK_WIDGET(scrolledwin), "folderview");
gtk_scrolled_window_set_policy
(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_POLICY_AUTOMATIC,
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list