Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-10-28 18:13:09 +0000
committerEric Williams2019-10-29 14:56:40 +0000
commit049ef11cbbb59d85197809bada18506a5b1ae0fe (patch)
treed06bae983fdb1b1bee789dc0a023db5d49654717
parent24d2f07252fd9911aadd274cc7735d961cee73fd (diff)
downloadeclipse.platform.swt-049ef11cbbb59d85197809bada18506a5b1ae0fe.tar.gz
eclipse.platform.swt-049ef11cbbb59d85197809bada18506a5b1ae0fe.tar.xz
eclipse.platform.swt-049ef11cbbb59d85197809bada18506a5b1ae0fe.zip
Bug 545804: [GTK] Add support for SVG files
Implement support on GTK side. Tested using the snippet attached on GTK 3.24 and Fedora 30. No AllNonBrowser JUnit tests fail. Change-Id: I1e35b08fc931634e36f4881fd209b8a0ddf28138 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/.settings/.api_filters6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/ImageLoader.java2
-rw-r--r--bundles/org.eclipse.swt/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.swt/build.xml2
-rw-r--r--bundles/org.eclipse.swt/pom.xml2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545804_SVGSupport.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/images/red_hat_fedora.svg1
8 files changed, 64 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/.settings/.api_filters b/bundles/org.eclipse.swt/.settings/.api_filters
index 3da34e65c1..fa464b814c 100644
--- a/bundles/org.eclipse.swt/.settings/.api_filters
+++ b/bundles/org.eclipse.swt/.settings/.api_filters
@@ -269,6 +269,12 @@
<message_argument value="COLOR_WIDGET_DISABLED_FOREGROUND"/>
</message_arguments>
</filter>
+ <filter id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.swt.SWT"/>
+ <message_argument value="IMAGE_SVG"/>
+ </message_arguments>
+ </filter>
</resource>
<resource path="Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java" type="org.eclipse.swt.events.ArmListener">
<filter id="576720909">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index d18b020230..5629185a5c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -4238,6 +4238,14 @@ public class SWT {
public static final int IMAGE_OS2_BMP = 7;
/**
+ * Image format constant indicating a SVG format image (value is 8).
+ * <br>Note that this is a <em>HINT</em> and is currently only supported on GTK.
+ *
+ * @since 3.113
+ */
+ public static final int IMAGE_SVG = 8;
+
+ /**
* GIF image disposal method constants indicating that the
* disposal method is unspecified (value is 0).
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/ImageLoader.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/ImageLoader.java
index df04ea1642..a1f6489dcc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/ImageLoader.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/ImageLoader.java
@@ -343,6 +343,7 @@ int getImageFormat(long loader) {
case "ico": return SWT.IMAGE_ICO;
case "jpeg": return SWT.IMAGE_JPEG;
case "png": return SWT.IMAGE_PNG;
+ case "svg": return SWT.IMAGE_SVG;
default: return SWT.IMAGE_UNDEFINED;
}
}
@@ -547,6 +548,7 @@ public void save(OutputStream stream, int format) {
case SWT.IMAGE_JPEG: typeStr = "jpeg"; break;
case SWT.IMAGE_PNG: typeStr = "png"; break;
case SWT.IMAGE_TIFF: typeStr = "tiff"; break;
+ case SWT.IMAGE_SVG: typeStr = "svg"; break;
}
byte [] type = Converter.wcsToMbcs(typeStr, true);
diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
index 12643d1e86..cf3132130d 100644
--- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt; singleton:=true
-Bundle-Version: 3.112.100.qualifier
+Bundle-Version: 3.113.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: plugin
DynamicImport-Package: org.eclipse.swt.accessibility2
diff --git a/bundles/org.eclipse.swt/build.xml b/bundles/org.eclipse.swt/build.xml
index e97f811149..a1794df148 100644
--- a/bundles/org.eclipse.swt/build.xml
+++ b/bundles/org.eclipse.swt/build.xml
@@ -18,7 +18,7 @@
<target name="init">
<property name="plugin" value="org.eclipse.swt" />
- <property name="version.suffix" value="3.112.100" />
+ <property name="version.suffix" value="3.113.0" />
<property name="full.name" value="${plugin}_${version.suffix}" />
<property name="temp.folder" value="${basedir}/temp.folder" />
<property name="plugin.destination" value="${basedir}" />
diff --git a/bundles/org.eclipse.swt/pom.xml b/bundles/org.eclipse.swt/pom.xml
index e22dc477e9..5d2399637b 100644
--- a/bundles/org.eclipse.swt/pom.xml
+++ b/bundles/org.eclipse.swt/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt</artifactId>
- <version>3.112.100-SNAPSHOT</version>
+ <version>3.113.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545804_SVGSupport.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545804_SVGSupport.java
new file mode 100644
index 0000000000..adcc0e6b6e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545804_SVGSupport.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Red Hat Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug545804_SVGSupport {
+
+public static void main(String[] args) {
+ Display display = new Display();
+ ImageLoader loader = new ImageLoader();
+ loader.load("./images/red_hat_fedora.svg");
+ Image image = new Image(display, loader.data[0]);
+ Shell shell = new Shell(display);
+ shell.setLayout (new GridLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ button.setImage(image);
+ button.setText("Button");
+ shell.setSize(300, 300);
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ image.dispose();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/images/red_hat_fedora.svg b/tests/org.eclipse.swt.tests.gtk/images/red_hat_fedora.svg
new file mode 100644
index 0000000000..062df671c1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/images/red_hat_fedora.svg
@@ -0,0 +1 @@
+<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 145"><defs><style>.cls-1{fill:#e00;}</style></defs><title>RedHat-Logo-Hat-Color</title><path d="M157.77,62.61a14,14,0,0,1,.31,3.42c0,14.88-18.1,17.46-30.61,17.46C78.83,83.49,42.53,53.26,42.53,44a6.43,6.43,0,0,1,.22-1.94l-3.66,9.06a18.45,18.45,0,0,0-1.51,7.33c0,18.11,41,45.48,87.74,45.48,20.69,0,36.43-7.76,36.43-21.77,0-1.08,0-1.94-1.73-10.13Z"/><path class="cls-1" d="M127.47,83.49c12.51,0,30.61-2.58,30.61-17.46a14,14,0,0,0-.31-3.42l-7.45-32.36c-1.72-7.12-3.23-10.35-15.73-16.6C124.89,8.69,103.76.5,97.51.5,91.69.5,90,8,83.06,8c-6.68,0-11.64-5.6-17.89-5.6-6,0-9.91,4.09-12.93,12.5,0,0-8.41,23.72-9.49,27.16A6.43,6.43,0,0,0,42.53,44c0,9.22,36.3,39.45,84.94,39.45M160,72.07c1.73,8.19,1.73,9.05,1.73,10.13,0,14-15.74,21.77-36.43,21.77C78.54,104,37.58,76.6,37.58,58.49a18.45,18.45,0,0,1,1.51-7.33C22.27,52,.5,55,.5,74.22c0,31.48,74.59,70.28,133.65,70.28,45.28,0,56.7-20.48,56.7-36.65,0-12.72-11-27.16-30.83-35.78"/></svg> \ No newline at end of file

Back to the top