PageRenderTime 526ms CodeModel.GetById 262ms app.highlight 6ms RepoModel.GetById 135ms app.codeStats 0ms

/src/demos/demo_xul.c

http://ftk.googlecode.com/
C | 56 lines | 45 code | 11 blank | 0 comment | 1 complexity | 5091e162851080d24427a0bd4a9afbfd MD5 | raw file
 1#include "ftk.h"
 2#include "ftk_xul.h"
 3
 4const char* t1 = "<window> </window>";
 5
 6#define IDC_QUIT 100
 7
 8static Ret button_quit_clicked(void* ctx, void* obj)
 9{
10	ftk_widget_unref(ctx);
11	return RET_OK;
12}
13
14#ifdef FTK_AS_PLUGIN
15#include "ftk_app_demo.h"
16FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
17FtkApp* ftk_app_demo_xul_create()
18{
19	return ftk_app_demo_create(_("xul"), ftk_main);
20}
21#else
22#define FTK_HIDE extern
23#endif /*FTK_AS_PLUGIN*/
24
25FTK_HIDE int FTK_MAIN(int argc, char* argv[])
26{
27	if(argc > 1)
28	{
29		FtkWidget* win = NULL;
30		FtkWidget* quit = NULL;
31		FtkXulCallbacks callbacks;
32		
33		FTK_INIT(argc, argv);
34		
35		callbacks.translate_text = NULL;
36		callbacks.load_image = (FtkXulLoadImage)ftk_icon_cache_load;
37		callbacks.ctx = ftk_icon_cache_create(NULL, "testdata");
38		win = ftk_xul_load_file(argv[1], &callbacks);
39		ftk_icon_cache_destroy(callbacks.ctx);
40		FTK_QUIT_WHEN_WIDGET_CLOSE(win);
41
42		quit = ftk_widget_lookup(win, IDC_QUIT);
43		ftk_button_set_clicked_listener(quit, button_quit_clicked, win);
44		ftk_widget_show_all(win, 1);
45
46		FTK_RUN();
47	}
48	else
49	{
50		ftk_logd("Usage: %s xul\n", argv[0]);
51
52		return 0;
53	}
54
55	return 0;
56}