From b084903dddf3d529781b5acd29f6623fef64f50f Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 12 Oct 2004 07:38:28 +0000 Subject: (untested, it compiles!). 2004-10-12 Not Zed * e-config.c (ech_check, ech_config_factory, emph_construct_menu): setup a "check" handler, page-check/validation callback. svn path=/trunk/; revision=27551 --- e-util/ChangeLog | 3 +++ e-util/e-config.c | 17 +++++++++++++++++ e-util/e-config.h | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index c2b0fd4a99..71e6c2c438 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,5 +1,8 @@ 2004-10-12 Not Zed + * e-config.c (ech_check, ech_config_factory, emph_construct_menu): + setup a "check" handler, page-check/validation callback. + * e-popup.c (e_popup_new): new method to create a targetless popup menu. diff --git a/e-util/e-config.c b/e-util/e-config.c index 25745c587c..b38b760f79 100644 --- a/e-util/e-config.c +++ b/e-util/e-config.c @@ -1196,6 +1196,19 @@ ech_abort(EConfig *ec, GSList *items, void *data) e_plugin_invoke(group->hook->hook.plugin, group->abort, ec->target); } +static gboolean +ech_check(EConfig *ec, const char *pageid, void *data) +{ + struct _EConfigHookGroup *group = data; + EConfigHookPageCheckData hdata; + + hdata.config = ec; + hdata.target = ec->target; + hdata.pageid = pageid?pageid:""; + + return GPOINTER_TO_INT(e_plugin_invoke(group->hook->hook.plugin, group->check, &hdata)); +} + static void ech_config_factory(EConfig *emp, void *data) { @@ -1208,6 +1221,9 @@ ech_config_factory(EConfig *emp, void *data) if (group->items) e_config_add_items(emp, group->items, ech_commit, ech_abort, NULL, group); + + if (group->check) + e_config_add_page_check(emp, NULL, ech_check, group); } static void @@ -1295,6 +1311,7 @@ emph_construct_menu(EPluginHook *eph, xmlNodePtr root) menu->target_type = map->id; menu->id = e_plugin_xml_prop(root, "id"); + menu->check = e_plugin_xml_prop(root, "check"); menu->commit = e_plugin_xml_prop(root, "commit"); menu->abort = e_plugin_xml_prop(root, "abort"); menu->hook = (EConfigHook *)eph; diff --git a/e-util/e-config.h b/e-util/e-config.h index ce119f1e56..96a6a7025a 100644 --- a/e-util/e-config.h +++ b/e-util/e-config.h @@ -272,6 +272,7 @@ typedef struct _EPluginHookTargetMap EConfigHookTargetMap; typedef struct _EPluginHookTargetKey EConfigHookTargetMask; typedef struct _EConfigHookItemFactoryData EConfigHookItemFactoryData; +typedef struct _EConfigHookPageCheckData EConfigHookPageCheckData; typedef void (*EConfigHookFunc)(struct _EPlugin *plugin, EConfigTarget *target); typedef void (*EConfigHookItemFactoryFunc)(struct _EPlugin *plugin, EConfigHookItemFactoryData *data); @@ -300,6 +301,21 @@ struct _EConfigHookItemFactoryData { struct _GtkWidget *old; }; +/** + * struct _EConfigHookPageCheckData - Check callback data. + * + * @config: + * @target: The current configuration target. This is also available + * on @config->target. + * @pageid: Name of page to validate, or "" means check all configuration. + * + **/ +struct _EConfigHookPageCheckData { + EConfig *config; + EConfigTarget *target; + const char *pageid; +}; + /** * struct _EConfigHookGroup - A group of configuration items. * @@ -308,6 +324,7 @@ struct _EConfigHookItemFactoryData { * @target_type: The target type expected by the items. This is * defined by implementing classes. * @items: A list of EConfigHookItem's for this group. + * @check: A validate page handler. * @commit: The name of the commit function for this group of items, or NULL * for instant-apply configuration windows. Its format is plugin-type defined. * @abort: Similar to the @commit function but for aborting or @@ -321,6 +338,7 @@ struct _EConfigHookGroup { char *id; /* target menu id for these config items */ int target_type; /* target type of this group */ GSList *items; /* items to add to group */ + char *check; /* validate handler, if set */ char *commit; /* commit handler, if set */ char *abort; /* abort handler, if set */ }; -- cgit