-
-
Notifications
You must be signed in to change notification settings - Fork 197
book: Use adw::ShortcutDialog
#2193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <gresources> | ||
| <gresource prefix="/org/gtk_rs/Todo6/"> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="shortcuts-dialog.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks">window.ui</file> | ||
| </gresource> | ||
| </gresources> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <interface> | ||
| <object class="GtkShortcutsWindow" id="help_overlay"> | ||
| <property name="modal">True</property> | ||
| <object class="AdwShortcutsDialog" id="shortcuts_dialog"> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Mention the changed id in the book |
||
| <child> | ||
| <object class="GtkShortcutsSection"> | ||
| <property name="section-name">shortcuts</property> | ||
| <property name="max-height">10</property> | ||
| <object class="AdwShortcutsSection"> | ||
| <property name="title" translatable="yes">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsGroup"> | ||
| <property name="title" translatable="yes" context="shortcut window">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Show shortcuts</property> | ||
| <property name="action-name">win.show-help-overlay</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Show shortcuts</property> | ||
| <property name="action-name">app.shortcuts</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </interface> | ||
| </interface> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |
| </item> | ||
| <item> | ||
| <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute> | ||
| <attribute name="action">win.show-help-overlay</attribute> | ||
| <attribute name="action">app.shortcuts</attribute> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Mention that change in the book |
||
| </item> | ||
| </menu> | ||
| <template class="TodoWindow" parent="GtkApplicationWindow"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <gresources> | ||
| <gresource prefix="/org/gtk_rs/Todo7/"> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="shortcuts-dialog.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks">window.ui</file> | ||
| </gresource> | ||
| </gresources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <interface> | ||
| <object class="GtkShortcutsWindow" id="help_overlay"> | ||
| <property name="modal">True</property> | ||
| <object class="AdwShortcutsDialog" id="shortcuts_dialog"> | ||
| <child> | ||
| <object class="GtkShortcutsSection"> | ||
| <property name="section-name">shortcuts</property> | ||
| <property name="max-height">10</property> | ||
| <object class="AdwShortcutsSection"> | ||
| <property name="title" translatable="yes">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsGroup"> | ||
| <property name="title" translatable="yes" context="shortcut window">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Show shortcuts</property> | ||
| <property name="action-name">win.show-help-overlay</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Show shortcuts</property> | ||
| <property name="action-name">app.shortcuts</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </interface> | ||
| </interface> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <gresources> | ||
| <gresource prefix="/org/gtk_rs/Todo8/"> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks" alias="shortcuts-dialog.ui">shortcuts.ui</file> | ||
| <file compressed="true" preprocess="xml-stripblanks">window.ui</file> | ||
| </gresource> | ||
| </gresources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <interface> | ||
| <object class="GtkShortcutsWindow" id="help_overlay"> | ||
| <property name="modal">True</property> | ||
| <object class="AdwShortcutsDialog" id="shortcuts_dialog"> | ||
| <child> | ||
| <object class="GtkShortcutsSection"> | ||
| <property name="section-name">shortcuts</property> | ||
| <property name="max-height">10</property> | ||
| <object class="AdwShortcutsSection"> | ||
| <property name="title" translatable="yes">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsGroup"> | ||
| <property name="title" translatable="yes" context="shortcut window">General</property> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Show shortcuts</property> | ||
| <property name="action-name">win.show-help-overlay</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="GtkShortcutsShortcut"> | ||
| <property name="title" translatable="yes" context="shortcut window">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Show shortcuts</property> | ||
| <property name="action-name">app.shortcuts</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show all tasks</property> | ||
| <property name="action-name">win.filter('All')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only open tasks</property> | ||
| <property name="action-name">win.filter('Open')</property> | ||
| </object> | ||
| </child> | ||
| <child> | ||
| <object class="AdwShortcutsItem"> | ||
| <property name="title" translatable="yes">Filter to show only completed tasks</property> | ||
| <property name="action-name">win.filter('Done')</property> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </child> | ||
| </object> | ||
| </interface> | ||
| </interface> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,3 +152,23 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/b | |
| This is how the boxed list style looks like in our app. | ||
|
|
||
| <div style="text-align:center"><img src="img/todo_6.png" alt="The To-Do app using libadwaita"/></div> | ||
|
|
||
| ## Shortcuts Dialog | ||
|
|
||
| Now that we are using Libadwaita, we should also update our keyboard shortcuts window to use [`adw::ShortcutsDialog`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ShortcutsDialog.html). | ||
| This widget is the Libadwaita equivalent of [`gtk::ShortcutsWindow`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.ShortcutsWindow.html) and provides better integration with the Adwaita style. | ||
|
|
||
| The main differences are: | ||
|
|
||
| - [`adw::ShortcutsDialog`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ShortcutsDialog.html) extends [`adw::Dialog`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.Dialog.html) rather than [`gtk::Window`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Window.html) | ||
| - It uses [`adw::ShortcutsSection`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ShortcutsSection.html) and [`adw::ShortcutsItem`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ShortcutsItem.html) instead of [`gtk::ShortcutsSection`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.ShortcutsSection.html), [`gtk::ShortcutsGroup`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.ShortcutsGroup.html), and [`gtk::ShortcutsShortcut`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.ShortcutsShortcut.html) | ||
| - The structure is simpler, with sections directly containing items | ||
|
Comment on lines
+158
to
+165
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify this and add diff of changed parts |
||
|
|
||
| Let us update our `shortcuts.ui` file: | ||
|
|
||
| Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/todo/6/resources/shortcuts.ui">listings/todo/6/resources/shortcuts.ui</a> | ||
|
|
||
| ```xml | ||
| {{#rustdoc_include ../listings/todo/6/resources/shortcuts.ui}} | ||
| ``` | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add screenshot |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Mention that change in the book