Commit a7fed97d authored by Nong Hoang Tu's avatar Nong Hoang Tu

New layout for AnonSurf

parent bcf66465
Pipeline #1756 canceled with stages
import gintro / [gtk, glib, gobject]
import displays / [detailPage, mainPage]
import displays / [detailPage, mainPage, bottombar]
import cores / [status, refresher, images]
import actions / [actDetailPage, actMainPage, gtkClick]
......@@ -40,9 +40,9 @@ proc createArea(boxMainWindow: Box) =
btnShowStatus = newButton("Tor Stats")
btnChangeID = newButton("Change\nIdentity")
btnCheckIP = newButton("My IP")
btnRestart = newButton("")
btnRestart = newButton("Restart")
imgStatus = newImageFromPixbuf(surfImages.imgSecMed)
mainWidget = createMainWidget(imgStatus, labelDetails, btnStart, btnShowDetails, btnShowStatus, btnChangeID, btnCheckIP, btnRestart)
mainWidget = createMainWidget(imgStatus, labelDetails, btnStart, btnShowStatus, btnChangeID, btnCheckIP, btnRestart)
btnRestart.connect("clicked", onClickRestart)
btnStart.connect("clicked", onClickRun)
......@@ -57,10 +57,9 @@ proc createArea(boxMainWindow: Box) =
imgStatusBoot = newImageFromPixbuf(surfImages.imgBootOff)
labelStatusBoot = newLabel("Not enabled at boot")
btnBoot = newButton("Enable")
btnBack = newButton("Back")
detailWidget = createDetailWidget(
labelDaemons, labelPorts, labelDNS, labelStatusBoot,
btnBoot, btnBack, imgStatusBoot
btnBoot, imgStatusBoot
)
btnBoot.connect("clicked", onClickBoot)
......@@ -69,11 +68,14 @@ proc createArea(boxMainWindow: Box) =
mainStack = newStack()
btnShowDetails.connect("clicked", onClickDetail, mainStack)
btnBack.connect("clicked", onClickBack, mainStack)
mainStack.addNamed(mainWidget, "main")
mainStack.addNamed(detailWidget, "detail")
boxMainWindow.add(mainStack)
let boxBottom = makeBottomBar(btnShowDetails)
boxMainWindow.add(boxBottom)
boxMainWindow.showAll()
var
......
......@@ -2,18 +2,16 @@ import gintro / gtk
import actMainPage
proc onClickBack*(b: Button, s: Stack) =
#[
Return main widget from current page
]#
s.setVisibleChildName("main")
proc onClickDetail*(b: Button, s: Stack) =
#[
Display status page
Display details widget or main widget
]#
s.setVisibleChildName("detail")
if b.label == "Details":
s.setVisibleChildName("detail")
b.label = "Back"
else:
s.setVisibleChildName("main")
b.label = "Details"
proc onClickExit*(b: Button) =
......
......@@ -56,15 +56,6 @@ proc surfIconPixbuf(): Pixbuf =
result = loadData.getPixbuf()
proc reloadIconPixbuf(): Pixbuf =
const
imgData = staticRead("../../../icons/reload.png")
let loadData = newPixbufLoader()
discard loadData.write(imgData)
discard loadData.close()
result = loadData.getPixbuf()
proc exitIconPixbuf(): Pixbuf =
const
imgData = staticRead("../../../icons/exit.png")
......@@ -86,6 +77,6 @@ proc aboutIconPixbuf(): Pixbuf =
let
surfImages* = initImgs()
surfIcon* = surfIconPixbuf()
reloadIcon* = reloadIconPixbuf()
# reloadIcon* = reloadIconPixbuf()
exitIcon* = exitIconPixbuf()
aboutIcon* = aboutIconPixbuf()
import gintro / [gtk, gobject]
import .. / cores / images
import about
proc makeBottomBar*(bSwitchWidget: Button): Box =
let
btnAbout = newButton("")
imgAbout = newImageFromPixbuf(aboutIcon)
bxBottomBar = newBox(Orientation.horizontal, 3)
btnAbout.setImage(imgAbout)
btnAbout.connect("clicked", onClickAbout)
bxBottomBar.packStart(bSwitchWidget, false, true, 3)
bxBottomBar.packEnd(btnAbout, false, true, 3)
return bxBottomBar
import gintro / [gtk, gobject]
import .. / cores / images
import about
import gintro / gtk
proc makeDetailPanel(imgStatus: Image, labDetails: Label, btnDetail, btnStatus: Button): Frame =
proc makeDetailPanel(imgStatus: Image, labDetails: Label, btnStatus, btnRestart: Button): Frame =
#[
Create the area Detail in main page
it has image of current AnonSurf
......@@ -17,7 +15,7 @@ proc makeDetailPanel(imgStatus: Image, labDetails: Label, btnDetail, btnStatus:
bxDetailPanel = newBox(Orientation.horizontal, 6)
bxDetailPanel.add(imgStatus)
bxButtons.packStart(btnDetail, false, true, 4)
bxButtons.packStart(btnRestart, false, true, 4)
bxButtons.packStart(btnStatus, false, true, 2)
areaInfo.packStart(labDetails, false, true, 3)
......@@ -49,38 +47,15 @@ proc makeToolBar(btnStart, btnID, btnIP: Button): Frame =
return fmTool
proc makeBottomBarForMain(btnRestart: Button): Box =
#[
Create bottom bar
It has About and Exit button
]#
let
boxBottomBar = newBox(Orientation.horizontal, 3)
imgRestart = newImageFromPixbuf(reloadIcon)
btnAbout = newButton("")
imgAbout = newImageFromPixbuf(aboutIcon)
btnRestart.setImage(imgRestart)
btnAbout.setImage(imgAbout)
btnAbout.connect("clicked", onClickAbout)
boxBottomBar.packStart(btnRestart, false, true, 3)
boxBottomBar.packEnd(btnAbout, false, true, 3)
return boxBottomBar
proc createMainWidget*(imgStatus: Image, lDetails: Label, bStart, bDetail, bStatus, bID, bIP, bRestart: Button): Box =
proc createMainWidget*(imgStatus: Image, lDetails: Label, bStart, bStatus, bID, bIP, bRestart: Button): Box =
#[
Create the page for main widget
]#
let
boxPanel = makeDetailPanel(imgStatus, lDetails, bDetail, bStatus)
boxPanel = makeDetailPanel(imgStatus, lDetails, bStatus, bRestart)
boxToolBar = makeToolBar(bStart, bID, bIP)
bottomBar = makeBottomBarForMain(bRestart)
mainWidget = newBox(Orientation.vertical, 3)
mainWidget.packStart(boxPanel, false, true, 2)
mainWidget.packStart(boxToolBar, false, true, 1)
mainWidget.packEnd(bottomBar, false, true, 2)
return mainWidget
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