diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 10:28:15 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 10:44:28 (GMT) |
commit | 333e68541e376a7b86703fad8e917f71c0f243d0 (patch) | |
tree | a658682ed01ba8dbb4d5ad0edab4999dd9e9ff54 /src/plugins | |
parent | 1e3fa9b79ebe55698e2aa7d5484baec7e8400a8f (diff) |
Extended the plugin API to include some panel events.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/pglist.h | 8 | ||||
-rw-r--r-- | src/plugins/plugin-def.h | 11 | ||||
-rw-r--r-- | src/plugins/plugin-int.h | 8 | ||||
-rw-r--r-- | src/plugins/plugin.c | 95 | ||||
-rw-r--r-- | src/plugins/plugin.h | 7 |
5 files changed, 129 insertions, 0 deletions
diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index fd8e30a..ccf854f 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -118,6 +118,14 @@ GPluginModule **get_all_plugins_for_action(PluginAction, size_t *); #define include_plugin_theme(d, r, c) \ process_all_plugins_for(PGA_GUI_THEME, g_plugin_module_include_theme, d, r, c) +/* DPS_RUNNING */ + +#define notify_panel_creation(i) \ + process_all_plugins_for(PGA_PANEL_CREATION, g_plugin_module_notify_panel_creation, i) + +#define notify_panel_docking(i, d) \ + process_all_plugins_for(PGA_PANEL_DOCKING, g_plugin_module_notify_panel_docking, i, d) + /* DPS_CONTENT */ #define handle_binary_content(a, c, i, s) \ diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index 5a2dc54..e99d7b1 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -79,6 +79,7 @@ typedef uint32_t plugin_action_t; /* DPC_GUI */ #define DPS_SETUP DEFINE_PLUGIN_SUB_CATEGORY(0) +#define DPS_RUNNING DEFINE_PLUGIN_SUB_CATEGORY(1) /* DPC_BINARY_PROCESSING */ @@ -133,6 +134,16 @@ typedef enum _PluginAction PGA_GUI_THEME = DPC_GUI | DPS_SETUP | DEFINE_PLUGIN_ACTION(0), /** + * DPC_GUI | DPS_RUNNING + */ + + /* Accrochage / décrochage de panneaux */ + PGA_PANEL_CREATION = DPC_GUI | DPS_RUNNING | DEFINE_PLUGIN_ACTION(0), + + /* Accrochage / décrochage de panneaux */ + PGA_PANEL_DOCKING = DPC_GUI | DPS_RUNNING | DEFINE_PLUGIN_ACTION(1), + + /** * DPC_BINARY_PROCESSING | DPS_CONTENT */ diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 129e155..9dd9173 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -60,6 +60,12 @@ typedef void (* pg_handle_loaded_fc) (const GPluginModule *, PluginAction, GLoad /* Complète une liste de resources pour thème. */ typedef void (* pg_include_theme_fc) (const GPluginModule *, PluginAction, gboolean, char ***, size_t *); +/* Rend compte de la création d'un panneau. */ +typedef void (* pg_notify_panel_fc) (const GPluginModule *, PluginAction, GPanelItem *); + +/* Rend compte d'un affichage ou d'un retrait de panneau. */ +typedef void (* pg_notify_docking_fc) (const GPluginModule *, PluginAction, GPanelItem *, bool); + /* Assure l'interprétation d'un format en différé. */ typedef bool (* pg_handle_format_analysis_fc) (const GPluginModule *, PluginAction, GKnownFormat *, wgroup_id_t, GtkStatusStack *); @@ -107,6 +113,8 @@ struct _GPluginModuleClass pg_get_modname_fc get_modname; /* Fourniture du nom brut */ pg_include_theme_fc include_theme; /* Extension d'un thème */ + pg_notify_panel_fc notify_panel; /* Création de panneau */ + pg_notify_docking_fc notify_docking; /* Affichage ou retrait */ pg_handle_content_fc handle_content; /* Explorations ou résolutions */ pg_handle_loaded_fc handle_loaded; /* Traitement de contenu chargé*/ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index df593ea..8b3654e 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -373,6 +373,28 @@ GPluginModule *g_plugin_module_new(const gchar *filename) break; + case DPS_RUNNING: + + switch (action) + { + case PGA_PANEL_CREATION: + valid = check_plugin_symbol(module, "chrysalide_plugin_on_panel_creation"); + break; + + case PGA_PANEL_DOCKING: + valid = check_plugin_symbol(module, "chrysalide_plugin_on_panel_docking"); + break; + + default: + log_variadic_message(LMT_WARNING, + _("Unknown action '0x%02x' in plugin '%s'..."), + interface->actions[i], filename); + break; + + } + + break; + default: log_variadic_message(LMT_WARNING, _("Unknown sub-category '0x%02x' in plugin '%s'..."), sub, filename); @@ -640,6 +662,28 @@ static void g_plugin_module_init_gclass(GPluginModuleClass *class, GModule *modu break; + case DPS_RUNNING: + + switch (action) + { + case PGA_PANEL_CREATION: + load_plugin_symbol(module, "chrysalide_plugin_on_panel_creation", + &class->notify_panel); + break; + + case PGA_PANEL_DOCKING: + load_plugin_symbol(module, "chrysalide_plugin_on_panel_docking", + &class->notify_docking); + break; + + default: + assert(false); + break; + + } + + break; + default: assert(false); break; @@ -1270,6 +1314,57 @@ void g_plugin_module_include_theme(const GPluginModule *plugin, PluginAction act /****************************************************************************** * * +* Paramètres : plugin = greffon à manipuler. * +* action = type d'action attendue. * +* item = nouveau panneau créé. * +* * +* Description : Rend compte de la création d'un panneau. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_plugin_module_notify_panel_creation(const GPluginModule *plugin, PluginAction action, GPanelItem *item) +{ + GPluginModuleClass *class; /* Classe de l'instance active */ + + class = G_PLUGIN_MODULE_GET_CLASS(plugin); + + class->notify_panel(plugin, action, item); + +} + + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à manipuler. * +* action = type d'action attendue. * +* item = panneau marqué par un changement d'affichage. * +* dock = indique une accroche et non un décrochage. * +* * +* Description : Rend compte d'un affichage ou d'un retrait de panneau. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_plugin_module_notify_panel_docking(const GPluginModule *plugin, PluginAction action, GPanelItem *item, bool dock) +{ + GPluginModuleClass *class; /* Classe de l'instance active */ + + class = G_PLUGIN_MODULE_GET_CLASS(plugin); + + class->notify_docking(plugin, action, item, dock); + +} + + +/****************************************************************************** +* * * Paramètres : plugin = greffon à manipuler. * * action = type d'action attendue. * * content = contenu binaire à traiter. * diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index f65d0eb..3e8d9c1 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -36,6 +36,7 @@ #include "../format/known.h" #include "../format/preload.h" #include "../gtkext/gtkstatusstack.h" +#include "../gui/panel.h" @@ -114,6 +115,12 @@ gpointer g_plugin_module_build_type_instance(GPluginModule *, PluginAction, GTyp /* Complète une liste de resources pour thème. */ void g_plugin_module_include_theme(const GPluginModule *, PluginAction, gboolean, char ***, size_t *); +/* Rend compte de la création d'un panneau. */ +void g_plugin_module_notify_panel_creation(const GPluginModule *, PluginAction, GPanelItem *); + +/* Rend compte d'un affichage ou d'un retrait de panneau. */ +void g_plugin_module_notify_panel_docking(const GPluginModule *, PluginAction, GPanelItem *, bool); + /* Procède à une opération liée à un contenu binaire. */ void g_plugin_module_handle_binary_content(const GPluginModule *, PluginAction, GBinContent *, wgroup_id_t, GtkStatusStack *); |