Open Japaxa2011gr opened 2 years ago
Where's your code?
I add this <signal name="clicked" handler="hello"></signal>
to the xml file and then I add the file to the builder. The builder automatically finds the function in the main code.
The builder automatically finds the function in the main code.
Is your code supposed to do this? There's no way the C library can dig for unexported Go functions to magically be called.
Where's your Go code?
This is how i do it in c I declare the function i want to use for the signal
G_MODULE_EXPORT void
hello(GtkWidget* widget, gpointer user_data)
{
g_print("hello");
}
static void
activate (GtkApplication *app, gpointer user_data)
{
GdkDisplay* display = gdk_display_get_default();
GtkCssProvider *provider = gtk_css_provider_new();
gtk_style_context_add_provider_for_display(display,GTK_STYLE_PROVIDER(provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
const gchar *css_file = "theme.css";
gtk_css_provider_load_from_file(provider,g_file_new_for_path(css_file));
GtkBuilder* builder = gtk_builder_new_from_file("grid.ui");
GObject* grid = gtk_builder_get_object( builder, "grid_main");
gtk_window_set_child(window,grid);
gtk_window_set_application (GTK_WINDOW (window), app);
gtk_widget_show (GTK_WIDGET (window));
}
and the builder connects it with the above function with just using <signal name="clicked" handler="hello"></signal>
in the xml file.
As I said above:
There's no way the C library can dig for unexported Go functions to magically be called.
I cant connect GtkBuilder signal handlers( ) to functions in main code. In plain c I was compiling with gmodule-export-2.0 and there was no problem.