Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Adding functions to OS.JAVA

Thank you for the assistance.

For completeness, I missed out two things:
a) I moved eclipse version and forgot to install SWT-Tools.
b) I had to add the method signature into OS_custom.h

Then after rebuilding the .so file the call to the new wrapper function worked.

Thank you

Leo

On 09/17/2014 01:55 AM, Aleksandar Kurtakov wrote:
----- Original Message -----
From: "Leo Ufimtsev" <lufimtse@xxxxxxxxxx>
To: platform-swt-dev@xxxxxxxxxxx
Sent: Tuesday, September 16, 2014 11:13:12 PM
Subject: [platform-swt-dev] Adding functions to OS.JAVA

Hello,

I'm new to swt development. I'm having issues with adding a new gtk
wrapper to OS.java and was hoping someone could help?

@Fedora 20, gtk3.10

As part of the button-size issue (394534), I need to add an extra
wrapper to OS.java.
I followed instructions:
https://www.eclipse.org/swt/jnigen.php

However, I'm running into UnsatisfiedLinkError.

My steps:

1) Added the following to OS.java
	/** @method flags=dynamic */
	public static final native void _gtk_widget_set_margin_right(long
/*int*/ widget, int margin); //LINFO Margin ++ func.
	public static final void gtk_widget_set_margin_right(long /*int*/
widget, int  margin) {
		lock.lock();
		try {
			_gtk_widget_set_margin_right(widget,margin);
		} finally {
			lock.unlock();
		}
	}

	//Note, gtk_widget_set_margin_right is deprecated as of gtk3.12. But
since I'm using gtk3.10, for the time being I thought I'd use this guy
first.

That's really bad idea. When things get deprecated, they are deprecated for a reason and fixes for these functions usually stop at the time of deprecation.
Please look for another function to use/way to do it. One way of doing it is to add gtk_widget_set_margin_end binding too and use it for GTK 3.12 or newer.


2) Cleaned all projects
3) ran build.xml from org.eclipse.swt.gtk.linux.x86_64/build.xml
    	- the following were selected:
     		 build.jars
      	 build_libraries

    	Build fails with:
/home/lufimtse/git/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml:928:
The following error occurred while executing this line:
/home/lufimtse/git/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml:900:
javax.script.ScriptException: ReferenceError: "importClass" is not
defined in <eval> at line number 3

This step should not be needed.


4) Open terminal. Export vars:
export JAVA_HOME=/usr/lib/jvm/java/
export GTK_VERSION=3.0

This means that you would recompile only gtk3 native wrapper. If you use the function in gtk2 code paths you need to recompile (export GTK_VERSION=2.0) and copy it's so file too. As the function you try to use is added in GTK 3.0 on GTK2.x you would get the error you mention. Please provide patches(in gerrit ideally - marked as [WIP] in the subject) in such cases as seeing the code makes it way easier to spot a problem than guessing.


Alexander Kurtakov
Red Hat Eclipse team


5) Re-build wrappers.
cd ~/git/eclipse.platform.swt/bundles/org.eclipse.swt/bin/library/
sh ./build.sh

6) Copy new .so's across:
cp -v
~/git/eclipse.platform.swt/bundles/org.eclipse.swt/bin/library/*.so
~/git/eclipse.platform.swt.binaries/bundles/org.eclipse.swt.gtk.linux.x86_64/

When I attempt to run my program that calls the native function, I get
an unsatisfied link exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.eclipse.swt.internal.gtk.OS._gtk_widget_set_margin_right(JI)V
	at org.eclipse.swt.internal.gtk.OS._gtk_widget_set_margin_right(Native
Method)
	at
org.eclipse.swt.internal.gtk.OS.gtk_widget_set_margin_right(OS.java:14565)
	at org.eclipse.swt.widgets.DateTime.createText(DateTime.java:139)
	at org.eclipse.swt.widgets.DateTime.<init>(DateTime.java:122)
	at
org.eclipse.swt.examples.controlexample.DateTimeTab.createExampleWidgets(DateTimeTab.java:65)
	at
org.eclipse.swt.examples.controlexample.Tab.createTabFolderPage(Tab.java:1307)
	at
org.eclipse.swt.examples.controlexample.ControlExample.<init>(ControlExample.java:60)
	at
org.eclipse.swt.examples.controlexample.ControlExample.main(ControlExample.java:217)


Thoughts?

Thank you

Leo Ufimtsev | Red Hat

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top