Skip to content

Commit

Permalink
v1.9.0: Now uses modGTK3 from https://bitbucket.org/pidog/modgtk3/ (V…
Browse files Browse the repository at this point in the history
…ersion from 2020-01-28) to improve size and layout of controls under Linux. Also updates the checkDoubleClick() to use the newer "gkt3" lib so that it won't crash on Linux when clicking into the textfield.
  • Loading branch information
tempelmann committed Jul 11, 2020
1 parent 1b6d4b9 commit e0265e9
Show file tree
Hide file tree
Showing 7 changed files with 800 additions and 47 deletions.
11 changes: 11 additions & 0 deletions cef/App.rbbas
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#tag Class
Protected Class App
Inherits Application
#tag Event
Sub Open()
#if TargetLinux
// Adjust control and font sizes on Linux. See the About note in the modGTK3 module
modGTK3.initGtkEntryFix // adjusts the char-widths property of GtkEntry to be 0
modGTK3.initGtkWidgetHeightFix // adjusts all controls to be at least their minimum height
modGTK3.InitGlobalGTK3Style // various CSS tweaks to override theme CSS
#endif
End Sub
#tag EndEvent

#tag Event
Function UnhandledException(error As RuntimeException) As Boolean
Dim md As New MessageDialog
Expand Down
5 changes: 5 additions & 0 deletions cef/CustomEditField.rbvcp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Picture=blockFoldedMarker;CustomEditField/imgs/blockFoldedMarker.png;&h1839406E;
Picture=blockFoldedTrailMarker;CustomEditField/imgs/blockFoldedTrailMarker.png;&h56B543D4;&h5781A286;false;0;&h0
Picture=blockStartMarker;CustomEditField/imgs/blockStartMarker.png;&h1678816B;&h5781A286;false;0;&h0
Picture=bookmarksimg;CustomEditField/imgs/bookmarksimg.png;&h4178E4F9;&h5781A286;false;0;&h0
Folder=GTK3;GTK3;&h4151186D;&h0;false
Module=modGTK3;GTK3/modGTK3/modGTK3.rbbas;&h331AFF41;&h4151186D;false
Class=GtkCssParsingErrorInfo;GTK3/modGTK3/GtkCssParsingErrorInfo.rbbas;&h316C6043;&h331AFF41;false
Class=GtkEntryFixHandlerClass;GTK3/modGTK3/GtkEntryFixHandlerClass.rbbas;&h422429B4;&h331AFF41;false
Class=GtkWidgetHeightFixHandlerClass;GTK3/modGTK3/GtkWidgetHeightFixHandlerClass.rbbas;&h542E4BFE;&h331AFF41;false
Picture=knobImage;demoimgs/knobImage.png;&h2B7F7D85;&h539CD772;false;0;&h0
Picture=markerdata;demoimgs/markerdata.png;&h3F09FEB8;&h539CD772;false;0;&h0
Picture=markermask;demoimgs/markermask.png;&h29324403;&h539CD772;false;0;&h0
Expand Down
88 changes: 41 additions & 47 deletions cef/CustomEditField/CustomEditField.rbbas
Original file line number Diff line number Diff line change
Expand Up @@ -1027,34 +1027,10 @@ Implements MessageReceiver
#tag Method, Flags = &h21
Private Function checkDoubleClick(X as integer, Y as integer) As boolean
//grabbed from RB examples
//if SelLength > 0 then Return False

dim doubleClickTime, currentClickTicks as Integer

#if targetMacOS then
Declare Function GetDblTime Lib "Carbon" () as Integer
doubleClickTime = GetDblTime()
if doubleClickTime <= 0 then
doubleClickTime = 30
end
#endif

#if targetWin32 then
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
doubleClickTime = GetDoubleClickTime()
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
#endif

#if TargetLinux then
Declare Function gtk_settings_get_default lib "libgtk-x11-2.0.so" as Ptr
Declare Sub g_object_get lib "libgtk-x11-2.0.so" (Obj as Ptr, first_property_name as CString, byref doubleClicktime as Integer, Null as Integer)
dim gtkSettings as MemoryBlock
gtkSettings = gtk_settings_get_default()
g_object_get(gtkSettings,"gtk-double-click-time",doubleClickTime, 0)
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
#endif
doubleClickTime = getDoubleClickTimeTicks()

dim result as Boolean = false
currentClickTicks = ticks
Expand All @@ -1080,31 +1056,11 @@ Implements MessageReceiver
#tag Method, Flags = &h21
Private Function checkTripleClick(X as integer, Y as integer) As boolean
//grabbed from RB examples
//if SelLength > 0 then Return False

if isDoubleClick = True then
dim doubleClickTime, currentClickTicks as Integer

#if targetMacOS then
Declare Function GetDblTime Lib "Carbon" () as Integer
doubleClickTime = GetDblTime()
#endif

#if targetWin32 then
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
doubleClickTime = GetDoubleClickTime()
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
#endif

#if TargetLinux then
Declare Function gtk_settings_get_default lib "libgtk-x11-2.0.so" as Ptr
Declare Sub g_object_get lib "libgtk-x11-2.0.so" (Obj as Ptr, first_property_name as CString, byref doubleClicktime as Integer, Null as Integer)
dim gtkSettings as MemoryBlock
gtkSettings = gtk_settings_get_default()
g_object_get(gtkSettings,"gtk-double-click-time",doubleClickTime, 0)
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
#endif
doubleClickTime = getDoubleClickTimeTicks()

dim result as Boolean = false
currentClickTicks = ticks
Expand Down Expand Up @@ -2053,6 +2009,44 @@ Implements MessageReceiver
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Function getDoubleClickTimeTicks() As Integer
dim doubleClickTime as Integer

#if targetMacOS then
Declare Function GetDblTime Lib "Carbon" () as Integer
doubleClickTime = GetDblTime()
#endif

#if targetWin32 then
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
doubleClickTime = GetDoubleClickTime()
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
#endif

#if TargetLinux then
const libname = "libgtk-3"
soft Declare Function gtk_settings_get_default lib libname () as Ptr
soft Declare Sub g_object_get lib libname (Obj as Ptr, first_property_name as CString, byref doubleClicktime as Integer, Null as Integer)
if not system.IsFunctionAvailable ("gtk_settings_get_default", libname) then
break
else
dim gtkSettings as Ptr = gtk_settings_get_default()
g_object_get (gtkSettings, "gtk-double-click-time", doubleClickTime, 0)
// DoubleClickTime now holds the number of milliseconds
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
end if
#endif

if doubleClickTime <= 0 then
doubleClickTime = 20 // 20 ticks = 1/3s = 330ms
end

return doubleClickTime
End Function
#tag EndMethod

#tag Method, Flags = &h1
Protected Sub getFieldXY(byref locx as Double, byref locy as Double)
//find the window where this control is...
Expand Down
136 changes: 136 additions & 0 deletions cef/GTK3/modGTK3/GtkCssParsingErrorInfo.rbbas
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#tag Class
Protected Class GtkCssParsingErrorInfo
#tag Method, Flags = &h0
Sub Constructor(provider as ptr, Section as ptr, error as ptr)
#If TargetLinux

Declare Function gtk_css_section_get_start_line Lib "libgtk-3" (obj as ptr) As uint32
Declare Function gtk_css_section_get_start_position Lib "libgtk-3" (obj as ptr) As uint32
Declare Function gtk_css_section_get_end_position Lib "libgtk-3" (obj as ptr) As uint32
Declare Function gtk_css_section_get_end_line Lib "libgtk-3" (obj as ptr) As uint32
Declare Function g_quark_to_string Lib "libgtk-3" (obj as ptr) As CString

StartLine=gtk_css_section_get_start_line(Section)
StartPosition=gtk_css_section_get_start_position(Section)
Endline=gtk_css_section_get_end_line(Section)
EndPosition=gtk_css_section_get_end_position(Section)

me.Provider=provider

ErrorMessage=error.CString(8)
#Else
#Pragma unused error
#Pragma unused Section
#Pragma unused provider
#EndIf
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Shared Sub Gtk_parsing_error(GtkCssProvider as ptr, GtkCssSection as ptr, GError As ptr, data as ptr)
#If TargetLinux

LastParsingError=new GtkCssParsingErrorInfo(GtkCssProvider,GtkCssSection,GError)

#Else
#Pragma unused data
#Pragma unused GError
#Pragma unused GtkCssSection
#Pragma unused GtkCssProvider
#EndIf
End Sub
#tag EndMethod


#tag Property, Flags = &h0
Endline As Integer
#tag EndProperty

#tag Property, Flags = &h0
EndPosition As Integer
#tag EndProperty

#tag Property, Flags = &h0
ErrorMessage As String
#tag EndProperty

#tag Property, Flags = &h0
Shared LastParsingError As modGTK3.GtkCssParsingErrorInfo
#tag EndProperty

#tag Property, Flags = &h0
Provider As ptr
#tag EndProperty

#tag Property, Flags = &h0
StartLine As Integer
#tag EndProperty

#tag Property, Flags = &h0
StartPosition As Integer
#tag EndProperty


#tag ViewBehavior
#tag ViewProperty
Name="Endline"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="EndPosition"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="ErrorMessage"
Group="Behavior"
Type="String"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="StartLine"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="StartPosition"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
InheritedFrom="Object"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
111 changes: 111 additions & 0 deletions cef/GTK3/modGTK3/GtkEntryFixHandlerClass.rbbas
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#tag Class
Private Class GtkEntryFixHandlerClass
#tag Method, Flags = &h0
Sub constructor()

#if TargetLinux
FoundEntries=new Dictionary
declare function g_signal_add_emission_hook lib "libgobject-2" (id as uint32,detail as int32,hook as ptr, notify as ptr) as uint32
declare function g_signal_lookup lib "libgobject-2" ( name as CString, type as uint32) as uint32
Declare Function gtk_widget_get_type Lib "libgtk-3" () As uint32
Declare Function gtk_entry_get_type Lib "libgtk-3" () As uint32

dim type as uint32=gtk_entry_get_type
dim wtype as uint32=gtk_widget_get_type
GtkEntryCallBackID=g_signal_add_emission_hook(g_signal_lookup("map",type),0,AddressOf GtkEntryFixCallback,nil)

#endif
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub destructor()
#if TargetLinux

declare sub g_signal_remove_emission_hook lib "libgobject-2" (id as uint32,detail as int32)
declare function g_signal_lookup lib "libgobject-2" ( name as CString, type as uint32) as uint32
Declare Function gtk_entry_get_type Lib "libgtk-3" () As uint32

dim type as uint32=gtk_entry_get_type
g_signal_remove_emission_hook(g_signal_lookup("map",type),GtkEntryCallBackID)

#endif
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Shared Function GtkEntryFixCallback(hint as ptr, count as uint32,params as ptr,data as ptr) As Boolean
#If TargetLinux

declare function g_value_get_object lib "libgtk-3" ( cls as ptr)as ptr
declare function g_object_class_find_property lib "libgtk-3" ( cls as ptr, prop as cstring)as ptr
Declare Sub g_object_set Lib "libgtk-3" (obj As ptr, name As CString, value As Int32,term As ptr=Nil)

dim widget as ptr=g_value_get_object(params)

if FoundEntries.HasKey(widget) then Return true

dim prop as ptr=g_object_class_find_property(widget.ptr(0),"width-chars")
if prop<>nil then
g_object_set(widget, "width-chars", 0)
end if

FoundEntries.Value(widget)=1

Return true
#Else
#Pragma unused data
#Pragma unused params
#Pragma unused count
#Pragma unused hint
#EndIf
End Function
#tag EndMethod


#tag Property, Flags = &h0
Shared FoundEntries As Dictionary
#tag EndProperty

#tag Property, Flags = &h21
Private GtkEntryCallBackID As uint32
#tag EndProperty


#tag ViewBehavior
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
InheritedFrom="Object"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
InheritedFrom="Object"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
Loading

0 comments on commit e0265e9

Please sign in to comment.