Javascript in Linux Desktop Yuren Ju
● Use Linux: 10 years ● For Desktop: 7-8 years Red Hat Debian Gentoo Debian Ubuntu Arch Linux Debian
Yuren Ju ● Blog: Yuren's Info AreaYuren's Info Area ● ● 社群 ● Hacking Thursday, KaLUG ● 工作: ASUSTek ● 興趣: Python, 咖啡, Linux
Javascript always use in Web Applications.
Javascript in Linux Desktop ● Web Application/Platform ● Desktop Platform ● Desktop Application
Internet Application Platform
Performance
Opportunity! Javascript for Web ApplicationDesktop Application
? Javascript in desktop ● Integration ● Layout ● Style/theme
Application Platform Web Desktop
Web Application JS HTM L +CSS CS S LayoutStyleProgramming Server side
Platform/Browser JS HTM L +CSS CS S LayoutStyleProgramming Layout engineJavascript engine
Platform/Browser (2)
To Desktop Application
Desktop - Platform ● XULRunner (Mozilla platform) ● GNOME Javascript runtime ● GJS/Seed
XULRunner Programming in Web Browser!
Mozilla applications
XULRunner JS CS S LayoutStyleProgramming Gecko layout engineSpiderMonkey XU L DO M Demo:
Mozilla Platform - integration Mozilla Application System XPCOM/NPAPI C++/Javascript
Mozilla Platform - integration D- BUS VT E notify Glade GT K
Javascript in GNOME ● Seed ● based on WebKit's JavaScriptCore ● GJS ● based on Mozilla's Spidermonkey engine
XULRunner JS CS S LayoutStyleProgramming Gecko layout engineSpiderMonkey XU L
Javascript in GNOME JS LayoutStyle Programming GObject introspectionSeed/GJS System library
Javascript in GNOME Javascript engine Javascript desktop runtime Javascript application System library C API: GTK, Gstreamer, Clutter, Glib, etc. GObject introspection JavascriptCore/SpiderMonkey Seed/GJS
Traditional arch. Native C API GStreamer Python/Perl/Ruby..., etc. VTEnotifyGTK Clutte r
GObject Introspection Native C API GI JS Java Pytho n Perl Ruby ? PHP? GStreamerVTEnotifyGTKClutter
Metadata using annotations in the comments
GObject Introspection ● Sharing binding infrastructure work, and making the platform even more binding friendly
g-ir-scanner 40 B B g-ir-compiler typelib Gir xml file Annotations
GObject Introspection foo.c foo.h Library source, with type annotations Foo.gir XML file Foo.typelib Binary file libgirepository.so Specific language bindings libfoo.so libffi.so
GObject Introspection Native C API GI JS Java Pytho n Perl Ruby ? PHP? GStreamerVTEnotifyGTKClutter
Seed/GJS D- BUS VT E notify Glade GT K $ aptitude search gir
Javascript 已經準備好了!
Hello world
Hello world (2)
Applications based on Seed ● Seed ● Swell-foop ● lightsoff
Demo - js-gallery
gnome-shell ● Use javascript to control your desktop file:///usr/share/gnome-shell/js/ui
Demo – gnome-shell extension
END Thank you!
e.g. use native GTK API gtk_label_set_text In java runtime
JNI GI If Java Runtime support GI... GtkLabel label = new GtkLabel (); label.setText ("hello"); JGIR Create a class that declares The native method Compile C code and generate native library Use javac to compile Use javah to generate header Write the C implementation of the native method
But I have..., why GI? ● Python-gtk ● Ruby-gnome2 ● java-gnome ● e.g. nautilus ● No python, ruby, java binding...
Layout/Theme ● GTK – gtk-theme-engine ● Gnome-shell (shell toolkit) – libcroco (CSS) ● MX toolkit – CSS
GJS vs seed ● EMCAScript support ● GJS support javascript extensions ● Seed support javascript 1.5 ● for each, let, etc. ● [item * 2 for each (item in list)]
Return values ● GJS ● print (texture.get_base_size()); ● Seed ● var height = {}, width = {}; ● texture.get_base_size (width, height); ● print (“width: ” + width.value + “, height: “ + height.value)
Clutter fine tune ● GJS ● No Actor.animate function ● Seed ● workaround for Actor.animate ● But seed-2.28/2.30 use different event mapping
Signal ● GJS ● actor.connect ("signal-name", callback) ● Seed ● actor.signal["signal-name"].connect (callback) ● actor.signal.destroy.connect (callback)
Presentation License CC Attribution 3.0 Unported
Images License Creative Commons (Attribution-Share Alike 3.0 Unported)