Article Title: gtk + and glade programming in Linux and the differences between glade2 and glade3. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems and open source, and other basic categories. This article mainly describes the differences between using multithreading and libpcap programming in Linux and using glade2 and glade3 to create interfaces, for Linux beginners, it is a good courseware 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) the name of the glade for xxyougladexxx.
(2) about 95 rows:
INTLLIBS = 'pkg-config -- cflags -- libs gtk +-2.0 gthread-2.0 'is modified 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 \
Replace callbacks. c callbacks. h:
Xxyougladexxx_SOURCES = \
Main. c \
Support. c support. h \
Interface. c interface. h \
Callbacks. c callbacks. h \
Xx1.c xx1.h \
Xx2.c xx2.h \ xx1 and xx2 are self-compiled. c and. H files.
(4) about 179 rows:
Xxyougladexxx_LDADD =-lpcap? Pthread and 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:
Primary des = \
-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) if no-pthread exists in PACKAGE_CFLAGS and PACKAGE_LIBS, 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-lrt-lgthread-2.0
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.