We've rewritten the presentation logic from main.c in JavaScript, but kept our custom triangle class in C. Remember in this commit, we're just generating the. we didn't introduce any runtime differences. There's not much point to running the program again, since. gir files are always automatically generated from the source code - don't try to edit it! We'll see how we can affect the scanning process later. Note that it has both the public API from the headers, as well as the GObject property color. Take a minute to examine the contents of this file. We need to both reconfigure and build, because we changed the wscript file as well as code. Side note: If you're more familiar with Automake, there are some sample rules in gir-repository, gobject-introspection (both libraries), and gnome-shell (application). This is necessary in order to get complete information about our GObjects. The -program argument gives the path to our built program. In a large program, you may have multiple namespaces, but here we just have one. Note that we picked a namespace Tut and a namespace version 1.0. The next change is telling the build system to scan our tut-triangle.c and tut-triangle.h files. You can see in this first part that we're adding a dependency on the GObject Introspection library. To see how that works, let's go to the next change, to the wscript file. The reason this is necessary is because the introspection program g-ir-scanner actually runs our program to dump data from it. In the changes to main.c, we're now using a GOption Group to process command line arguments, and we're using g_irepository_get_option_group to add an option. ![]() Let's go through the diff this commit introduced. In this step, all we will do is run g-ir-scanner on our source code to generate an XML representation of our C Tut Triangle class. Now, we're going to add a dependency on GObject Introspection. You should see a small window with a triangle appear on the screen. (If you're not familiar with waf don't worry, it's not really important in this tutorial) Note in particular that in comparison we've changed the namespace prefix to TUT_ having a unique namespace is a requirement for GObject Introspection. Src/tut-triangle.c and src/tut-triangle.h implement a custom Clutter Actor subclass. Src/main.c sets up the stage, mainloop, and creates an instance of our custom triangle actor. You should take a minute to look over the structure of the code it's quite simple. It's a modified version of the triangle example from the Clutter tutorial. Right now the project just depends on Clutter. You may find it convenient to browse the Gitorious page for the tutorial. Now, we're going go back to the beginning of this project, so we can follow along as it evolves. Git clone git:///gjs-clutter-sample/mainline.git gjs-clutter-sample We'll assume at this point that you can now do something like the following:Ĭhecking out and building the tutorial project ![]() Most of the concepts in this tutorial should translate fairly easily into another language/runtime. You can pick from among many different languages and runtimes see the GObject Introspection page. Some familiarity with all of these technologies is assumed if not, see the GObject tutorial, Clutter tutorial, the Mozilla JavaScript Reference, and the Gjs page.įor the purposes of this tutorial, you'll need to have installed Gjs, the Mozilla Spider Monkey binding. This tutorial will introduce a small Clutter application using C/GObject for low level graphics work, and Java Script for composite widgets, configuration, prototyping, etc. Creating a multilevel application with GObject Introspection
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |