3
votes

I am using Glade to add a listbox to a window and then loading the GUI into Julia using Gtk.jl's GtkBuilder. When loading the listbox Julia considers it a GtkContainer widget rather than a listbox (listbox doesn't seem to exist in the Julia package's source code except for one or two comments). I've scoured the Gtk.jl source code and just can't find anything (or understand enough of what I'm looking at).

A few of the Listbox signals work, but the most important one ("row-activated") does not. I really need this signal to emit... Is this not implemented? Is there a bug? Am I doing something wrong? Do I just need to use the more complicated GtkTreeView?

The commented out lines of julia code are the signals that do not fire (that I also don't really care about). According to the Gtk docs the "activate" signal is for the GtkListboxRow, and it's the "row-activated" signal the user needs to use, but I can't get it to emit...

"listbox Example.glade":

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkWindow" id="win">
    <property name="can_focus">False</property>
    <child>
      <placeholder/>
    </child>
    <child>
      <object class="GtkListBox" id="lb">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label1</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label2</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label3</property>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>
using Gtk

app = GtkBuilder(filename = "listbox Example.glade")

win = app["win"]

lb = app["lb"]

showall(win)

# id1 = signal_connect(lb, "activate-cursor-row") do widget
#     println("activate-cursor-row")
# end

# id2 = signal_connect(lb, "move-cursor") do widget
#     println("move-cursor")
# end

id3 = signal_connect(lb, "row-activated") do widget
    println("row-activated")
end

id4 = signal_connect(lb, "row-selected") do widget
    println("row-selected")
end

id5 = signal_connect(lb, "select-all") do widget
    println("select-all")
end

id6 = signal_connect(lb, "selected-rows-changed") do widget
    println("selected-rows-change")
end

# id7 = signal_connect(lb, "toggle-cursor-row") do widget
#     println("toggle-cursor-row")
# end

id8 = signal_connect(lb, "unselect-all") do widget
    println("unselect-all")
end

# id9 = signal_connect(lb, "activate") do widget
#     println("activate")
# end
julia> typeof(lb)
Gtk.GtkContainerLeaf
1
It may be worth it to open an issue on the Gtk.jl github since I am not sure if the maintainers for that packager are on here. You can link them this question!logankilpatrick

1 Answers

2
votes

Each signal has his own set of arguments. For example, "selected-rows-changed" only has widget, while "row-activated" has widget and row.

https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBox-selected-rows-changed https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBox-row-activated

You should change:

id3 = signal_connect(lb, "row-activated") do widget
    println("row-activated")
end

to:

id3 = signal_connect(lb, "row-activated") do widget, row
    println("row-activated")
end