File: weatherApp.js.page

package info (click to toggle)
gnome-devel-docs 40.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 79,188 kB
  • sloc: javascript: 2,514; xml: 2,407; ansic: 2,229; python: 1,854; makefile: 805; sh: 499; cpp: 131
file content (65 lines) | stat: -rw-r--r-- 4,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" type="guide" style="task" id="weatherApp.js" xml:lang="sv">
  <info>
  <title type="text">Väderprogram (Javascript)</title>
    <link type="guide" xref="js#examples"/>
    <revision version="0.1" date="2012-03-09" status="stub"/>

    <credit type="author copyright">
      <name>Susanna Huhtanen</name>
      <email its:translate="no">ihmis.suski@gmail.com</email>
      <years>2012</years>
    </credit>
    <credit type="editor">
      <name>Marta Maria Casetti</name>
      <email its:translate="no">mmcasetti@gmail.com</email>
      <years>2013</years>
    </credit>

    <desc>Hur du planerar ett program som använder asynkrona anrop. Asynkrona anrop kommer presenteras genom ett väderprogram.</desc>

  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Sebastian Rasmussen</mal:name>
      <mal:email>sebras@gmail.com</mal:email>
      <mal:years>2019</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Anders Jonsson</mal:name>
      <mal:email>anders.jonsson@norsjovallen.se</mal:email>
      <mal:years>2021</mal:years>
    </mal:credit>
  </info>

  <title>Väderprogram</title>
  <synopsis>
    <p>I denna guide kommer vi konstruera ett väderprogram som använder asynkrona anrop. Väderinformation i detta exempel hämtas från geonames.org och programmet använder <link href="http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code:_E">ICAO-koder </link> för att skicka din väderbegäran. För att skriva alla kodexemplen själv behöver du en redigerare att skriva kod i, Terminal samt GNOME 3 eller högre installerat på din dator. I denna guide kommer vi gå igenom följande delar:</p>

    <list>
      <item><p><link xref="#planningUi">Planera det grafiska användargränssnittet</link></p></item>
      <item><p><link xref="#asynchronous">Asynkrona anrop</link></p></item>
      <item><p><link xref="#main">Huvudprogramfilen</link></p></item>
      <item><p><link xref="#main">Det lokala biblioteket GeoNames</link></p></item>
      <item><p><link xref="#main">Autotools och ikoner</link></p></item>
    </list>
  </synopsis>

  <p>Efter att ha läst denna handledning bör du se detta på din skärm:</p>
  <media type="image" mime="image/png" src="media/weatherAppJs.png"/>

  <section id="planningUi">
    <title>Planera det grafiska användargränssnittet</title>
    <p>Att strukturera ett program för GNOME 3 betyder att du kommer använda <link href="http://developer.gnome.org/platform-overview/stable/gtk">GTK+</link>. Den viktigaste saken att komma ihåg är att huvudfönstret endast kommer acceptera en komponent. Du måste planera din struktur enligt detta (detta exempel använder Gtk.Grid). En användbar metod är att rita ut huvudfönstret och placera varje komponent som behövs i den rutan. Genom att titta på en bild på ditt framtida program är det lättare att säga vad relationerna mellan komponenter är. Exempelvis så placerar Gtk.Grid dina komponenter i relation till andra komponenter, så efter att den första komponenten är på plats kan placering av komponenter göras i förhållande till någon annan komponent i rutnätet.</p>
  </section>
  <section id="asynchronous">
    <title>Asynkrona anrop</title>
    <p> With many programming languages, all operations are run synchronously - you tell the program to do something, and it will wait until that action completes before proceeding. This is however bad for
    graphical user interfaces, as then the whole application will be frozen while the program waits for
    the operation. Going asynchronous (async) helps here. With async calls, your UI won't be blocked with any requests. Async calls make your application more flexible and better equipped to handle situations when calls take more time than expected or for some reason get jammed. Async calls can be used for example file system I/O and for slower calculations in the background.   </p>
    <p>    In this example we have to get data from geonames.org. While we do that we want the rest of our program to continue. If we wouldn't get any information from geonames.org for the lack of internet connection and this would be a synchronous application we would never  get to the point where our main_quit() is processed correctly and the application would have to killed from Terminal.  </p>
  </section>
  <section id="main">
    <title>Programmets olika delar</title>
  </section>
</page>