From patchwork Thu Aug 22 22:01:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Yadav X-Patchwork-Id: 11110161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7B831399 for ; Thu, 22 Aug 2019 22:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7263233FD for ; Thu, 22 Aug 2019 22:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404825AbfHVWBR (ORCPT ); Thu, 22 Aug 2019 18:01:17 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:48393 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404199AbfHVWBR (ORCPT ); Thu, 22 Aug 2019 18:01:17 -0400 Received: from localhost.localdomain (unknown [1.186.12.26]) (Authenticated sender: me@yadavpratyush.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 6EA15240002; Thu, 22 Aug 2019 22:01:14 +0000 (UTC) From: Pratyush Yadav To: Cc: Pratyush Yadav , Junio C Hamano , Johannes Sixt , Bert Wesarg Subject: [PATCH v2 1/4] git-gui: Move revert confirmation dialog creation to separate function Date: Fri, 23 Aug 2019 03:31:04 +0530 Message-Id: <20190822220107.4153-2-me@yadavpratyush.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822220107.4153-1-me@yadavpratyush.com> References: <20190819214110.26461-1-me@yadavpratyush.com> <20190822220107.4153-1-me@yadavpratyush.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Upcoming commits will introduce reverting lines and hunks. They also need to prompt the user for confirmation. Put the dialog creation in its separate function so the same code won't be repeated again and again. Signed-off-by: Pratyush Yadav --- lib/index.tcl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/index.tcl b/lib/index.tcl index b588db1..cb7f74a 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -388,6 +388,18 @@ proc do_add_all {} { add_helper [mc "Adding all changed files"] $paths } +proc revert_dialog {query} { + return [tk_dialog \ + .confirm_revert \ + "[appname] ([reponame])" \ + "$query" \ + question \ + 1 \ + [mc "Do Nothing"] \ + [mc "Revert Changes"] \ + ] +} + proc revert_helper {txt paths} { global file_states current_diff_path @@ -430,17 +442,12 @@ proc revert_helper {txt paths} { set query [mc "Revert changes in these %i files?" $n] } - set reply [tk_dialog \ - .confirm_revert \ - "[appname] ([reponame])" \ - "$query + set query "$query + +[mc "Any unstaged changes will be permanently lost by the revert."]" + + set reply [revert_dialog $query] -[mc "Any unstaged changes will be permanently lost by the revert."]" \ - question \ - 1 \ - [mc "Do Nothing"] \ - [mc "Revert Changes"] \ - ] if {$reply == 1} { checkout_index \ $txt \