Try Glade note

Source: Internet
Author: User
Tags gtk

The first attempt to use GTK is endless and complicated.CodeJust now, I realized that glade can easily generate a GUI, which is completely separated from the code. Even if you want to modify the interface, you don't need to compile it again, which is indeed very convenient.

There are many tutorials on how to use glade. Let me talk about some difficulties.

Note the following when adding handler to various signal.

First, Handler should be exactly the same as the callback function form of signal, including the function name, parameter type, number of parameters, and return type; this can be found in the GTK User Manual (by the way, the tool devhelp on Ubuntu is very convenient ).

Second, it has also plagued me for a long time: the problem of binding signal and hanlder.

In C code, there are two ways to bind signal and handler:

Gtk_builder_connect_signals and gtk_builder_connect_signals_full.

The former is automatically bound. This function uses a part of gmodule and glib to dynamically load modules to query applications.ProgramSymbol table (function name, variable name, etc.), find the function in the application that can match the callback function name specified in Glade, and connect to the signal. However
Gtk_builder_connect_signals can only work in C. Therefore, if your compiler is g ++, binding is not allowed. I think this is another issue of name mangling (the hateful Microsoft is trying to develop another set of standards to solve so much trouble ......), Therefore, to avoid the trouble, you can force the handler to be called in the form of C, that is, add extern "C" before hangler, and the G ++ test passes in Ubuntu.

The latter is manually bound to singal and hanler. During my trial, I found that no extern "C" is added. What is the difference between the two functions.

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.