PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/apps/filemanager/ftk_app_file_browser.c

http://ftk.googlecode.com/
C | 70 lines | 57 code | 13 blank | 0 comment | 9 complexity | bf49167a3504a184382f98a5b1da6ad9 MD5 | raw file
 1#include "ftk_file_browser.h"
 2#include "ftk_app_file_browser.h"
 3
 4typedef struct _PrivInfo
 5{
 6	FtkBitmap* icon;
 7}PrivInfo;
 8
 9static FtkBitmap* ftk_app_file_browser_get_icon(FtkApp* thiz)
10{
11	DECL_PRIV(thiz, priv);
12	const char* name="filem.png";
13	char file_name[FTK_MAX_PATH + 1] = {0};
14	return_val_if_fail(priv != NULL, NULL);
15	
16	if(priv->icon != NULL) return priv->icon;
17	
18	snprintf(file_name, FTK_MAX_PATH, "%s/icons/%s", APP_DATA_DIR, name);
19	priv->icon = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), file_name);
20	if(priv->icon != NULL) return priv->icon;
21
22	snprintf(file_name, FTK_MAX_PATH, "%s/icons/%s", APP_LOCAL_DATA_DIR, name);
23	priv->icon = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), file_name);
24
25	return priv->icon;
26}
27
28static const char* ftk_app_file_browser_get_name(FtkApp* thiz)
29{
30	return _("File Browser");
31}
32
33static Ret ftk_app_file_browser_run(FtkApp* thiz, int argc, char* argv[])
34{
35	FtkWidget* win = ftk_file_browser_create(FTK_FILE_BROWER_APP);
36	ftk_window_set_animation_hint(win, "app_main_window");
37	ftk_file_browser_set_path(win, "./");
38	ftk_file_browser_load(win);
39#ifdef HAS_MAIN
40	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
41#endif	
42	return RET_OK;
43}
44
45static void ftk_app_file_browser_destroy(FtkApp* thiz)
46{
47	if(thiz != NULL)
48	{
49		DECL_PRIV(thiz, priv);
50		ftk_bitmap_unref(priv->icon);
51		FTK_FREE(thiz);
52	}
53
54	return;
55}
56
57FtkApp* ftk_app_file_browser_create(void)
58{
59	FtkApp* thiz = FTK_ZALLOC(sizeof(FtkApp) + sizeof(PrivInfo));
60
61	if(thiz != NULL)
62	{
63		thiz->run  = ftk_app_file_browser_run;
64		thiz->get_icon = ftk_app_file_browser_get_icon;
65		thiz->get_name = ftk_app_file_browser_get_name;
66		thiz->destroy = ftk_app_file_browser_destroy;
67	}
68
69	return thiz;
70}