File: dev-help-appmenu.page

package info (click to toggle)
gnome-devel-docs 40.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • 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 (88 lines) | stat: -rw-r--r-- 2,538 bytes parent folder | download | duplicates (2)
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
<page xmlns="http://projectmallard.org/1.0/"
      xmlns:its="http://www.w3.org/2005/11/its"
      type="topic" style="task"
      id="dev-help-appmenu">

  <info>
    <link type="seealso" xref="dev-help"/>
    <revision version="0.1" date="2013-06-19" status="review"/>

    <credit type="author copyright">
      <name>Radina Matic</name>
      <email its:translate="no">radina.matic@gmail.com</email>
      <years>2013</years>
    </credit>
    <credit type="editor">
      <name>Ekaterina Gerasimova</name>
      <email its:translate="no">kittykat3756@gmail.com</email>
      <years>2013</years>
    </credit>

    <include href="cc-by-sa-3-0.xml" xmlns="http://www.w3.org/2001/XInclude"/>

  </info>

  <title>Add <gui>Help</gui> to the application menu</title>

  <links type="series" style="floatend">
    <title>Set up help</title>
  </links>

  <p>Most GNOME applications should have an application menu. The
  <gui style="menuitem">Help</gui> menu item should go above the
  <gui style="menuitem">About</gui> menu item.</p>

  <example>
  <note>
    <p>This example, based on
    <app href="https://gitlab.gnome.org/GNOME/cheese/blob/master/src/cheese-main.vala">Cheese</app>,
    assumes that your application is written in Vala. It will be slightly
    different for other programming languages.</p>
  </note>

  <p>Add the <gui style="menuitem">Help</gui> item to the list of actions:</p>
  <code>
   private const GLib.ActionEntry action_entries[] = {
        <input>{ "help", on_help },</input>
        { "about", on_about },
        { "quit", on_quit }
    };

   add_action_entries (action_entries, my_Gtk_Application);
</code>

  <p>Add the <gui style="menuitem">Help</gui> menu item to the application
  menu:</p>

<code>
  var menu = new GLib.Menu ();
  var section = new GLib.Menu ();

  <input>var item = new GLib.MenuItem (_("_Help"), "app.help");
  item.set_attribute ("accel", "s", "F1");
  section.append_item (item);</input>
</code>

  <p>View the help with <app>Yelp</app> when the
  <gui style="menuitem">Help</gui> menu item is clicked:</p>

<code>
  private void on_help ()
  {
    var screen = main_window.get_screen ();
    try
    {
      Gtk.show_uri (screen, <input>"help:cheese"</input>, Gtk.get_current_event_time ());
    }
    catch (Error err)
    {
      message ("Error opening help: %s", err.message);
    }
  }
</code>

  <p>To link to a section on the <file>index.page</file>, use
  <code>"help:<input>applicationname</input>/index#<input>sectionid</input>"</code>.</p>

  </example>
</page>