GTK + and X Analysis Applied in Embedded Linux systems

Source: Internet
Author: User
Article Title: GTK + and X Analysis Applied in Embedded Linux systems. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In Embedded Linux, there are many GUI systems, including Qt/Embedded, FLTK, Microwindows, and GTK +. What kind of GUI is used as a developer? How many changes do you make to transform a system to meet your needs? What is the size of the modified system? These are problems that developers may encounter. What we will discuss here is to make a detailed analysis of these contents. Through our discussion, you will have a definite understanding of GTK + and X-based GUI applications in embedded Linux.
 
With the development of embedded system applications, more and more applications need to use GUI for development to achieve better interaction.
 
GUI Selection in Embedded Linux is a trade-off process for most developers. Select GTK + to run on X system, and then run X system on the framebuffer embedded in the system. This is a good choice.
 
Advantages of GTK + and X
 
Of course, GTK + and X are generally considered as good combinations of large desktop systems, but they also have many advantages for Embedded Systems:
 
1. The X-window system and GTK + are both very stable and reliable. The X-window system has undergone long-term development and application practices. GTK + is also a mature open source code project;
 
2. The X-window system is a flexible client/server model structure. The crash of an application client does not affect other parts of the graphics system. This is a very important feature, it is conducive to supporting third-party application extension development without affecting the main part;
 
3. GTK + has two important Libraries: GDK and GLIB. GDK abstracts the underlying window management. To port GTK + to another different window system, we only need to port GDK. GLIB is a collection of tools, including data types, various macro definitions, type conversion, and string processing. Any application can connect to this GLIB library and use various data types and methods, to avoid code duplication or developers re-invent the wheel, which helps reduce the size of the entire system;
 
4. Cropping GTK +/X is very easy. They have good configurable options and clear code structures, this ensures that you can safely and correctly remove unnecessary code segments;
 
5. GTK + has a large number of applications, and GTK + has been used in many important application systems;
 
6. GTK + authorization is LGPL, X is non-copyleft free license, and any third-party developed systems can be linked to them;
 
7. GTK +/X are both based on C code, rather than C ++;
 
8. GTK + uses C to implement the object-oriented architecture;
 
  Other GUI Systems
 
Other available graphics systems include Qt/Embedded, FLTK, and Microwindows.
 
1. Qt/E is relatively advanced. It is a complete, framebuffer-based GUI system developed by Trolltech;
 
2. Qt/E has an efficient graphic rendering effect. It also includes the TrueType font system and alpha blending translucent processing;
 
3. However, Qt/E does not use the LGPL authorization method, but uses two authorization Methods: Development and Use of GPL, and commercial use requires authorization and royalty;
 
4. Qt/E is written in C ++;
 
5. Qt/E is very large. An iPAQ QPE includes a 3.3 MB Qt/E library and a kb QPE Library (similar to Xlib );
 
6. Qt/E is not stable enough. QPE demo is good, but it has crashed;
 
7. FLTK (the Fast Light Toolkit) is a small GUI graphics system written in C ++ with few features and a small application scope;
 
8. Compared with X-Window, Microwindows is also a good choice. It occupies approximately kb-600kb of memory and file storage space. Although there is a GTK + port on it, but it is not mature enough;
 
 X-window: much smaller than you think
 
For the X-window system, the majority of network developers have done a lot of work to reduce its size, the most well-known is TinyX. you can crop unnecessary code and remove static data from XLIB to reduce the overall size, such as the color management system, arc shape, and rough lines.
 
Most developers think that X systems are huge, but what you hear is a misunderstanding of people who do not know X well. After cropping, GTK +/X is more effective than GTK +/FB and Qt/E, and XLIB provides better support for general applications, application Development will become more efficient.
 
 How to crop GTK +
 
We can crop from the standard GTK + release version, crop unnecessary ones, modify existing code, and add the Code required for new features. The crop scope includes small changes and some major structural and core changes.
 
1. Remove the Widgets window
 
In the beginning, we removed unwanted Widgets, such as GtkGamma, gtkhrloud, obsolete GtkList (replaced by GtkCList), and The GtkFrame border we don't need.
 
2. Widgets window size and drawing
 
Then, modify the size and Drawing Method of Widgets. GTK + provides a theme engine mechanism to control the appearance and effect of the window. It allows you to set the font, row interval, and draw features during running. This mechanism is good, but not flexible enough. Hard coding is used for many settings in the Code. In addition, a topic is a bunch of additional code segments and parameters, this will increase the overall size.
 
You need to find the content that affects the overall size of the window system and modify it. For example, the size and drawing of a button include the Border width, the position of x/y (the parameter required by the topic engine), the default interval (constant ), the default position (constant) in the upper left corner to obtain the focus. These do not need to be so complete in the embedded system. We can simplify the code as needed to avoid the complexity of GTK +.
 
In addition, using object-oriented methods to inherit the features of window Widgets is also an effective method as a subclass.
 
3. GtkWindow
 
GTK + always assumes that a window contains another window, which is a nested relationship. But it is not completely correct when we often encounter apps with soft keyboards. Although the keyboard belongs to a window, it will go beyond that window. To break through this assumption, you need to add some features to the GtkWindow and process the keyboard as a special subwindow.
 
In the window where the keyboard is located, you must handle the keyboard button events and forward the buttons to the keyboard toolbar. When the keyboard is pressed, the keyboard callback function is registered to the original window, so that the keyboard will respond to the button event. Add an interface on the GtkWindow to create the interface and press the response button.
 
In the embedded system of a small screen, you can simplify the scroll bar, remove the border, and use a single scroll bar. These are more suitable for embedded systems.

[1] [2] Next page

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.