linux应用程序开发指南之21-19.pdf

linux应用程序开发指南之21-19.pdf

ID:52243367

大小:265.60 KB

页数:11页

时间:2020-03-25

linux应用程序开发指南之21-19.pdf_第1页
linux应用程序开发指南之21-19.pdf_第2页
linux应用程序开发指南之21-19.pdf_第3页
linux应用程序开发指南之21-19.pdf_第4页
linux应用程序开发指南之21-19.pdf_第5页
资源描述:

《linux应用程序开发指南之21-19.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、下载第五部分附录附录AGnomeHello源代码这里是本书中多次用到的GnomeHello的源代码。它是学习Gnome编程非常好的材料。源代码共分为五个文件,分别是hello.c、app.c、app.h、menu.c以及menu.h。A.1第一部分:hello.c#include#include#include"app.h"staticvoidsession_die(GnomeClient*client,gpointerclient_data);staticgintsave_session(GnomeClie

2、nt*client,gintphase,GnomeSaveStylesave_style,gintis_shutdown,GnomeInteractStyleinteract_style,gintis_fast,gpointerclient_data);staticintgreet_mode=FALSE;staticchar*message=NULL;staticchar*geometry=NULL;structpoptOptionoptions[]={{"greet",‘g’,POPT_ARG_NONE,&greet_mode,0,N_("Sa

3、yhellotospecificpeoplelistedonthecommandline"),NULL},{"message",‘m’,POPT_ARG_STRING,&message,0,N_("Specifyamessageotherthan"Hello,World!""),N_("MESSAGE")},294使用第五部分附录下载{"geometry",‘’,POPT_ARG_STRING,&geometry,0,N_("Specifythegeometryofthemainwindow"),N_("GEOMETRY")},{NULL

4、,‘’,0,NULL,0,NULL,NULL}};intmain(intargc,char*argv[]){GtkWidget*app;poptContextpctx;char**args;inti;GSList*greet=NULL;GnomeClient*client;bindtextdomain(PACKAGE,GNOMELOCALEDIR);textdomain(PACKAGE);gnome_init_with_popt_table(PACKAGE,VERSION,argc,argv,options,0,&pctx);/*参数分析*/

5、args=poptGetArgs(pctx);if(greet_mode&&args){i=0;while(args[i]!=NULL){greet=g_slist_prepend(greet,args[i]);++i;附录AGnomeHello源代码使用295下载}/*Puttheminorder*/greet=g_slist_reverse(greet);}elseif(greet_mode&&args==NULL){g_error(_("Youmustspecifysomeonetogreet."));}elseif(args!=NULL)

6、{g_error(_("Commandlineargumentsareonlyallowedwith--greet."));}else{g_assert(!greet_mode&&args==NULL);}poptFreeContext(pctx);/*会话管理*/client=gnome_master_client();gtk_signal_connect(GTK_OBJECT(client),"save_yourself",GTK_SIGNAL_FUNC(save_session),argv[0]);gtk_signal_connect(GT

7、K_OBJECT(client),"die",GTK_SIGNAL_FUNC(session_die),NULL);app=hello_app_new(message,geometry,greet);g_slist_free(greet);gtk_widget_show_all(app);gtk_main();return0;}staticgintsave_session(GnomeClient*client,gintphase,GnomeSaveStylesave_style,gintis_shutdown,GnomeInteractStyle

8、interact_style,gintis_fast,gpointerclient_data){gchar**argv;guintarg

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。