Re: Callbacks when glade file is loaded using a dynamic library



On Thu, Apr 22, 2010 at 7:21 PM, dfg dfg <abxccd msn com> wrote:

Hi everyone,

Currently, I have built my main application using glade. This file is then loaded by a C application.

I then created another interface using Glade. When my main application loads, it loads a .so library which 
contains code for this subsection (kind of like a plugin).

The .so file loads in the second glade file and attaches it into the interface of the main application. 
This all works problem.

The problem I am facing now is that gtk_builder_connect_signals (builder, NULL); does not work.

For my .so file, i have 3 files:

  -libmyplugin.c
  -libmyplugincallbacks.h
  -libmyplugincallbacks.c


My code for the libmyplugin.c file looks like this:

  #include <stdlib.h>
  #include <gtk/gtk.h>
  #include "libmyplugincallbacks.h"

  #define GUI "libmyplugingui.ui"
  int startplugin(){
     extern *mainBuilder;
     GtkBuilder *subbuilder;

     //Do things like attach the glade file into the main glade file.
     gtk_builder_connect_signals (builder, NULL);

  }



My libmyplugincallbacks.h

  #include <gtk/gtk.h>

  void myfunc (GtkCellRenderer *cell, GtkCellEditable *editable, const gchar *path, gpointer data);



My libplugincallbacks.c

  #ifdef HAVE_CONFIG_H
  #  include <config.h>
  #endif

  #include "libmyplugincallbacks.h"
  #include <string.h>

  void myfunc(GtkCellRenderer *cell, GtkCellEditable *editable, const gchar *path, gpointer data){
    if (GTK_IS_ENTRY (editable))
      {
      //Do stuff
      }
  }



When I compile my program, the .so file compiles properly. However, when ever I run the program, it loads 
the .so file. Once GTK builder gets to the stage where it connects the signals, it will complain that 
"myfunc" cannot be found. I have double checked the name of the function in my glade file and it is spelt 
and entered correctly.

You generally need to export your symbols by linking the app with
--export-dynamic flag:

pkg-config --libs gmodule-2.0

Should do the right thing to make your symbols visible.

Cheers,
           -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]