Ejemplo n.º 1
0
Ret  fbus_proxy_set_notify_listener(FBusProxy* thiz, FBusProxyListener listener, void* ctx)
{
	return_val_if_fail(thiz != NULL, RET_FAIL);

	thiz->listener = listener;
	thiz->listener_ctx = ctx;
	
	if(thiz->source != NULL)
	{
		ftk_main_loop_remove_source(ftk_default_main_loop(), thiz->source);
		thiz->source = NULL;
	}

	if(listener != NULL)
	{
		thiz->source = fbus_source_proxy_create(thiz, thiz->stream, listener, ctx);

		if(thiz->source != NULL)
		{
			ftk_main_loop_add_source(ftk_default_main_loop(), thiz->source);
		}
	}

	return RET_OK;
}
Ejemplo n.º 2
0
static Ret _bt_on_item_clicked(void *ctx, void *list)
{
	FtkListItemInfo* info = NULL;
	FtkListModel* model = ftk_list_view_get_model(list);
	int i = ftk_list_view_get_selected(list);

	printf("%s : clicked index %d\n", __func__, i);

	ftk_list_model_get_data(model, i, (void**)&info);
	if(info != NULL && !info->disable)
	{
		info->state = !info->state;
	}

	if (i < _bt_dev_num) {
		FtkWidget *label = ftk_widget_lookup((FtkWidget *)ctx, IDC_INFO);
		if (label) ftk_widget_set_text(label, "접속 중");

		_bt_connect = i;
		_timer = ftk_source_timer_create(300, _bt_connect_start, ctx);
		ftk_main_loop_add_source(ftk_default_main_loop(), _timer);
	}

	return RET_OK;
}
Ejemplo n.º 3
0
static FtkWidget* ftk_bluetooth_create_window(void)
{
	FtkWidget *widget;
	FtkListRender* render = NULL;

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

	ftk_widget_set_text(win, "블루투스");

	widget = ftk_label_create(win, 10, 10, 220, 30);
	ftk_widget_set_id(widget, IDC_INFO);
	ftk_widget_set_text(widget, "검색 중");

	widget = ftk_list_view_create(win, 10, 40, 220, 200);
	ftk_list_view_set_clicked_listener(widget, _bt_on_item_clicked, win);
	ftk_widget_set_id(widget, IDC_LIST);

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

	ftk_list_render_default_set_marquee_attr(render,
			FTK_MARQUEE_AUTO | FTK_MARQUEE_RIGHT2LEFT | FTK_MARQUEE_FOREVER);

	ftk_list_view_init(widget, _model, render, 40);
	ftk_list_model_unref(_model);

	_timer = ftk_source_timer_create(300, _bt_scan_start, win);
	ftk_main_loop_add_source(ftk_default_main_loop(), _timer);

	return win;
}
Ejemplo n.º 4
0
static Ret desktop_on_button_close_applist_clicked(void* ctx, void* obj)
{
	ftk_main_loop_add_source(ftk_default_main_loop(), g_timer);

	desktop_update_time(_win);
	ftk_widget_show(ctx, 0);

	return RET_OK;
}
Ejemplo n.º 5
0
Ret ftk_wait_box_start_waiting(FtkWidget* thiz)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(priv != NULL, RET_FAIL);
	return_val_if_fail(!priv->waiting, RET_FAIL);

	priv->offset = 0;
	priv->waiting = 1;
	ftk_source_ref(priv->timer);

	return ftk_main_loop_add_source(ftk_default_main_loop(), priv->timer);
}
Ejemplo n.º 6
0
Ret ftk_list_render_default_set_marquee_attr(FtkListRender* thiz, FtkMarqueeAttr marquee_attr)
{
	DECL_PRIV(thiz, priv);
	return_val_if_fail(thiz != NULL, RET_FAIL);

	priv->marquee_attr = marquee_attr;

	if(priv->marquee_timer == NULL)
	{
		priv->marquee_timer = ftk_source_timer_create(MARQUEE_MOVE_INTERVAL, marquee_timer_func, thiz);
		ftk_main_loop_add_source(ftk_default_main_loop(), priv->marquee_timer);
	}

	return RET_OK;
}
Ejemplo n.º 7
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkGc gc = {.mask = FTK_GC_BG};
	TimerInfo* info = NULL;

	FTK_INIT(argc, argv);
	info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
	info->times = 100;
		
	FtkSource* timer = ftk_source_timer_create(1000, timeout, info);
	FtkWidget* win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

	width = ftk_widget_width(win);
	height = ftk_widget_height(win);

	FtkWidget* label = ftk_label_create(win, 10, 10, width - 20, 20);
	ftk_widget_set_text(label, "arabic bidi demo");
	
	label = ftk_label_create(win, 10, 40, width - 20, 20);
	ftk_widget_set_text(label, "English Text");
	assert(strcmp(ftk_widget_get_text(label), "English Text") == 0);
	
	gc.bg.a = 0xff;
	gc.bg.r = 0xF0;
	gc.bg.g = 0xF0;
	gc.bg.b = 0x80;
	label = ftk_label_create(win, 10, height/2, width - 20, 120);
	ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
	ftk_widget_set_text(label, "ان منح حياتك للمسيح تعد خطوة ايمان يمكنك القيام بها عن طريق الصلاة");
	
	label = ftk_label_create(win, 50, height/2-30, width, 20);
	info->label = label;
	
	ftk_widget_set_text(win, "label demo");
	ftk_widget_show_all(win, 1);

	ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
	ftk_main_loop_add_source(ftk_default_main_loop(), timer);

	FTK_RUN();

	return 0;
}
Ejemplo n.º 8
0
static Ret ftk_bluetooth_on_scan(void* ctx, void* obj)
{
	FtkWidget *info;

	if (_timer) {
		ftk_main_loop_remove_source(ftk_default_main_loop(), _timer);
		_timer = NULL;
	}

	info = ftk_widget_lookup((FtkWidget *)ctx, IDC_INFO);
	if (info) ftk_widget_set_text(info, "검색 중");

	ftk_list_model_reset(_model);

	_timer = ftk_source_timer_create(300, _bt_scan_start, ctx);
	ftk_main_loop_add_source(ftk_default_main_loop(), _timer);

	return RET_OK;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
static Ret  ftk_wnd_manager_default_dispatch_event(FtkWndManager* thiz, FtkEvent* event)
{
	DECL_PRIV(thiz, priv);
	FtkWidget* target = NULL;
	return_val_if_fail(thiz != NULL && event != NULL, RET_FAIL);

	if(priv->dieing)
	{
		return RET_OK;
	}

	if(event->type == FTK_EVT_KEY_DOWN || event->type == FTK_EVT_KEY_UP)
	{
		ftk_wnd_manager_default_key_translate(thiz, event);
	}

	if(ftk_wnd_manager_dispatch_globals(thiz, event) != RET_OK)
	{
		return RET_REMOVE;
	}

	switch(event->type)
	{
		case FTK_EVT_WND_DESTROY:
		{
			if(priv->top_window == event->widget)
			{
				priv->top_window = NULL;
			}

			priv->disable_anim++;
			ftk_wnd_manager_default_remove(thiz, (FtkWidget*)event->widget);	
			priv->disable_anim--;
			return RET_OK;
		}
		case FTK_EVT_HIDE:
		{
			priv->disable_anim++;
			ftk_wnd_manager_default_emit_top_wnd_changed(thiz);
			priv->disable_anim--;
			ftk_wnd_manager_default_do_animation(thiz, event);
			ftk_wnd_manager_update(thiz);
			return RET_OK;
		}
		case FTK_EVT_SHOW:
		{
			priv->disable_anim++;
			ftk_wnd_manager_default_emit_top_wnd_changed(thiz);
			priv->disable_anim--;
			ftk_wnd_manager_default_do_animation(thiz, event);
			if(ftk_widget_type((FtkWidget*)event->widget) == FTK_WINDOW 
				&& ftk_wnd_manager_default_map_panels(thiz, !ftk_wnd_manager_default_has_fullscreen_win(thiz)) == RET_OK)
			{
				ftk_wnd_manager_update(thiz);
			}
			return RET_OK;
		}
		case FTK_EVT_RELAYOUT_WND:
		{
			ftk_wnd_manager_default_relayout(thiz);
			break;
		}
		default:break;
	}

	if(event->type == FTK_EVT_MOUSE_DOWN || event->type == FTK_EVT_KEY_DOWN)
	{
		priv->pressed_event = *event;
		ftk_source_ref(priv->long_press_timer);
		ftk_source_timer_reset(priv->long_press_timer);
		ftk_main_loop_add_source(ftk_default_main_loop(), priv->long_press_timer);
	}
	
	if(event->type == FTK_EVT_MOUSE_UP|| event->type == FTK_EVT_KEY_UP)
	{
		ftk_main_loop_remove_source(ftk_default_main_loop(), priv->long_press_timer);
	}

	if((event->type == FTK_EVT_MOUSE_DOWN 
		|| event->type == FTK_EVT_MOUSE_UP
		|| event->type == FTK_EVT_MOUSE_MOVE) && priv->grab_widget == NULL)
	{
		int x = event->u.mouse.x;
		int y = event->u.mouse.y;
		
		target = ftk_wnd_manager_find_target(thiz, x, y);
		if(event->type == FTK_EVT_MOUSE_DOWN && !ftk_widget_has_attr(target, FTK_ATTR_NO_FOCUS))
		{
			priv->focus_widget = target;
		}
	}
	else if(event->widget != NULL)
	{
		target = (FtkWidget*)event->widget;
	}
	else if(priv->grab_widget != NULL)
	{
		target = priv->grab_widget;
	}
	else if(priv->focus_widget != NULL)
	{
		target = priv->focus_widget;
	}
	else if(priv->top > 0)
	{
		target = priv->windows[priv->top - 1];
	}

	if(target != NULL && !ftk_widget_is_insensitive(target))
	{
		ftk_widget_ref(target);
		ftk_widget_event(target, event);
		ftk_widget_unref(target);
	}

	return RET_OK;
}
Ejemplo n.º 11
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkGc gc = {0};
	TimerInfo* info = NULL;
	FtkSource* timer = NULL;
	FtkWidget* win = NULL;
	FtkWidget* label = NULL;

	gc.mask = FTK_GC_BG;

	FTK_INIT(argc, argv);
	info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
	info->times = 5;
		
	timer = ftk_source_timer_create(1000, timeout, info);
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

	width = ftk_widget_width(win);
	height = ftk_widget_height(win);

#ifdef WIN32	
	label = ftk_label_create(win, 10, 10, width - 20, 20);
	ftk_widget_set_text(label, "中文文本");
#else
#endif
	label = ftk_label_create(win, 10, 40, width - 20, 20);
	ftk_widget_set_text(label, "English Text(center)");
	ftk_label_set_alignment(label, FTK_ALIGN_CENTER);
	assert(strcmp(ftk_widget_get_text(label), "English Text(center)") == 0);
	
	label = ftk_label_create(win, 10, 70, width - 20, 20);
	ftk_widget_set_text(label, "English Text(right)");
	ftk_label_set_alignment(label, FTK_ALIGN_RIGHT);

	gc.bg.a = 0xff;
	gc.bg.r = 0xF0;
	gc.bg.g = 0xF0;
	gc.bg.b = 0x80;
	label = ftk_label_create(win, 10, height/2, width - 20, 120);
	ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
#ifdef WIN32	
	ftk_widget_set_text(label, "The linux mobile development(with background color)");
#else
	ftk_widget_set_text(label, "中英文混合多行文本显示:the linux mobile development.带有背景颜色。");
#endif
	label = ftk_label_create(win, 50, height/2-30, width, 20);
	info->label = label;
	
	ftk_widget_set_text(win, "label demo");
	ftk_widget_show_all(win, 1);

	ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
	ftk_main_loop_add_source(ftk_default_main_loop(), timer);

	FTK_RUN();

	return 0;
}
Ejemplo n.º 12
0
static Ret  ftk_input_method_hw_handle_event(FtkInputMethod* thiz, FtkEvent* event)
{
	Ret ret = RET_OK;
	DECL_PRIV(thiz, priv);
	return_val_if_fail(priv != NULL && event != NULL, RET_FAIL);
	
	switch(event->type)
	{
		case FTK_EVT_MOUSE_DOWN:
		{
			if(priv->hand_write_state == FTK_HW_NONE)
			{
				priv->hand_write_state = FTK_HW_FIRST;
				ftk_stroke_painter_begin(priv->painter);
			}
			else if(priv->hand_write_state == FTK_HW_FIRST)
			{
				priv->hand_write_state = FTK_HW_WRITING;
			}

			priv->pen_down = 1;
			priv->points_nr = 0;
			
			ftk_source_disable(priv->commit_timer);
			ftk_main_loop_remove_source(ftk_default_main_loop(), priv->commit_timer);
			ret = ftk_input_method_hw_add_point(thiz, event->u.mouse.x, event->u.mouse.y);

			if(priv->hand_write_state == FTK_HW_FIRST)
			{
				ftk_source_timer_reset(priv->click_timer);
				ftk_main_loop_remove_source(ftk_default_main_loop(), priv->click_timer);
				if(ftk_main_loop_add_source(ftk_default_main_loop(), priv->click_timer) == RET_OK)
				{
					ftk_source_ref(priv->click_timer);
				}
			}

			ftk_logd("FTK_EVT_MOUSE_DOWN: %d\n", priv->points_nr);
			break;
		}
		case FTK_EVT_MOUSE_MOVE:
		{
			if(priv->pen_down && priv->hand_write_state != FTK_HW_NONE)
			{
				ret = ftk_input_method_hw_add_point(thiz, event->u.mouse.x, event->u.mouse.y);
			}

			break;
		}
		case FTK_EVT_MOUSE_UP:
		{
			priv->pen_down = 0;
			if(priv->hand_write_state != FTK_HW_NONE)
			{
				ret = ftk_input_method_hw_add_point(thiz, event->u.mouse.x, event->u.mouse.y);

				ftk_source_enable(priv->commit_timer);
				ftk_source_timer_reset(priv->commit_timer);
				if(ftk_main_loop_add_source(ftk_default_main_loop(), priv->commit_timer) == RET_OK)
				{
					ftk_source_ref(priv->commit_timer);
				}
	
				if(priv->points_nr < 5)
				{
					ret = RET_OK;
					break;
				}
				else
				{
					ftk_hand_write_engine_add_stroke(priv->engine, priv->points, priv->points_nr);
				}
			}
			ftk_logd("FTK_EVT_MOUSE_UP: %d\n", priv->points_nr);

			break;
		}
		case FTK_EVT_IM_ACT_COMMIT:
		{
			ftk_input_method_hw_end(thiz);
			ftk_input_method_hw_reset(thiz);

			break;
		}
		default:break;
	}

	return ret;
}