📜 ⬆️ ⬇️

Training on MAEMO. Day 1

On March 23, the first day of the MAEMO training was held in the building of the Scientific and Research Center of the Moscow State University. Lomonosov Moscow.
On this day, the following topics were considered:

Foreword


First I will talk about the organization of the training.
At the entrance, traditionally everyone was given badges. As well as a CD with the necessary software, documentation and presentations.
There were coffee breaks. Coffee, though instant, but one of the best. Also tea, mineral water and traditional cookies.
Lunch is not included in the training program, but I'll tell you about lunch later, this is a separate topic.
The training took place according to the following scheme, the first two introductory topics, then GTK, then Hildon and the task for independent execution, then again about some of the features of Hildon and MAEMO and again the task.


Introduction to MAEMO. Overview of devices and versions.


The first presentation was a review, it was done by Dmitry Malichenko, SPB GUAP .


An important part of the introduction was the description of the MAEMO architecture, the main components you can see in the image


In principle, there is nothing more to say about the introductory one, as already well-known things went further, like the description of the N900 iron.
')

Working environment IDE Overview


The report was made by the same speaker. I also referred this presentation to the introductory, because in general everything that was told within its framework does not represent anything new, however, I’ll dwell on the most important points:

What is required for development



Running emulator


Login to scratchbox is done with the command / scratchbox / login .
Using the sb-menu script in the scratch box, you can change the environment and the platform for assembly and emulation.
To display the emulator graphic screen outside of the scratch box, you need to run Xephyr with the following command:
$ Xephyr: 2 -host-cursor -screen 800x480x16 -dpi 96 -ac &

and to run MAEMO itself, execute the command in the scratch box:
export DISPLAY =: 2
af-sb-init.sh start


To run a graphical application from the scratchbox console, use the run-standalone.sh script.
It adds the necessary environment to the application being started.

Work tools


At least application development will require:

Most of this should already be installed, but if something is missing, you can install it yourself with a familiar apt.

IDE



The only IDE under which it is recommended to write now is EsBox - a modified Eclipse.
esbox.garage.maemo.org/2nd_edition/index.html
You can also use native Eclipse integration.
wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Development_Environment/Maemo_Eclipse_Integration

At this point all the entries ended and the programming began.

GTK Introduction


This section will certainly be absolutely not interesting to people working with GTK every day, if you are one of these, you can safely skip.
However, for me as Qt'shnik, this was completely new information.
The report was made by: Yevgeny Linsky, St. Petersburg GUAP


GTK + is a graphical object-oriented library in C.
This imposes a strong imprint on the development style since the “clean” C does not support classes and objects.
example:
In C ++, you would write this:
GtkButton *btn = new GtkButton(); btn->setLabel( "label" ); GtkWindow *w = (GtkWindow *) btn; * This source code was highlighted with Source Code Highlighter .
  1. GtkButton *btn = new GtkButton(); btn->setLabel( "label" ); GtkWindow *w = (GtkWindow *) btn; * This source code was highlighted with Source Code Highlighter .
  2. GtkButton *btn = new GtkButton(); btn->setLabel( "label" ); GtkWindow *w = (GtkWindow *) btn; * This source code was highlighted with Source Code Highlighter .
  3. GtkButton *btn = new GtkButton(); btn->setLabel( "label" ); GtkWindow *w = (GtkWindow *) btn; * This source code was highlighted with Source Code Highlighter .
GtkButton *btn = new GtkButton(); btn->setLabel( "label" ); GtkWindow *w = (GtkWindow *) btn; * This source code was highlighted with Source Code Highlighter .


On C, you have to write like this:
  1. GtkButton * btn = gtk_button_new ();
  2. gtk_button_set_label (btn, "label" );
  3. GtkWindow * w = GTK_WINDOW (btn);
* This source code was highlighted with Source Code Highlighter .


From my point of view, it is scary, but more on that and in general about the expediency of using GTK later.

GTK structure


The main components of the library you can see in the image.


Practical use


The basis of the GTK widget set is the GtkWidget basic graphic element, it is
base class for all graphic elements, I inherit buttons, menus, toolbars, etc. from it.

GTK is a signal-oriented library, i.e. when a certain event occurs (for example, a button is pressed) a signal is emitted. A developer can associate a signal with some previously described handler, this is done
the g_signal_connect () function.

An example of the simplest program on GTK, which only displays a window and closes along a “cross”
  1. #include <gtk / gtk.h>
  2. static void on_close (GtkWindow * window, gpointer user_data) {
  3. gtk_main_quit ();
  4. }
  5. int main ( int argc, char * argv []) {
  6. GtkWidget * window;
  7. gtk_init (& argc, & argv);
  8. window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  9. gtk_window_set_title (GTK_WINDOW (window), "simple" );
  10. gtk_widget_set_size_request (window, 300, 100);
  11. gtk_widget_show_all (window);
  12. g_signal_connect (window, "destroy" , G_CALLBACK (on_close), NULL);
  13. gtk_main ();
  14. return 0;
  15. }
* This source code was highlighted with Source Code Highlighter .


Initially , the GTK environment is initialized with the gtk_init () function,
After that, the main program window is created - gtk_window_new () ,
sets the size of the window and its title,
gtk_widget_show_all () is then called, which tells the main window to draw itself and all its descendants,
after which a handler is set ( on_close () ) to exit the program and
the gtk_main () function is executed , which starts the main application loop.

After this, it was told about GTK containers, containers are widgets into which you can invest
other widgets, I will not talk about them here, anyone interested in reading the introduction to GTK
it's all simple enough.

At the end of the presentation were reviewed several examples of applications that you can download for this
link .

Introduction to Hildon


The report was done by Evgeny Linisky.
Hildon is a graphic library for MAEMO. Hildon is a superstructure over GTK,
adds a mobile-specific implementation, for example, a touch-based input interface.

Hildon completely copies the GTK interface, replacing some functions with its own, due to which
allows you to interact through the drawn elements.
For example, the menu in MAEMO, is simply a sheet of large buttons that are convenient to press.
The main ToolBar moves down, as is customary in MAEMO. It is important to note that regarding
Toolbar developers MAEMO give the following recommendation - it should contain only really frequently used
Application functions, all non-essential functions should be placed in the menu.

After this part of the presentation, the time for "interactive" came and we were asked
port the gtk application to MAEMO-Hildon.
GTK example and the result proposed by the author of the report can be downloaded and studied here.

It is important to note that, unlike GTK in Hildon, the canvas redraw event is executed only when the application is started, but not when the window is minimized / maximized.

Dinner


After the majority of the participants coped with the task and the “debriefing” was performed
The lunch break began. In search of catering, we (a group of three people) traveled ~ 7km, and all because no one knew where to eat in the Moscow State University area, and the wrong direction was initially chosen.
We were 15 minutes late for the continuation, however, the organizers were late too, and apparently for the same reason.
So we missed nothing.

Work with Hildon. A stack of windows. HildonPannableArea (kinetic finger scrolling)


A stack of windows that implements chains of consecutive windows, in which you can return from the top to the bottom with the back button, this approach is very convenient for mobile applications.
Creating a stack window is done using the hildon_stackable_window_new () function;
And switching to the next window with gtk_widget_show_all () with a parameter is a pointer to the next window.
The application can implement multiple stacks of windows.

HildonPannableArea - A container widget that can include the number of child widgets exceeding the screen size,
and implementing inertial finger scrolling. The widget is created by the hildon_pannable_area_new () function.

After the presentation, the interactive started again, and we were asked to implement an example using the HildonPannableArea and the stack of windows.
However, GTK for today we already ate, and decided to try to do the same on Qt for MAEMO
How to install it and use it Read the habraser tass article .
As expected, the Qt code turned out to be two times shorter, if we count in rows, and 2.5 times were the lines themselves shorter. This once again proves that something must be made an instrument suitable for this. Moreover, MAEMO 6 (or MeeGo) will completely switch to Qt as a graphic library.
View the code on Qt here .

Work with Hildon. What else is interesting.




useful links


maemo.org/api_refs/5.0/5.0-final - all the necessary documentation for development under MAEMO.
fruct.org - the site of the organization that conducted the training.
maemoworld.ru - the site of the Russian community MAEMO.

Some more photos


Coffee break audience:

Organizers and speakers (SPB GUAP)

Demonstration of the application task from the task of porting a Desktop-GTK application to MAEMO-Hildon in the Scratchbbox emulator

The same application but already on the device, ported personally by me (in the photo my hand, by the way :))


About the second day of the training will tell you habrapayuchatel tass .

For this, I ask you to bow out, thanks for reading.

The authors


Vasily Sorokin: @ VasiliySorokin .
Kormalev Denis: @ BlackTass .

Source: https://habr.com/ru/post/89046/


All Articles