Skip to content

Commit e0265e9

Browse files
committed
v1.9.0: Now uses modGTK3 from https://bitbucket.org/pidog/modgtk3/ (Version 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.
1 parent 1b6d4b9 commit e0265e9

File tree

7 files changed

+800
-47
lines changed

7 files changed

+800
-47
lines changed

cef/App.rbbas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#tag Class
22
Protected Class App
33
Inherits Application
4+
#tag Event
5+
Sub Open()
6+
#if TargetLinux
7+
// Adjust control and font sizes on Linux. See the About note in the modGTK3 module
8+
modGTK3.initGtkEntryFix // adjusts the char-widths property of GtkEntry to be 0
9+
modGTK3.initGtkWidgetHeightFix // adjusts all controls to be at least their minimum height
10+
modGTK3.InitGlobalGTK3Style // various CSS tweaks to override theme CSS
11+
#endif
12+
End Sub
13+
#tag EndEvent
14+
415
#tag Event
516
Function UnhandledException(error As RuntimeException) As Boolean
617
Dim md As New MessageDialog

cef/CustomEditField.rbvcp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ Picture=blockFoldedMarker;CustomEditField/imgs/blockFoldedMarker.png;&h1839406E;
7373
Picture=blockFoldedTrailMarker;CustomEditField/imgs/blockFoldedTrailMarker.png;&h56B543D4;&h5781A286;false;0;&h0
7474
Picture=blockStartMarker;CustomEditField/imgs/blockStartMarker.png;&h1678816B;&h5781A286;false;0;&h0
7575
Picture=bookmarksimg;CustomEditField/imgs/bookmarksimg.png;&h4178E4F9;&h5781A286;false;0;&h0
76+
Folder=GTK3;GTK3;&h4151186D;&h0;false
77+
Module=modGTK3;GTK3/modGTK3/modGTK3.rbbas;&h331AFF41;&h4151186D;false
78+
Class=GtkCssParsingErrorInfo;GTK3/modGTK3/GtkCssParsingErrorInfo.rbbas;&h316C6043;&h331AFF41;false
79+
Class=GtkEntryFixHandlerClass;GTK3/modGTK3/GtkEntryFixHandlerClass.rbbas;&h422429B4;&h331AFF41;false
80+
Class=GtkWidgetHeightFixHandlerClass;GTK3/modGTK3/GtkWidgetHeightFixHandlerClass.rbbas;&h542E4BFE;&h331AFF41;false
7681
Picture=knobImage;demoimgs/knobImage.png;&h2B7F7D85;&h539CD772;false;0;&h0
7782
Picture=markerdata;demoimgs/markerdata.png;&h3F09FEB8;&h539CD772;false;0;&h0
7883
Picture=markermask;demoimgs/markermask.png;&h29324403;&h539CD772;false;0;&h0

cef/CustomEditField/CustomEditField.rbbas

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,34 +1027,10 @@ Implements MessageReceiver
10271027
#tag Method, Flags = &h21
10281028
Private Function checkDoubleClick(X as integer, Y as integer) As boolean
10291029
//grabbed from RB examples
1030-
//if SelLength > 0 then Return False
10311030

10321031
dim doubleClickTime, currentClickTicks as Integer
10331032

1034-
#if targetMacOS then
1035-
Declare Function GetDblTime Lib "Carbon" () as Integer
1036-
doubleClickTime = GetDblTime()
1037-
if doubleClickTime <= 0 then
1038-
doubleClickTime = 30
1039-
end
1040-
#endif
1041-
1042-
#if targetWin32 then
1043-
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
1044-
doubleClickTime = GetDoubleClickTime()
1045-
// DoubleClickTime now holds the number of milliseconds
1046-
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
1047-
#endif
1048-
1049-
#if TargetLinux then
1050-
Declare Function gtk_settings_get_default lib "libgtk-x11-2.0.so" as Ptr
1051-
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)
1052-
dim gtkSettings as MemoryBlock
1053-
gtkSettings = gtk_settings_get_default()
1054-
g_object_get(gtkSettings,"gtk-double-click-time",doubleClickTime, 0)
1055-
// DoubleClickTime now holds the number of milliseconds
1056-
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
1057-
#endif
1033+
doubleClickTime = getDoubleClickTimeTicks()
10581034

10591035
dim result as Boolean = false
10601036
currentClickTicks = ticks
@@ -1080,31 +1056,11 @@ Implements MessageReceiver
10801056
#tag Method, Flags = &h21
10811057
Private Function checkTripleClick(X as integer, Y as integer) As boolean
10821058
//grabbed from RB examples
1083-
//if SelLength > 0 then Return False
1059+
10841060
if isDoubleClick = True then
10851061
dim doubleClickTime, currentClickTicks as Integer
10861062

1087-
#if targetMacOS then
1088-
Declare Function GetDblTime Lib "Carbon" () as Integer
1089-
doubleClickTime = GetDblTime()
1090-
#endif
1091-
1092-
#if targetWin32 then
1093-
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
1094-
doubleClickTime = GetDoubleClickTime()
1095-
// DoubleClickTime now holds the number of milliseconds
1096-
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
1097-
#endif
1098-
1099-
#if TargetLinux then
1100-
Declare Function gtk_settings_get_default lib "libgtk-x11-2.0.so" as Ptr
1101-
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)
1102-
dim gtkSettings as MemoryBlock
1103-
gtkSettings = gtk_settings_get_default()
1104-
g_object_get(gtkSettings,"gtk-double-click-time",doubleClickTime, 0)
1105-
// DoubleClickTime now holds the number of milliseconds
1106-
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
1107-
#endif
1063+
doubleClickTime = getDoubleClickTimeTicks()
11081064

11091065
dim result as Boolean = false
11101066
currentClickTicks = ticks
@@ -2053,6 +2009,44 @@ Implements MessageReceiver
20532009
End Sub
20542010
#tag EndMethod
20552011

2012+
#tag Method, Flags = &h21
2013+
Private Function getDoubleClickTimeTicks() As Integer
2014+
dim doubleClickTime as Integer
2015+
2016+
#if targetMacOS then
2017+
Declare Function GetDblTime Lib "Carbon" () as Integer
2018+
doubleClickTime = GetDblTime()
2019+
#endif
2020+
2021+
#if targetWin32 then
2022+
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
2023+
doubleClickTime = GetDoubleClickTime()
2024+
// DoubleClickTime now holds the number of milliseconds
2025+
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
2026+
#endif
2027+
2028+
#if TargetLinux then
2029+
const libname = "libgtk-3"
2030+
soft Declare Function gtk_settings_get_default lib libname () as Ptr
2031+
soft Declare Sub g_object_get lib libname (Obj as Ptr, first_property_name as CString, byref doubleClicktime as Integer, Null as Integer)
2032+
if not system.IsFunctionAvailable ("gtk_settings_get_default", libname) then
2033+
break
2034+
else
2035+
dim gtkSettings as Ptr = gtk_settings_get_default()
2036+
g_object_get (gtkSettings, "gtk-double-click-time", doubleClickTime, 0)
2037+
// DoubleClickTime now holds the number of milliseconds
2038+
doubleClickTime = doubleClickTime / 1000.0 * 60 ' converted to Ticks
2039+
end if
2040+
#endif
2041+
2042+
if doubleClickTime <= 0 then
2043+
doubleClickTime = 20 // 20 ticks = 1/3s = 330ms
2044+
end
2045+
2046+
return doubleClickTime
2047+
End Function
2048+
#tag EndMethod
2049+
20562050
#tag Method, Flags = &h1
20572051
Protected Sub getFieldXY(byref locx as Double, byref locy as Double)
20582052
//find the window where this control is...
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#tag Class
2+
Protected Class GtkCssParsingErrorInfo
3+
#tag Method, Flags = &h0
4+
Sub Constructor(provider as ptr, Section as ptr, error as ptr)
5+
#If TargetLinux
6+
7+
Declare Function gtk_css_section_get_start_line Lib "libgtk-3" (obj as ptr) As uint32
8+
Declare Function gtk_css_section_get_start_position Lib "libgtk-3" (obj as ptr) As uint32
9+
Declare Function gtk_css_section_get_end_position Lib "libgtk-3" (obj as ptr) As uint32
10+
Declare Function gtk_css_section_get_end_line Lib "libgtk-3" (obj as ptr) As uint32
11+
Declare Function g_quark_to_string Lib "libgtk-3" (obj as ptr) As CString
12+
13+
StartLine=gtk_css_section_get_start_line(Section)
14+
StartPosition=gtk_css_section_get_start_position(Section)
15+
Endline=gtk_css_section_get_end_line(Section)
16+
EndPosition=gtk_css_section_get_end_position(Section)
17+
18+
me.Provider=provider
19+
20+
ErrorMessage=error.CString(8)
21+
#Else
22+
#Pragma unused error
23+
#Pragma unused Section
24+
#Pragma unused provider
25+
#EndIf
26+
End Sub
27+
#tag EndMethod
28+
29+
#tag Method, Flags = &h21
30+
Private Shared Sub Gtk_parsing_error(GtkCssProvider as ptr, GtkCssSection as ptr, GError As ptr, data as ptr)
31+
#If TargetLinux
32+
33+
LastParsingError=new GtkCssParsingErrorInfo(GtkCssProvider,GtkCssSection,GError)
34+
35+
#Else
36+
#Pragma unused data
37+
#Pragma unused GError
38+
#Pragma unused GtkCssSection
39+
#Pragma unused GtkCssProvider
40+
#EndIf
41+
End Sub
42+
#tag EndMethod
43+
44+
45+
#tag Property, Flags = &h0
46+
Endline As Integer
47+
#tag EndProperty
48+
49+
#tag Property, Flags = &h0
50+
EndPosition As Integer
51+
#tag EndProperty
52+
53+
#tag Property, Flags = &h0
54+
ErrorMessage As String
55+
#tag EndProperty
56+
57+
#tag Property, Flags = &h0
58+
Shared LastParsingError As modGTK3.GtkCssParsingErrorInfo
59+
#tag EndProperty
60+
61+
#tag Property, Flags = &h0
62+
Provider As ptr
63+
#tag EndProperty
64+
65+
#tag Property, Flags = &h0
66+
StartLine As Integer
67+
#tag EndProperty
68+
69+
#tag Property, Flags = &h0
70+
StartPosition As Integer
71+
#tag EndProperty
72+
73+
74+
#tag ViewBehavior
75+
#tag ViewProperty
76+
Name="Endline"
77+
Group="Behavior"
78+
Type="Integer"
79+
#tag EndViewProperty
80+
#tag ViewProperty
81+
Name="EndPosition"
82+
Group="Behavior"
83+
Type="Integer"
84+
#tag EndViewProperty
85+
#tag ViewProperty
86+
Name="ErrorMessage"
87+
Group="Behavior"
88+
Type="String"
89+
EditorType="MultiLineEditor"
90+
#tag EndViewProperty
91+
#tag ViewProperty
92+
Name="Index"
93+
Visible=true
94+
Group="ID"
95+
InitialValue="-2147483648"
96+
InheritedFrom="Object"
97+
#tag EndViewProperty
98+
#tag ViewProperty
99+
Name="Left"
100+
Visible=true
101+
Group="Position"
102+
InitialValue="0"
103+
InheritedFrom="Object"
104+
#tag EndViewProperty
105+
#tag ViewProperty
106+
Name="Name"
107+
Visible=true
108+
Group="ID"
109+
InheritedFrom="Object"
110+
#tag EndViewProperty
111+
#tag ViewProperty
112+
Name="StartLine"
113+
Group="Behavior"
114+
Type="Integer"
115+
#tag EndViewProperty
116+
#tag ViewProperty
117+
Name="StartPosition"
118+
Group="Behavior"
119+
Type="Integer"
120+
#tag EndViewProperty
121+
#tag ViewProperty
122+
Name="Super"
123+
Visible=true
124+
Group="ID"
125+
InheritedFrom="Object"
126+
#tag EndViewProperty
127+
#tag ViewProperty
128+
Name="Top"
129+
Visible=true
130+
Group="Position"
131+
InitialValue="0"
132+
InheritedFrom="Object"
133+
#tag EndViewProperty
134+
#tag EndViewBehavior
135+
End Class
136+
#tag EndClass
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#tag Class
2+
Private Class GtkEntryFixHandlerClass
3+
#tag Method, Flags = &h0
4+
Sub constructor()
5+
6+
#if TargetLinux
7+
FoundEntries=new Dictionary
8+
declare function g_signal_add_emission_hook lib "libgobject-2" (id as uint32,detail as int32,hook as ptr, notify as ptr) as uint32
9+
declare function g_signal_lookup lib "libgobject-2" ( name as CString, type as uint32) as uint32
10+
Declare Function gtk_widget_get_type Lib "libgtk-3" () As uint32
11+
Declare Function gtk_entry_get_type Lib "libgtk-3" () As uint32
12+
13+
dim type as uint32=gtk_entry_get_type
14+
dim wtype as uint32=gtk_widget_get_type
15+
GtkEntryCallBackID=g_signal_add_emission_hook(g_signal_lookup("map",type),0,AddressOf GtkEntryFixCallback,nil)
16+
17+
#endif
18+
End Sub
19+
#tag EndMethod
20+
21+
#tag Method, Flags = &h0
22+
Sub destructor()
23+
#if TargetLinux
24+
25+
declare sub g_signal_remove_emission_hook lib "libgobject-2" (id as uint32,detail as int32)
26+
declare function g_signal_lookup lib "libgobject-2" ( name as CString, type as uint32) as uint32
27+
Declare Function gtk_entry_get_type Lib "libgtk-3" () As uint32
28+
29+
dim type as uint32=gtk_entry_get_type
30+
g_signal_remove_emission_hook(g_signal_lookup("map",type),GtkEntryCallBackID)
31+
32+
#endif
33+
End Sub
34+
#tag EndMethod
35+
36+
#tag Method, Flags = &h21
37+
Private Shared Function GtkEntryFixCallback(hint as ptr, count as uint32,params as ptr,data as ptr) As Boolean
38+
#If TargetLinux
39+
40+
declare function g_value_get_object lib "libgtk-3" ( cls as ptr)as ptr
41+
declare function g_object_class_find_property lib "libgtk-3" ( cls as ptr, prop as cstring)as ptr
42+
Declare Sub g_object_set Lib "libgtk-3" (obj As ptr, name As CString, value As Int32,term As ptr=Nil)
43+
44+
dim widget as ptr=g_value_get_object(params)
45+
46+
if FoundEntries.HasKey(widget) then Return true
47+
48+
dim prop as ptr=g_object_class_find_property(widget.ptr(0),"width-chars")
49+
if prop<>nil then
50+
g_object_set(widget, "width-chars", 0)
51+
end if
52+
53+
FoundEntries.Value(widget)=1
54+
55+
Return true
56+
#Else
57+
#Pragma unused data
58+
#Pragma unused params
59+
#Pragma unused count
60+
#Pragma unused hint
61+
#EndIf
62+
End Function
63+
#tag EndMethod
64+
65+
66+
#tag Property, Flags = &h0
67+
Shared FoundEntries As Dictionary
68+
#tag EndProperty
69+
70+
#tag Property, Flags = &h21
71+
Private GtkEntryCallBackID As uint32
72+
#tag EndProperty
73+
74+
75+
#tag ViewBehavior
76+
#tag ViewProperty
77+
Name="Index"
78+
Visible=true
79+
Group="ID"
80+
InitialValue="-2147483648"
81+
InheritedFrom="Object"
82+
#tag EndViewProperty
83+
#tag ViewProperty
84+
Name="Left"
85+
Visible=true
86+
Group="Position"
87+
InitialValue="0"
88+
InheritedFrom="Object"
89+
#tag EndViewProperty
90+
#tag ViewProperty
91+
Name="Name"
92+
Visible=true
93+
Group="ID"
94+
InheritedFrom="Object"
95+
#tag EndViewProperty
96+
#tag ViewProperty
97+
Name="Super"
98+
Visible=true
99+
Group="ID"
100+
InheritedFrom="Object"
101+
#tag EndViewProperty
102+
#tag ViewProperty
103+
Name="Top"
104+
Visible=true
105+
Group="Position"
106+
InitialValue="0"
107+
InheritedFrom="Object"
108+
#tag EndViewProperty
109+
#tag EndViewBehavior
110+
End Class
111+
#tag EndClass

0 commit comments

Comments
 (0)