Page 1 of 1

WebViewGadget() access to settings / features ?

Posted: Sat Jun 21, 2025 1:34 pm
by Mijikai
Is there a way to get access to a WebViewGadget() settings / features ?
Mostly for Linux (WebKit-GTK) but also Windows.

Stuff like this for example (WebKit-GTK):

Code: Select all

void
webkit_settings_set_enable_private_browsing (
  WebKitSettings* settings,
  gboolean enabled
)

Re: WebViewGadget() access to settings / features ?

Posted: Sun Jun 22, 2025 10:21 am
by Mijikai
Got this, still no solution thought.

WebViewFeatureList (WebKit-GTK):

Code: Select all

EnableExplicit

ImportC ""
  webkit_web_view_get_settings.i(*webview);<- how to get / use this ?
  webkit_settings_set_feature_enabled.i(*settings,*feature,enabled.i);<- how to get / use this ?
  webkit_feature_get_name.i(*feature)
  webkit_feature_list_get.i(*feature,index.i)
  webkit_settings_get_all_features.i()
  webkit_settings_get_development_features.i()
  webkit_settings_get_experimental_features.i()
  webkit_feature_list_get_length.i(*list)
  webkit_feature_list_ref.i(*list)
  webkit_feature_list_unref.i(*list)
EndImport

Structure _WEBKIT_FEATURE_LIST
  *feature
  *reference
  count.i
  position.i
  *entry
EndStructure

Procedure.i WebViewFeatureListOpen()
  Protected._WEBKIT_FEATURE_LIST *list
  With *list
    *list = AllocateStructure(_WEBKIT_FEATURE_LIST)
    If *list
      \feature = webkit_settings_get_all_features()
      If \feature
        \reference = webkit_feature_list_ref(\feature)
        If \reference
          \count = webkit_feature_list_get_length(\reference)
          ProcedureReturn *list
        EndIf
      EndIf
      FreeStructure(*list)    
    EndIf
    ProcedureReturn #Null
  EndWith
EndProcedure

Procedure.i WebViewFeatureCount(*list._WEBKIT_FEATURE_LIST)
  With *list
    ProcedureReturn \count
  EndWith
EndProcedure

Procedure.i WebViewFeatureListReset(*list._WEBKIT_FEATURE_LIST)
  With *list
    \position = #Null
    ProcedureReturn #Null
  EndWith
EndProcedure

Procedure.i WebViewFeatureNext(*list._WEBKIT_FEATURE_LIST)
  With *list
    If \position < \count
      \entry = webkit_feature_list_get(\reference,\position)
      \position + 1
      ProcedureReturn #True
    EndIf
    \position = 0
    ProcedureReturn #False
  EndWith
EndProcedure

Procedure.s WebViewFeatureName(*list._WEBKIT_FEATURE_LIST)
  Protected *name
  With *list
    *name = webkit_feature_get_name(\entry)
    If *name
      ProcedureReturn PeekS(*name,-1,#PB_UTF8)
    EndIf
    ProcedureReturn #Null$
  EndWith
EndProcedure

Procedure.i WebViewFeatureListClose(*list._WEBKIT_FEATURE_LIST)
  With *list
    webkit_feature_list_unref(\reference)
    FreeStructure(*list)
    ProcedureReturn #Null
  EndWith 
EndProcedure

Procedure.i main()
  Protected *list
  Protected.s name
  If OpenWindow(0,#Null,#Null,800,600,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
    WebViewGadget(0,0,0,WindowWidth(0),WindowHeight(0))
    
    *list = WebViewFeatureListOpen()
    If *list
      While WebViewFeatureNext(*list)
        name = WebViewFeatureName(*list)
        If name
          Debug name
        EndIf
      Wend
    EndIf
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
      EndSelect
    ForEver
    CloseWindow(0)  
  EndIf
EndProcedure

End main()

Re: WebViewGadget() access to settings / features ?

Posted: Sun Jun 22, 2025 2:26 pm
by mk-soft
I have tried to set the private browsing. With g_object_set_property and webkit_settings_set_enable_private_browsing.
With both the private browsing is not activated and returns false with the get property.

Tested with WebGadgetExtensions

Code: Select all

    Define result.GValue, value.GValue
    value\g_type = #G_TYPE_BOOLEAN
    g_value_set_boolean_(@value, #True)
    type = WebKit_SetProperty(#MainWebGadget, "enable-private-browsing", @value.GValue)
    
    type = WebKit_GetProperty(#MainWebGadget, "enable-private-browsing", @result.GValue)
    Debug "enable-private-browsing = " + g_value_get_boolean_(result)

Re: WebViewGadget() access to settings / features ?

Posted: Sun Jun 22, 2025 3:36 pm
by Mijikai
@mk-soft thanks for the info & link.
Had the same result, seems like its not possible.

Theres also:

Code: Select all

gboolean
webkit_website_data_manager_is_ephemeral (
  WebKitWebsiteDataManager* manager
)

Re: WebViewGadget() access to settings / features ?

Posted: Mon Jun 23, 2025 8:51 am
by Kukulkan
Due to my knowledge, the PB WebViewGadget is based on the webview project. Maybe this points to the correct direction for any additional API?

The available webview API is here. The function webview_get_native_handle looks promising...

Re: WebViewGadget() access to settings / features ?

Posted: Mon Jun 23, 2025 12:20 pm
by mk-soft
The webkit interface is known for Linux and is already used by PB and my WebGadget Extentions.
I assume that the webview must be created with default settings and that these settings cannot be changed later with private browsing.

See https://webkitgtk.org/reference/webkit2 ... bView.html

Re: WebViewGadget() access to settings / features ?

Posted: Mon Jun 23, 2025 6:26 pm
by Mijikai
I assume its the same for the WebGadget() ?
How about the history, is there a way to delete it ?

Re: WebViewGadget() access to settings / features ?

Posted: Mon Jun 23, 2025 8:00 pm
by mk-soft
Mijikai wrote: Mon Jun 23, 2025 6:26 pm I assume its the same for the WebGadget() ?
How about the history, is there a way to delete it ?
See your folder "/home/[UserName]/.local/share/[YourWebApp]

Re: WebViewGadget() access to settings / features ?

Posted: Mon Jun 23, 2025 8:47 pm
by Mijikai
@mk-soft thanks, i will give it a try :D