gtk_widget_freeze_child_notify()

Has anyone successfully used gtk_widget_freeze_child_notify() to temporarily prevent a control (such as e.g. a TextArea) from redrawing?

I have been able to fix a visual annoyance for a TextArea using the freeze() and unfreeze() methods posted by JulianS on Windows. I’m looking for a way to achieve the same on Linux (particularly Ubuntu).

I updated freeze() and unfreeze() as follows, but it doesn’t seem to make a difference:

[code]Public Sub Freeze(extends w as TextArea)
#if TargetWindows
Const WM_SETREDRAW = &hB
call SendMessage( w.Handle, WM_SETREDRAW, 0, 0 )
#elseif TargetLinux //https://developer.gnome.org/gtk3/stable/GtkWidget.html
Soft Declare Sub gtk_widget_freeze_child_notify Lib “gtk” ( hwnd as integer )
if System.IsFunctionAvailable(“gtk_widget_freeze_child_notify”, “gtk”) then
gtk_widget_freeze_child_notify(w.Handle)
end if
#else
#Pragma Unused w
#EndIf
End Sub

Public Sub UnFreeze(extends w as TextArea)
#if TargetWindows
Const WM_SETREDRAW = &hB
call SendMessage( w.Handle, WM_SETREDRAW, 1, 0 )
w.Refresh
#elseif TargetLinux // GtkWidget: GTK+ 3 Reference Manual
Soft Declare Sub gtk_widget_thaw_child_notify Lib “gtk” ( hwnd as integer )
if System.IsFunctionAvailable(“gtk_widget_thaw_child_notify”, “gtk”) then
gtk_widget_thaw_child_notify(w.Handle)
w.Refresh
end if
#else
#Pragma Unused w
#EndIf
End Sub
[/code]
I have confirmed that gtk_widget_freeze_child_notify() and gtk_widget_thaw_child_notify() are being executed. However, unlike on Windows, the textArea on Ubuntu still happily redraws, even after gtk_widget_freeze_child_notify() was called.

Any help with this would be greatly appreciated.

Not sure it’s the exact behavior you’re looking for, but you can freeze the GDK Window of the control. The side effect is that the entire window seems to be prevented from redrawing, so nothing gets updated at all (eg. resizes are just an outline)

Public Sub Freeze(extends w as TextArea)
  #if TargetWindows
    Const WM_SETREDRAW = &hB
    call SendMessage( w.Handle, WM_SETREDRAW, 0, 0 )
  #elseif TargetLinux //https://developer.gnome.org/gtk3/stable/GtkWidget.html
    Soft Declare Sub gdk_window_freeze_updates Lib "gtk-3" ( hwnd as ptr )
    Soft Declare Function gtk_widget_get_window Lib "gtk-3" ( hwnd as ptr ) as ptr
    if System.IsFunctionAvailable("gdk_window_freeze_updates", "gtk-3") then
      gdk_window_freeze_updates(gtk_widget_get_window(ptr(w.Handle)))
    end if
  #else
    #Pragma Unused w
  #EndIf
End Sub

Public Sub UnFreeze(extends w as TextArea)
  #if TargetWindows
    Const WM_SETREDRAW = &hB
    call SendMessage( w.Handle, WM_SETREDRAW, 1, 0 )
    w.Refresh
  #elseif TargetLinux // https://developer.gnome.org/gtk3/stable/GtkWidget.html
    Soft Declare Sub gdk_window_thaw_updates Lib "gtk-3" ( hwnd as ptr )
    Soft Declare Function gtk_widget_get_window Lib "gtk-3" ( hwnd as ptr ) as ptr
    if System.IsFunctionAvailable("gdk_window_thaw_updates", "gtk-3") then
      gdk_window_thaw_updates(gtk_widget_get_window(ptr(w.Handle)))
    end if
  #else
    #Pragma Unused w
  #EndIf
End Sub

Thanks! I’ll give that a try.