-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-22T18:14:15","documenter_version":"1.7.0"}} | ||
{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-28T14:03:14","documenter_version":"1.7.0"}} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Menus · Gtk4.jl</title><meta name="title" content="Menus · Gtk4.jl"/><meta property="og:title" content="Menus · Gtk4.jl"/><meta property="twitter:title" content="Menus · Gtk4.jl"/><meta name="description" content="Documentation for Gtk4.jl."/><meta property="og:description" content="Documentation for Gtk4.jl."/><meta property="twitter:description" content="Documentation for Gtk4.jl."/><script data-outdated-warner src="../../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../search_index.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../../">Gtk4.jl</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../../">Home</a></li><li><span class="tocitem">Manual</span><ul><li><a class="tocitem" href="../gettingStarted/">Getting Started</a></li><li><a class="tocitem" href="../properties/">Properties</a></li><li><a class="tocitem" href="../methods/">Automatically generated methods</a></li><li><a class="tocitem" href="../layout/">Layout</a></li><li><a class="tocitem" href="../signals/">Signals and Callbacks</a></li><li><a class="tocitem" href="../builder/">Builder</a></li><li><a class="tocitem" href="../actions/">Actions</a></li><li><a class="tocitem" href="../buttons/">Buttons</a></li><li class="is-active"><a class="tocitem" href>Menus</a><ul class="internal"><li><a class="tocitem" href="#[GtkMenuButton](https://docs.gtk.org/gtk4/class.MenuButton.html)"><span>GtkMenuButton</span></a></li><li><a class="tocitem" href="#[GtkPopoverMenu](https://docs.gtk.org/gtk4/class.PopoverMenu.html)"><span>GtkPopoverMenu</span></a></li><li><a class="tocitem" href="#Widgets-with-context-menus"><span>Widgets with context menus</span></a></li></ul></li><li><a class="tocitem" href="../textwidgets/">Text Widgets</a></li><li><a class="tocitem" href="../display/">Display widgets</a></li><li><a class="tocitem" href="../combobox/">Dropdown widgets</a></li><li><a class="tocitem" href="../listtreeview/">List and Tree Widgets</a></li><li><a class="tocitem" href="../dialogs/">Dialogs</a></li><li><a class="tocitem" href="../keyevents/">Key Events</a></li><li><a class="tocitem" href="../canvas/">Drawing with Cairo</a></li></ul></li><li><span class="tocitem">Howto</span><ul><li><a class="tocitem" href="../../howto/nonreplusage/">Using Gtk4 outside the REPL</a></li><li><a class="tocitem" href="../../howto/async/">Asynchronous UI</a></li><li><a class="tocitem" href="../../howto/sysimage/">Gtk4 in a sysimage</a></li></ul></li><li><a class="tocitem" href="../../diff3to4/">Gtk.jl to Gtk4.jl</a></li><li><span class="tocitem">Reference</span><ul><li><a class="tocitem" href="../../doc/reference/">Gtk4 Reference</a></li><li><a class="tocitem" href="../../doc/GLib_reference/">GLib Reference</a></li><li><a class="tocitem" href="../../doc/Gtk4_types_reference/">Gtk4 Types</a></li><li><a class="tocitem" href="../../doc/GLib_types_reference/">GLib Types</a></li><li><a class="tocitem" href="../../doc/constants_reference/">Constants</a></li><li><a class="tocitem" href="../../doc/preferences/">Preference Settings</a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Manual</a></li><li class="is-active"><a href>Menus</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Menus</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/JuliaGtk/Gtk4.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/JuliaGtk/Gtk4.jl/blob/main/docs/src/manual/menus.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="Menus"><a class="docs-heading-anchor" href="#Menus">Menus</a><a id="Menus-1"></a><a class="docs-heading-anchor-permalink" href="#Menus" title="Permalink"></a></h1><p>A menu lets you organize lots of options or actions. In days of yore there was often an extensive menu bar at the top of an application window. Nowadays it's more common to see a button or two showing more limited menus when clicked.</p><p>Menus in GTK are defined using a <a href="https://docs.gtk.org/gio/class.MenuModel.html">menu model</a>. This and related classes are defined in the library libgio rather than libgtk. Thus in Gtk4.jl these objects are defined in the submodule Gtk4.GLib rather than Gtk4.</p><p>To define a menu with three simple items, each of which is associated with an action, one could use:</p><pre><code class="language-julia hljs">using Gtk4.GLib | ||
|
||
menu = GMenu() | ||
item1 = GMenuItem("Open...", "app.open") | ||
push!(menu,item1) | ||
item2 = GMenuItem("Save...", "app.save") | ||
push!(menu,item2) | ||
item3 = GMenuItem("Quit", "app.quit") | ||
push!(menu,item3)</code></pre><p>Alternatively one can define menus using GtkBuilder XML rather than Julia code. The above menu would be implemented in XML using:</p><pre><code class="language-julia hljs">using Gtk4, Gtk4.GLib | ||
|
||
const menuxml = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<interface> | ||
<menu id="my_menu"> | ||
<item> | ||
<attribute name="label">Open...</attribute> | ||
<attribute name="action">app.open</attribute> | ||
</item> | ||
<item> | ||
<attribute name="label">Save...</attribute> | ||
<attribute name="action">app.save</attribute> | ||
</item> | ||
<item> | ||
<attribute name="label">Quit</attribute> | ||
<attribute name="action">app.quit</attribute> | ||
</item> | ||
</menu> | ||
</interface> | ||
""" | ||
b = GtkBuilder(menuxml, -1) | ||
menu = b["my_menu"]::Gtk4.GLib.GMenuLeaf</code></pre><p><a href="../actions/#Actions">Actions</a> that are stateful are automatically shown in menus as toggle items. To organize items it's possible to define sections and submenus.</p><p>So far we have just discussed how to define menus. To actually show a menu we have to use one of a few widgets that are discussed below.</p><h2 id="[GtkMenuButton](https://docs.gtk.org/gtk4/class.MenuButton.html)"><a class="docs-heading-anchor" href="#[GtkMenuButton](https://docs.gtk.org/gtk4/class.MenuButton.html)"><a href="https://docs.gtk.org/gtk4/class.MenuButton.html">GtkMenuButton</a></a><a id="[GtkMenuButton](https://docs.gtk.org/gtk4/class.MenuButton.html)-1"></a><a class="docs-heading-anchor-permalink" href="#[GtkMenuButton](https://docs.gtk.org/gtk4/class.MenuButton.html)" title="Permalink"></a></h2><p>This button widget presents a menu when clicked. Often the icon used for this button is a "hamburger" (three horizontal lines, GTK icon name "open-menu-symbolic") or three dots (GTK icon name "view-more-symbolic").</p><p>The following code creates a menu button with the "hamburger" icon and sets its menu model:</p><pre><code class="language-julia hljs">b = GtkMenuButton(;icon_name="open-menu-symbolic") | ||
menu = create_menu() # method that outputs the menu model (like a GMenu) | ||
Gtk4.menu_model(b, menu)</code></pre><h2 id="[GtkPopoverMenu](https://docs.gtk.org/gtk4/class.PopoverMenu.html)"><a class="docs-heading-anchor" href="#[GtkPopoverMenu](https://docs.gtk.org/gtk4/class.PopoverMenu.html)"><a href="https://docs.gtk.org/gtk4/class.PopoverMenu.html">GtkPopoverMenu</a></a><a id="[GtkPopoverMenu](https://docs.gtk.org/gtk4/class.PopoverMenu.html)-1"></a><a class="docs-heading-anchor-permalink" href="#[GtkPopoverMenu](https://docs.gtk.org/gtk4/class.PopoverMenu.html)" title="Permalink"></a></h2><p>This widget can be used to create a context menu. An example can be found in ImageView.jl.</p><h2 id="Widgets-with-context-menus"><a class="docs-heading-anchor" href="#Widgets-with-context-menus">Widgets with context menus</a><a id="Widgets-with-context-menus-1"></a><a class="docs-heading-anchor-permalink" href="#Widgets-with-context-menus" title="Permalink"></a></h2><p>Some GTK widgets define their own context menus, for example <code>GtkLabel</code>, <code>GtkEntry</code>, and <code>GtkTextView</code>. To add options to these menus you can use their property <code>extra-menu</code>.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../buttons/">« Buttons</a><a class="docs-footer-nextpage" href="../textwidgets/">Text Widgets »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.7.0 on <span class="colophon-date" title="Saturday 28 September 2024 14:03">Saturday 28 September 2024</span>. Using Julia version 1.10.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |