Closed jangernert closed 5 years ago
Gir think that ShortcutLabel
is final type so all functions defined in main impl.
If you think that it not right, try final_type=false
Also version need be 3.22
and actually autodetected without it normally
By "Final type" I meant that it can't have children. This class is sure final as its class have disguised="1"
<record name="ShortcutLabelClass" c:type="GtkShortcutLabelClass" disguised="1" glib:is-gtype-struct-for="ShortcutLabel">
<source-position filename="gtk/gtkshortcutlabel.h" line="35"/>
</record>
@EPashkin thank you for your help. I got the basic
example to compile with the modified gtk-rs
However, when adding the ShortcutLabel
to the window instead of the button I get the following warnings at runtime and no widget is added to the window:
(basic:2737): GLib-GObject-WARNING **: 23:23:04.823: instance with invalid (NULL) class pointer
(basic:2737): GLib-GObject-CRITICAL **: 23:23:04.823: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(basic:2737): GLib-GObject-CRITICAL **: 23:23:04.823: g_object_set_qdata: assertion 'G_IS_OBJECT (object)' failed
(basic:2737): GLib-GObject-WARNING **: 23:23:04.823: instance with invalid (NULL) class pointer
(basic:2737): GLib-GObject-CRITICAL **: 23:23:04.823: g_signal_handlers_destroy: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(basic:2737): GLib-GObject-WARNING **: 23:23:04.823: instance with invalid (NULL) class pointer
(basic:2737): GLib-GObject-CRITICAL **: 23:23:04.823: g_signal_handlers_destroy: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(basic:2737): GLib-GObject-CRITICAL **: 23:23:04.823: g_object_unref: assertion 'old_ref > 0' failed
The generated code is here. Am I still missing something?
The accelerator seems to be parsed correctly as I get an additional error message when entering an invalid string.
edit: Creating the ShotcutLabel
with a Builder
and a .ui
file works fine. I then can set the accelerator from code no problem. It's just the rust constructor that doesn't seem to be working.
Thanks for confirmation.
Generated code looks good for me, maybe error in usage (as Builder works fine).
Can you also check what line in your code produced warning (as I know nothing can go wrong in ShortcutLabel::new
)
This is the basic example with the ShortcutLabel
:
fn build_ui(application: >k::Application) {
let window = gtk::ApplicationWindow::new(application);
window.set_title("First GTK+ Program");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_default_size(350, 70);
let shortcut_label = gtk::ShortcutLabel::new("<ctrl>F");
window.add(&shortcut_label);
window.show_all();
}
The above mentioned warnings happen when adding the widget to the window. Not when constructing it.
When constructing the ShortcutLabel
and not using it I get a new runtime warning (even when adding back in the original button, so the window has a child widget):
Gtk-WARNING **: 09:56:20.279: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().
The problem is in the generated new
function. Should be from_glib_none
, not _full
. This is also memory unsafe as is now, it must be _none
:)
I guess there's a broken GI annotation that causes this.
Can you create a PR with the code? I guess for now we'd just implement new
manually and report that bug to gtk.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
@sdroege Good catch. IMHO this better fixed on gir-files side until bug fixed upstream, so I added PR
@EPashkin I can confirm the solution @sdroege proposed works fine. I prepared a branch with the generated code without a new()
function and a separate manually implemented new()
function.
Should I open a PR or wait till gtk-rs/gir-files#40 is merged?
IMHO simpler wait for right gir-files
Merged in gir-files so just update the submodule and regen.
I've been missing gtk-rs bindings for
ShortcutLabel
. I tried to whip up a PR adding them, but I didn't get it working. Is there a more detailed documentation to follow? What I did was adding a new object toGir.toml
:and call
make gir
.With that I ended up with
auto/shortcuts_label.rs
which definesShortcutLabel
but notShortcutLabelExt
. All methods are implemented as part ofShortcutLabel
.I managed to build the examples with the locally modified version of the gtk crate. But the
ShortcutLabel
type is not available publicly.Some of the widgets have some manual wrapper code in addition to the auto generated code. But
ShortcutsWindow
for example doesn't. So I'm not really sure how to proceed.Any help would be welcome.