REDHAT Linux9 GNOME desktop construction CC ++ IDE development environment

zhaozj2021-02-17  82

Zhang Shanyou (SHANYOUGZ@21cn.com) Software Development Engineer

Original in my website http://shanyou.sti.gd.cn/cplusplus/gtk2/anjuta.html

The Anjuta package is provided on the Redhat Linux. It provides a Glade application interface design tool. LINUX uses Anjuta and Glade and the GlaDemM package to build a IDE environment developed under the C / C software, you can perform GTK / GNOME Application development.

It is difficult to write a good graphical user interface when developing Linux programs. After the GIMP toolkit (GTK) is born, this matter is easier. When Damon Chaplin wrote Glade, this is used to generate in a GTK environment. After the tool of the graphic user interface is easier. But Glade is still not an "integrated development environment" (such as Visual Basic, etc.), because the programmer cannot manually modify the code generated by the Glade in the Glade environment. Now, all this has become the past: Anjuta is born!

Anjuta uses Glade to generate the capabilities of a beautiful user interface, add the ability to edit your own strong source program, which is an excellent application to quickly develop an integrated environment (IDE). In the past, people use Glade to do interface, use Emacs or VI, etc. The editing procedures, edit the development project with a terminal simulator. Use Anjuta, all of these complicated zero-scattered tasks can be done in a unified, integrated, natural environment.

First, software preparation:

Download libzvt-2.0.1-0.ximian.6.6.i386.rpm

http://tux.cprm.net/pub/ximian/xd2/redhat-9-i386/libzvt-2.0.1-0.ximian.6.6.i386.rpm

Download Anjuta-1.1.97-1.rH90.i386.rpm

Http://rpm.pbone.net/index.php3/stat/4/IDPL/772608/com/anjuta-1.1.97-1.rH90.i386.rpm.html

Download ANJUTA-1.0.2-1.i386.rpm

http://henet.dl.sourceforge.net/sourceforge/anjuta/anjuta-1.0.2-1.i386.rpm

Download gtkmm2-2.2.3-fr1.i386.rpm

http://ftp.freshrpms.net/pub/freshrpms/redhat/9/gtkmm2/gtkmm2-2.2.3-fr1.i386.rpm

Download gtkmm2-devel-2.2.3-fr1.i386.rpm

http://ftp.freshrpms.net/pub/freshrpms/redhat/9/gtkmm2/gtkmm2-devel-2.2.3-fr1.i386.rpm

Download Libsigc - 1.2.5-fr1.i386.rpm

http://ftp.freshrpms.net/pub/freshrpms/redhat/9/libsigc /libsigc -1.2.5-fr1.i386.rpm

Download GlademM-1.1.3D-Snap.i586.rpm

http://loban.caltech.edu/gchch/glademm-1.1.3d-snap.i586.rpm

Download libsigc - devel-1.2.5-fr1.i386.rpm

http://ftp.freshrpms.net/pub/freshrpms/redhat/9/libsigc /libsigc -devel-1.2.5-fr1.i386.rpm

Second, install the package

Install Redhat Linux 9 Select Install the software development item so that you will install Glade, then log in to the root user, install the following software package. Rpm -ivh libzvt-2.0.1-0.ximian.6.6.i386.rpm // Anjuta Dependent package

RPM-IBSIGC - 1.2.5-fr1.i386.rpm

RPM-IVH gtkmm2-devel-2.2.3-fr1.i386.rpm

RPM-IVH IBSIGC - Devel-1.2.5-fr1.i386.rpm

RPM-IVH gtkmm2-2.2.3-fr1.i386.rpm

RPM-IVH GLADEMM-1.1.3D-SNAP.I586.RPM

RPM-IVH Anjuta-1.0.2-1.i386.rpm

RPM -UVH Anjuta-1.1.97-1.RH90.I386.rpm

Note: Directly install Anjuta-1.1.97 will find that several problems you have to pay attention to here.

1. To install the Ximian version of the libzvt package, you just want to install me mentioned above.

To install Anjuta 1.0.1 first, then updated via rpm -uvh anjuta 1.1.97

Third, carry out C / C procedures on the first Anjuta1.1.97

Let us build a simple Hello World program with Anjuta.

Establish a new project

Please open Anjuta first. Please select menu item program -> More programming tools -> Anjuta IDE. GNOME application wizard "Gnome 2.0 Application Wizard" will appear. Although people just click "Next" button Yes, don't have to go to the Elf dialog box, here you still want you to read each message on the dialog. Now, after you read the information on the dialog box in the first step of the Elf, press the Next button.

The second step is very critical. Here you need to decide the type of application you want to build. Let's choose "Gnome 2.0 Project" and continue to go. Step 3 To determine the basic configuration of the application. Please fill in the configuration information of the application very carefully. In this tutorial, enter the following information.

Project Name: HelloWorld (Program project name) Note that the project name without spaces Version: 0.1 (version) Author: (Your Name) program name: helloworld (program name) programming languages: There are C, C and C / C three options, hereby select C program type: There are three options executable, dynamic link libraries, and static link libraries.

The following fourth step is written in the project;

The fifth step is the other options for the project, the GNU copyright statement and the localization support item of the program. If you don't want, you can remove them. You'd better select an icon for this application project, which will appear in GNOME application In the program menu. Here we choose Hello World Example as the project name, select Applications in the Group domain. Finally click on the Next button and the finish button. At this time, the application project is established.

Because we are just establishing an example program, we can easily go. If we are building an application project to be used in real world, we must be extravagant when filling out the parameters of the application wizard, because they are very important for your application project.

Design user interface

After the end of the application wizard, Anjuta began to establish a directory structure of your application project, run the parameter configuration script and establish an application project itself. The entire creation process is displayed in the lower part of the Anjuta development environment. After the creation process is over, the left side of the screen shows the application project tree structure. This tree structure contains your source file, documentation, and graphics files.

Now is the time to start Glade and use its design graphical user interface. Please go to the menu item-> Edit the graphical interface to run the Glade. You will see three windows: 1) Glade main window, 2) Properties window, and 3) Drawing Tools window.

Take a simple GTK window. Please click on the first item listed on the GLADE main view, then press the DEL to delete the key. Now go to the Tool Window (Palette), click on the first icon. At this time, a blank gtkwindow built it. This will be the main window Window1 of our app. Go to the property window (Properties), type "Hello World!". Now you will pick up a table (Table) 2 line 2 on the main window Window1 on the tool window now. Thus, the main window is divided into four parts of the same size.

Now remove two buttons from the tool window, add them in both boxes below the main window. Set the names and tag properties of these two buttons as follows:

Left button:

Name: bt_ok

Tags: OK

Right button:

Name: bt_exit

Tags: exit

In the upper half of the window, add a tag control on the left; add one input box ENTRY control at the upper half. The name of the input box is taken as Entry. Set the tag property of the above tag control to 'What's your name, sir?'.

Now connect two buttons and Clicked events on the properties (Signals Tab). Use the Glade preset reverse call function name. Please don't forget to click the Add button. This common error will result in a blank Callbacks.c file. On the source file callbacks.c, we will join the source code via the Anjuta interface.

Now, the main window looks not so beautiful. You can try to change the width and height of the window, and try to change several properties of the horizontal and vertical enclosures, see if you can make the window look good. (Note: You can go to Menu View, select the control tree, and then select the control.) The following is the setting of some attributes:

* Set the property homogeneous of the following horizontal envelope box;

* Set the properties fill of the attribute Fill of the pointing button of the property window to YES;

* Set the properties of the primary window WINDOW1 to NO.

After changing these attributes, my main window looks as follows:

After the interface is designed, click the "Storage" button on the Glade main window, then click the "Qianqi" button. This will update your application project's SRC directory in your application project in your new design. Now let's choose menu Project -> EXIT, go back to the Anjuta user interface. Start programming!

Editor

Now return to the Anjuta environment, you should be able to see Callbacks.c in the project source program list on the left side of the screen. Double click Open the program. So we can edit the program on the left side of the Anjuta integrated development environment.

Sometimes something is more likely to understand if there is a color, more interesting. Anjuta's "Syntax Highlights" function (on the "Format" menu) is this. Anjuta has a lot of useful features, you can play slowly. Maybe it is very good to spend some time, familiar with this integrated environment.

Now return to the callbacks.c file, we see two reverse call functions: ON_BT_OK_CLICKED and ON_BT_EXIT_CLICKED. Let's add a function call in the second function: gtk_main_quit (). In this way, the function becomes:

#ifdef Have_config_H

# include

#ENDIF

#include

#include "callbacks.h"

#include "interface.h" #include "support.h"

Void on_bt_ok_clicked (gtkbutton * button, gpoint user_data)

{

GTK_MAIN_QUIT ();

}

The purpose of this function call is to end the entire application when the user clicks the exit button. In addition to this, we join the following function call in the on_bt_ok_clicked function:

Void on_bt_ok_clicked (gtkbutton * button, gpoint user_data)

{

Gtkwidget * entry = lookup_widget (gtk_widget (button), "entry");

Gtkwidget * msgbox = gnome_app_new ("Hello World", "Hello World");

Gchar * text1, * text2;

Text1 = gtk_entry_get_text (gtk_entry (entry);

Text2 = strcat ("Hello,", Text1);

GNOME_APP_MESSAGE (gnome_app (msgbox), Text2);

}

Generate target code, execution, and distribution

Now I am tested for your program; this is very interesting. Select the menu item first -> Create a project. At this time, Anjuta starts compiling and linking the source program main.c, interface.c, support.c and callback.c, and then puts the generated executable Hello in the src directory. The compiler generally uses GCC.

If you are lucky, the compile process does not have any error messages, please select the menu item to create-> Execute the program so Anjuta open up a terminal window and run your application HelloWorld! Please enter your name on the input box, then Click the OK button. I hope that your application will return back to you: Hello ... You can knock in a greeting word, then exit the button EXIT, see if the program will be properly exited. If you quit normally, it's good! Your hard work has finally made the result!

At this point you can install your application into the window system: select menu items -> Installation Although you may not want to create a Tarball file for your app, you may be like this. Done. Before the release of the application, you must fill in the files of TODO, CHANGELOG, INSTALL, and Readme. To create an app, please click Create -> Create a Rubber Creation Process may last for a few seconds, eventually Create a file helloWorld-0.1.tar.gz in / home / (username) / projects / helloworld / directory.

转载请注明原文地址:https://www.9cbs.com/read-31278.html

New Post(0)