This file is indexed.

/usr/share/help/fr/gnome-devel-demos/radiobutton.js.page is in gnome-devel-docs 3.18.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="radiobutton.js" xml:lang="fr">
  <info>
  <title type="text">RadioButton (JavaScript)</title>
    <link type="guide" xref="beginner.js#buttons"/>
    <revision version="0.1" date="2012-06-15" status="draft"/>

    <credit type="author copyright">
      <name>Taryn Fox</name>
      <email its:translate="no">jewelfox@fursona.net</email>
      <years>2012</years>
    </credit>

    <desc>Un seul peut être sélectionné à la fois</desc>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Luc Rebert,</mal:name>
      <mal:email>traduc@rebert.name</mal:email>
      <mal:years>2011</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Alain Lojewski,</mal:name>
      <mal:email>allomervan@gmail.com</mal:email>
      <mal:years>2011-2012</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Luc Pionchon</mal:name>
      <mal:email>pionchon.luc@gmail.com</mal:email>
      <mal:years>2011</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Bruno Brouard</mal:name>
      <mal:email>annoa.b@gmail.com</mal:email>
      <mal:years>2011-12</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Luis Menina</mal:name>
      <mal:email>liberforce@freeside.fr</mal:email>
      <mal:years>2014</mal:years>
    </mal:credit>
  </info>

  <title>RadioButton</title>
  <media type="image" mime="image/png" src="media/radiobuttontravel.png"/>
  <p>Le terme « bouton de radio » provient de l'analogie avec les anciennes radios de nos vieux véhicules. Ils avaient des boutons poussoirs programmés et un seul pouvait resté enfoncé à la fois, transmettant une seule station. Si vous en enfonciez un autre, cela faisait sortir automatiquement le précédent. Ici, nos RadioButtons fonctionnent exactement de la même façon.</p>
  <p>Chaque bouton de radio nécessite une étiquette texte et un groupe. Un seul bouton d'un même groupe peut être sélectionné à la fois. Ne nommez pas chaque groupe ; définissez seulement les nouveaux boutons à l'intérieur d'un groupe qui existe déjà. Si vous créez un bouton en dehors d'un groupe existant, il générera automatiquement un nouveau groupe pour s'y loger.</p>
    <links type="section"/>

  <section id="imports">
    <title>Bibliothèques à importer</title>
    <code mime="application/javascript"><![CDATA[
#!/usr/bin/gjs

const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
]]></code>
    <p>Ce sont les bibliothèques que nous devons importer pour faire fonctionner cette application. N'oubliez pas que la ligne qui informe GNOME que nous allons utiliser Gjs doit toujours se trouver au début.</p>
    </section>

  <section id="applicationwindow">
    <title>Création de la fenêtre de l'application</title>
    <code mime="application/javascript"><![CDATA[
const RadioButtonExample = new Lang.Class({
    Name: 'RadioButton Example',

    // Create the application itself
    _init: function() {
        this.application = new Gtk.Application({
            application_id: 'org.example.jsradiobutton',
            flags: Gio.ApplicationFlags.FLAGS_NONE
        });

    // Connect 'activate' and 'startup' signals to the callback functions
    this.application.connect('activate', Lang.bind(this, this._onActivate));
    this.application.connect('startup', Lang.bind(this, this._onStartup));
    },

    // Callback function for 'activate' signal presents window when active
    _onActivate: function() {
        this._window.present();
    },

    // Callback function for 'startup' signal builds the UI
    _onStartup: function() {
        this._buildUI ();
    },
]]></code>
    <p>Tout le code de cet exemple est dans la classe RadioButtonExample. Le code ci-dessus crée un <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link> pour y mettre nos éléments graphiques et la fenêtre qui les contient.</p>
    <code mime="application/javascript"><![CDATA[
    // Build the application's UI
    _buildUI: function() {

        // Create the application window
        this._window = new Gtk.ApplicationWindow({
            application: this.application,
            window_position: Gtk.WindowPosition.CENTER,
            border_width: 20,
            title: "Travel Planning"});
]]></code>
    <p>La fonction _buildUI est l'endroit où nous mettons tout le code nécessaire à la création de l'interface utilisateur de l'application. La première étape consiste à créer une <link xref="GtkApplicationWindow.js">Gtk.ApplicationWindow</link> pour y mettre tous nos éléments graphiques.</p>
  </section>

  <section id="button">
    <title>Création des boutons de radio</title>
    <code mime="application/javascript"><![CDATA[
        // Create a label for the first group of buttons
        this._placeLabel = new Gtk.Label ({label: "Where would you like to travel to?"});
]]></code>

    <p>Utilisez une étiquette <link xref="label.js">Gtk.Label</link> pour définir chaque groupe de boutons de radio séparément. Vous pouvez mettre les boutons de radio de tous les différents groupes où vous voulez, donc si vous voulez que l'on sache lesquels vont ensemble, vous devez organiser les choses en fonction.</p>

    <code mime="application/javascript"><![CDATA[
        // Create three radio buttons three different ways
        this._place1 = new Gtk.RadioButton ({label: "The Beach"});

        this._place2 = Gtk.RadioButton.new_from_widget (this._place1);
        this._place2.set_label ("The Moon");

        this._place3 = Gtk.RadioButton.new_with_label_from_widget (this._place1, "Antarctica");
        // this._place3.set_active (true);
]]></code>

    <p>Voici trois méthodes différentes pour créer des boutons de radio. La première est la méthode habituelle, où nous créons un nouveau Gtk.RadioButton et lui assignons ses propriétés en même temps. La seconde et la troisième utilisent des fonctions qui prennent en charge automatiquement quelques unes des propriétés ; new_from_widget ne prend qu'un argument : le nouveau bouton de radio que vous voulez mettre dans le même groupe, alors que new_with_label_from_widget prend ce même argument et l'étiquette qui va avec en même temps.</p>
    <p>Le premier bouton de radio d'un groupe est celui sélectionné par défaut. Décommentez la dernière ligne de cet exemple de code pour apprendre comment en définir un autre pour qu'il devienne celui sélectionné par défaut.</p>

    <code mime="application/javascript"><![CDATA[
        // Create a label for the second group of buttons
        this._thingLabel = new Gtk.Label ({label: "And what would you like to bring?" });

        // Create three more radio buttons
        this._thing1 = new Gtk.RadioButton ({label: "Penguins" });
        this._thing2 = new Gtk.RadioButton ({label: "Sunscreen", group: this._thing1 });
        this._thing3 = new Gtk.RadioButton ({label: "A spacesuit", group: this._thing1 });
]]></code>
    <p>Ici, nous créons l'étiquette du second groupe de boutons et ensuite nous les générons tous de la même manière.</p>
    </section>

    <section id="ui">
    <title>Création du reste de l'interface utilisateur</title>

    <code mime="application/javascript"><![CDATA[
        // Create a stock OK button
        this._okButton = new Gtk.Button ({
            label: 'gtk-ok',
            use_stock: 'true',
            halign: Gtk.Align.END });

        // Connect the button to the function which handles clicking it
        this._okButton.connect ('clicked', Lang.bind (this, this._okClicked));
]]></code>
    <p>Ce code crée un bouton <link xref="button.js">Gtk.Button</link> et le lie à une fonction qui affiche un message stupide si on clique sur OK, selon les boutons qui sont sélectionnés.</p>
    <p>To make sure the button's "OK" label shows up properly in every language that GNOME is translated into, remember to use one of Gtk's <link href="https://developer.gnome.org/gtk3/3.4/gtk3-Stock-Items.html">stock button types</link>.</p>

    <code mime="application/javascript"><![CDATA[
        // Create a grid to put the "place" items in
        this._places = new Gtk.Grid ();

        // Attach the "place" items to the grid
        this._places.attach (this._placeLabel, 0, 0, 1, 1);
        this._places.attach (this._place1, 0, 1, 1, 1);
        this._places.attach (this._place2, 0, 2, 1, 1);
        this._places.attach (this._place3, 0, 3, 1, 1);

        // Create a grid to put the "thing" items in
        this._things = new Gtk.Grid ({ margin_top: 50 });

        // Attach the "thing" items to the grid
        this._things.attach (this._thingLabel, 0, 0, 1, 1);
        this._things.attach (this._thing1, 0, 1, 1, 1);
        this._things.attach (this._thing2, 0, 2, 1, 1);
        this._things.attach (this._thing3, 0, 3, 1, 1);

        // Create a grid to put everything in
        this._grid = new Gtk.Grid ({
            halign: Gtk.Align.CENTER,
            valign: Gtk.Align.CENTER,
            margin_left: 40,
            margin_right: 50 });

        // Attach everything to the grid
        this._grid.attach (this._places, 0, 0, 1, 1);
        this._grid.attach (this._things, 0, 1, 1, 1);
        this._grid.attach (this._okButton, 0, 2, 1, 1);

        // Add the grid to the window
        this._window.add (this._grid);
]]></code>
    <p>Organisons chaque groupe de boutons de radio dans une grille <link xref="grid.js">Gtk.Grid</link> séparée. Comme cela, nous pouvons modifier l'agencement plus aisément plus tard. Mettons une marge en haut de la deuxième grille pour séparer visuellemnt les deux ensembles de choix.</p>
    <p>Après les avoir organisé, nous les mettons dans une troisième grille principale, avec le bouton OK. Puis, nous lions le tout à la fenêtre.</p>

    <code mime="application/javascript"><![CDATA[
        // Show the window and all child widgets
        this._window.show_all();
    },
]]></code>

    <p>Enfin, nous indiquons à la fenêtre de s'afficher avec son contenu au démarrage de l'application.</p>

  </section>

  <section id="function">
    <title>Fonction prenant en charge votre sélection</title>
    <code mime="application/javascript"><![CDATA[
    _okClicked: function () {

        // Create a popup that shows a silly message
        this._travel = new Gtk.MessageDialog ({
            transient_for: this._window,
            modal: true,
            message_type: Gtk.MessageType.OTHER,
            buttons: Gtk.ButtonsType.OK,
            text: this._messageText() });

        // Show the popup
        this._travel.show();

        // Bind the OK button to the function that closes the popup
        this._travel.connect ("response", Lang.bind (this, this._clearTravelPopUp));

    },
]]></code>
    <p>Quand vous cliquez sur OK, une boîte de dialogue <link xref="messagedialog.js">Gtk.MessageDialog</link> s'affiche. Cette fonction crée et affiche le message surgissant et ensuite connecte son bouton OK à une fonction qui le ferme. Le contenu du message surgissant dépend de la fonction _messageText(), qui renvoie une valeur différente selon les options que vous avez choisies.</p>

    <code mime="application/javascript"><![CDATA[
    _messageText: function() {

        // Create a silly message for the popup depending on what you selected
        var stringMessage = "";

        if (this._place1.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "Penguins love the beach, too!";

            else if (this._thing2.get_active())
                stringMessage = "Make sure to put on that sunscreen!";

            else stringMessage = "Are you going to the beach in space?";

        }

        else if (this._place2.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "The penguins will take over the moon!";

            else if (this._thing2.get_active())
                stringMessage = "A lack of sunscreen will be the least of your problems!";

            else stringMessage = "You'll probably want a spaceship, too!";
        }

        else if (this._place3.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "The penguins will be happy to be back home!";

            else if (this._thing2.get_active())
                stringMessage = "Antarctic sunbathing may be hazardous to your health!";

            else stringMessage = "Try bringing a parka instead!";
        }

        return stringMessage;

    },
]]></code>
    <p>La méthode get_active() permet de savoir quel bouton de radio a été pressé. Cette fonction renvoie un message stupide différent selon le bouton qui a été pressé. Sa valeur de retour est utilisée comme propriété du texte de la boîte de dialogue de message.</p>

    <code mime="application/javascript"><![CDATA[
    _clearTravelPopUp: function () {

        this._travel.destroy();

    }

});
]]></code>
    <p>Cette fonction est appelée quand le bouton OK du texte de la boîte de dialogue de message est pressé. Elle fait seulement disparaître le message surgissant.</p>

    <code mime="application/javascript"><![CDATA[
// Run the application
let app = new RadioButtonExample ();
app.application.run (ARGV);
]]></code>
    <p>Enfin, nous créons une nouvelle instance de la classe RadioButtonExample et lançons l'application.</p>
  </section>

  <section id="complete">
    <title>Exemple complet de code</title>
<code mime="application/javascript" style="numbered">#!/usr/bin/gjs

const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;

const RadioButtonExample = new Lang.Class({
    Name: 'RadioButton Example',

    // Create the application itself
    _init: function() {
        this.application = new Gtk.Application({
            application_id: 'org.example.jsradiobutton',
            flags: Gio.ApplicationFlags.FLAGS_NONE
        });

    // Connect 'activate' and 'startup' signals to the callback functions
    this.application.connect('activate', Lang.bind(this, this._onActivate));
    this.application.connect('startup', Lang.bind(this, this._onStartup));
    },

    // Callback function for 'activate' signal presents window when active
    _onActivate: function() {
        this._window.present();
    },

    // Callback function for 'startup' signal builds the UI
    _onStartup: function() {
        this._buildUI ();
    },



    // Build the application's UI
    _buildUI: function() {

        // Create the application window
        this._window = new Gtk.ApplicationWindow({
            application: this.application,
            window_position: Gtk.WindowPosition.CENTER,
            border_width: 20,
            title: "Travel Planning"});

        // Create a label for the first group of buttons
        this._placeLabel = new Gtk.Label ({label: "Where would you like to travel to?"});

        // Create three radio buttons three different ways
        this._place1 = new Gtk.RadioButton ({label: "The Beach"});

        this._place2 = Gtk.RadioButton.new_from_widget (this._place1);
        this._place2.set_label ("The Moon");

        this._place3 = Gtk.RadioButton.new_with_label_from_widget (this._place1, "Antarctica");
        // this._place3.set_active (true);

        // Create a label for the second group of buttons
        this._thingLabel = new Gtk.Label ({label: "And what would you like to bring?" });

        // Create three more radio buttons
        this._thing1 = new Gtk.RadioButton ({label: "Penguins" });
        this._thing2 = new Gtk.RadioButton ({label: "Sunscreen", group: this._thing1 });
        this._thing3 = new Gtk.RadioButton ({label: "A spacesuit", group: this._thing1 });

        // Create a stock OK button
        this._okButton = new Gtk.Button ({
            label: 'gtk-ok',
            use_stock: 'true',
            halign: Gtk.Align.END });

        // Connect the button to the function which handles clicking it
        this._okButton.connect ('clicked', Lang.bind (this, this._okClicked));

        // Create a grid to put the "place" items in
        this._places = new Gtk.Grid ();

        // Attach the "place" items to the grid
        this._places.attach (this._placeLabel, 0, 0, 1, 1);
        this._places.attach (this._place1, 0, 1, 1, 1);
        this._places.attach (this._place2, 0, 2, 1, 1);
        this._places.attach (this._place3, 0, 3, 1, 1);

        // Create a grid to put the "thing" items in
        this._things = new Gtk.Grid ({ margin_top: 50 });

        // Attach the "thing" items to the grid
        this._things.attach (this._thingLabel, 0, 0, 1, 1);
        this._things.attach (this._thing1, 0, 1, 1, 1);
        this._things.attach (this._thing2, 0, 2, 1, 1);
        this._things.attach (this._thing3, 0, 3, 1, 1);

        // Create a grid to put everything in
        this._grid = new Gtk.Grid ({
            halign: Gtk.Align.CENTER,
            valign: Gtk.Align.CENTER,
            margin_left: 40,
            margin_right: 50 });

        // Attach everything to the grid
        this._grid.attach (this._places, 0, 0, 1, 1);
        this._grid.attach (this._things, 0, 1, 1, 1);
        this._grid.attach (this._okButton, 0, 2, 1, 1);

        // Add the grid to the window
        this._window.add (this._grid);

        // Show the window and all child widgets
        this._window.show_all();
    },



    _okClicked: function () {

        // Create a popup that shows a silly message
        this._travel = new Gtk.MessageDialog ({
            transient_for: this._window,
            modal: true,
            message_type: Gtk.MessageType.OTHER,
            buttons: Gtk.ButtonsType.OK,
            text: this._messageText() });

        // Show the popup
        this._travel.show();

        // Bind the OK button to the function that closes the popup
        this._travel.connect ("response", Lang.bind (this, this._clearTravelPopUp));

    },



    _messageText: function() {

        // Create a silly message for the popup depending on what you selected
        var stringMessage = "";

        if (this._place1.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "Penguins love the beach, too!";

            else if (this._thing2.get_active())
                stringMessage = "Make sure to put on that sunscreen!";

            else stringMessage = "Are you going to the beach in space?";

        }

        else if (this._place2.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "The penguins will take over the moon!";

            else if (this._thing2.get_active())
                stringMessage = "A lack of sunscreen will be the least of your problems!";

            else stringMessage = "You'll probably want a spaceship, too!";
        }

        else if (this._place3.get_active()) {

            if (this._thing1.get_active())
                stringMessage = "The penguins will be happy to be back home!";

            else if (this._thing2.get_active())
                stringMessage = "Antarctic sunbathing may be hazardous to your health!";

            else stringMessage = "Try bringing a parka instead!";
        }

        return stringMessage;

    },




    _clearTravelPopUp: function () {

        this._travel.destroy();

    }

});

// Run the application
let app = new RadioButtonExample ();
app.application.run (ARGV);
</code>
  </section>

  <section id="in-depth">
    <title>Documentation approfondie</title>
<list>
  <item><p><link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link></p></item>
  <item><p><link href="http://developer.gnome.org/gtk3/stable/GtkApplicationWindow.html">Gtk.ApplicationWindow</link></p></item>
  <item><p><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Button.html">Gtk.Button</link></p></item>
  <item><p><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Grid.html">Gtk.Grid</link></p></item>
  <item><p><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Label.html">Gtk.Label</link></p></item>
  <item><p><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.RadioButton.html">Gtk.RadioButton</link></p></item>
</list>
  </section>
</page>