aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/ChangeLog3
-rw-r--r--e-util/e-config.c17
-rw-r--r--e-util/e-config.h18
3 files changed, 38 insertions, 0 deletions
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 <NotZed@Ximian.com>
+ * 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);
@@ -301,6 +302,21 @@ struct _EConfigHookItemFactoryData {
};
/**
+ * 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.
*
* @hook: Parent object.
@@ -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 */
};