Glade
Simple use instructions + examplesGlade has been developed in GNOME. It is an extension of GTK/gdk, a traditional interface design tool. It can meet the basic needs of visual development of Graphical User Interfaces Based on GTK + libraries.
1. Introduction to glade
If there is a software that can display the graphic interface design in front of developers in a timely manner, and after the design, you can directly see the appearance of the interface, in this way, the programmer's main focus is on the development of the core functions of the application. This is the so-called visual programming idea.
In Windows, this visual integrated development environment already has many mature products, such as VC ++, VB, Pb, Delphi, and C ++ bulider. Linux-based software is not rich, but it is not blank, such as Borland's kylix. Currently, Glade has been developed in GNOME. It is an extension of GTK/gdk, a traditional interface design tool. It can meet the basic needs of visual development of Graphical User Interfaces Based on GTK + libraries.
Glade can generate interface code for you. The basic process is as follows:
1. Let Glade design the interface elements, set the Interface Element attributes, and set the callback function for the component signal;
2. Save it as XML format, observe and modify the parts that do not meet the requirements;
3. compile other part of the application code, load the glade file in the application, and compile the C code to generate the execution file.
This mode completely separates the design interface from other parts of the code, and it is possible that the application does not need to be compiled after the interface is modified. The graphic user interface design team does not have to worry about the running details of applications, and programmers can also use their time for other aspects, instead of repeatedly writing a large number of cumbersome GTK + functions for interface modifications. This form of Division of Labor Development meets the requirements of software engineering, making it easier to develop GUI software.
Ii. Prerequisites for using glade
Before learning how to use glade, we assume that you have a preliminary understanding of the basic usage of the Linux operating system, are familiar with the processing commands of the RPM or gzip package, and have a certain understanding of the C language, familiar with message processing programming. The above basics are essential knowledge for using glade. If you have any questions about the above, you can check the relevant information first. To use glade for more flexible application development, you are advised to familiarize yourself with the GCC compiler and master the compiling rules of make files.
Let's take a look at how to add glade to the development environment of the Linux operating system in two steps:
1. Obtain the source code of glade
You can find the glade source code in the release of most Linux operating systems, or download it from the Internet. Currently, the website that can easily obtain the source code is http://www.glade.pn.org/. the downloaded file can be rpmor zipformat.
2. decompress, compile, and install glade
After obtaining the source code, decompress the compressed package and then run make to compile glade.
III,
Something you need to know before learning glade1,
GnomeIt is a tool that allows users to easily operate and set the computer environment. Gnome includes panel (used to start this program and display the current status), desktop (where applications and materials are stored), and a series of standard desktop tools and applications, in addition, each application can operate normally. No matter what operating system you used before, you can easily use the powerful graphic interface tool of gnome.
Gnome is completely open (Free Software) and developed by many programmers around the world. You can obtain its source code for free. If you are interested in GNOME, visit the gnome website http://www.gnome.org. 2,
GTK (gimp Toolkit)Is a toolkit for creating graphical user interfaces. It complies with the lgpl license, so you can use it to develop open-source software, free software, or even commercial software with closed source code, without spending any money to purchase licenses and use rights. GTK is essentially an object-oriented application interface (API ). Although fully written in C, it is implemented based on the idea of classes and callback functions (pointers to functions. 3. Another name is
The third component of glib. The glib library is the most common C language function library in Linux. It has good portability and practicability. Glib is the basis of GTK + Library and gnome. Glib can be used on multiple platforms, such as Linux, UNIX, and windows. It includes some replacement functions of standard functions and some functions that process data structures such as linked lists. These substitution functions are used to enhance the portability of GTK because some of the functions they implement are not implemented on other UNIX systems or do not comply with standards, such as g_strerror (). Some are enhancements to the corresponding libc functions, such as g_malloc () with enhanced debugging functions. In version 2.0, glib has added the following new content: type system, which forms the basis of the GTK class hierarchy. It is a widely used Signal System in GTK, abstract A thread API for different platforms and a tool for Loading modules.
Iv. Form and interface design
1
First, I use fedora 6. Because the version is relatively new, the graphic interface is good, the glade function is better, and the glade translation is better. It includes glade2.0, gcc4.0, and GTK graphic interface library GTK + 2.6. However, the memory requirements are relatively high. Especially when using virtual machines, the brothers will find that the memory must be adjusted to MB to enter the GUI installed in the system and run XWindow (and compare cards), preferably above MB.2. Enter the XWindow on the glade interface. Choose Application> programming> Glade interface designer. (See Figure 1) Figure 1 Software Interface: (see figure 2) Select New in Figure 2. Select New GTK + project in the pop-up dialog box. (the portability of GTK + project is good ,) (See figure 3) Figure 3 palette (color palette, control bar) window (see figure 4), click the GTK + basic-> window (window) icon (1st widgets in Row 3 ). (see figure 5) a blank window called window1.
Figure 4 Figure 5 Click the menu in the glade main window to view (View)-> show widget tree (show widget tree). A widget tree window is displayed. All controls in use are displayed. Now there is only one window1. (See figure 6) Figure 6 click the palette (palette, which is the control bar)-> 2nd vertical boxes in the grid tool) -> click window1 in the blank window. A prompt box is displayed. Enter number of rows, 3, and OK (see figure 7) figure 7 three dashes appear in the window (see figure 8) Figure 8 click the palette (palette, which is the control bar)-> the first line of tool 3rd (toolbar) control-> click row 1st of the three grid lines in the blank window (window1). A prompt box is displayed, and the number of input items is displayed. Enter 3 and select OK (see figure 9) figure 9 there are three created-as-you-go toolbar (see figure 10) at the top of the window. Figure 10 click the palette (which is the control bar)-> 6th of the 3rd tools (images) controls-> click the one line in the blank window (window1) that is added to the toolbar controls (see figure 11) figure 11 set image control properties-> control property bar-> widget-> icon: Back (GTK-go-back)-> name: (I define image_mbut Ton_back)-> 2nd and 3 add image controls by creation-> select back from the control attribute bar icon-> name: (I defined it as image_mbutton_help and image_mbutton_exit ). (See figure 12) Figure 12 place the cursor on the toolbar control-> attribute bar-> common options (common)-> Height: 30 (see figure 13) figure 13 place the cursor over the 1st custom image controls on the toolbar-> attribute bar-> common options-> height: 30 width: 30 (see Figure 14) figure 14 others click the same color palette (palette, is the control bar)-> 3rd label controls in the 1st line tool-> click a blank window (window1) 2 rows in (see Figure 15) Figure 15 click the palette (palette, is the control bar)-> 2nd vertical boxes in the grid tool) -> click the last grid. In the displayed dialog box, enter number of rows, 2, and select OK. In the grid tool, 3rd are table boxes) in Windows 1, click grid> prompt Box> Number of rows (rows), 4, and 3. Select OK (see figure 16) figure 16 click the color palette (palette, which is the control bar)-> 4th rows 1st control buttons (buttons) -> put them in a 4*3 grid with 1st grids-> repeatedly put 12 grids in order-> put 13th in the bottom large grid (see figure 17) figure 17 set properties of each control in the control tree (widget tree) Select the window (window1) control, and then set its property values in the Properties window: (see figure 18) figure 18 in a widget entry, resizable is set to No. (see figure 18)
In a common entry, width is set to 360, and height is set to 300. (see figure 19) Figure 19. In the signal entry, click the signal below "... "Button, select destroy from the drop-down menu, and select" add. click the left (see figure 20) Figure 20 widget entry, select the button1-button13 in turn, and set the attribute values of each button:
In a common entry, the button1-button12's width is set to 120, the height is set to 50. The label of button1 is set to 1. and so on, and the button1-button9 is set to 1-9, respectively.
Set the label of button10 to 0. Name To gtk_button_num0. (other values are as follows)
The label of button11 is set to +. Name To gtk_button_add.
Set the label of button12 to-. Name To gtk_button_sub. (see figure 21). In Figure 21 signal (signal), add a clicked semaphore for each button.
In the signal entry, click the signal below "... "Button, select clicked from the drop-down menu, and select OK. click Add in the lower left corner. (see figure 22) Figure 22: name of the component (widget) Entry of the label control (Label): gtk_label_shownum, label: 0, and height: 50. (See figure 23) Figure 23 Save the project and click the Save icon in the glade main window. set the project name and glade file name to "gtk_window_test2 ". the project is saved at/root/GTK (see figure 24). Figure 24. Select the main window to generate a file (see figure 25). Figure 25 Select an application-> attachment-> terminal (see figure 26) figure 261, CD/root/GTK/gtk_window_test2/2 ,. /autogen. SH3, make4, CD src5 ,. /gtk_window_test run to see the interface.