Differences between gtk + and glade programming and glade2 and glade3 in Linux

Source: Internet
Author: User
Tags cairo

This article mainly explainsLinuxMultithreading and libpcap are used in the system.Programming, UseGlade2. Different from the glade3 production interface, it is a good courseware for Linux beginners to help them get started!

Differences between creating interfaces using glade2 and glade3:

The main difference between Glade2 and glade3 is that glade2 will automatically generate makefile and other files, while glade3 is only used to generate interfaces and then called by libglade and GtkBuilder. glade file, the advantage is that the Code and interface are completely separated, to avoid code changes and need to be re-compiled.

After designing the interface, Glade2 can click Save and then combine the code to generate the code. Main. c, callbacks. c, interface. c, support. c. c. You can add code in callbacks. c. Add the message function code of the event. However, if you want to call other files, for example, write programs will use their own. c and. H files, so you must modify the makefile, mainly to modify/src/Makefile.

I Code in the following environment:

(1) system Fedora9

(2) The version of glade2 is glade2-2.12.2

(2) version of gtk +: 2.12.9

The modification is as follows (the red part is the place to be modified:

(1) about 46th rows:

am_xxyougladexxx_OBJECTS = main.$(OBJEXT) support.$(OBJEXT) \ interface.$(OBJEXT) callbacks.$(OBJEXT)

The modified code is as follows:

am_xxyougladexxx_OBJECTS = main.$(OBJEXT) support.$(OBJEXT) \ interface.$(OBJEXT) callbacks.$(OBJEXT) xx1.$(OBJEXT) \ xx2.$(OBJEXT)

Specifically, xxyougladexxx is the name of glade.

(2) about 95 rows:

INTLLIBS = `pkg-config --cflags --libs gtk+-2.0 gthread-2.0`

The purpose of this modification is to set the library command to be called.

(3) Place the source file in lines around 173

xxyougladexxx_SOURCES = \ main.c \ support.c support.h \ interface.c interface.h \ callbacks.c callbacks.h

Replace:

xxyougladexxx_SOURCES = \ main.c \ support.c support.h \ interface.c interface.h \ callbacks.c callbacks.h \ xx1.c xx1.h\ xx2.c xx2.h \

Among them, xx1 and xx2 are self-written. c and. H files.

(4) about 179 rows:

Xxyougladexxx_LDADD =-lpcap-pthread Add the library file-lpcap-pthread, the first is libpcap, and the second is multithreading.

(5) If-pthread is not added to DES, the following must be added:

INCLUDES = \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

(6) In PACKAGE_CFLAGS and PACKAGE_LIBS, if no-pthread exists, add it:

PACKAGE_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include PACKAGE_LIBS = -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0

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.