Skip to content

Commit

Permalink
Added password changing to the save window
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuhlman committed May 27, 2016
1 parent 3429a99 commit 9e6b270
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions gui/sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func propertiesWindow(db pwsafe.DB) {

saveTime := gtk.NewLabel(fmt.Sprintf("Last Save at %v", v3db.LastSave.Format(time.RFC3339)))

passwordLabel := gtk.NewLabel("New Password")
passwordValue := gtk.NewEntry()
passwordValue.SetVisibility(false)

password2Label := gtk.NewLabel("Repeated New Password")
password2Value := gtk.NewEntry()
password2Value.SetVisibility(false)

descriptionFrame := gtk.NewFrame("Description")
descriptionWin := gtk.NewScrolledWindow(nil, nil)
descriptionWin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
Expand All @@ -52,6 +60,7 @@ func propertiesWindow(db pwsafe.DB) {
descriptionFrame.Add(descriptionWin)

saveButton := gtk.NewButtonWithLabel("Save")
// todo it would be nice if pressing enter in an field activated this.
saveButton.Clicked(func() {
v3db.Name = nameValue.GetText()

Expand All @@ -60,6 +69,17 @@ func propertiesWindow(db pwsafe.DB) {
buffer.GetEndIter(&end)
v3db.Description = buffer.GetText(&start, &end, true)

pw := passwordValue.GetText()
if pw != "" {
pw2 := password2Value.GetText()
if pw != pw2 {
errorDialog(window, "Error Passwords don't match")
} else if err := db.SetPassword(pw); err != nil {
errorDialog(window, fmt.Sprintf("Error Updating password\n%s", err))
}

}

err := pwsafe.WritePWSafeFile(db, savePathValue.GetText())
if err != nil {
errorDialog(window, fmt.Sprintf("Error Saving database to a file\n%s", err))
Expand Down Expand Up @@ -94,6 +114,16 @@ func propertiesWindow(db pwsafe.DB) {
hbox.Add(saveTime)
vbox.PackStart(hbox, false, false, 0)

hbox = gtk.NewHBox(true, 1)
hbox.Add(passwordLabel)
hbox.Add(passwordValue)
vbox.PackStart(hbox, false, false, 0)

hbox = gtk.NewHBox(true, 1)
hbox.Add(password2Label)
hbox.Add(password2Value)
vbox.PackStart(hbox, false, false, 0)

vbox.Add(descriptionFrame)

hbox = gtk.NewHBox(true, 1)
Expand Down

0 comments on commit 9e6b270

Please sign in to comment.