Skip to content

Commit c60f863

Browse files
committed
Linux: Set Window Icon
1 parent d2822dd commit c60f863

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

Components/Modules/Controls.xojo_code

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,32 @@ Protected Module Controls
113113
End Sub
114114
#tag EndMethod
115115

116+
#tag Method, Flags = &h0, CompatibilityFlags = TargetHasGUI
117+
Sub SetWindowIcon_Linux(Extends poWindow As Window, Assigns poIcon As Picture)
118+
'Set Icon for a Window
119+
'in order to show the Icon in the 'Launch Bar'
120+
121+
#If TargetLinux And TargetDesktop Then 'GTK3
122+
If (poIcon = Nil) Then Return
123+
124+
Declare Sub gtk_window_set_icon Lib "libgtk-3" (windowHandle As Integer, icon As Ptr)
125+
Declare Sub g_object_unref Lib "libgtk-3" (Object As Ptr)
126+
127+
Try
128+
Dim ptrToIcon As Ptr = poIcon.CopyOSHandle(Picture.HandleType.LinuxGdkPixbuf)
129+
If (ptrToIcon <> Nil) Then
130+
gtk_window_set_icon(poWindow.Handle, ptrToIcon)
131+
g_object_unref(ptrToIcon)
132+
End If
133+
Catch err As RuntimeException
134+
'ignore
135+
End Try
136+
137+
#EndIf
138+
139+
End Sub
140+
#tag EndMethod
141+
116142
#tag Method, Flags = &h0, CompatibilityFlags = TargetHasGUI
117143
Sub WM_SendMessage(piHwnd as Integer, piMsg as UInt32, piWParam as Integer, piLParam as Integer)
118144
#if TargetWindows then
@@ -150,34 +176,41 @@ Protected Module Controls
150176
Name="Name"
151177
Visible=true
152178
Group="ID"
179+
InitialValue=""
153180
Type="String"
181+
EditorType=""
154182
#tag EndViewProperty
155183
#tag ViewProperty
156184
Name="Index"
157185
Visible=true
158186
Group="ID"
159187
InitialValue="-2147483648"
160188
Type="Integer"
189+
EditorType=""
161190
#tag EndViewProperty
162191
#tag ViewProperty
163192
Name="Super"
164193
Visible=true
165194
Group="ID"
195+
InitialValue=""
166196
Type="String"
197+
EditorType=""
167198
#tag EndViewProperty
168199
#tag ViewProperty
169200
Name="Left"
170201
Visible=true
171202
Group="Position"
172203
InitialValue="0"
173204
Type="Integer"
205+
EditorType=""
174206
#tag EndViewProperty
175207
#tag ViewProperty
176208
Name="Top"
177209
Visible=true
178210
Group="Position"
179211
InitialValue="0"
180212
Type="Integer"
213+
EditorType=""
181214
#tag EndViewProperty
182215
#tag EndViewBehavior
183216
End Module

Windows/ConnectWindow.rbfrm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,17 @@ End
699699
End Function
700700
#tag EndMethod
701701

702+
#tag Method, Flags = &h0
703+
Sub Constructor()
704+
Super.Constructor
705+
706+
#If TargetLinux And TargetDesktop Then 'GTK3
707+
Dim oIcon As Picture = icon.BestRepresentation(128, 128, 1.0)
708+
If (oIcon <> Nil) Then Self.SetWindowIcon_Linux = oIcon
709+
#EndIf
710+
End Sub
711+
#tag EndMethod
712+
702713
#tag Method, Flags = &h21
703714
Private Function GetSSLCertificate() As FolderItem
704715
Dim f As FolderItem

Windows/ServerWindow.rbfrm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7897,6 +7897,10 @@ End
78977897
db = serverDB
78987898
Super.Constructor
78997899

7900+
#If TargetLinux And TargetDesktop Then 'GTK3
7901+
Dim oIcon As Picture = icon.BestRepresentation(128, 128, 1.0)
7902+
If (oIcon <> Nil) Then Self.SetWindowIcon_Linux = oIcon
7903+
#EndIf
79007904
End Sub
79017905
#tag EndMethod
79027906

0 commit comments

Comments
 (0)