<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GTK+ 3 &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/gtk-3/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 09 Mar 2021 22:03:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>GTK3 Can Be a Pain in the Themes</title>
		<link>https://blog.xojo.com/2018/07/26/gtk3-can-be-a-pain-in-the-themes/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Thu, 26 Jul 2018 10:01:33 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[GTK+ 3]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4586</guid>

					<description><![CDATA[Since Xojo uses GTK3 and native controls that means your app's controls will use the theme of the Linux distribution the app runs on. If this is a problem for your apps, there are a couple ways you can work around it like: using fixed control padding or loading a specific theme.]]></description>
										<content:encoded><![CDATA[<p>Starting with Xojo 2017r2, Linux apps use GTK3. Since Xojo uses native controls that means your app&#8217;s controls will use the theme of the Linux distribution the app runs on. This can sometimes mean that your app&#8217;s UI will not look exactly like what you designed in the Layout Editor because a theme may dramatically change control sizes and padding. This is a problem that can occur with any modern GTK3 app.</p>
<p>If this is a problem for your apps, there are a couple ways you can work around it.</p>
<p><span id="more-4586"></span></p>
<h3>Use Fixed/Locked Control Padding</h3>
<p>For many apps, the primary concern is to not have controls change their size or position depending on the theme being used. You can ensure specific styling for controls in your apps by using a static amount of padding that won&#8217;t change regardless of the user&#8217;s theme selection. This has the benefit of letting your app use other aspects of the theme, such as colors, while maintaining control layout better.</p>
<h3>Have Your App Load and Use a Specific Theme</h3>
<p>If you would like your app to use a specific theme so that your layout works exactly as you want it, you can bundle a theme and load it when your app starts. Your app will use this loaded theme regardless of what the user has selected as a theme for the distribution.</p>
<p>Both of these solutions can be handled by Declares that you put in your App.Open event handler.</p>
<p>We&#8217;ve put together a couple sample projects to demonstrate these two solutions:</p>
<p><a href="http://files.xojo.com/BlogExamples/GTK3ThemeExamples.zip">Download GTK3ThemeExamples</a></p>
<p>The examples should be sufficient for most apps. But if you require more control of themes and how they render widgets, you will have to dig deeper into Linux. The <a href="https://blog.gtk.org/2017/04/05/the-gtk-inspector/">GTK+ Inspector</a> can be a great tool for this as it lets you see property and widget information in real time.</p>
<p>For more information and details, refer to <a href="http://developer.xojo.com/gtk3-themes">GTK3 Themes</a> in the User Guide.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Change Window Opacity Using a Linux Gtk Declare</title>
		<link>https://blog.xojo.com/2018/04/17/change-window-opacity-using-a-linux-gtk-declare/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 17 Apr 2018 10:00:58 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Declares]]></category>
		<category><![CDATA[GTK+ 2]]></category>
		<category><![CDATA[GTK+ 3]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4119</guid>

					<description><![CDATA[You can call into Linux APIs to use methods and properties that are not built into the framework by using the Declare command.]]></description>
										<content:encoded><![CDATA[<p>You can call into Linux APIs to use methods and properties that are not built into the framework by using the Declare command. To create a Declare statement you first need to track down the API you want to use using Linux documentation.</p>
<p><span id="more-4119"></span></p>
<p>The Linux API is largely based on the C/C++ programming language and makes heavy use of structures.</p>
<p>As a simple example, the <a href="https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-opacity">gtk_widget_set_opacity method in libgtk-3</a> can be used to change the window opacity so that it appears more transparent. This is what the method declaration looks like in the Gnome docs:</p>
<pre>void
gtk_widget_set_opacity (GtkWidget *widget,
 double opacity);</pre>
<p>This tells you it is a method (sub) because the &#8220;void&#8221; at the beginning indicates it does not return a value. The first parameter is a pointer to a GtkWidget, which in this case is the handle to the Xojo window. The opacity is a Double in the range of 0 to 1.</p>
<p>So the above method call translates to a Declare that looks like this:</p>
<pre>Declare Sub gtk_widget_set_opacity Lib "libgtk-3" (handle As Integer, opacity As Double)</pre>
<p>To set the window to 75% opacity you can call it like this:</p>
<pre>gtk_widget_set_opacity(Self.Handle, 0.75)</pre>
<p>Because this method is called for a window, you can put it in a Xojo Extension Method to make it easier to call. To do this, create a global method on a module like this:</p>
<pre>Public Sub Opacity(Extends w As Window, value As Double)
  #If TargetLinux Then
    Declare Sub gtk_widget_set_opacity Lib "libgtk-3" (handle As Integer, opacity As Double)
     gtk_widget_set_opacity(w, value)
  #EndIf
End Sub</pre>
<p>Note the use of the &#8220;#If TargetLinux&#8221; line. This prevents this code from being compiled into Windows or macOS builds of your app where the code could possible crash your app.</p>
<p>This now allows you to have code like this on a window&#8217;s Open event to center the window:</p>
<pre>Self.Opacity(0.75)</pre>
<p>To learn more in the Xojo Documentation:</p>
<ul>
<li><a href="https://documentation.xojo.com/topics/declares/calling_native_linux_apis.html">Calling Native Linux APIs</a></li>
</ul>


<p>If there are Linux-related or other topics, regarding Xojo Programming or general technology, you are interested in reading about on the Xojo Blog about please <a href="https://www.xojo.com/company/contact.php">let us know!</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Goodbye GTK+ 2, Hello GTK+ 3</title>
		<link>https://blog.xojo.com/2017/08/15/goodbye-gtk-2-hello-gtk-3/</link>
		
		<dc:creator><![CDATA[William Yu]]></dc:creator>
		<pubDate>Tue, 15 Aug 2017 10:34:33 +0000</pubDate>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[GTK+ 2]]></category>
		<category><![CDATA[GTK+ 3]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=3238</guid>

					<description><![CDATA[With the release of Xojo 2017 Release 2 we have updated our Linux Desktop framework to use GTK+ 3 instead of GTK+ 2.]]></description>
										<content:encoded><![CDATA[<p>With the release of Xojo 2017 Release 2 we have updated our Linux Desktop framework to use GTK+ 3 instead of GTK+ 2. For those not familiar with Linux, GTK+ is a User Interface (i.e. UI) toolkit, much like Cocoa is for macOS and Win32 controls (or WinForms.NET or WPF) is for Windows. GTK+ 2 has been supplying the user interface for Xojo Desktop apps for Linux since we first targeted Linux over a decade ago. It has since been deprecated in favor of GTK+ 3 for quite some time now and GTK+ 2 is typically not installed by default on most Linux distros these days, which makes deploying Xojo Desktop apps on Linux more painful. Unfortunately GTK+ 3 is not ABI compatible with GTK+ 2 so we could not migrate to using GTK+ 3 without completely ditching GTK+ 2.</p>
<p>Let&#8217;s take a closer look at what this means for your Linux apps:</p>
<p><span id="more-3238"></span></p>
<table cellpadding="5">
<tbody>
<tr>
<th>Target</th>
<th>2017r1.1 (and prior) requirements</th>
<th>2017r2 requirements</th>
</tr>
<tr>
<td>Linux console/web apps</td>
<td>Ubuntu 10.04, CentOS 6.0, etc.</td>
<td><b>No change</b></td>
</tr>
<tr>
<td>Linux (x86, x86-64) Desktop apps</td>
<td>Ubuntu 10.04, CentOS 6.0, etc.</p>
<ul>
<li>GTK+ 2.20</li>
<li>libwebkitgtk-1.0.0 (for HTMLViewer)</li>
</ul>
</td>
<td>Ubuntu 12.04, CentOS 7.0, etc.</p>
<ul>
<li>GTK+ 3.4.1</li>
<li>libwebkitgtk-3.0.0 (for HTMLViewer)</li>
</ul>
</td>
</tr>
<tr>
<td>Linux Pi (ARM) Desktop apps</td>
<td>Raspian Wheezy</p>
<ul>
<li>GTK+ 2.20</li>
</ul>
</td>
<td>Raspian Wheezy (<b>no change</b>)</p>
<ul>
<li>GTK+ 3.4.1</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Besides the benefit of not having to tell your end users to install GTK+ 2 on their particular Linux distro, here are some other notable items affected by the GTK+ 3 transition:</p>
<table cellpadding="5">
<tbody>
<tr>
<th>Feature</th>
<th>GTK+ 2</th>
<th>GTK+ 3</th>
</tr>
<tr>
<td>HiDPI</td>
<td>
<ul>
<li>No inherent scaling</li>
</ul>
</td>
<td>
<ul>
<li>Scales automatically on integral scale factors (i.e. 1x, 2x, 3x, etc.)</li>
</ul>
</td>
</tr>
<tr>
<td>Controls</td>
<td>
<ul>
<li>Child controls do not clip on a transparent parent control (like a Canvas)</li>
</ul>
</td>
<td>
<ul>
<li>Child controls properly clip on all parent controls</li>
<li>Default control sizes have generally increased, depending on theme/distro</li>
<li>Ability to style controls using CSS, for example:<br />
In ~/config/gtk-3.0/gtk.cssGtkButton {<br />
padding: 1px;<br />
}</li>
</ul>
</td>
</tr>
<tr>
<td>TextField</td>
<td>
<ul>
<li>Border can be removed</li>
</ul>
</td>
<td>
<ul>
<li>Depending on GTK+ 3 version the border cannot be removed (i.e. Ubuntu 12.04 yes, Ubuntu 15.10 no)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>While there&#8217;s a short list of actual differences, there have been numerous changes underneath made during this transition. For example, features that we had to custom code because GTK+ 2 did not offer them but GTK+ 3 did. Updating to GTK+ 3 is the final piece to our cross-platform HiDPI support for Desktop apps. Until the day comes when we have to say goodbye to GTK+ 3 (GTK+ 4 is already in the works), we welcome its inclusion in Xojo with a long overdue &#8220;Hello&#8221;!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
