From 8407bfb0cb9d8e58c40758b552c4eb71fe5f6415 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 14 Feb 2014 11:02:59 -0500 Subject: [PATCH] Changed manual sysData construction to use a helper function instead. --- button.go | 6 +----- checkbox.go | 6 +----- sysdata.go | 8 ++++++++ window.go | 6 +----- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/button.go b/button.go index c3f5c7e..2c6706f 100644 --- a/button.go +++ b/button.go @@ -19,11 +19,7 @@ type Button struct { // NewButton creates a new button with the specified text. func NewButton(text string) (b *Button) { return &Button{ - sysData: &sysData{ - cSysData: cSysData{ - ctype: c_button, - }, - }, + sysData: mksysdata(c_button), initText: text, Clicked: make(chan struct{}), } diff --git a/checkbox.go b/checkbox.go index 89768ef..fc5c197 100644 --- a/checkbox.go +++ b/checkbox.go @@ -20,11 +20,7 @@ type Checkbox struct { // NewCheckbox creates a new checkbox with the specified text. func NewCheckbox(text string) (c *Checkbox) { return &Checkbox{ - sysData: &sysData{ - cSysData: cSysData{ - ctype: c_checkbox, - }, - }, + sysData: mksysdata(c_checkbox), initText: text, } } diff --git a/sysdata.go b/sysdata.go index 3ffc4c0..eda749e 100644 --- a/sysdata.go +++ b/sysdata.go @@ -36,3 +36,11 @@ const ( c_checkbox nctypes ) + +func mksysdata(ctype int) *sysData { + return &sysData{ + cSysData: cSysData{ + ctype: ctype, + }, + } +} diff --git a/window.go b/window.go index da5606a..5bf167a 100644 --- a/window.go +++ b/window.go @@ -25,11 +25,7 @@ type Window struct { // NewWindow creates a new window with the given title and size. The window is not constructed at the OS level until a call to Open(). func NewWindow(title string, width int, height int) *Window { return &Window{ - sysData: &sysData{ - cSysData: cSysData{ - ctype: c_window, - }, - }, + sysData: mksysdata(c_window), initTitle: title, initWidth: width, initHeight: height,