|
1 | 1 | #tag Module |
2 | 2 | Protected Module Controls |
3 | | - #tag Method, Flags = &h1 |
4 | | - Protected Sub GTK3_GlobalStyleCSS() |
5 | | - //GTK3 |
6 | | - #If TargetLinux and (XojoVersion >= 2017.02) Then |
7 | | - Dim sLinuxOSVersion As String = "undefined" |
8 | | - |
9 | | - Dim shlHost As New Shell |
10 | | - shlHost.Execute "lsb_release -d" 'Description: Ubuntu 16.04.3 LTS |
11 | | - Dim sResult As String |
12 | | - if (shlHost.ErrorCode = 0) then sResult = Trim(shlHost.Result) |
13 | | - |
14 | | - 'if we get the expected result |
15 | | - if (Left(sResult, 12) = "Description:") then |
16 | | - sResult = ReplaceLineEndings(sResult, " ") |
17 | | - sLinuxOSVersion = Trim(Mid(sResult, 13)) |
18 | | - end if |
19 | | - |
20 | | - |
21 | | - Dim sStylesCSS() As String |
22 | | - |
23 | | - sStylesCSS.Append("entry, .entry { min-height:10px; min-width:18px; }") |
24 | | - sStylesCSS.Append("entry, .entry { padding:1px; padding-left: 5px; padding-right: 5px; margin:0px; }") |
25 | | - if (InStr(sLinuxOSVersion, "Ubuntu 16.04") > 0) then |
26 | | - sStylesCSS.Append("entry, .entry { padding:4px; }") |
27 | | - end if |
28 | | - sStylesCSS.Append("button, .button { min-height:16px; min-width:18px; }") |
29 | | - sStylesCSS.Append("button, .button { padding:0px; padding-left: 4px; padding-right: 4px; margin:0px; }") |
30 | | - sStylesCSS.Append("messagedialog .dialog-action-area button { padding: 5px; }") |
31 | | - sStylesCSS.Append("GtkMessageDialog * { padding: 5px; margin: 5px; }") |
32 | | - sStylesCSS.Append("GtkMessageDialog GtkButton GtkLabel{ padding: 4px; padding-top: 2px; padding-bottom: 4px; margin: 0px; }") |
33 | | - 'sStylesCSS.Append("scrollbar.horizontal trough slider { min-height:8px; }") |
34 | | - 'sStylesCSS.Append("scrollbar.vertical trough slider { min-width:8px; }") |
35 | | - sStylesCSS.Append("progressbar trough { min-width:1px; }") |
36 | | - |
37 | | - 'Ubuntu 14 has a parsing error when assigning "min-width/height" |
38 | | - 'so let's go through the Styles one-by-one, and just assign those that work in the client's distribution |
39 | | - for i As Integer = 0 to UBound(sStylesCSS) |
40 | | - GTK3_GlobalStyleCSS = sStylesCSS(i) |
41 | | - next |
42 | | - #EndIf |
43 | | - End Sub |
44 | | - #tag EndMethod |
45 | | - |
46 | | - #tag Method, Flags = &h21 |
47 | | - Private Sub GTK3_GlobalStyleCSS(Assigns psCSSData As String) |
48 | | - //GTK3 |
49 | | - #If TargetLinux and (XojoVersion >= 2017.02) Then |
50 | | - If (Trim(psCSSData) = "") Then Return |
51 | | - |
52 | | - Try |
53 | | - Declare Function gdk_screen_get_default Lib "libgdk-3" () As Ptr |
54 | | - Declare Function gtk_css_provider_new Lib "libgtk-3" () As Ptr |
55 | | - Declare Function gtk_css_provider_load_from_data Lib "libgtk-3" (provider As Ptr, data As CString, dataLen As Integer, error As Ptr) As Boolean |
56 | | - Declare Sub gtk_style_context_add_provider_for_screen Lib "libgtk-3" (Screen As Ptr, provider As Ptr, priority As UInt32) |
57 | | - Declare Sub g_object_unref Lib "libgobject-2.0" (obj As Ptr) |
58 | | - |
59 | | - Const GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600 |
60 | | - |
61 | | - Dim Screen As Ptr = gdk_screen_get_default |
62 | | - Dim provider As Ptr = gtk_css_provider_new |
63 | | - If (provider = Nil) Then Return |
64 | | - |
65 | | - try |
66 | | - If gtk_css_provider_load_from_data(provider, psCSSData, psCSSData.Len, Nil) Then |
67 | | - gtk_style_context_add_provider_for_screen(Screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION) |
68 | | - End If |
69 | | - |
70 | | - Catch err As RuntimeException |
71 | | - 'ignore |
72 | | - Finally |
73 | | - g_object_unref(provider) |
74 | | - End Try |
75 | | - |
76 | | - Catch err As RuntimeException |
77 | | - 'ignore |
78 | | - End Try |
79 | | - |
80 | | - #EndIf |
81 | | - End Sub |
82 | | - #tag EndMethod |
83 | | - |
84 | | - #tag Method, Flags = &h0 |
85 | | - Sub InitControl_GTK3(Extends poControl As Control) |
86 | | - //GTK3 |
87 | | - #If TargetLinux And (XojoVersion >= 2017.02) Then |
88 | | - Declare Sub g_object_set Lib "libgtk-3" (obj As Ptr, name As CString, value As Int32, term As ptr=Nil) |
89 | | - Declare Function gtk_bin_get_child Lib "libgtk-3" (obj As ptr) As Ptr |
90 | | - |
91 | | - If (poControl IsA TextField) Then |
92 | | - g_object_set(Ptr(TextField(poControl).Handle), "width-chars", 0) |
93 | | - End If |
94 | | - |
95 | | - If (poControl IsA ComboBox) Then |
96 | | - Dim t As Ptr = gtk_bin_get_child(Ptr(ComboBox(poControl).Handle)) |
97 | | - g_object_set(t, "width-chars", 0) |
98 | | - End If |
99 | | - #EndIf |
100 | | - |
101 | | - |
102 | | - End Sub |
103 | | - #tag EndMethod |
104 | | - |
105 | 3 | #tag Method, Flags = &h1 |
106 | 4 | Protected Sub InitControl_Height(poControl As RectControl, Assigns piHeight As Integer) |
107 | 5 | if (poControl.Height < piHeight) then |
|
0 commit comments