亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gtk_tut-2.html

?? GTK development guide
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
 <TITLE>GTK v1.2 Tutorial: Getting Started</TITLE>
 <LINK HREF="gtk_tut-3.html" REL=next>
 <LINK HREF="gtk_tut-1.html" REL=previous>
 <LINK HREF="gtk_tut.html#toc2" REL=contents>
</HEAD>
<BODY TEXT="#CCCCCC" BGCOLOR="#000000" LINK="#33cc00" VLINK="#009900" ALINK="#FF0000">
<A HREF="gtk_tut-3.html">Next</A>
<A HREF="gtk_tut-1.html">Previous</A>
<A HREF="gtk_tut.html#toc2">Contents</A>
<HR>
<H2><A NAME="s2">2. Getting Started</A></H2>

<P>The first thing to do, of course, is download the GTK source and
install it. You can always get the latest version from ftp.gtk.org in
/pub/gtk. You can also view other sources of GTK information on
<A HREF="http://www.gtk.org/">http://www.gtk.org/</A>. GTK
uses GNU autoconf for configuration. Once untar'd, type ./configure
--help to see a list of options.
<P>The GTK source distribution also contains the complete source to all
of the examples used in this tutorial, along with Makefiles to aid
compilation.
<P>To begin our introduction to GTK, we'll start with the simplest
program possible. This program will create a 200x200 pixel window and
has no way of exiting except to be killed by using the shell.
<P>
<BLOCKQUOTE><CODE>
<PRE>
/* example-start base base.c */

#include &lt;gtk/gtk.h>

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    
    gtk_init (&amp;argc, &amp;argv);
    
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
    
    gtk_main ();
    
    return(0);
}
/* example-end */
</PRE>
</CODE></BLOCKQUOTE>
<P>You can compile the above program with gcc using:
<BLOCKQUOTE><CODE>
<PRE>
gcc base.c -o base `gtk-config --cflags --libs`
</PRE>
</CODE></BLOCKQUOTE>
<P>The meaning of the unusual compilation options is explained below in
<A HREF="#sec_compiling">Compiling Hello World</A>.
<P>All programs will of course include gtk/gtk.h which declares the
variables, functions, structures, etc. that will be used in your GTK
application.
<P>The next line:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gtk_init (&amp;argc, &amp;argv);
</PRE>
</CODE></BLOCKQUOTE>
<P>calls the function gtk_init(gint *argc, gchar ***argv) which will be
called in all GTK applications. This sets up a few things for us such
as the default visual and color map and then proceeds to call
gdk_init(gint *argc, gchar ***argv). This function initializes the
library for use, sets up default signal handlers, and checks the
arguments passed to your application on the command line, looking for
one of the following:
<P>
<UL>
<LI> <CODE>--gtk-module</CODE></LI>
<LI> <CODE>--g-fatal-warnings</CODE></LI>
<LI> <CODE>--gtk-debug</CODE></LI>
<LI> <CODE>--gtk-no-debug</CODE></LI>
<LI> <CODE>--gdk-debug</CODE></LI>
<LI> <CODE>--gdk-no-debug</CODE></LI>
<LI> <CODE>--display</CODE></LI>
<LI> <CODE>--sync</CODE></LI>
<LI> <CODE>--no-xshm</CODE></LI>
<LI> <CODE>--name</CODE></LI>
<LI> <CODE>--class</CODE></LI>
</UL>
<P>It removes these from the argument list, leaving anything it does not
recognize for your application to parse or ignore. This creates a set
of standard arguments accepted by all GTK applications.
<P>The next two lines of code create and display a window.
<P>
<BLOCKQUOTE><CODE>
<PRE>
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show (window);
</PRE>
</CODE></BLOCKQUOTE>
<P>The <CODE>GTK_WINDOW_TOPLEVEL</CODE> argument specifies that we want the
window to undergo window manager decoration and placement. Rather than
create a window of 0x0 size, a window without children is set to
200x200 by default so you can still manipulate it.
<P>The gtk_widget_show() function lets GTK know that we are done setting
the attributes of this widget, and that it can display it.
<P>The last line enters the GTK main processing loop.
<P>
<BLOCKQUOTE><CODE>
<PRE>
  gtk_main ();
</PRE>
</CODE></BLOCKQUOTE>
<P>gtk_main() is another call you will see in every GTK application.
When control reaches this point, GTK will sleep waiting for X events
(such as button or key presses), timeouts, or file IO notifications to
occur. In our simple example, however, events are ignored.
<P>
<H2><A NAME="ss2.1">2.1 Hello World in GTK</A>
</H2>

<P>Now for a program with a widget (a button).  It's the classic
hello world a la GTK.
<P>
<BLOCKQUOTE><CODE>
<PRE>
/* example-start helloworld helloworld.c */

#include &lt;gtk/gtk.h>

/* This is a callback function. The data arguments are ignored
 * in this example. More on callbacks below. */
void hello( GtkWidget *widget,
            gpointer   data )
{
    g_print ("Hello World\n");
}

gint delete_event( GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   data )
{
    /* If you return FALSE in the "delete_event" signal handler,
     * GTK will emit the "destroy" signal. Returning TRUE means
     * you don't want the window to be destroyed.
     * This is useful for popping up 'are you sure you want to quit?'
     * type dialogs. */

    g_print ("delete event occurred\n");

    /* Change TRUE to FALSE and the main window will be destroyed with
     * a "delete_event". */

    return(TRUE);
}

/* Another callback */
void destroy( GtkWidget *widget,
              gpointer   data )
{
    gtk_main_quit();
}

int main( int   argc,
          char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;
    GtkWidget *button;
    
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init(&amp;argc, &amp;argv);
    
    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    
    /* When the window is given the "delete_event" signal (this is given
     * by the window manager, usually by the "close" option, or on the
     * titlebar), we ask it to call the delete_event () function
     * as defined above. The data passed to the callback
     * function is NULL and is ignored in the callback function. */
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);
    
    /* Here we connect the "destroy" event to a signal handler.  
     * This event occurs when we call gtk_widget_destroy() on the window,
     * or if we return FALSE in the "delete_event" callback. */
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);
    
    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    
    /* Creates a new button with the label "Hello World". */
    button = gtk_button_new_with_label ("Hello World");
    
    /* When the button receives the "clicked" signal, it will call the
     * function hello() passing it NULL as its argument.  The hello()
     * function is defined above. */
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (hello), NULL);
    
    /* This will cause the window to be destroyed by calling
     * gtk_widget_destroy(window) when "clicked".  Again, the destroy
     * signal could come from here, or the window manager. */
    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                               GTK_SIGNAL_FUNC (gtk_widget_destroy),
                               GTK_OBJECT (window));
    
    /* This packs the button into the window (a gtk container). */
    gtk_container_add (GTK_CONTAINER (window), button);
    
    /* The final step is to display this newly created widget. */
    gtk_widget_show (button);
    
    /* and the window */
    gtk_widget_show (window);
    
    /* All GTK applications must have a gtk_main(). Control ends here
     * and waits for an event to occur (like a key press or
     * mouse event). */
    gtk_main ();
    
    return(0);
}
/* example-end */
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="sec_compiling"></A> <A NAME="ss2.2">2.2 Compiling Hello World </A>
</H2>

<P>To compile use:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gcc -Wall -g helloworld.c -o helloworld `gtk-config --cflags` \
    `gtk-config --libs`
</PRE>
</CODE></BLOCKQUOTE>
<P>This uses the program <CODE>gtk-config</CODE>, which comes with GTK. This
program "knows" what compiler switches are needed to compile programs
that use GTK. <CODE>gtk-config --cflags</CODE> will output a list of include
directories for the compiler to look in, and <CODE>gtk-config --libs</CODE>
will output the list of libraries for the compiler to link with and
the directories to find them in. In the above example they could have
been combined into a single instance, such as
<CODE>`gtk-config --cflags --libs`</CODE>.
<P>Note that the type of single quote used in the compile command above
is significant.
<P>The libraries that are usually linked in are:
<UL>
<LI>The GTK library (-lgtk), the widget library, based on top of GDK.</LI>
<LI>The GDK library (-lgdk), the Xlib wrapper.</LI>
<LI>The gmodule library (-lgmodule), which is used to load run time
extensions.</LI>
<LI>The GLib library (-lglib), containing miscellaneous functions;
only g_print() is used in this particular example. GTK is built on top
of glib so you will always require this library. See the section on
<A HREF="gtk_tut-20.html#sec_glib">GLib</A> for details.</LI>
<LI>The Xlib library (-lX11) which is used by GDK.</LI>
<LI>The Xext library (-lXext). This contains code for shared memory
pixmaps and other X extensions.</LI>
<LI>The math library (-lm). This is used by GTK for various purposes.</LI>
</UL>
<P>
<H2><A NAME="ss2.3">2.3 Theory of Signals and Callbacks</A>
</H2>

<P>Before we look in detail at <EM>helloworld</EM>, we'll discuss signals
and callbacks. GTK is an event driven toolkit, which means it will
sleep in gtk_main until an event occurs and control is passed to the
appropriate function.
<P>This passing of control is done using the idea of "signals". (Note
that these signals are not the same as the Unix system signals, and
are not implemented using them, although the terminology is almost
identical.) When an event occurs, such as the press of a mouse button,
the appropriate signal will be "emitted" by the widget that was
pressed.  This is how GTK does most of its useful work. There are
signals that all widgets inherit, such as "destroy", and there are
signals that are widget specific, such as "toggled" on a toggle
button.
<P>To make a button perform an action, we set up a signal handler to
catch these signals and call the appropriate function. This is done by
using a function such as:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gint gtk_signal_connect( GtkObject     *object,
                         gchar         *name,
                         GtkSignalFunc  func,
                         gpointer       func_data );
</PRE>
</CODE></BLOCKQUOTE>
<P>where the first argument is the widget which will be emitting the
signal, and the second the name of the signal you wish to catch. The
third is the function you wish to be called when it is caught, and the
fourth, the data you wish to have passed to this function.
<P>The function specified in the third argument is called a "callback
function", and should generally be of the form
<P>
<BLOCKQUOTE><CODE>
<PRE>
void callback_func( GtkWidget *widget,
                    gpointer   callback_data );
</PRE>
</CODE></BLOCKQUOTE>
<P>where the first argument will be a pointer to the widget that emitted
the signal, and the second a pointer to the data given as the last
argument to the gtk_signal_connect() function as shown above.
<P>Note that the above form for a signal callback function declaration is
only a general guide, as some widget specific signals generate
different calling parameters. For example, the CList "select_row"
signal provides both row and column parameters.
<P>Another call used in the <EM>helloworld</EM> example, is:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gint gtk_signal_connect_object( GtkObject     *object,
                                gchar         *name,
                                GtkSignalFunc  func,
                                GtkObject     *slot_object );
</PRE>
</CODE></BLOCKQUOTE>
<P>gtk_signal_connect_object() is the same as gtk_signal_connect() except
that the callback function only uses one argument, a pointer to a GTK
object. So when using this function to connect signals, the callback
should be of the form
<P>
<BLOCKQUOTE><CODE>
<PRE>
void callback_func( GtkObject *object );
</PRE>
</CODE></BLOCKQUOTE>
<P>where the object is usually a widget. We usually don't setup callbacks
for gtk_signal_connect_object however. They are usually used to call a
GTK function that accepts a single widget or object as an argument, as
is the case in our <EM>helloworld</EM> example.
<P>The purpose of having two functions to connect signals is simply to
allow the callbacks to have a different number of arguments. Many
functions in the GTK library accept only a single GtkWidget pointer as
an argument, so you want to use the gtk_signal_connect_object() for
these, whereas for your functions, you may need to have additional
data supplied to the callbacks.
<P>
<H2><A NAME="ss2.4">2.4 Events</A>
</H2>

<P>In addition to the signal mechanism described above, there is a set
of <EM>events</EM> that reflect the X event mechanism. Callbacks may
also be attached to these events. These events are:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久婷婷国产精品综合| 久久99国内精品| 91丝袜美女网| 亚洲视频一区在线| 91在线你懂得| 亚洲国产成人av好男人在线观看| 欧美性色黄大片| 日韩精品成人一区二区在线| 欧美大片拔萝卜| 国内久久精品视频| 亚洲欧美一区二区视频| 在线观看一区日韩| 欧美aaaaa成人免费观看视频| 日韩精品中午字幕| 国产a精品视频| 亚洲精品视频观看| 欧美一区二区三区的| 精品一区二区三区av| 亚洲欧美综合在线精品| 在线成人免费观看| 国产精品一区二区三区99| 亚洲欧洲制服丝袜| 精品久久国产老人久久综合| 成人亚洲精品久久久久软件| 亚洲国产综合在线| 精品国产一二三| 色综合久久88色综合天天6 | 成人免费不卡视频| 亚洲激情校园春色| 欧美大黄免费观看| 91麻豆精东视频| 韩国一区二区三区| 亚洲午夜久久久久中文字幕久| 亚洲精品一区二区精华| 91久久精品一区二区| 久草中文综合在线| 自拍偷拍亚洲综合| 久久丝袜美腿综合| 欧美日韩国产综合一区二区 | 国产日韩欧美麻豆| 欧美日韩一卡二卡| 成人ar影院免费观看视频| 性欧美疯狂xxxxbbbb| 国产精品美女一区二区| 正在播放亚洲一区| 91成人看片片| 成人美女在线视频| 毛片不卡一区二区| 亚洲一区二区av在线| 国产欧美日韩在线| 日韩网站在线看片你懂的| 在线观看日韩精品| 99免费精品视频| 激情欧美日韩一区二区| 亚洲电影一级黄| 亚洲天堂av老司机| 国产女人aaa级久久久级 | 欧美日韩免费在线视频| 成人综合在线视频| 国产精品一区二区在线观看网站| 日韩av中文字幕一区二区三区| 一区二区三区av电影| 国产精品―色哟哟| 国产色产综合色产在线视频| 欧美成人在线直播| 91精品国产综合久久久蜜臀粉嫩| 在线观看一区二区视频| 91麻豆文化传媒在线观看| 不卡免费追剧大全电视剧网站| 国产精品一区二区三区网站| 国产永久精品大片wwwapp| 美女爽到高潮91| 免费观看成人鲁鲁鲁鲁鲁视频| 婷婷久久综合九色综合伊人色| 亚洲一区二区四区蜜桃| 一区二区三区四区不卡在线| 亚洲黄色在线视频| 亚洲精品日日夜夜| 国内精品视频一区二区三区八戒| 蜜臀久久久99精品久久久久久| 蜜桃视频在线一区| 另类小说色综合网站| 久久99九九99精品| 国产一区二区视频在线播放| 国产真实乱子伦精品视频| 国模无码大尺度一区二区三区| 国产激情91久久精品导航| 国产91综合一区在线观看| 国产91综合网| 91亚洲男人天堂| 欧美午夜精品一区二区三区 | 成人免费va视频| jlzzjlzz欧美大全| 欧美系列在线观看| 精品女同一区二区| 久久久精品人体av艺术| 欧美国产成人精品| 夜夜嗨av一区二区三区网页| 亚洲va中文字幕| 免费高清在线一区| 成人午夜在线免费| 欧美在线看片a免费观看| 91精品国产一区二区人妖| 精品国产一区二区三区久久久蜜月| 国产日韩欧美精品综合| 亚洲裸体xxx| 日韩国产欧美三级| 国产福利精品一区| 91丨porny丨蝌蚪视频| 欧美高清www午色夜在线视频| 538prom精品视频线放| 国产喷白浆一区二区三区| 亚洲一二三四在线观看| 精品亚洲免费视频| bt7086福利一区国产| 欧美高清视频不卡网| 欧美极品美女视频| 日韩国产欧美三级| www.66久久| 日韩欧美国产电影| 亚洲欧美电影一区二区| 蜜臀久久99精品久久久久宅男| 99精品视频在线观看| 日韩午夜中文字幕| 日本一区二区不卡视频| 免费观看久久久4p| 一本大道av伊人久久综合| 精品日韩一区二区三区| 亚洲精品国产精品乱码不99| 精品一区二区三区久久久| 日本韩国精品一区二区在线观看| 久久综合精品国产一区二区三区| 亚洲福利视频导航| 国产成人综合网站| 91精品国模一区二区三区| 亚洲免费色视频| 欧美肥大bbwbbw高潮| 中文字幕第一区综合| 久久精品国产一区二区三 | a美女胸又www黄视频久久| 欧美成人伊人久久综合网| 亚洲bt欧美bt精品| 91亚洲资源网| 国产精品情趣视频| 国产美女视频一区| 日韩一级精品视频在线观看| 亚洲综合激情小说| 91香蕉国产在线观看软件| 久久久久久电影| 久久电影网电视剧免费观看| 欧美久久一二区| 一区二区久久久| av电影天堂一区二区在线观看| 日韩视频免费观看高清在线视频| 性做久久久久久免费观看欧美| 91蝌蚪porny| 国产精品色一区二区三区| 国产成人午夜片在线观看高清观看| 日韩欧美一区二区在线视频| 日产欧产美韩系列久久99| 欧美日韩一区二区电影| 亚洲国产毛片aaaaa无费看| 94-欧美-setu| 亚洲色图制服丝袜| 色国产精品一区在线观看| 亚洲欧美日韩国产手机在线| av欧美精品.com| 亚洲男人都懂的| 欧美亚洲动漫制服丝袜| 亚洲一区在线视频| 欧美另类高清zo欧美| 免费观看91视频大全| 日韩美女视频在线| 国产激情视频一区二区在线观看| 欧美国产欧美综合| 不卡一区二区中文字幕| 亚洲视频精选在线| 一本久道久久综合中文字幕| 亚洲国产aⅴ成人精品无吗| 91精品婷婷国产综合久久性色 | 亚洲444eee在线观看| 欧美久久一二区| 久久99精品国产麻豆不卡| www欧美成人18+| 国产成人在线影院| 中文字幕在线不卡国产视频| 日本精品免费观看高清观看| 亚洲综合免费观看高清完整版| 在线免费观看日本一区| 蜜桃视频第一区免费观看| 国产亚洲成av人在线观看导航| av午夜一区麻豆| 午夜精品久久久久久久久久久| 欧美成人精品高清在线播放| 国产v日产∨综合v精品视频| 亚洲狠狠丁香婷婷综合久久久| 欧美久久久久久久久| 国产一二精品视频| 亚洲欧美一区二区三区久本道91| 91精品国产欧美一区二区18|