Skip to content

Commit

Permalink
Removed the initText parameter from sysData.make() and changed all in…
Browse files Browse the repository at this point in the history
…vocations to call sysData.setText() separately; this avoids the need to check if sysData.setText() is valid. Also implemented that on GTK+.
  • Loading branch information
andlabs committed Apr 1, 2014
1 parent 8115361 commit 2647d28
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion area.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (a *Area) make(window *sysData) error {
defer a.lock.Unlock()

a.sysData.handler = a.handler
err := a.sysData.make("", window)
err := a.sysData.make(window)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion button.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ func (b *Button) make(window *sysData) error {
defer b.lock.Unlock()

b.sysData.event = b.Clicked
err := b.sysData.make(b.initText, window)
err := b.sysData.make(window)
if err != nil {
return err
}
b.sysData.setText(b.initText)
b.created = true
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion checkbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ func (c *Checkbox) make(window *sysData) error {
c.lock.Lock()
defer c.lock.Unlock()

err := c.sysData.make(c.initText, window)
err := c.sysData.make(window)
if err != nil {
return err
}
c.sysData.setText(c.initText)
c.created = true
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion combobox.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (c *Combobox) make(window *sysData) (err error) {
c.lock.Lock()
defer c.lock.Unlock()

err = c.sysData.make("", window)
err = c.sysData.make(window)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion label.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ func (l *Label) make(window *sysData) error {
l.lock.Lock()
defer l.lock.Unlock()

err := l.sysData.make(l.initText, window)
err := l.sysData.make(window)
if err != nil {
return err
}
l.sysData.setText(l.initText)
l.created = true
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion lineedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ func (l *LineEdit) make(window *sysData) error {
defer l.lock.Unlock()

l.sysData.alternate = l.password
err := l.sysData.make(l.initText, window)
err := l.sysData.make(window)
if err != nil {
return err
}
l.sysData.setText(l.initText)
l.created = true
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion listbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (l *Listbox) make(window *sysData) (err error) {
l.lock.Lock()
defer l.lock.Unlock()

err = l.sysData.make("", window)
err = l.sysData.make(window)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (p *ProgressBar) make(window *sysData) error {
p.lock.Lock()
defer p.lock.Unlock()

err := p.sysData.make("", window)
err := p.sysData.make(window)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion sysdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type cSysData struct {

// this interface is used to make sure all sysDatas are synced
var _xSysData interface {
make(initText string, window *sysData) error
make(window *sysData) error
firstShow() error
show()
hide()
Expand Down
8 changes: 1 addition & 7 deletions sysdata_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ var classTypes = [nctypes]*classData{
c_combobox: &classData{
make: gtk_combo_box_text_new,
makeAlt: gtk_combo_box_text_new_with_entry,
// TODO setText
text: gtk_combo_box_text_get_active_text,
append: gtk_combo_box_text_append_text,
insert: gtk_combo_box_text_insert_text,
Expand All @@ -86,7 +85,6 @@ var classTypes = [nctypes]*classData{
c_listbox: &classData{
make: gListboxNewSingle,
makeAlt: gListboxNewMulti,
// TODO setText
text: gListboxText,
append: gListboxAppend,
insert: gListboxInsert,
Expand All @@ -112,7 +110,7 @@ var classTypes = [nctypes]*classData{
},
}

func (s *sysData) make(initText string, window *sysData) error {
func (s *sysData) make(window *sysData) error {
ct := classTypes[s.ctype]
ret := make(chan *C.GtkWidget)
defer close(ret)
Expand Down Expand Up @@ -152,7 +150,6 @@ func (s *sysData) make(initText string, window *sysData) error {
}
<-ret
}
s.setText(initText)
return nil
}

Expand Down Expand Up @@ -183,9 +180,6 @@ func (s *sysData) hide() {
}

func (s *sysData) setText(text string) {
if classTypes[s.ctype].setText == nil { // does not have concept of text
return
}
ret := make(chan struct{})
defer close(ret)
uitask <- func() {
Expand Down
3 changes: 2 additions & 1 deletion window.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (w *Window) Open(control Control) (err error) {
panic("window already open")
}
w.sysData.event = w.Closing
err = w.sysData.make(w.initTitle, nil)
err = w.sysData.make(nil)
if err != nil {
return fmt.Errorf("error opening window: %v", err)
}
Expand All @@ -87,6 +87,7 @@ func (w *Window) Open(control Control) (err error) {
if err != nil {
return fmt.Errorf("error setting window size (in Window.Open()): %v", err)
}
w.sysData.setText(w.initTitle)
// TODO separate showing?
err = w.sysData.firstShow()
if err != nil {
Expand Down

0 comments on commit 2647d28

Please sign in to comment.