All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark <mlevedahl@gmail.com>
To: Johannes Sixt via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH 2/5] gitk: condense repetitive code around color buttons into foreach loops
Date: Fri, 7 Aug 2026 10:37:10 -0400	[thread overview]
Message-ID: <a2e12e20-ad46-4521-9d45-5b74730361f1@gmail.com> (raw)
In-Reply-To: <edb567608e1bda16efbdb8d4ec359318cf105284.1785998419.git.gitgitgadget@gmail.com>

On 8/6/26 2:40 AM, Johannes Sixt via GitGitGadget wrote:
> From: Johannes Sixt <j6t@kdbg.org>
> 
> The color selection elements in the Preferences dialog are set up in a
> very uniform manner. The code doing that has grown in the past by simply
> modifying a copy of a paragraph. Extract the varying parts into a list
> and then operate the repeating parts in a foreach loop. This helps a
> later change where we want to set up the UI elements in a different way.
> 
> Change the UI names "markbgsep" and "selbgsep" to drop the "sep", which
> has obviously been left over by accident when "hunksep" was copied.
> 
> Change the suffix "but" to "btn", which resonates a bit better when
> reading the code.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  gitk-git/gitk | 114 ++++++++++++++++++++++++--------------------------
>  1 file changed, 55 insertions(+), 59 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index f5eb963b86..137940defb 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -11832,55 +11832,46 @@ proc prefspage_colors {notebook} {


> -
> -    label $page.linkfg -padx 40 -relief sunk
> -    ttk::button $page.linkfgbut -text [mc "Link"] \
> -        -command [list choosecolor linkfgcolor {} $page [mc "link"]]
> -    grid x $page.linkfgbut $page.linkfg -sticky w
> +
> +    set coloruielems [list \
> +        bg          bgcolor {} \
> +                    [mc "Background"] \
> +                    [mc "background"] \
> +        fg          fgcolor {} \
> +                    [mc "Foreground"] \
> +                    [mc "foreground"] \
The list is computed and used each time a dialog box is started from all static elements,
no real change. But this cleanly separates the per item data from the boiler plate,
definitely more readable. Good.

  reply	other threads:[~2026-08-07 14:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  6:40 [PATCH 0/5] gitk: make color preferences visually more pleasing and better usable Johannes Sixt via GitGitGadget
2026-08-06  6:40 ` [PATCH 1/5] gitk: set intitial colors of swatches using the available helper Johannes Sixt via GitGitGadget
2026-08-07 14:36   ` mark
2026-08-06  6:40 ` [PATCH 2/5] gitk: condense repetitive code around color buttons into foreach loops Johannes Sixt via GitGitGadget
2026-08-07 14:37   ` mark [this message]
2026-08-06  6:40 ` [PATCH 3/5] gitk: show color preferences on the button instead of the label Johannes Sixt via GitGitGadget
2026-08-07 14:37   ` mark
2026-08-08  9:33     ` Johannes Sixt
2026-08-06  6:40 ` [PATCH 4/5] gitk: use more natural language for labels of color preferences Johannes Sixt via GitGitGadget
2026-08-06  6:40 ` [PATCH 5/5] gitk: avoid constructing dialog titles from text pieces Johannes Sixt via GitGitGadget
2026-08-07 14:37   ` mark
2026-08-08 10:00     ` Johannes Sixt
2026-08-08 14:55       ` Mark Levedahl
2026-08-09  7:27         ` Johannes Sixt
2026-08-08 16:32       ` Junio C Hamano
2026-08-09  7:04         ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a2e12e20-ad46-4521-9d45-5b74730361f1@gmail.com \
    --to=mlevedahl@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.