Create a small example of NBTK on moblin: Hello Moblin

Source: Internet
Author: User
Tags rpmbuild

Moblin is a clutter-based UI. The NBTK will help you to recommend UIS such as buttons, tooltips, and scrollbars, and support CSS stacked style tables. Installing nbtk on a non-moblin linux operating system is troublesome. We need to make some modifications to configure. For example, if clutter is not installed using rpm, it uses source compiling, to ensure that the installation is complete, comment out the required CLUTTER rpm package in nbtk requirement, and process css (which can be downloaded in repo.moblin.org ). If you have a moblin operating system, it is very convenient, As long as yum is OK.

I want to know some functions that NBTK can provide and see if it is helpful for clutter development. Today, I updated the netbook version 2.1 final, which is much better than the previous version. At least it is called "usable", which makes it inconvenient to use the UI/UX, for example, the copy function in firefox is insufficient and Font/image scaling is not allowed. It feels much better. There is an example of Hello moblin in the Moblin community. As a reference, the auxiliary tool is used above, and installation is required. The installation is troublesome (in fact, it is self-Lazy ). The following is my processing process.

1. Create the example directory hello-1.0.0 in the user directory, which contains the following files

:

File 1

: Configure configuration file, which is set to executable mode, as follows:

[Wei @ Wei-desktop hello-1.0.0] $ cat configure

Echo "Hello, this is configure file ."

File 2

: Source code file hello. c, as follows:

# Include <nbtk/nbtk. h>

Int main (INT argc, char * argv [])

{

Clutteractor * stage;

Nbtkwidget * button;

Clutter_init (& argc, & argv );

Stage = clutter_stage_get_default ();

Button = nbtk_button_new_with_label ("Hello moblin! ");

Clutter_container_add_actor (clutter_container (stage), clutter_actor (button ));

Clutter_actor_show (stage );

Clutter_main ();

Return 0;

}

File 3

: Desktop file, desktop file description can refer to: http://www.ibm.com/developerworks/cn/linux/l-cn-dtef/

[Desktop entry]

Version = 1.0.0

Encoding = UTF-8

Name = nbtk Hello Testing

Name [zh_cn] = nbtk test Applet

Comment = nbtk Hello little program for testing

Comment [zh_cn] = nbtk test applet Hello world!

Exec = Hello

Icon =/usr/local/share/icon/hello.png

Terminal = false

Type = Application

Startupnotify = true

Categories = applications; office;

File 4

: Map File hello.png

File 5

: Makefile file, refer to kernel compilation and RPM Packaging

, As shown below

Cc = gcc

Cflags + =-wall-G 'pkg-config clutter-1.0 nbtk-1.2 -- cflags'

Include =

Libs + =-wall-G 'pkg-config clutter-1.0 nbtk-1.2 -- libs'

Objects = Hello. o

Target = Hello

Destdir =

ALL: $ (target)

Hello. O:

$ (CC) $ (cflags)-C hello. c

$ (Target): $ (objects)

$ (CC) $ (libs)-O hello $ (objects)

Install:

CP $ (target) $ (destdir)/usr/local/bin/$ (target)

CP $ (target). Desktop $ (destdir)/usr/local/share/applications/$ (target). Desktop

CP folder (target).png $ (destdir)/usr/local/share/icon/folder (target).png

RM: clean

Clean:

Rm-f *. o

Rm $ (target) $ (destdir)/usr/local/bin/$ (target)

Rm $ (DESTDIR)/usr/local/share/applications/$ (TARGET). desktop

Rm $ (DESTDIR)/usr/local/share/icon/objects (target).png

2. encapsulated as an RPM package

Compress hello-1.0.0into hello-1.0.0.tar.gz and place it in ~ In/rpmbuild/SOURCES, we ~ /Rpmbuild/SPECS to create the file hello. spec. For details, refer to kernel compilation and RPM packaging.
And http://hlee.javaeye.com/blog/343499
As follows:

Name: hello

Version: 1.0.0

Release: 1

Summary: NBTK hello testing

Group: Development/Tools

License: GPL

# URL:

Source0: hello-1.0.0.tar.gz

BuildRoot: % (mktemp-ud % {_ tmppath}/% {name}-% {version}-% {release}-XXXXXX)

BuildRequires: clutter-devel> = 1.0 nbtk-devel> = 1.1.13

Requires: clutter> = 1.0 nbtk> = 1.1.13

% Description

The NBTK hello little program is used to test how to build an application in moblin, just for study.

% Prep

% Setup-q

% Build

% Configure

# Make % {? _ Smp_mflags}

Make

% Install

Rm-rf $ RPM_BUILD_ROOT

Install-d $ RPM_BUILD_ROOT/usr/local/bin

Install-d $ RPM_BUILD_ROOT/usr/local/share/applications

Install-d $ RPM_BUILD_ROOT/usr/local/share/icon

Make install DESTDIR = $ RPM_BUILD_ROOT

% Clean

Rm-rf $ RPM_BUILD_ROOT

% Files

% Defattr (-, root, root ,-)

/Usr/local/bin/hello

/Usr/local/share/applications/hello. desktop

/Usr/local/share/icon/hello.png

# % Doc

% Changelog

Run laterRpmbuild-ba hello. spec

If the command is invalid, install rpmbuild and Yum install rpm-build.

3. Install hello

In ~ /Rpmbuild/RPMS/i386 found two RMP packages, respectively: hello-1.0.0-1.i386.rpm and hello-debuginfo-1.0.0-1.i386.rpm, we install Hello rpm,Sudo rpm-IVH hello-1.0.0-1.i386.rpm

Then, we will see the related icons in the moblin application. We can click the icon to display the shortcut key in myzone on the homepage.

 

 

 

Related links:
My clutter blog

My moblin articles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.