Commit 7287d8e7 authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

add refresher to work

parent 279d33f4
Pipeline #3763 canceled with stages
......@@ -2,33 +2,28 @@ import gintro / [gtk, glib, gobject]
# import gtk / cores / [status, refresher, images]
import cores / [handle_activities, handle_killapps]
import gtk / widgets / [details_widget, main_widget, bottom_widget]
import gtk / anonsurf_icons
import gtk / [ansurf_icons, ansurf_gui_refresher]
import gtk / gui_activities / [details_widget_activities, main_widget_activities, core_activities]
import cores / handle_activities
import gtk / [ansurf_get_status, ansurf_objects]
# type
# RefreshObj = ref object
# mainObjs: MainObjs
# detailObjs: DetailObjs
# stackObjs: Stack
proc handleRefresh(args: RefreshObj): bool =
#[
Program is having 2 pages: main and detail
This handleRefresh check which page is using
so it update only 1 page for better performance
]#
let
freshStatus = getSurfStatus()
# portStatus = getStatusPorts()
# proc handleRefresh(args: RefreshObj): bool =
# #[
# Program is having 2 pages: main and detail
# This handleRefresh check which page is using
# so it update only 1 page for better performance
# ]#
# let
# freshStatus = getSurfStatus()
# # portStatus = getStatusPorts()
# if args.stackObjs.getVisibleChildName == "main":
# updateMain(args.mainObjs, freshStatus)
# else:
# updateDetail(args.detailObjs, freshStatus)
if args.stackObjs.getVisibleChildName == "main":
updateMain(args.mainObjs, freshStatus)
else:
updateDetail(args.detailObjs, freshStatus)
# return SOURCE_CONTINUE
return SOURCE_CONTINUE
proc createArea(boxMainWindow: Box) =
......@@ -83,39 +78,39 @@ proc createArea(boxMainWindow: Box) =
boxMainWindow.showAll()
# var
# mainArgs = MainObjs(
# btnRun: btnStart,
# btnID: btnChangeID,
# btnDetail: btnShowDetails,
# btnStatus: btnShowStatus,
# btnIP: btnCheckIP,
# lDetails: labelDetails,
# btnRestart: btnRestart,
# imgStatus: imgStatus,
# )
# detailArgs = DetailObjs(
# lblServices: labelDaemons,
# lblPorts: labelPorts,
# lblDns: labelDNS,
# lblBoot: labelStatusBoot,
# btnBoot: btnBoot,
# imgBoot: imgStatusBoot
# )
# refresher = RefreshObj(
# mainObjs: mainArgs,
# detailObjs: detailArgs,
# stackObjs: mainStack,
# )
var
mainArgs = MainObjs(
btnRun: btnStart,
btnID: btnChangeID,
btnDetail: btnShowDetails,
btnStatus: btnShowStatus,
btnIP: btnCheckIP,
lDetails: labelDetails,
btnRestart: btnRestart,
imgStatus: imgStatus,
)
detailArgs = DetailObjs(
lblServices: labelDaemons,
lblPorts: labelPorts,
lblDns: labelDNS,
lblBoot: labelStatusBoot,
btnBoot: btnBoot,
imgBoot: imgStatusBoot
)
refresher = RefreshObj(
mainObjs: mainArgs,
detailObjs: detailArgs,
stackObjs: mainStack,
)
# Load latest status when start program
# let
# atStartStatus = getSurfStatus()
# # atStartPorts = getStatusPorts()
# updateMain(mainArgs, atStartStatus)
# updateDetail(detailArgs, atStartStatus)
let
atStartStatus = getSurfStatus()
# atStartPorts = getStatusPorts()
updateMain(mainArgs, atStartStatus)
updateDetail(detailArgs, atStartStatus)
# discard timeoutAdd(200, handleRefresh, refresher)
discard timeoutAdd(200, handleRefresh, refresher)
proc main =
......
const
ERROR_UNKNOWN* = -4
ERROR_FILE_NOT_FOUND* = -3
ERROR_FILE_EMPTY* = -2
ERROR_DNS_LOCALHOST* = -1
STT_DNS_TOR* = 0
sysResolvConf = "/etc/resolv.conf"
proc ansurf_dns_server_compare() =
discard
proc ansurf_dns_status() =
discard
import os
import strutils
import services
import services_status
const
......
import gintro / gtk
import ansurf_objects
# import .. / .. / utils / dnsutils
# import status
# import .. / actions / actMainPage
# import images
# import .. / displays / noti
# import strutils
type
MainObjs* = ref object
btnRun*: Button
btnID*: Button
btnDetail*: Button
btnStatus*: Button
btnIP*: Button
lDetails*: Label
imgStatus*: Image
btnRestart*: Button
DetailObjs* = ref object
lblServices*: Label
lblPorts*: Label
lblDns*: Label
lblBoot*: Label
btnBoot*: Button
imgBoot*: Image
import ansurf_icons
import ansurf_get_status
import strutils
import .. / cores / commons / dns_utils
proc updateDetail*(args: DetailObjs, myStatus: Status) =
......@@ -184,12 +164,12 @@ proc updateMain*(args: MainObjs, myStatus: Status) =
args.btnID.setSensitive(false)
args.btnStatus.setSensitive(false)
if worker.running:
args.btnIP.setSensitive(false)
else:
let finalAddr = channel.tryRecv()
if finalAddr.dataAvailable:
# channel.close()
worker.joinThread()
sendNotify($finalAddr.msg.thisAddr, $finalAddr.msg.isUnderTor, $finalAddr.msg.iconName)
args.btnIP.setSensitive(true)
# if worker.running:
# args.btnIP.setSensitive(false)
# else:
# let finalAddr = channel.tryRecv()
# if finalAddr.dataAvailable:
# # channel.close()
# worker.joinThread()
# # sendNotify($finalAddr.msg.thisAddr, $finalAddr.msg.isUnderTor, $finalAddr.msg.iconName)
# args.btnIP.setSensitive(true)
......@@ -31,4 +31,11 @@ type
isControlPort*: bool
isDNSPort*: bool
isSocksPort*: bool
isTransPort*: bool
\ No newline at end of file
isTransPort*: bool
# MyIP* = object
# thisAddr*: string
# isUnderTor*: string
# iconName*: string
# var
# worker*: system.Thread[void]
# channel*: Channel[MyIP]
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