Gtk.ShortcutsWindow showing nothing but a search button (Gtk 3.24)

Hello,

In Vala, I’m loading a shortcuts.ui resource with a Gtk.Builder, then I fetch the Gtk.ShortcutsWindow by its identifier, set it transient to my Gtk.ApplicationWindow and call present() on it. The result is an empty window with a search button. When I type some letters, the filtered shortcuts do appear at last. I expected them to be all shown at startup and not only while i am typing some search query. What’s wrong ?

Here is the beginning of the shortcuts.ui:

<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <object class="GtkShortcutsWindow" id="shortcuts-window">
    <property name="title" translatable="yes">Keyboard shortcuts</property>
    <property name="modal">true</property>
    <child>
      <object class="GtkShortcutsSection" id="shortcuts-section">
        <property name="section-name">Shortcuts</property>
        <property name="max-height">12</property>
        <property name="visible">true</property>
        <child>
          <object class="GtkShortcutsGroup">
            <property name="title" translatable="yes">Tasks</property>
            <child>
              <object class="GtkShortcutsShortcut">
                <property name="accelerator">&lt;ctrl&gt;S</property>
                <property name="title" translatable="yes">Sort completed tasks</property>
              </object>
            </child>
            <child>
            ... and so on...

The relevant loading part is as follow:

            var builder = new Gtk.Builder ();
            builder.add_from_resource ("/bar/foo/shortcuts.ui");
            var window = builder.get_object ("shortcuts-window") as Gtk.ShortcutsWindow;
            window.set_transient_for (this);
            window.present ();

After some research on the web, I tested seveal tricks but they did not change anything to this. I’d be grateful for some help :'-) Oh by the way, I’m using Gtk 3.24.

In GTK3, widgets are not visible by default, so each of the widgets in your ui file needs to set the visible property (or you’d need to call window.show_all()).

That is no longer the case in GTK4.

Oh thank you @chrisaw! I tried window.show_all () but that was not enough, I don’t know why. I had to set all widget the visible property to true in the shortcuts.ui resource and this worked at last! Many thanks for your quick answer!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.