Linux中国  设为主页
 收藏本站
 
当前位置: > 首页 ->Linux技术 ->系统管理 ->GTK v1.2 Tutorial(英文)
  相关分类: 
入门与提高
系统管理
网络应用
嵌入式系统
内核研究
服务器相关
发行版专区
Linux程序设计
Linux安全
BSD相关
桌面应用
  站内搜索: 
热门文章排行
热门文章排行 Adaptec 2100S RAID卡安装快速指南 (05-05)
JSP专题:第六部分:用JSP实现聊天室(05-05)
Linux 99问(一)(05-05)
Linux系统中网络配置详解(05-05)
JSP专题:第六部分:用JSP实现聊天室(05-05)
精采文章排行
精采文章排行 Motorola微处理器bootloader分析与应(06-04)
Linux系统:让内存不再泄漏的实用技(06-04)
Fedora Core5 NFS服务器搭建过程介绍(06-04)
新手看招 手把手教你安装VMware虚拟(06-04)
“侵权事件” 红帽称微软企图干扰用(06-04)
 

GTK v1.2 Tutorial(英文)

作者:Webmaster   来源:Linux-cn.com   点击:   日期:2007-05-05 [收藏] [投稿]

  IE是否经常中毒?推荐您

1. Introduction

  GTK (GIMP Toolkit) is a library for creating graphical user interfaces. It is licensed using the LGPL license, so you can develop open software, free software, or even commercial non-free software using GTK without having to spend anything for licenses or royalties.

  It's called the GIMP toolkit because it was originally written for developing the GNU Image Manipulation Program (GIMP), but GTK has now been used in a large number of software projects, including the GNU Network Object Model Environment (GNOME) project. GTK is built on top of GDK (GIMP Drawing Kit) which is basically a wrapper around the low-level functions for accessing the underlying windowing functions (Xlib in the case of the X windows system). The primary authors of GTK are:

  Peter Mattis petm@xcf.berkeley.edu

  Spencer Kimball spencer@xcf.berkeley.edu

  Josh MacDonald jmacd@xcf.berkeley.edu

  GTK is essentially an object oriented application programmers interface (API). Although written completely in C, it is implemented using the idea of classes and callback functions (pointers to functions).

  There is also a third component called GLib which contains a few replacements for some standard calls, as well as some additional functions for handling linked lists, etc. The replacement functions are used to increase GTK's portability, as some of the functions implemented here are not available or are nonstandard on other unixes such as g_strerror(). Some also contain enhancements to the libc versions, such as g_malloc that has enhanced debugging utilities.

  This tutorial describes the C interface to GTK. There are GTK bindings for many other languages including C++, Guile, Perl, Python, TOM, Ada95, Objective C, Free Pascal, and Eiffel. If you intend to use another language's bindings to GTK, look at that binding's documentation first. In some cases that documentation may describe some important conventions (which you should know first) and then refer you back to this tutorial. There are also some cross-platform APIs (such as wxWindows and V) which use GTK as one of their target platforms; again, consult their documentation first.

  If you're developing your GTK application in C++, a few extra notes are in order. There's a C++ binding to GTK called GTK--, which provides a more C++-like interface to GTK; you should probably look into this instead. If you don't like that approach for whatever reason, there are two alternatives for using GTK. First, you can use only the C subset of C++ when interfacing with GTK and then use the C interface as described in this tutorial. Second, you can use GTK and C++ together by declaring all callbacks as static functions in C++ classes, and again calling GTK using its C interface. If you choose this last approach, you can include as the callback's data value a pointer to the object to be manipulated (the so-called "this" value). Selecting between these options is simply a matter of preference, since in all three approaches you get C++ and GTK. None of these approaches requires the use of a specialized preprocessor, so no matter what you choose you can use standard C++ with GTK.

  This tutorial is an attempt to document as much as possible of GTK, but it is by no means complete. This tutorial assumes a good understanding of C, and how to create C programs. It would be a great benefit for the reader to have previous X programming experience, but it shouldn't be necessary. If you are learning GTK as your first widget set, please comment on how you found this tutorial, and what you had trouble with. There are also C++, Objective C, ADA, Guile and other language bindings available, but I don't follow these.

  This document is a "work in progress". Please look for updates on http://www.gtk.org/.

  I would very much like to hear of any problems you have learning GTK from this document, and would appreciate input as to how it may be improved. Please see the section on Contributing for further information.

2. Getting Started

  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 http://www.gtk.org/. GTK uses GNU autoconf for configuration. Once untar'd, type ./configure --help to see a list of options.

  The GTK source distribution also contains the complete source to all of the examples used in this tutorial, along with Makefiles to aid compilation.

  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.

·Fedora Core5 NFS服务器搭建过程介绍 ·Linux系统:让内存不再泄漏的实用技巧 ·新手看招 手把手教你安装VMware虚拟机 ·“侵权事件” 红帽称微软企图干扰用户 ·删除Linux后 如何找回Windows启动菜单 ·菜鸟乐园 Linux中常见文件系统格式介绍 ·Linux操作系统下IPTables配置方法详解 ·实用技巧 Linux系统的经典使用技巧八则 ·Linux系统文件优化及磁盘检查方法介绍

/* example-start base base.c */
#include <gtk/gtk.h>
int main( int argc,
char *argv[] )
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main ();
return(0);
}
/* example-end */


 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<

上一页12 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 下一页

上一篇:GTK入门导引   下一篇:GDK Reference Manual
文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论

   相关文章:
·Motorola微处理器bootloader分析与应用

   文章评论:(1条)
  
 请留名: 匿名评论   点击查看所有评论 论坛讨论
 

 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。