[Solved] supressing gtk warning messages
Posted: Saturday 7th August 2021 8:38pm
Anyone know of a way to suppress the gtk warning messages?
The best answer i have so far is this "hack"...
Uses gb.args
if the arg -q or --quiet is given then before the app loads it launches itself with any and all args plus "2>/dev/null" to redirect the error output and an additional arg -s.
when the 2nd run instance quits the 1st one that launched the second one also quits before it's even done anything.
the check works earliest in the _new() method. in _init() gb.args does not work.
PS. as it runs it's own exe you will need to "Make Executable" before it can work
It's a form with a tiny little TextArea in it, so small it produces warnings on my system when i move the mouse around the window...
(Test:79673): Gdk-CRITICAL **: 20:26:58.775: gdk_window_is_visible: assertion 'GDK_IS_WINDOW (window)' failed
Run with -q and all is quiet.
./Test.gambas -q
Of course this method will suppress ANY error messages ,
shell commands can be fixed by adding '>2&1'
Shell "/run/mycommand 2>&1"
that redirects error output to stdout and stdout is still showing
Please somebody tell me there's a better way...
The best answer i have so far is this "hack"...
Uses gb.args
if the arg -q or --quiet is given then before the app loads it launches itself with any and all args plus "2>/dev/null" to redirect the error output and an additional arg -s.
when the 2nd run instance quits the 1st one that launched the second one also quits before it's even done anything.
the check works earliest in the _new() method. in _init() gb.args does not work.
PS. as it runs it's own exe you will need to "Make Executable" before it can work
Public Sub _new()
Args.Begin()
Dim bQuiet As Boolean = Args.Has("q", "quiet", "supress gtk error messages")
If bQuiet Then bQuiet = (Args.Has("s", "supressed", "supressed gtk error warnings") == False)
Args.End()
If bQuiet And File.In.IsTerm Then ' if we are not run from a terminal then no need for any of this
Dim sRestOfargs As String[] = Args.All.Copy()
' the next 2 lines just handle if being run from the IDE and make Arg[0] be executable name.
If Not InStr(sRestOfargs[0], "/") Then sRestOfargs[0] = Application.Path &/ Application.Name
If File.Ext(sRestOfargs[0]) <> "gambas" Then sRestOfargs[0] &= ".gambas"
sRestOfargs.Insert(["-s", "2>/dev/null"])
Shell sRestOfargs.Join(" ")
Me.Close
Return
Endif
End
Attached is a simple test appIt's a form with a tiny little TextArea in it, so small it produces warnings on my system when i move the mouse around the window...
(Test:79673): Gdk-CRITICAL **: 20:26:58.775: gdk_window_is_visible: assertion 'GDK_IS_WINDOW (window)' failed
Run with -q and all is quiet.
./Test.gambas -q
Of course this method will suppress ANY error messages ,
shell commands can be fixed by adding '>2&1'
Shell "/run/mycommand 2>&1"
that redirects error output to stdout and stdout is still showing
Please somebody tell me there's a better way...