Skip to content

Commit

Permalink
Merge pull request #387 from Seanstoppable/defaultunknown
Browse files Browse the repository at this point in the history
Add default unknown widget
  • Loading branch information
anandsudhir committed Feb 15, 2019
2 parents 8a4c3ac + 90f150d commit 1f93ae7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Expand Up @@ -57,6 +57,7 @@ import (
"github.com/wtfutil/wtf/travisci"
"github.com/wtfutil/wtf/trello"
"github.com/wtfutil/wtf/twitter"
"github.com/wtfutil/wtf/unknown"
"github.com/wtfutil/wtf/victorops"
"github.com/wtfutil/wtf/weatherservices/prettyweather"
"github.com/wtfutil/wtf/weatherservices/weather"
Expand Down Expand Up @@ -259,6 +260,7 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
case "zendesk":
widgets = append(widgets, zendesk.NewWidget(app))
default:
widgets = append(widgets, unknown.NewWidget(app, widgetName))
}
}

Expand Down
31 changes: 31 additions & 0 deletions unknown/widget.go
@@ -0,0 +1,31 @@
package unknown

import (
"fmt"

"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
)

type Widget struct {
wtf.TextWidget
}

func NewWidget(app *tview.Application, name string) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, name, name, false),
}

return &widget
}

/* -------------------- Exported Functions -------------------- */

func (widget *Widget) Refresh() {

widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name)))
widget.View.Clear()

content := fmt.Sprintf("Widget %s does not exist", widget.Name)
widget.View.SetText(content)
}

0 comments on commit 1f93ae7

Please sign in to comment.