Commit 90da776f authored by Nong Hoang Tu's avatar Nong Hoang Tu

Ask user to check update

parent a192a29f
Pipeline #708 failed
import strutils
import httpclient
import os
import gintro / notify
import gintro / [gtk, gobject, notify]
type
Mirror = object
......@@ -49,14 +49,14 @@ proc parseDateFromText(data: string): string =
return line
proc sendNotify*(sumary, body, icon: string) =
proc sendNotify(sumary, body, icon: string) =
#[
Display IP when user click on CheckIP button
Show the information in system's notification
]#
discard init("Parrot Updater")
let ipNotify = newNotification(sumary, body, icon) # security-low
let ipNotify = newNotification(sumary, body, icon)
discard ipNotify.show()
......@@ -89,4 +89,67 @@ proc checkUpdate() =
sendNotify("Server last update: " & serverDate, "Local last update: " & localDate, "security-low")
checkUpdate()
proc onClickYes(b: Button) =
checkUpdate()
mainQuit()
proc onClickNo(b: Button) =
#[
Close program by click on exit button
]#
mainQuit()
proc onExit(w: Window) =
#[
Close program by click on title bar
]#
mainQuit()
proc doYouWantUpdate(b: Box) =
let
labelAsk = newLabel("Check for update?")
btnY = newButton("Yes")
btnN = newButton("No")
boxButton = newBox(Orientation.horizontal, 3)
btnY.connect("clicked", onClickYes)
btnN.connect("clicked", onClickNo)
boxButton.add(btnY)
boxButton.packEnd(btnN, false, true, 3)
b.add(labelASk)
b.add(boxButton)
b.showAll()
proc showPopup =
#[
Create new window
]#
gtk.init()
let
mainBoard = newWindow()
boxMainWindow = newBox(Orientation.vertical, 3)
mainBoard.title = "Parrot Updater"
mainBoard.position = WindowPosition.center
doYouWantUpdate(boxMainWindow)
mainBoard.add(boxMainWindow)
mainBoard.setBorderWidth(3)
mainBoard.show()
mainBoard.connect("destroy", onExit)
gtk.main()
if paramCount() == 1 and paramStr(1) == "--silent":
checkUpdate()
else:
showPopup()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment