[Commits] Patch to support customisation of summary row height

Folling coding at folling.de
Sun Oct 9 12:12:22 UTC 2022


Hello all,

this is my first ever contribution to an open source project, pardon if I'm
missing any etiquette or part of the process.

This patch does two things:

1. It allows the user to override the row height of the summary view table. A
value of 0 will reset it to the default height, this appears to be aligned with
the default behaivour of GtkCMCTree. A better UX, to my mind, would
be to display the default value in the field and add a "reset to default" button
next to it, but this should do for now.
2. It fixes the drawing of the tree expander arrow. "Fix" here is subjective, I
believe the original implementation was broken, but maybe it was supposed to be
offset by some magical margin. It is now always centred in the middle of the
row.

At the end you can find the actual patch data (generated with git diff -u as
requested). Note, it does not compile without warnings, but those warnings are
not generated by my code and should probably be addressed elsewhere.

diff --git a/src/gtk/gtkcmctree.c b/src/gtk/gtkcmctree.c
index 78e3ddab6..a9df5dadd 100644
--- a/src/gtk/gtkcmctree.c
+++ b/src/gtk/gtkcmctree.c
@@ -432,12 +432,8 @@ draw_expander (GtkCMCTree     *ctree,
     justification_factor = -1;
   else
     justification_factor = 1;
-  if (!GTK_CMCLIST_ROW_HEIGHT_SET(GTK_CMCLIST(clist)))
-      y = (clip_rectangle->y + (clip_rectangle->height - PM_SIZE) / 2 -
-          (clip_rectangle->height + 1) % 2) + 1;
-  else
-      y = (clip_rectangle->y + (clip_rectangle->height/2 - PM_SIZE) / 2 -
-          (clip_rectangle->height/2 + 1) % 2) + 1;
+
+  y = clip_rectangle->y + (clip_rectangle->height - PM_SIZE) / 2;
 
   if (!ctree_row->children)
     {
diff --git a/src/prefs_common.c b/src/prefs_common.c
index 02eb41c0a..abcd31bbd 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -642,6 +642,9 @@ static PrefParam param[] = {
 	{"summaryview_height", "244", &prefs_common.summaryview_height, P_INT,
 	 NULL, NULL, NULL},
 
+	{"summary_row_height", "0", &prefs_common.summary_row_height, P_INT,
+	 NULL, NULL, NULL},
+
 	{"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
 	 NULL, NULL, NULL},
 	{"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
diff --git a/src/prefs_common.h b/src/prefs_common.h
index 0d5220f02..736373e7a 100644
--- a/src/prefs_common.h
+++ b/src/prefs_common.h
@@ -315,6 +315,8 @@ struct _PrefsCommon
 	gint summaryview_width;
 	gint summaryview_height;
 
+	gint summary_row_height;
+
 	gint main_msgwin_x;
 	gint main_msgwin_y;
 	gint msgview_width;
diff --git a/src/prefs_summaries.c b/src/prefs_summaries.c
index 4939830a5..0fae91c4f 100644
--- a/src/prefs_summaries.c
+++ b/src/prefs_summaries.c
@@ -52,6 +52,7 @@ typedef struct _SummariesPage
 
 	GtkWidget *optmenu_folder_unread;
 	GtkWidget *spinbtn_ng_abbrev_len;
+	GtkWidget *spinbtn_summary_row_height;
 	GtkWidget *checkbtn_useaddrbook;
 	GtkWidget *checkbtn_show_tooltips;
 	GtkWidget *checkbtn_threadsubj;
@@ -330,7 +331,10 @@ static void prefs_summaries_create_widget(PrefsPage
*_page, GtkWindow *window, GtkWidget *optmenu_folder_unread;
 	GtkWidget *label_ng_abbrev;
 	GtkWidget *spinbtn_ng_abbrev_len;
+	GtkWidget *spinbtn_summary_row_height;
+	GtkWidget *label_summary_row_height;
 	GtkAdjustment *spinbtn_ng_abbrev_len_adj;
+	GtkAdjustment *spinbtn_summary_row_height_adj;
 	GtkWidget *checkbtn_useaddrbook;
 	GtkWidget *checkbtn_show_tooltips;
 	GtkWidget *checkbtn_threadsubj;
@@ -607,9 +611,27 @@ static void prefs_summaries_create_widget(PrefsPage
*_page, GtkWindow *window, (vbox1, checkbtn_show_tooltips,
 		 _("Show tooltips"));
 
-	hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
-	gtk_widget_show (hbox2);
-	gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
+	hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
+	gtk_widget_show (hbox1);
+	gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
+
+	label_summary_row_height = gtk_label_new
+		(_("Override the default summary row height"));
+	gtk_widget_show (label_summary_row_height);
+	gtk_box_pack_start (GTK_BOX (hbox1), label_summary_row_height, FALSE,
FALSE, 0); +
+	spinbtn_summary_row_height_adj = GTK_ADJUSTMENT(gtk_adjustment_new (0,
0, 128, 1, 10, 0));
+	spinbtn_summary_row_height = gtk_spin_button_new
+		(GTK_ADJUSTMENT (spinbtn_summary_row_height_adj), 1, 0);
+	gtk_widget_show (spinbtn_summary_row_height);
+	gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_summary_row_height,
+			    FALSE, FALSE, 0);
+	gtk_spin_button_set_numeric (GTK_SPIN_BUTTON
(spinbtn_summary_row_height),
+				     TRUE);
+
+	label_summary_row_height = gtk_label_new (_("px"));
+	gtk_widget_show (label_summary_row_height);
+	gtk_box_pack_start (GTK_BOX (hbox1), label_summary_row_height, FALSE,
FALSE, 0); 
 	vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
 	gtk_widget_show (vbox1);
@@ -676,6 +698,7 @@ static void prefs_summaries_create_widget(PrefsPage *_page,
GtkWindow *window, 
 	prefs_summaries->optmenu_folder_unread = optmenu_folder_unread;
 	prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
+	prefs_summaries->spinbtn_summary_row_height =
spinbtn_summary_row_height; prefs_summaries->checkbtn_useaddrbook =
checkbtn_useaddrbook; prefs_summaries->checkbtn_show_tooltips =
checkbtn_show_tooltips; prefs_summaries->checkbtn_threadsubj =
checkbtn_threadsubj; @@ -727,6 +750,8 @@ static void
prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
prefs_common.thread_by_subject);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
prefs_common.ng_abbrev_len);
+	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_summary_row_height),
+			prefs_common.summary_row_height);
 	gtk_entry_set_text(GTK_ENTRY(entry_datefmt), 
 			prefs_common.date_format?prefs_common.date_format:"");	
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder),
@@ -803,6 +828,9 @@ static void prefs_summaries_save(PrefsPage *_page)
 	prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
 			GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
 	
+	prefs_common.summary_row_height = gtk_spin_button_get_value_as_int(
+			GTK_SPIN_BUTTON(page->spinbtn_summary_row_height));
+		
 	g_free(prefs_common.date_format); 
 	prefs_common.date_format = gtk_editable_get_chars(
 			GTK_EDITABLE(page->entry_datefmt), 0, -1);	
diff --git a/src/summaryview.c b/src/summaryview.c
index bd0eb8c06..bb8822c06 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -6897,13 +6897,18 @@ void summary_set_column_order(SummaryView *summaryview)
 	else
 		summary_redisplay_msg(summaryview);
 
-	/* get normal row height */
-	gtk_cmclist_set_row_height(GTK_CMCLIST(ctree), 0);
-	normal_row_height = GTK_CMCLIST(ctree)->row_height;		
-		
-	if ((prefs_common.layout_mode == SMALL_LAYOUT ||
prefs_common.layout_mode == VERTICAL_LAYOUT) &&
-	    prefs_common.two_line_vert) {
-		gtk_cmclist_set_row_height(GTK_CMCLIST(summaryview->ctree),
2*normal_row_height + 2); +
+	if (prefs_common.summary_row_height != 0) {
+		gtk_cmclist_set_row_height(GTK_CMCLIST(ctree),
prefs_common.summary_row_height);
+	} else {
+		/* get normal row height */
+		gtk_cmclist_set_row_height(GTK_CMCLIST(ctree), 0);
+		normal_row_height = GTK_CMCLIST(ctree)->row_height;
	
+			
+		if ((prefs_common.layout_mode == SMALL_LAYOUT ||
prefs_common.layout_mode == VERTICAL_LAYOUT) &&
+		    prefs_common.two_line_vert) {
+
gtk_cmclist_set_row_height(GTK_CMCLIST(summaryview->ctree), 2*normal_row_height
+ 2);		
+		}
 	}
 }
 
Regards
Folling
 


More information about the Commits mailing list