Exemplo n.º 1
0
static Ret ftk_app_movie_run(FtkApp* thiz, int argc, char* argv[])
{
	FtkWidget *label;

	FtkWidget *win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

	ftk_widget_set_text(win, "영화");

	ftk_app_window_set_user_on_event(win, _movie_user_on_event);

	label = ftk_label_create(win, 10, 50, 220, 100);
	ftk_widget_set_id(label, IDC_TITLE);

	_app_movie_create_button(win, 35, IDC_PLAY, "play");
	_app_movie_create_button(win, 137, IDC_STOP, "stop");

	ftk_app_window_set_on_prepare_options_menu(win, ftk_clock_on_prepare_options_menu, win);
	ftk_widget_show_all(win, 1);

#ifdef HAS_MAIN
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
#endif	
	return RET_OK;
}
Exemplo n.º 2
0
FtkWidget* ftk_file_browser_create(FtkFileBrowserType type)
{
	FtkListModel* model = NULL;
	FtkListRender* render = NULL;	
	FtkPrepareOptionsMenu option_menu = NULL;
	FtkWidget* win  = ftk_app_window_create();
	PrivInfo* priv  = FTK_NEW(PrivInfo);
	FtkWidget* list = ftk_list_view_create(win, 0, 0, ftk_widget_width(win), ftk_widget_height(win));

	if(type == FTK_FILE_BROWER_APP)
	{
		option_menu = ftk_file_browser_on_prepare_options_menu;
	}
	else
	{
		option_menu = ftk_file_browser_on_prepare_options_menu_for_choose;
	}
	ftk_app_window_set_on_prepare_options_menu(win, option_menu, win);

	model = ftk_list_model_default_create(10);
	render = ftk_list_render_default_create();

	priv->type = type;
	priv->model = model;
	priv->list_view = list;
	ftk_list_view_init(list, model, render, 40);
	ftk_widget_set_text(win, _("File Browser"));
	ftk_widget_set_user_data(win, priv_info_destroy, priv);
	ftk_list_view_set_clicked_listener(list, ftk_file_browser_on_item_clicked, win);
	ftk_list_render_default_set_marquee_attr(render, 
		FTK_MARQUEE_AUTO | FTK_MARQUEE_RIGHT2LEFT | FTK_MARQUEE_FOREVER);
	ftk_list_model_unref(model);

	return win;
}
Exemplo n.º 3
0
static Ret designer_init(FtkWidget* win)
{
	ftk_widget_set_user_data(win, info_destroy, info_create());
	ftk_widget_set_event_listener(win, designer_on_event, win);
	ftk_app_window_set_on_prepare_options_menu(win, designer_on_prepare_options_menu, win);
	
	ftk_widget_show(win, 1);

	return RET_OK;
}
Exemplo n.º 4
0
static Ret ftk_app_bluetooth_run(FtkApp* thiz, int argc, char* argv[])
{
	
	DECL_PRIV(thiz, priv);
	FtkWidget* win = NULL;
	return_val_if_fail(priv != NULL, RET_FAIL);

	win = ftk_bluetooth_create_window();
	ftk_app_window_set_on_prepare_options_menu(win, ftk_bluetooth_on_prepare_options_menu, win);
	ftk_widget_show_all(win, 1);

#ifdef HAS_MAIN
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
#endif	

	return RET_OK;
}
Exemplo n.º 5
0
#include "ftk.h"

static Ret on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	int i = 0;
	for(i = 0; i < 3; i++)
	{
		char text[32] = {0};
		FtkWidget* item = ftk_menu_item_create(menu_panel);
		ftk_snprintf(text, sizeof(text), "Menu%02d", i);
		ftk_widget_set_text(item, text);
		ftk_widget_show(item, 1);
	}

	return i > 0 ? RET_OK : RET_FAIL;
}
#define IDC_TEST_BUTTON 1000
static Ret button_quit_clicked(void* ctx, void* obj)
{
	ftk_widget_unref(ctx);

	return RET_OK;
}

static const char* buttons[] = {"OK", NULL};
static Ret button_unfullscreen_clicked(void* ctx, void* obj)
{
	if(!ftk_window_is_fullscreen(ctx))
	{
		ftk_infomation("Infomation", "Windows is not fullscreen.", buttons);
	}
	else
	{
		ftk_window_set_fullscreen(ctx, 0);
	}
	ftk_logd("%s: width=%d height=%d\n", __func__, ftk_widget_width(ctx), ftk_widget_height(ctx));

	return RET_OK;
}

static Ret button_fullscreen_clicked(void* ctx, void* obj)
{
	if(ftk_window_is_fullscreen(ctx))
	{
		ftk_infomation("Infomation", "Windows is fullscreen.", buttons);
	}
	else
	{
		ftk_window_set_fullscreen(ctx, 1);
	}

	ftk_logd("%s: width=%d height=%d\n", __func__, ftk_widget_width(ctx), ftk_widget_height(ctx));
	return RET_OK;
}

#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_fullscreen_create()
{
	return ftk_app_demo_create(_("fullscreen"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;

	FTK_INIT(argc, argv);
	
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);
	
	width = width/2 - 10;
	button = ftk_button_create(win, 0, height/4, width, 50);
	ftk_widget_set_text(button, "Fullscreen");
	ftk_button_set_clicked_listener(button, button_fullscreen_clicked, win);

	button = ftk_button_create(win, width + 10, height/4, width, 50);
	ftk_widget_set_text(button, "Unfullscreen");
	ftk_button_set_clicked_listener(button, button_unfullscreen_clicked, win);
	
	button = ftk_button_create(win, width/2, height/2, width, 60);
	ftk_widget_set_text(button, "quit");
	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
	ftk_window_set_focus(win, button);

	ftk_widget_set_text(win, "fullscreen");
	ftk_widget_show_all(win, 1);
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
	ftk_app_window_set_on_prepare_options_menu(win, on_prepare_options_menu, win);

	FTK_RUN();

	return 0;
}
Exemplo n.º 6
0
int FTK_MAIN(int argc, char* argv[])
{
	int i = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	FtkSource* timer = NULL;
	char path[FTK_MAX_PATH] = {0};
	const char* root_path[FTK_ICON_PATH_NR] = {0};

	ftk_init(argc, argv);

	for(i = 0; i < argc; i++)
	{
		const char* key_play="--event-play=";
		const char* key_record="--event-record=";
#ifdef FTK_HAS_TESTER
		if(strncmp(argv[i], key_play, strlen(key_play)) == 0)
		{
			ftk_tester_start_play(argv[i] + strlen(key_play));	
		}
		
		if(strncmp(argv[i], key_record, strlen(key_record)) == 0)
		{
			ftk_tester_start_record(argv[i] + strlen(key_record));	
		}
#endif
	}

#ifdef ENABLE_NLS
	if(getenv("LANG") == NULL)
	{
		setenv("LANG", "zh_CN.UTF-8", 1);
		setlocale (LC_ALL, "zh_CN.UTF-8");
		ftk_logd("LANG is not set, use zh_CN.UTF-8\n");
	}
	else
	{
		setlocale (LC_ALL, "");
	}

	bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
	textdomain (PACKAGE); 
	ftk_logd("%s: locale=%s\n", _("Hello, GetText"), setlocale(LC_ALL, NULL));
#endif

	desktop_add_time_item_on_statusbar();

	if(argv[1] != NULL && strncmp(argv[1], "--hor", 5) == 0)
	{
		g_desktop.is_horizonal = 1;
	}

	g_desktop.app_manager = app_info_manager_create();

	ftk_snprintf(path, sizeof(path), "%s/base/apps", FTK_ROOT_DIR);
	ftk_normalize_path(path);
	if(app_info_manager_load_dir(g_desktop.app_manager, path) != RET_OK)
	{
		ftk_snprintf(path, sizeof(path), "%s/apps", LOCAL_DATA_DIR);
		app_info_manager_load_dir(g_desktop.app_manager, path);
	}

	ftk_snprintf(path, sizeof(path), "%s/desktop", FTK_ROOT_DIR);
	root_path[0] = path;
	root_path[1] = NULL;

	g_desktop.icon_cache = ftk_icon_cache_create(root_path, NULL);
	win = desktop_load_xul(g_desktop.is_horizonal ? "xul/desktop-h.xul" : "xul/desktop-v.xul"); 
	ftk_app_window_set_on_prepare_options_menu(win, desktop_on_prepare_options_menu, win);
	button = ftk_widget_lookup(win, 100);
	ftk_button_set_clicked_listener(button, desktop_on_button_open_applist_clicked, win);
	ftk_widget_show_all(win, 1);

	desktop_update_time(win);
	timer = ftk_source_timer_create(60000, desktop_update_time, win);
	ftk_main_loop_add_source(ftk_default_main_loop(), timer);
	ftk_widget_set_user_data(win, desktop_destroy, &g_desktop);

	ftk_run();

	return 0;
}