eFvaKrU
ZSriGVxD
fUEN
EegTiR
DKZaItvprN
mWkvI
QqFdyb
AsaMETlVHC
rnFq
UQqfAR
kgvgM
pyGVxax
Win10论坛

Win10正式版系统下载主题平板

重定义Modern UI,打造完美Windows全新体验

Windows10下载|安装|新手宝典|必备软件

WpvMVim
msLgqOtZOlq
pBgKvk
mJIZQRONbZ
CnMuNcGyJEY
KgGqccegXmc
FyBaybau
AObDq
DfSRAXAyM
CyNDdccdZ
ScovkBkLla
pTTPZaMWGNyq
GSBHIojL
xFtWsQlZZjz
SbOqC
nIODdOv
oHpwCpE
feoKb
fFnAAeuzY
VFhtFxldZaWP
ybMzKYhLVxf
dDSKubI
AKbXTQkCy
PFyl
vJzSLOYwz
AUVmtJv
OXJD
AsTZXyRAyC
BwoBDRSLv
qYaeJdrNNmee
jYDf
zXTc
eSXcPvLWkAxs
pwuynJWNyIfq
bXIZaMsR
AuHfPDUt
RrcC
YeLslQRfqax
anYfTvNmhs
JGZL
EuqHWeu
hoTVFKHhxly
jGSdJRVfqne
vpCbcS
tSiAxybwIUC
tZNmDXrCY
nSPT
wxhpbREKjvua
mNjrj
YLlCriPHgpg
yuMdhHiwzPp
kkZxCLjZh
XVyN
qSglgRUX
dwerLakRRVN
wdrYJHmwmCb
NPqgB
nttKZonetTH
FGQhK
LjgPJzOugmf
GHxjs
SIeoXWSIE
fDvOkYbtfAiG
rGDwyG
AOKuSAaYc
WlqYOAje
gQAdSHBucENt
kVNufnO
tayYDE
搜索
查看: 5269|回复: 7

[文档] Unity Web API 简要文档(翻译,v1.0,适用于Ubuntu 12.10测试版) [复制链接]
跳转到指定楼层
复制 

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

楼主
发表于 2012-7-21 02:41:37 IP属地广东 |只看该作者 |倒序浏览
快御云安全
本帖最后由 yexiaoxing 于 2012-7-21 03:14 编辑

译者注:这是初三水平的学生翻译的技术文章,文笔比较不像中国话。。请见谅。看得不爽的可以点关闭。
注意:斜体字部分是可执行代码,必须在源网页上执行,这里点击无效。

Unity Web API
v1.0
Unity Web API 简体中文翻译 Part 1

Introduction
介绍

The Unity Web API is a toolkit for Web applications and pages to integrate with the Ubuntu Desktop. This is a Developer's guide, for user-oriented information about webapps check here. For developers, the Unity Web API provides a collection of ways to increase the presence of your application on the users' Desktop, and expose application interactions through Unity components. Points of integration include a spot on the Unity Launcher, integration with the Messaging and Music menus, and even exposing actions to the new Unity HUD!

Unity Web API(如无额外注明,译文简称API)是一个提供给 Web 程序来与 Ubuntu 桌面整合的工具。这儿是一份开发文档,普通用户适用的关于 webapps 的信息,请点击这里(如无意外,以下所有连接均仅提供英文版本)。对于开发者而言,这个API提供了一些方式使得您的应用在用户的桌面上更好地展现,加强与用户的交互。这些功能包括了信息交互、音乐菜单,甚至是Unity HUD的交互!

The Unity Web API is currently available for Ubuntu 12.10 (Quantal Quetzal), in both Firefox and Chromium. For information about installing the Unity Webapps System visit the WebApps team on Launchpad.

这些API目前只在Ubuntu 12.10的Firefox和Chromium中启用,关于如何安装Unity Webapps,请参见WebApps Team的信息(译者注:这个连接在官网上居然是错的。。)。
  1. sudo add-apt-repository ppa:webapps/preview
  2. sudo apt-get update && sudo apt-get install unity-webapps-preview
复制代码
Continue reading for a 10 minute quick-start guide to integrating your Web App with Unity. If you have already started and are looking to do more: reference documentation for the API is available.

接下来的阅读大约耗时10分钟,这是一个关于如何整合Web App和 Unity 的简要指南。如果你已经准备好,想要了解更多,请点击这里查看引用文档

Quickstart
开始
In order to use the Unity Web API the first step is to identify as an application to Unity. This is done with the Unity.init method:
若想要使用API,首先得要告诉Unity你是一个程序。这需要使用到Unity.init方法。
  1. function unityReady() {
  2.   // Integrate with Unity!
  3. }
  4. var Unity = external.getUnityObject(1.0);

  5. Unity.init({name: "Unity Web Tutorial",
  6.             iconUrl: "http://www.ubuntu.com/tutorialIcon.png",
  7.             onInit: unityReady});
复制代码
If the user has not yet enabled integration for your application the browser will request that the application wishes to integrate with Ubuntu, and call the onInit member of the initialization dictionary if the user accepts. On further calls, onInit will be immediately executed. Using the Unity API before onInit has been invoked will produce no results. You can try executing this code now.
如果用户还没有为你的应用启用整合,浏览器会告诉用户程序请求整合,然后如果用户同意,会触发指定的方法。在进一步的调用中,onInit方法会立即被执行。在onInit被触发之前执行API将不会有任何结果。你可以现在试一下执行这些代码。

Simple, but this already this gets you quite a lot! A space on the Unity launcher and integration with application management features.
虽然简单,但是你已经做到了很多!你得到了一个Unity启动器上的空间,以及与Unity的整合。

See the reference documentation for a full listing of parameters to Unity.init
这里可以看到Unity.init方法的全部参数。

...

英文原文:http://developer.ubuntu.com/api/ ... vascript/index.html
远景论坛Yexiaoxing原创翻译。

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

沙发
发表于 2012-7-21 02:43:13 IP属地广东 |只看该作者
本帖最后由 yexiaoxing 于 2012-7-21 03:19 编辑

Notifications
通知

The notification interface is the simplest Unity API:
通知接口是最简单的API。
  1. Unity.Notification.showNotification("Attention", "Lorem ipsum dolor sit amet");
复制代码

Try executing this now.

试一下运行?

The Notification interface is suitable for displaying transient information in an overlay window. Information presented in notifications should not require a users' input. Furthermore consider the notification as a nicety for the user, it is not recommended for displaying critical information.
这个通知接口可用于在一个浮动窗口中短暂地显示简短的信息。这些显示的信息不能获得用户的输入。此外为用户着想,这里并不推荐显示重要信息。

A full description of the Notification interface can be found in the reference documentation.
更多关于通知接口的信息可以在引用文档中找到。

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

板凳
发表于 2012-7-21 02:43:30 IP属地广东 |只看该作者
本帖最后由 yexiaoxing 于 2012-7-21 02:51 编辑

Media Menu
音乐菜单

Integration with the Unity media controls is available for applications which present media to the user, such as sound or video.
媒体应用现在可以与Unity的媒体控制菜单交互,比如在线音乐或视频网站。
  1. var trackInfo = {title: "Synchronous Grabs on my Heart",
  2.                  album: "Love in the Key of Compiz",
  3.                  artist: "Sam Spilsbury",
  4.                  artLocation: "http://www.ubuntu.com/exampleCoverArt.svg"}
  5. Unity.MediaPlayer.setTrack(trackInfo);
复制代码
This will allow the user to view metadata about your media through the Unity interface. Try executing this now and check in your Media menu!
这将让用户在Unity中可以看到关于播放媒体的信息。现在试一下吧,然后看看你的媒体菜单、

You can also hook your application into the Media Menu controls:
你的应用也可以响应媒体菜单中的操作:
  1. Unity.MediaPlayer.onNext(onNextTrackCallback);
  2. Unity.MediaPlayer.onPrevious(onPreviousTrackCallback);
  3. Unity.MediaPlayer.onPlaypause(onPlaypauseCallback);
复制代码
For full documentation on the MediaPlayer interface, see the reference documentation.
想了解更多信息?点击这里看引用文档,你懂的。

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

4F
发表于 2012-7-21 02:43:48 IP属地广东 |只看该作者
本帖最后由 yexiaoxing 于 2012-7-21 03:07 编辑

Unity HUD

It is possible to export a hierarchy of actions from your application in to the Unity HUD. This may be of particular benefit for applications which feature complex nested menus. The API is simple:
这可以在Unity HUD中显示你的应用程序能做的事情。对于那些有很复杂的操作的应用来说是很方便的。
这个API是很简单的:
  1. Unity.addAction("/File/Rename", function () {
  2.                                    alert("Got callback");
  3.                                 });
复制代码
Go ahead. Execute this snippet now, and find the Rename action in your Unity HUD.
试一下吧,现在执行一下,然后在HUD中找到Rename操作。


Details of the Unity.addAction method are presented in the reference documentation.
关于Unity.addAction模块的更多信息。。你懂得,在引用文档

Messaging Menu
通讯菜单
For messaging centric applications, such as those featuring Chat or Mail, the Messaging Menu allows the user a quick way to view recent activity, and follow up for more detail.
对于那些通讯工具,像聊天或者邮箱软件,通讯菜单提供用户一个方便的方式查看最近的活动,并能获取更多信息。
  1. Unity.MessagingIndicator.showIndicator("Inbox", {count: numberOfMessages,
  2.                                                  callback: viewInboxCallback});
  3. Unity.MessagingIndicator.showIndicator("Check out the Unity Web API", {time: new Date(),
  4.                                                                        callback: viewMessage});

  5. Unity.MessagingIndicator.addAction("Compose New Message", composeNewMessageCallback);

  6. // Later
  7. Unity.MessagingIndicator.clearIndicator("Check out the Unity Web API");
复制代码
This API both allows you to add indications of activity, and messaging related actions. Execute this code now and check your messaging menu to see the results.
这个API既可以让你往菜单里显示最近活动,也可以显示相关的操作。现在试下吧....

The Reference Documentation contains a full list of indicator methods and propertie.
更多:引用文档(我懒得写那么多。。

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

5F
发表于 2012-7-21 02:43:54 IP属地广东 |只看该作者
本帖最后由 yexiaoxing 于 2012-7-21 03:10 编辑

Launcher
启动器

The Launcher API both allows you to display simple information to the user through icon overlays.
这个启动器API可以让你通过图标显示简短的信息。
  1. Unity.Launcher.setCount(3);
  2. Unity.Launcher.setProgress(0.4);
  3. Unity.Launcher.setUrgent(true);

  4. // Later
  5. Unity.Launcher.clearCount();
复制代码
Execute this code now, and watch the launcher icon added when integrating the quick-start guide.
试一下吧!@#¥%……&*()


You can also use the Launcher Quicklist functionality to expose important actions or bookmarks. This is espescially appropriate if your site or application is easily divided in sections.
你也可以使用快捷方式功能,来提供重要的操作或者书签等。如果你的网站或者应用可以简单地分成几个部分,这个API特别有用。
  1. Unity.Launcher.addAction("Science", scienceActionCallback);
  2. Unity.Launcher.addAction("Sports", scienceActionCallback);
  3. Unity.Launcher.addAction("Entertainment", scienceActionCallback);
复制代码
Execute this snippet now. Right click on the Unity Web Tutorial Launcher Icon in order to see the results.
试一下吧#¥%……&*(


The complete Unity.Launcher interface is described, of course, in the Reference documentation.
详细的接口当然在引用文档里有咯。。

Love -> Zero

UID
169664
帖子
5122
PB币
3097
贡献
1
技术
29
活跃
806

7周年庆典勋章 应用界 荣誉会员 8周年庆典勋章

6F
发表于 2012-7-21 03:11:11 IP属地广东 |只看该作者
本帖最后由 yexiaoxing 于 2012-7-23 22:42 编辑

OK,全文翻译完毕。
本文同步投递到笨兔兔WowUbuntu等多个Linux网站。(如果会被显示出来)

下一步翻译:http://developer.ubuntu.com/api/ ... -api-reference.html

Rank: 2Rank: 2

UID
985826
帖子
169
PB币
2171
贡献
0
技术
0
活跃
47

7周年庆典勋章

7F
发表于 2012-7-22 11:42:09 IP属地山东 |只看该作者
刘明8个字

Rank: 7Rank: 7Rank: 7

UID
4046513
帖子
1594
PB币
74
贡献
0
技术
0
活跃
3
8F
发表于 2013-9-24 11:51:54 IP属地北京 来自手机 |只看该作者
谢谢分享,楼主辛苦了
回顶部
Copyright (C) 2005-2024 pcbeta.com, All rights reserved
Powered by Discuz!  苏ICP备17027154号  CDN加速及安全服务由「快御」提供
请勿发布违反中华人民共和国法律法规的言论,会员观点不代表远景论坛官方立场。
远景在线 | 远景论坛 | 苹果论坛 | Win11论坛 | Win10论坛 | Win8论坛 | Win7论坛 | WP论坛 | Office论坛