GTK2.0 Learning 1. Prepare to first observe a document provided by the gtk2.0 development kit. As you can see, what should we do for the first development. ThenaddthebinfoldertoyourPATH. MakesureyouhavenootherversionsofGTKinPATH. Run: pkg-config -- cflagsgt
GTK2.0 Learning 1. Prepare to first observe a document provided by the gtk2.0 development kit. As you can see, what should we do for the first development. Then add the bin folder to your PATH. Make sure you have no other versions of GTK in PATH. Run: pkg-config -- cflags gt
GTK2.0 + Learning
1. Prepare
First, observe a document provided by the gtk2.0 development kit. As you can see, what should we do for the first development.
Then add the bin folder to your PATH. Make sure you have no other
Versions of GTK + in PATH. Run:
Pkg-config -- cflags gtk ++-2.0
And verify that it prints out something reasonable. Run:
Gtk-demo
And verify that it works.
To use the MS-Windows theme engine, create a file etc./gtk-2.0/gtkrc
Containing the line:
Gtk-theme-name = "MS-Windows"
2. Build a GTK + development environment in Visual Studio 2008
1. Download The all-in-one bundles package at http://www.gtk.org/download-windows.html, which currently has 2.16 and 2.22. Decompress the downloaded package to any directory, such as "D: \ Environment \ gtk ".
2. system environment variable configuration: My computer-> properties-> Advanced properties-> environment variables-> system variables-> Path, add "; D: \ Environment \ gtk \ bin ".
3. Set the VS2008 compiling environment
(1) set the directory containing files: Tools-> options-> projects and solutions-> VC ++ directories-> directories displaying the content-> include files, add the include folder in the GTK directory and all the first-level folders in the include folder. There are 12 items in total. There are two include folders in the subfolders of the lib folder, as shown in.
(2) Go to the library file view and add the Lib folder of the GTK directory.
4. Create an empty project for C ++, and add it to project> Project Properties> Configuration Properties> linker> additional dependencies:
Glib-2.0.lib gtk-win32-2.0.lib gdk-win32-2.0.lib gobject-2.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib gmodule-2.0.lib pango-1.0.lib intl. lib
5. Test: Create a CPP file and write the following code. If the file runs properly, the configuration is successful.
# Include
Int main (int argc, char ** argv)
{
GtkWidget * window;
Gtk_init (& argc, & argv );
Window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
G_signal_connect (GTK_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL );
Gtk_widget_show (window );
Gtk_main ();
Return 0;
}
References
Http://blog.csdn.net/zfpnuc/archive/2010/06/04/5646735.aspx
Http://www.programmersheaven.com/article/105521-Visual+Studio+2008+configuration+for+GTK%2B+GUI+development/info.aspx
3. Font problems during development
When the program runs the following warning:
(GTKTest01.exe: 4876): Pango-WARNING **: couldn't load font "Not-Rotated
9 ", falling back to" Sans Not-Rotated 9 ", until CT uugly output.
(GTKTest01.exe: 4876): Pango-WARNING **: couldn't load font "9 9", falling
Back to "Sans 9", until CT uugly output.
This means that our gtk program cannot recognize the default font format when the system loads the system.
As described in the first section, the MS-Windows theme engine is loaded during gtk program development. Therefore, we need to manually change the font format used when its gtk program is running.
Find the gtkrc file in C: \ gtk \ share \ themes \ MS-Windows \ gtk-2.0 and add the following content at the end of the file:
Style "user-font"
{
Font_name = "Simsun 10"
}
Widget_class "*" style "user-font"
In this way, we specify the font for the gtk program.
4. instance learning
. Example 1
For the above sub-classes, we will first introduce the structure of the gtk window:
Window à GtkAccelGroup à vbox, hbox ..... (Layout) a variety of controls.
Note that the box add control method is gtk_box_pack_start.
Add gtk_container_add for Common Containers.
The usage of menu should be introduced in particular:
Menubar à menuItem à menu à menuItem
. Menu
The gtk_menu_shell_appen method is used to add menuItem to menu or menubar, while the gtk_menu_item_set_submenu method is used in menu to menuItem.
Then, for the use of events, g_signal_connect is used. For the parameter passing of functions, we need to continue to learn.
5. Problems
1. Transfer Event Processing Parameters
2. Processing of header file xxx. h
3. The GtkTextView can be written. Add a right-click event to add the writability after the pop-up menu.