Sign up

Builder.connectSignals

Has anyone got any examples of using Builder.connectSignals I think I must be missing some compilation flags and/or function annotations. The comment in generated/gtkd/gtk/Builder.d isn't entirely helpful – but this may be my problem.

Re: Builder.connectSignals

(It seems I cannot edit posts once posted.)

I should have said I am on Debian Sid using SCons for building with the ldc2 compiler from Debian packages and the gtkd-3 library from Debian packages. The current output from executing is:

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'quit'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'refreshFontSize'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'refreshSampleText'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'familyListSingleClicked'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'familyListDoubleClicked'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'about'.  Did you compile with -rdynamic?

(gfontbrowser:15267): Gtk-WARNING **: Could not find signal handler 'quit'.  Did you compile with -rdynamic?

I have functions:

extern (C) void about(Event e, Widget w) {
	About.about();
}

extern (C) void quit() {
  exit(0);
}

extern (C) void refreshFontSize() {
  writeln("refreshFontSize");
}

extern (C) void refreshSampleText() {
  writeln("refreshSampleText");
}

extern (C) void familyListSingleClicked() {
  writeln("familyListSingleClicked");
}

extern (C) void familyListDoubleClicked() {
  writeln("familyListDoubleClicked");
}

which I had thought would be bound by the call:

builder.connectSignals(null);

Re: Builder.connectSignals

On 05-01-18 18:30, Russel Winder wrote:

Has anyone got any examples of using Builder.connectSignals I think I must be missing some compilation flags and/or function annotations. The comment in generated/gtkd/gtk/Builder.d isn't entirely helpful – but this may be my problem.

As far as i can tell gtk_builder_connect_signals passes null to
g_module_open to open the executable. Only that only works when the
gtk libraries are linked with the executable at compile time and not
when using dlopen to load the libraries.

Re: Builder.connectSignals

I'll try the current code with a static compile and see if that changes things.

C and C++ code work with dynamic linking, is this a GtkD restriction?

Re: Builder.connectSignals

On 10-01-18 12:08, Russel Winder wrote:

I'll try the current code with a static compile and see if that changes things.

C and C++ code work with dynamic linking, is this a GtkD restriction?

There is a difference between using dlopen to load the libraries at
runtime and linking with the dynamic gtk libraries at compile time.

GtkD does the first and that causes the problems with GModule and
connectSignals, the later should work correctly.

GtkD uses dlopen due to historic reasons, gir-to-d does support
generating both options and at some point we should switch the default
we use for GtkD.

Re: Builder.connectSignals

On 10-01-18 19:05, Mike Wey wrote:

There is a difference between using dlopen to load the libraries at
runtime and linking with the dynamic gtk libraries at compile time.

GtkD does the first and that causes the problems with GModule and
connectSignals, the later should work correctly.

GtkD uses dlopen due to historic reasons, gir-to-d does support
generating both options and at some point we should switch the default
we use for GtkD.

I've added a generate target to the make file so you can use: make <br>generate-compiletime to regenerate GtkD so it doesn't use dlopen.