[shortcut] Add a tutorial for adding a widget.
authorKyuho Jo <kyuho.jo@samsung.com>
Tue, 28 Jul 2015 08:12:58 +0000 (17:12 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Tue, 28 Jul 2015 08:12:58 +0000 (17:12 +0900)
Change-Id: I7f99ea492157a00cbfbdabe8d0b53043cadcb6e4
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
org.tizen.tutorials/html/native/app_framework/shortcut_tutorial_n.htm

index 84aeaa4..359ff2e 100644 (file)
                <p class="toc-title">Content</p>
                <ul class="toc">
                        <li><a href="#add">Adding a Shortcut</a></li>
-               </ul>           
+               </ul>
+               <ul class="toc">
+                       <li><a href="#add_widget">Adding a Widget</a></li>
+               </ul>
                <p class="toc-title">Related Info</p>
                <ul class="toc">
                        <li><a href="../../../../org.tizen.guides/html/native/app/shortcut_n.htm">Shortcut Guide</a></li>
                <li><a href="#add">Adding a Shortcut</a>
                <p>Add a shortcut to the home screen.</p></li>
        </ul>
+       <ul>
+               <li><a href="#add_widget">Adding a Widget</a>
+               <p>Add a widget to the home screen.</p></li>
+       </ul>
 
  <h2 id="add" name="add">Adding a Shortcut</h2>
 
@@ -70,7 +77,6 @@
 <li><p>To add a shortcut, use the <span style="font-family: Courier New,Courier,monospace">shortcut_add_to_home()</span> function:</p>
 
 <pre class="prettyprint">shortcut_add_to_home(&quot;Music Player&quot;, LAUNCH_BY_APP, NULL, &quot;/path/to/icon&quot;, 1, result_cb, NULL);</pre>
-
 <p>To add a shortcut, you have to know the package name and set an icon for the application. The icon parameter can be set to <span style="font-family: Courier New,Courier,monospace">NULL</span> (as above) to add a default icon for the application.</p></li>
 
 <li><p>To track possible errors, define a callback function:</p>
 }
 </pre></li></ol>
 
+<h2 id="add_widget" name="add_widget">Adding a Widget</h2>
+<p>To add a Widget to the home screen from your application:</p>
+<ol>
+<li>
+<p>Before adding a widget on the home screen, a widget application must be prepared. Refer the <a href="widget_tutorial_n.htm">Widget application tutorial</a> and create a widget application</p>
+</li>
+<li><p>To add a widget, use the <span style="font-family: Courier New,Courier,monospace">shortcut_add_to_home_widget()</span> function:</p>
+
+<pre class="prettyprint">shortcut_add_to_home_widget(&quot;alter_name&quot;, WIDGET_SIZE_1x1, &quot;org.tizen.testwidget&quot;, &quot;/opt/media/Pictures/alter_icon.png&quot;, -1.0f, 0, result_cb, NULL);</pre>
+
+<p>To add a widget, you have to know the widget id and supported sizes.</p>
+<p>Alter name and icon will be shown when the widget is not available.</li>
+
+<li><p>To track possible errors, define a callback function:</p>
+<pre class="prettyprint">static int result_cb(int ret, void *data)
+{
+&nbsp;&nbsp;&nbsp;if (ret &lt; 0)
+&nbsp;&nbsp;&nbsp;{
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Error handling
+&nbsp;&nbsp;&nbsp;}
+&nbsp;&nbsp;&nbsp;else
+&nbsp;&nbsp;&nbsp;{
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// No error detected
+&nbsp;&nbsp;&nbsp;}
+}
+</pre></li></ol>
+
 <script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
 <script type="text/javascript" src="../../scripts/showhide.js"></script>