当前位置:文档之家› qt for mobile slides day 3

qt for mobile slides day 3

qt for mobile slides day 3
qt for mobile slides day 3

Qt for Mobile Developers
Maemo
1
Course Agenda Friday
? Maemo
? Maemo Devices ? SW Architecture ? Basic Tools
? SDK Installation, Application Deployment
? Web Run-Time
? WRT Widgets ? Development Tools ? Tools
? Common WRT
? Common WRT and Hybrid Applications
? GTK+ and Hildon
? Maemo Qt (Qt 4.5.3)
? ? ? ? ? ? ? ? Qt for X11 Qt for Hildon Styling Input Methods Widgets Limitations Mobility Project Maemo 6
? WebKit Internals
? ? ? ? ? ? WebKit Project WebKit Engine Building Blocks WebKit Core JavaScript Core Document Parsing
? Course Summary
2

What is Maemo?
? Maemo is an open-source development platform for Internet Tablets
? 90% of source code is open-source ? Latest platform contains also phone functionality (mobile computer)
? Most of the tools, libraries and development processes that are used in Maemo are equally used and applied in the desktop arena
? Easy SW portability ? UI design should consider mobility issues
3
Maemo Devices and OS Versions
? Nokia 770 Internet Tablet
? Based on Internet Tablet OS 2006 edition and maemo platform v2.2 – Gregale
? Nokia N800
? Based on Internet Tablet OS 2007/2008 edition and maemo platform v3.2/v4.0 – Bora ? GTK+ based UI framework
? Nokia N810
? Based on Internet Tablet OS 2008 edition and maemo platform v4.0/v4.1 – Chinook, Diablo ? Any UI framework running on the top of X11 (Qt libraries, Java)
? Nokia N900
? Based on OS 2009 edition and maemo platform v5.0 – Fremantle ? Qt 4.6 port under development
4

Mobile Computer Hardware
Nokia N900
TI OMAP 3 processor, Cortex A8 CPU HSPA/3G support – online anywhere 3G connectivity High definition camera support (integrated Image Signal Processor) HW acceleration for OpenGL ES 2.0 XGA (1024 x 768) display with 16 M colors High-speed USB 2.0
5
Some Fremantle Features
? ? ? ? ? ? ? ? ARMv7 architecture CPU Media Application Framework Clutter – OpenGL ES – based library for creating UIs Meta Tracker – Extracts meta data from the files and adds indexes to the file system for faster access GUPnP – GObject-based Universal Plug’n’Play Framework Advanced Audio Distribution (A2DP) & Audio Video Remote Control (AVRCP) profiles OpenMAX Linux 2.6 OMAP-port kernel
6

Maemo Software Architecture
Hildon Application Framework UI FW libraries Games Wrapper Matchbox Hildon App Mgr Tracker Hildon Home Hildon Input Method FW Hildon Control Panel
Clutter
Hildon Desktop
Multimedia subsystem PulseAudio GUPnP GStreamer Media App FW libcanberra Speex audio codec Bellagio OpenMAC IL FM Transmitter
Connectivity subsystem BlueZ GW OBEX WLAN Wireless tools
Real-time communications subsystem Glib Telepathy Connection Manager Farsight2 libnice AddressBook API Accounts API Event Logger API
System SW subsystem HAL
Battery query interface API Vibra service API API Device orientation API
Core subsystem X Window Linux kernel Open GL ES drivers
7
Scratchbox
? Cross-compilation in Linux is difficult – well is it actually?
? Partly because of autotools – which should be helpful
? Some Linux distributors solve the problem by not supporting cross-compilation ? Scratchbox solves the problem by totally isolating host and target environments
? Supports two separate targets: X86 and ARMEL ? https://www.doczj.com/doc/d312484460.html,
? Autotools-based build scripts can be run on Scratchbox without modification when building for the target
8

Scratchbox 2
? Scratchbox 1 requires a copy of each file in the isolated file system
? Rootstrap – like a “standard” Linux file system ? Safe for dummies ? Impossible to overwrite system files – user may only break the SB environment ? Large disk image ? SB supports only vi and pico
? Install another copy of your favorite editor or edit outside SB
? Scratchbox 2 shares as many system files as possible
? Not for dummies ? More efficient disk usage ? Easier integration of tools – is it difficult in SB1?
9
Maemo SDK+
? Uses SB2 ? Can be installed together with SB1 and other Maemo SDKs ? More straightforward everything
? Installation ? Development ? Debugging
? Yet another IDE – Anjuta
? Supports everything from code template wizards to application packaging
10

World of Universes
? Three Universes ? Host universe
? Development with IDE
? Cross-compilation universe
? Separate rootstrap for each target
? Execution universe
? Tools to create packages ? Device installation ? Target debugging and emulation
? In SB1, you work inside Scratchbox ? In SB2, you give sb2 command in front of each SB command
11
GNU Autotools
? Supports building portable SW
? autogen.sh is a script file to make other script files to build the project, i.e. calls autoconf and automake ? configure.ac includes definitions on how to produce the configure script (configure) for the project – used by autoconf
? Autoconf creates .configure shell script
? Makefile.am includes the files and subdirectories needed to make the application: src/, po/ and data/ and all the Makefiles in src/, po/, and data/ directories ? Makefile.am is an automake configuration file. Automake creates the actual Makefile
? Build the project
? $ ./autogen.sh && ./configure && make;
? Project wizard in esbox creates all these files
12

Typical Source File Organization
? Common application file structure
? src/ - source code ? debian/ - files related to debian packaging ? data/ - icons, .desktop file, D-BUS service file ? po/ - localized files
13
Using Scratchbox
? Start it by typing the command
? scratchbox
? Configure targets
? sb-menu
? Switch between targets
? sb-conf select FREMANTLE_X86 (FREMANTLE_ARMEL)
? Otherwise work in a similar way like outside SB ? Single source concept
? Single source – multiple targets
14

Build Tools
? You may use gcc or g++ directly in the command line
? Hopefully, nobody does that
? The pkg-config tool is extremely useful, if using shell
? Helps solving required header files and libraries ? List libraries: pkg-config --list-all ? List header folders: pkg-config --cflags gtk+-2.0 ? Now building is easy ? [sbox-FREMANTLE_X86: ~/Hw]: gcc -Wall helloworld.c `pkg-config --cflags gtk+-2.0` -o helloworld `pkg-config --libs gtk+-2.0`
? Use of autotools recommended
? Application integration with Maemo platform ? Application packing
15
XServer
? X server allows applications to create windows to which they can draw on the screen ? Applications are X server clients ? X server also provides key press and pointer events to applications ? Maemo applications require a pseudo X server to be installed
? It acts as an X client to a real X server
? Xephyr X server is typically used with Maemo SDK
? Kdrive-based X server capable of emulating 16-bit color depth for clients
16

XServer Initialization
? Outside Scratchbox, say
? Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb & ? To install Xephyr, say ? apt-get install xserver-xephyr
? In Scratchbox, direct the display to window 2 by typing
? export DISPLAY=:2
? Your maemo window does not look very nice yet…
? Fonts, decorations, UI framework ? Your application needs to be integrated with Maemo platform (managed by Maemo window manager) ? Application must be killed with CTRL-c – clicking X does not kill application window yet
17
Hildon Application Framework Start
? Launch the application framework
? [sbox-FREMANTLE_X86: ~/Hw]: af-sb-init.sh start
? Hint! If you cannot launch application framework, the process may be running already. Give a command af-sb-init.sh stop in that case ? Run standalone shell (themes, fonts will work)
? [sbox-FREMANTLE_X86: ~/Hw]: run-standalone.sh ./helloworld
18

Maemo Framework
? A few files are required to make your maemo application visible in the maemo framework ? Maemo .desktop file
? Makes the application visible to Task Navigator
? D-BUS service file
? Allows application launching and connects to D-BUS services (e.g. some events are received from D-BUS)
? Maemo initialization
? Without this, application is killed soon after launch
19
Maemo .desktop File
? Should be named as [app name].desktop ? Copied to /usr/share/applications/hildon
[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Name=Hello World Exec=/usr/bin/helloworld Icon=qgn_list_documents X-Window-Icon=maemopad-window X-Window-Icon-Dimmed=maemopad-window-dimmed X-Osso-Service=helloworld X-Osso-Type=application/x-executable X-HildonDesk-ShowInToolbar=true
20

D-BUS Service File
? When a D-BUS message is sent to an application, D-BUS launches the app, if it is not running ? Only one instance of D-BUS service can run at a time ? File is installed in /usr/share/dbus-1/services/ ? File name is [app name].service
[D-BUS Service] Name=com.nokia.helloworld Exec=/usr/bin/helloworld
21
Maemo Initialization
? Functionality provided by LibOSSO library ? Intialization connects to D-BUS
? osso_context_t * osso_initialize(const gchar *application, const gchar* version, gboolean activation, GMainContext *context) ? Boolean value TRUE tells D-BUS that the application has been launched by DBUS daemon (not used by the framework) ? void osso_deinitialize(osso_context_t *osso) osso_context_t *osso_context; /* Initialize maemo application */ osso_context = osso_initialize( "example", "0.0.1", TRUE, NULL); if (osso_context == NULL) { return OSSO_ERROR; }
22

Deployment
? Maemo applications are distributed as Debian packages ? Two phases
? Create package structure – Use dh_make tool ? Create the actual package – Use dpkg-buildpackage tool
? IDE use recommended (e.g. ESBOX)
23
Deployment Using ESBOX
? Create a new folder to contain package eventually ? Create the package structure ? Several files created
? debian/rules
? Makefile containing commands to build the package
? debian/control
? Specifies package data, dependencies, binaries (like Symbian .pkg file)
? debian/copyright ? debian/compat ? debian/changelog
? Edit files, if you need
24

Control File
? ? ? ? ? Edit the maintainer field Define build dependencies Add depends info Add some package description Add Qt library dependency, if Qt used (libqt4-dev)
Source: helloworld Section: unknown Priority: extra Maintainer: unknown Build-Depends: debhelper (>= 5), autotools-dev Standards-Version: 3.7.2 Package: helloworld Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description:
25
Deployment Using ESBOX
? After creation the package structure, just create the package, e.g. from the context menu
26

Package Creation Manually
? Rename your project folder (required by dh_make)
? mv helloworld helloworld-1.0
? Create the basic package structure into a debian folder
? dh_make --createorig --single –e petri.niemi@https://www.doczj.com/doc/d312484460.html, -c gpl
? A single application package created making a copy of the original source archive and using a GPL license ? Edit rules, control, copyright etc. files as needed ? Build the actual package
? dpkg-buildpackage –rfakeroot -b
? Look at the details how to edit the package files and the Qt .pro file in Qt for Maemo Developers Guide (available in Forum Nokia https://www.doczj.com/doc/d312484460.html,)
27
Lost Interest Already?
? How do I remember all this? ? Esbox IDE helps
? Eclipse using Scratchbox
? Provides
? Documentation ? Buidling (and generation of all required files) ? XServer initialization ? Debugging ? Debian package creation ? Device installation
28

GTK+
? GIMP Toolkit
? Licensed under LGPL 2.1
? Cross-platform compatible
? Unix/Linux, Windows, MAC, N900 etc, OpenMoko
? Library with a number of UI widgets ? Written completely in C with object-oriented concepts
? Classes, inheritance ? C++ wrappers exist – still C
? Event driven ? Observer pattern based on signals and callback functions
29
GTK Features
? ? ? ? ? ? ? ? ? ? Native look and feel Theme support Thread safe Object-oriented approach Internationalization Localization Accessibility Bidirectional text support UTF8 support Documentation
30

Basic GTK+ Concepts
? Widget
? GUI component drawn on the screen
? Container
? Special widget containing other widgets
? Packaging
? A process where widgets are added to a container
? Event
? Notification of a completed service, such as key press
? Signal
? After an event, a notification to an observer. E.g. clicked()
? Visibility
? Each widget can be visible or invisible
? Property
? GObject data or value
31
Common Application Libraries – 1(2)
glibc Glib GTK+ GDK Gdk-pixbuf GObject libosso Hildon APIs GStreamer The core C library API Replacement of some GObject library functionality for compatibility reasons Widget set library based on the GDK GIMP Drawing Kit (Xlib wrapper) Image manipulation, bitmap image handling, alpha blending GObject type – the core of GTK maemo base library, application initialization, access to D-BUS Maemo Hildon application framework built on the top of GNOME GStreamer multimedia framework
32

Common Application Libraries – 2(2)
libxml2 Pango libatk D-BUS GConf libcurl SQLite LibC++ XML and HTML parser and tools Text rendering framework for internationalization Accessibility framework Inter-process communication framework Configuration management framework HTTP access library SQL database library Standard library for C++ language
33
GTK+ Basics
? Data types
? Use gint, gchar, gpointer (GObject pointer) etc. ? Typedefs to standard C types
? Casting
? Frequently used cast macros ? G_OBJCET(object), GTK_WIDGET(widget), GTK_SIGNAL_FUNC(function), GTK_WINDOW(window), GTK_CONTAINER(container) ? g_signal_connect( G_OBJECT (button), "clicked", G_CALLBACK (callback_function), callback_data);
? Timer usage
? gint g_timeout_add (guint32 interval, GtkFunction function, gpointer data);
34

GTK+ Widgets – 1(2)
? Windows
? Windows and dialogs
? Displays
? Label, image, progress bar, status bar
? Buttons and toggles
? Check, radio, toggle, and link buttons
? Numerical
? Horizontal, vertical scales, spin button, text data entry
? Multi-line text editor ? Tree, list, icon grid viewer
? Customizable renderers (model/view model)
? Combo box
? With or without entry
35
GTK+ Widgets – 2(2)
? Menus
? With images, radio buttons and check items
? Toolbars
? With radio, toggle, and menu buttons
? UI Manager
? Creating menus and toolbars dynamically from XML
? Selectors
? Color, file, font selection
? Layouts
? Tabulated, table, expander widget, frames, separators etc.
? Status icon ? Printing widgets
36

Hildon and GTK Widgets
? Hildon widgets derived from GtkWidget
? Derived from GtkObject derived from GObject
? Naming convention
? Type written with underscore characters between words ? For example, HildonAppMenu ? GtkWidget *hildon_app_menu_new();
? Recommended way to create GTK objects
? Use Hildon constructors whenever possible
? For example, size can be properly set
? Connect signals ? Set attributes/properties ? Pack into a container ? Show the widget
37
Hildon GUI Application Structure
? ? ? ? ? ? ? ? Hildon and GTK library initialization – hildon_gtk_init() - QCoreApplication Access to HildonProgram object – hildon_program_get_instance() Main view (window) creation – hildon_window_new() Main view (window) registration – hildon_program_add_window() Widget creation, signal connections Widgets packed into containers Widgets made visible Event loop started - gtk_main() – QCoreApplication::exec()
38

First Hildon Program
#include #include #include #include #include #include int main( int argc, char* argv[] ) { /* Create needed variables */ HildonProgram *program; HildonWindow *window; GtkWidget *button; osso_context_t *osso_cont; osso_return_t ret; // APP_NAME and APP_VER defined using macros osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL); if (osso_cont == NULL) { fprintf (stderr, "osso_initialize failed.\n"); exit (1); } /* Initialize the GTK. */ gtk_init( &argc, &argv );
39
First Hildon Program
/* Create the hildon program and setup the title */ program = HILDON_PROGRAM(hildon_program_get_instance()); g_set_application_name("Hello World"); /* Create HildonWindow and set it to HildonProgram */ window = HILDON_WINDOW(hildon_window_new()); hildon_program_add_window(program, window); /* Quit program when window is closed. */ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); /* Quit program when window is otherwise destroyed. */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); /* Create button and add it to main view */ button = gtk_button_new_with_label(_("Hello World!!!")); gtk_container_add(GTK_CONTAINER(window), button); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (button_clicked), NULL); /* Begin the main application */ gtk_widget_show_all ( GTK_WIDGET ( window ) ); gtk_main(); return 0; }
40

相关主题
文本预览
相关文档 最新文档