So, CoffeeScript it is, and the first thing that goes is
const Lang = imports.lang;
This is what CoffeeScript replaces. Now we have a real 1st class class statement.
So here is my port of Gnome's HelloWorld example,
Gtk = imports.gi.Gtk
class Application
#create the application
constructor: () ->
@application = new Gtk.Application()
#connect to 'activate' and 'startup' signals to handlers.
@application.connect('activate', @_onActivate)
@application.connect('startup', @_onStartup)
# create the UI
_buildUI: () ->
@_window = new Gtk.ApplicationWindow(application: @application, title: "Hello World!")
@_window.set_default_size(200, 200)
@label = new Gtk.Label(label: "Hello World" )
@_window.add(@label)
# handler for 'activate' signal
_onActivate: () =>
# show the window and all child widgets
@_window.show_all()
# handler for 'startup' signal
_onStartup: () =>
@_buildUI()
#run the application
app = new Application()
app.application.run(ARGV)
The important thing to note, is that we no longer use Lang.bind:
this.application.connect('activate', Lang.bind(this, this._onActivate));
Instead, the function definition is bound using the fat arrow:
_onActivate: () =>
The other thing I ran into is shebang support. Coffeescript treats it as a coment and discards it.
So I follow up my compile with a simple fix replacing the coffescript header with shebang.
coffee -c test.coffee
sed -i "s/\/\/ Generated by CoffeeScript 1.11.1/\#\!\/usr\/bin\/env gjs/" test.js
great blog
ReplyDeletehttp://www.piratecity.online/
Both CoffeeScript and Gtk are strong development tools that provide flexible frameworks for creating apps. If you're working on academic research, it's imperative that you get professional dissertation proposal help in addition to investigating these technologies.
ReplyDeleteWonderful post about GTK and CoffeeScript! It's exciting to watch how these tools evolve to make development smoother and more efficient. While reading this, I couldn't help but think of how versatile men's leather aviator jackets are in terms of style. A decent aviator jacket lends a timeless, adaptable touch to any wardrobe, just as GTK and CoffeeScript provide coding flexibility. Keep up the fantastic work.
ReplyDeleteExcellent tips for integrating Gtk with CoffeeScript! It's amazing how Gtk offers a strong UI foundation and CoffeeScript streamlines JavaScript syntax. This combination has the potential to revolutionise the way developers create programs that are both aesthetically pleasing and efficient. Integrating these technologies with web application development services can improve the functionality and user experience of projects you're working on in the current day. I appreciate you giving this important knowledge!
ReplyDeleteHowever it enables innovative front-end programming by utilizing the elegant features of CoffeeScript and the powerful UI components of GTK. In addition seeking for the professional linkedin profile writing UAE to ensure get the highly demanding profile with updated skills on portfolio.
ReplyDeleteHi there, this is Salman from Pakistan. I am an expert in fashion and lifestyle items, specifically Replica shoes Pakistan. With a sharp eye for quality and trends, I assist companies and brands in showcasing goods that appeal to today's fashion-forward consumer base. My areas of experience are in product presentation, market analysis, and designing collections that combine affordability and style.
ReplyDeleteHi there, I'm from Pakistan, and my name is Sufiyan Ahmed. I have worked with Haramain Foods for many years, specialising in Organic Foods and supplying natural, health-conscious food solutions. I am passionate about promoting healthy and clean living, and I have a thorough understanding of organic food production and sustainable processes. My dedication to quality, purity, and client health is evident in my work. My goal with Haramain Foods is to increase the availability and dependability of organic options for every household.
ReplyDelete