PageRenderTime 29ms CodeModel.GetById 16ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/src/demos/demo_msgbox.c

http://ftk.googlecode.com/
C | 101 lines | 77 code | 24 blank | 0 comment | 0 complexity | 04deeab88fc9001ad75c9f5cbfb94d5c MD5 | raw file
  1#include "ftk.h"
  2
  3static const char* buttons1[] = {"Yes", NULL};
  4static const char* buttons2[] = {"Yes", "No", NULL};
  5static const char* buttons3[] = {"Yes", "No", "Cancel", NULL};
  6static Ret button_warning(void* ctx, void* obj)
  7{
  8	int ret = ftk_warning("Warning", "December 31, 2008: patchwork.kernel.org is now available for general use. It is currently only monitoring the Linux Kernel mailing-list, but should be useful to kernel developers in dealing with patches flying across the wire.", buttons1);
  9
 10	ftk_logd("%s: ret = %d\n", __func__, ret);
 11
 12	return RET_OK;
 13}
 14
 15static Ret button_info(void* ctx, void* obj)
 16{
 17	int ret = ftk_infomation("Infomation", "September 19, 2008: mirrors.kernel.org has been flipped over to using our new GeoDNS based bind server (named-geodns). This means that, at the dns query level, our servers will attempt to direct you to the nearest / fastest kernel.org mirror for your request. This means that you no longer have to use mirrors.us.kernel.org or mirrors.eu.kernel.org to generally route you to the right place. This does mean a change to mirrors.kernel.org no longer explicitly pointing at mirrors.us.kernel.org. Additional information on named-geodns will be forth coming, check back here for an addendum soon.", buttons2);
 18
 19	ftk_logd("%s: ret = %d\n", __func__, ret);
 20	return RET_OK;
 21}
 22
 23static Ret button_question(void* ctx, void* obj)
 24{
 25	int ret = ftk_question("Question", "Are you sure to quit?", buttons3);
 26	ftk_logd("%s: ret = %d\n", __func__, ret);
 27
 28	return RET_OK;
 29}
 30
 31static Ret button_tips(void* ctx, void* obj)
 32{
 33	int ret = ftk_tips("The dialog will quit in 3 seconds.");
 34	ftk_logd("%s: ret = %d\n", __func__, ret);
 35
 36	return RET_OK;
 37}
 38
 39static Ret button_quit(void* ctx, void* obj)
 40{
 41	ftk_widget_unref(ctx);
 42	return RET_OK;
 43}
 44
 45#ifdef FTK_AS_PLUGIN
 46#include "ftk_app_demo.h"
 47FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
 48FtkApp* ftk_app_demo_msgbox_create()
 49{
 50	return ftk_app_demo_create(_("msgbox"), ftk_main);
 51}
 52#else
 53#define FTK_HIDE extern
 54#endif /*FTK_AS_PLUGIN*/
 55
 56FTK_HIDE int FTK_MAIN(int argc, char* argv[])
 57{
 58	int y = 0;
 59	int width = 0;
 60	int height = 0;
 61	FtkWidget* win = NULL;
 62	FtkWidget* button = NULL;
 63
 64	FTK_INIT(argc, argv);
 65		
 66	win = ftk_app_window_create();
 67	width = ftk_widget_width(win);
 68	height = ftk_widget_height(win);
 69
 70	y = (height - 240)/2;
 71	y = y > 0 ? y : 0;
 72
 73	button = ftk_button_create(win, 0, y, width/2, 50);
 74	ftk_widget_set_text(button, "question");
 75	ftk_button_set_clicked_listener(button, button_question, win);
 76	
 77	button = ftk_button_create(win, width/2, y, width/2, 50);
 78	ftk_widget_set_text(button, "warning");
 79	ftk_button_set_clicked_listener(button, button_warning, win);
 80	
 81	button = ftk_button_create(win, 0, y+60, width/2, 50);
 82	ftk_widget_set_text(button, "info");
 83	ftk_button_set_clicked_listener(button, button_info, win);
 84
 85	button = ftk_button_create(win, width/2, y+60, width/2, 50);
 86	ftk_widget_set_text(button, "tips");
 87	ftk_button_set_clicked_listener(button, button_tips, win);
 88	
 89	button = ftk_button_create(win, width/4, y+120, width/2, 50);
 90	ftk_widget_set_text(button, "quit");
 91	ftk_button_set_clicked_listener(button, button_quit, win);
 92
 93	ftk_widget_set_text(win, "message box demo");
 94	ftk_widget_show_all(win, 1);
 95	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
 96
 97	FTK_RUN();
 98
 99	return 0;
100}
101