Ejemplo n.º 1
0
static int lua_ftk_question(lua_State* L)
{
	tolua_Error err = {0};
	int retv;
	const char* title;
	const char* text;
	const char** buttons;
	int param_ok = tolua_isstring(L, 1, 0, &err) && tolua_isstring(L, 2, 0, &err) && tolua_istable(L, 3, 0, &err);

	return_val_if_fail(param_ok, 0);

	title = tolua_tostring(L, 1, 0);
	text = tolua_tostring(L, 2, 0);
	buttons = tolua_tostrings(L, 3, 0);
	retv = ftk_question(title, text, buttons);
	tolua_pushnumber(L, (lua_Number)retv);
	free(buttons);

	return 1;
}
Ejemplo n.º 2
0
static Ret ftk_file_browser_on_remove(void* ctx, void* obj)
{
	int i = 0;
	int ret = 0;
	const char* buttons[3];
	FtkWidget* win = (FtkWidget*)ctx;
	FtkListItemInfo* info = NULL;
	PrivInfo* priv = (PrivInfo*)ftk_widget_user_data(win);
	char message[FTK_MAX_PATH + 30] = {0};
	buttons[0] = _("Yes");
	buttons[1] = _("No");
	buttons[2] = NULL;
		
	i = ftk_list_view_get_selected(priv->list_view);
	ftk_list_model_get_data(priv->model, i, (void**)&info);
	return_val_if_fail(info != NULL, RET_FAIL);
	
	if(strcmp(info->text, _("..")) == 0)
	{
		return RET_FAIL;
	}

	ftk_strs_cat(message, sizeof(message), _("Are you sure to remove:\n "), info->text, NULL);

	if((ret = ftk_question(_("Remove"), message, buttons)) == 1)
	{
		char path[FTK_MAX_PATH+1] = {0};
		ftk_strs_cat(path, FTK_MAX_PATH, priv->path, "/", info->text, NULL);
		if(ftk_fs_delete(path) == RET_OK)
		{
			ftk_list_model_remove(priv->model, i);
		}
		else
		{
			ftk_strs_cat(message, sizeof(message), _("Remove failed:\n"), info->text, NULL);
			ftk_tips(message);
		}
	}
	
	return RET_OK;
}
Ejemplo n.º 3
0
static Ret ftk_app_window_on_event(const char *file) {
    int ret;
    const char *buttons[3] = {
        "YES", "NO", NULL
    };
    const char *_buttons[2] = {
        "OK", NULL
    };

    if (1 == ftk_question("Firmware Update", "Firmware found in udisk. Update it?",  buttons)) {
        ret = FW_update(file);
        if (ret) {
            ftk_warning("Firmware Update", "Update Failed.", _buttons);
        } else {
            if (1 == ftk_infomation("Firmware Update", "Update succeeded.\nReboot to install. Reboot Now?", buttons)) {
                system("reboot");
                while (1);
            }
        }
    }
    return RET_REMOVE;
}