public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
From: git@ipfire.org
To: ipfire-scm@lists.ipfire.org
Subject: [git.ipfire.org] IPFire 2.x development tree branch, seventeen, updated. a5c99abe185bb8429149f4eadc1ce8244d3f6130
Date: Mon, 03 Nov 2014 18:36:38 +0100	[thread overview]
Message-ID: <20141103173638.F1AD32128C@argus.ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 3581 bytes --]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, seventeen has been updated
       via  a5c99abe185bb8429149f4eadc1ce8244d3f6130 (commit)
       via  8f6e429843317243f412486813533c610c186673 (commit)
      from  b154ded15d18987dfad297ee1ea7a07feb87bab6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a5c99abe185bb8429149f4eadc1ce8244d3f6130
Merge: 8f6e429 b154ded
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date:   Mon Nov 3 18:36:31 2014 +0100

    Merge remote-tracking branch 'origin/seventeen' into seventeen

commit 8f6e429843317243f412486813533c610c186673
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date:   Mon Nov 3 18:35:56 2014 +0100

    installer: Correctly position buttons in dialogs

-----------------------------------------------------------------------

Summary of changes:
 src/installer/main.c | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

Difference in files:
diff --git a/src/installer/main.c b/src/installer/main.c
index ad388e6..9262a40 100644
--- a/src/installer/main.c
+++ b/src/installer/main.c
@@ -104,6 +104,37 @@ static int newtWinOkCancel(const char* title, const char* message, int width, in
 		const char* btn_txt_ok, const char* btn_txt_cancel) {
 	int ret = 1;
 
+	unsigned int btn_width_ok = strlen(btn_txt_ok);
+	unsigned int btn_width_cancel = strlen(btn_txt_cancel);
+
+	// Maybe make the box wider to fix both buttons inside
+	unsigned int min_width = btn_width_ok + btn_width_cancel + 5;
+	if (width < min_width)
+		width = min_width;
+
+	unsigned int btn_pos_ok = (width / 3) - (btn_width_ok / 2) - 1;
+	unsigned int btn_pos_cancel = (width * 2 / 3) - (btn_width_cancel / 2) - 1;
+
+	// Move buttons a bit if they overlap
+	while ((btn_pos_ok + btn_width_ok + 5) > btn_pos_cancel) {
+		// Move the cancel button to the right if there is enough space left
+		if ((btn_pos_cancel + btn_width_cancel + 2) < width) {
+			++btn_pos_cancel;
+			continue;
+		}
+
+		// Move the OK button to the left if possible
+		if (btn_pos_ok > 1) {
+			--btn_pos_ok;
+			continue;
+		}
+
+		// If they still overlap, we cannot fix the situtation
+		// and break. Should actually never get here, because we
+		// adjust the width of the window earlier.
+		break;
+	}
+
 	newtCenteredWindow(width, height, title);
 
 	newtComponent form = newtForm(NULL, NULL, 0);
@@ -112,12 +143,8 @@ static int newtWinOkCancel(const char* title, const char* message, int width, in
 	newtTextboxSetText(textbox, message);
 	newtFormAddComponent(form, textbox);
 
-	unsigned int btn_width_ok = strlen(btn_txt_ok);
-	unsigned int btn_width_cancel = strlen(btn_txt_cancel);
-
-	newtComponent btn_ok = newtButton((width / 3) - (btn_width_ok / 2) - 2, height - 4, btn_txt_ok);
-	newtComponent btn_cancel = newtButton((width * 2 / 3) - (btn_width_cancel / 2) - 2, height - 4,
-		btn_txt_cancel);
+	newtComponent btn_ok = newtButton(btn_pos_ok, height - 4, btn_txt_ok);
+	newtComponent btn_cancel = newtButton(btn_pos_cancel, height - 4, btn_txt_cancel);
 
 	newtFormAddComponents(form, btn_ok, btn_cancel, NULL);
 


hooks/post-receive
--
IPFire 2.x development tree

                 reply	other threads:[~2014-11-03 17:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20141103173638.F1AD32128C@argus.ipfire.org \
    --to=git@ipfire.org \
    --cc=ipfire-scm@lists.ipfire.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox