32 const gchar *full_filename,
const gchar *filename);
45 return g_module_supported();
72 new->init_proc = NULL;
74 new->quit_proc = NULL;
92 if (plugin->
handle != NULL)
94 g_module_close(plugin->
handle);
97 if (plugin->
info != NULL)
105 g_free(plugin->
info);
108 if (plugin->
filter != NULL)
114 g_free(plugin->
path);
116 g_free(plugin->
error);
117 g_free(plugin->
extra);
136 const gchar *full_filename,
const gchar *filename)
141 plugin->
handle = g_module_open(full_filename, G_MODULE_BIND_MASK);
143 if (plugin->
handle == NULL)
145 log_message(main_struct, G_LOG_LEVEL_WARNING, Q_(
"Could not open plugin %s - %s"), filename, g_module_error());
163 gboolean get_symbol = FALSE;
165 if (plugin != NULL && plugin->
handle != NULL)
169 if (get_symbol == FALSE)
171 log_message(main_struct, G_LOG_LEVEL_WARNING,
"%s", g_module_error());
203 plugin->
info->
id = plugins_nb;
205 log_message(main_struct, G_LOG_LEVEL_INFO, Q_(
"plugin %s loaded."), filename);
227 const gchar *full_filename = NULL;
229 gchar *ext = g_strdup_printf(
".%s", G_MODULE_SUFFIX);
231 full_filename = g_build_filename(PLUGINS_DIR, filename, NULL);
233 log_message(main_struct, G_LOG_LEVEL_DEBUG,
"full_filename = %s ; ext = %s ; filename = %s", full_filename, ext, filename);
236 if ( (g_file_test(full_filename, G_FILE_TEST_IS_DIR) == FALSE) &&
237 (strcmp(strrchr(filename,
'.'), ext) == 0)
241 plugin->
path = g_strdup_printf(
"%s", PLUGINS_DIR);
242 plugin->
filename = g_strdup_printf(
"%s", filename);
247 init_plugin(main_struct, plugin, filename, plugins_nb);
260 GDir *plugins_dir = NULL;
261 GError *error = NULL;
262 const gchar *filename = NULL;
263 unsigned int plugins_nb = 0;
268 plugins_dir = g_dir_open(PLUGINS_DIR, 0, &error);
270 if (plugins_dir == NULL)
272 log_message(main_struct, G_LOG_LEVEL_WARNING,
"%s", error->message);
277 while ((filename = g_dir_read_name(plugins_dir)) != NULL)
279 if (g_str_has_prefix(filename,
"libheraia") == FALSE)
284 g_dir_close(plugins_dir);
298 if (plugin != NULL && plugin->
info != NULL && plugin->
info->
name != NULL)
301 plugin->
cmi_entry = GTK_CHECK_MENU_ITEM(gtk_check_menu_item_new_with_label(plugin->
info->
name));
307 g_signal_connect(G_OBJECT(plugin->
cmi_entry),
"toggled", G_CALLBACK(plugin->
run_proc), main_struct);
310 gtk_widget_show(GTK_WIDGET(plugin->
cmi_entry));
325 GList *list = g_list_first(plugins_list);
327 gboolean stop = FALSE;
329 while (list != NULL && stop != TRUE)
332 if (plugin != NULL && plugin->
info != NULL)
334 if (strcmp(plugin->
info->
name, name) == 0)
358 gchar *filename = NULL;
360 filename = g_strdup_printf(
"%s.gtkbuilder", plugin->
info->
name);
366 if (plugin->
xml == NULL)
This is the main structure.
RefreshProc refresh_proc
Called when the cursor changes it's position.
void load_plugins(heraia_struct_t *main_struct)
looks at the plugins dir(s) and loads the needed plugins (all ;-) (one at a time !!) ...
gboolean load_plugin_xml(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
Loads the xml's definition file that describes the plugin (.gtkbuilder suffix) tries the paths found ...
void refresh_all_plugins(heraia_struct_t *main_struct)
To help the main program to send events to the plugins.
void log_message(heraia_struct_t *main_struct, GLogLevelFlags log_level, const char *format,...)
A function that helps logging a message a the specified level.
heraia_plugin_t * new_plugin(void)
Creates a new empty plugin it may be initialised by the plugin itself !
GtkBuilder * load_xml_file(GList *location_list, gchar *filename)
loads the GtkBuilder xml file ('filename') that describes an interface, tries all the paths defined i...
GtkBuilder * xml
Eventually the plugin's GtkBuilder XML interface.
static heraia_plugin_t * get_plugin_init_symbol(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
If the handle is ok, we want to have the heraia_plugin_init function (to call it) in order to init th...
InitProc init_proc
Called when the application initialy starts up.
plugin_info_t * info
The plugin information.
static void load_one_plugin(heraia_struct_t *main_struct, const gchar *filename, guint plugins_nb)
Here we manage to load one plugin at a time (and this is really enough !)
RunProc run_proc
Called to run an interface everytime the plugin is called.
xml_t * xmls
All the xmls used in the program, loaded at running time.
gboolean plugin_capable(void)
Says whether the system can handle plugins (or not)
heraia_plugin_t * find_plugin_by_name(GList *plugins_list, gchar *name)
Finds the desired plugin by its name and return the plugin structure or NULL.
GModule * handle
The module handle.
void * extra
Plugin-specific data.
heraia_plugin_t * heraia_plugin_init(heraia_plugin_t *plugin)
Initialisation plugin function called when the plugin is loaded (some sort of pre-init) ...
static void init_plugin(heraia_struct_t *main_struct, heraia_plugin_t *plugin, const gchar *filename, guint plugins_nb)
finalising initialisation : if everything went fine, the plugin is added to the plugin list and a men...
GtkBuilder * main
the main interface xml description
PluginState state
The state of the plugin.
Complete plugin structure.
GList * plugins_list
A list of plugins.
This file contains all the definitions and includes all other .h files.
Detailed information about a plugin.
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
char * error
last error message
static heraia_plugin_t * get_plugin_handle(heraia_struct_t *main_struct, heraia_plugin_t *plugin, const gchar *full_filename, const gchar *filename)
Here we try to get a handle for the Gmodule referenced by full_filename.
plugin_filter_t * filter
The plugin filter.
void free_plugin(heraia_plugin_t *plugin)
free an unused plugin use with caution
char * filename
Filename of the plugin.
char * path
The path to the plugin.
GtkCheckMenuItem * cmi_entry
The CheckMenuItem that may be created in the heraia interface.
GList * location_list
this is the location list where we store some paths
void add_entry_to_plugins_menu(heraia_struct_t *main_struct, heraia_plugin_t *plugin)
adds a menu entry to the plugin menu adds a signal handler when the menu is toggled ...