Commit 1f33e93a authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

Add status widget

parent d0491cfe
Pipeline #3771 canceled with stages
......@@ -43,7 +43,7 @@ proc createArea(boxMainWindow: Box) =
mainWidget = createMainWidget(imgStatus, labelDetails, btnStart, btnShowStatus, btnChangeID, btnCheckIP, btnRestart)
btnRestart.connect("clicked", ansurf_gtk_do_restart, cb_send_msg)
# btnStatus.connect("clicked", ansurf_gtk_do_status) # TODO handle do status differently
btnShowStatus.connect("clicked", ansurf_gtk_do_status)
btnStart.connect("clicked", ansurf_gtk_do_start_stop, cb_send_msg)
btnChangeID.connect("clicked", ansurf_gtk_do_changeid, cb_send_msg)
btnCheckIP.connect("clicked", ansurf_gtk_do_myip, cb_send_msg)
......
......@@ -2,6 +2,7 @@ import gintro / gtk
import .. / .. / cores / handle_activities
import .. / .. / cores / handle_killapps
import .. / ansurf_objects
import .. / widgets / tor_status_widget
let cb_kill_apps = init_gtk_askkill()
......@@ -55,5 +56,5 @@ proc ansurf_gtk_do_changeid*(b: Button, cb_send_msg: proc) =
createThread(ansurf_workers_common, do_anonsurf_changeid, (cb_send_msg))
proc ansurf_gtk_do_status*() =
echo "status (in development)"
proc ansurf_gtk_do_status*(b: Button) =
onClickTorStatus()
import gintro / [gtk, vte, gobject, glib]
proc callback_dummy(terminal: ptr Terminal00; pid: int32; error: ptr glib.Error; userData: pointer) {.cdecl.} =
#[
Dummy callback proc to fix problem of VTE
]#
discard
proc onVTEExit(v: Terminal, signal: int, d: Dialog) =
d.destroy()
proc onClickTorStatus*() =
#[
Spawn a native GTK terminal and run nyx with it to show current tor status
]#
let
statusDialog = newDialog()
statusArea = statusDialog.getContentArea()
nyxTerm = newTerminal()
statusDialog.setTitle("Tor bandwidth")
statusDialog.setResizable(false)
nyxTerm.connect("child-exited", onVTEExit, statusDialog)
nyxTerm.spawnAsync(
{noLastlog}, # pty flags
nil, # working directory
["/usr/bin/nyx", "--config", "/etc/anonsurf/nyxrc"], # args
[], # envv
{}, # spawn flag
nil, # Child setup
nil, # child setup data
nil, # chlid setup data destroy
-1, # timeout
nil, # cancellabel
callback_dummy, # callback
nil, # pointer
)
statusArea.packStart(nyxTerm, false, true, 3)
statusDialog.showAll()
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