changeset 8285:d335cc7bca54

[gaim-migrate @ 9009] Added a type hint to GaimRequestField. This will be used for neat stuff I'm planning on. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 18 Feb 2004 02:39:47 +0000
parents 980b3bd976ae
children 89d9d004e3f3
files src/request.c src/request.h
diffstat 2 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/request.c	Tue Feb 17 20:08:45 2004 +0000
+++ b/src/request.c	Wed Feb 18 02:39:47 2004 +0000
@@ -273,6 +273,9 @@
 	if (field->label != NULL)
 		g_free(field->label);
 
+	if (field->type_hint != NULL)
+		g_free(field->type_hint);
+
 	if (field->type == GAIM_REQUEST_FIELD_STRING)
 	{
 		if (field->u.string.default_value != NULL)
@@ -329,6 +332,18 @@
 	field->visible = visible;
 }
 
+void
+gaim_request_field_set_type_hint(GaimRequestField *field,
+								 const char *type_hint)
+{
+	g_return_if_fail(field != NULL);
+
+	if (field->type_hint != NULL)
+		g_free(field->type_hint);
+
+	field->type_hint = (type_hint == NULL ? NULL : g_strdup(type_hint));
+}
+
 GaimRequestFieldType
 gaim_request_field_get_type(const GaimRequestField *field)
 {
@@ -361,6 +376,14 @@
 	return field->visible;
 }
 
+const char *
+gaim_request_field_get_type_hint(const GaimRequestField *field)
+{
+	g_return_val_if_fail(field != NULL, NULL);
+
+	return field->type_hint;
+}
+
 GaimRequestField *
 gaim_request_field_string_new(const char *id, const char *text,
 							  const char *default_value, gboolean multiline)
--- a/src/request.h	Tue Feb 17 20:08:45 2004 +0000
+++ b/src/request.h	Wed Feb 18 02:39:47 2004 +0000
@@ -65,6 +65,7 @@
 
 	char *id;
 	char *label;
+	char *type_hint;
 
 	gboolean visible;
 
@@ -364,12 +365,24 @@
 /**
  * Sets whether or not a field is visible.
  *
- * @param field  The field.
+ * @param field   The field.
  * @param visible TRUE if visible, or FALSE if not.
  */
 void gaim_request_field_set_visible(GaimRequestField *field, gboolean visible);
 
 /**
+ * Sets the type hint for the field.
+ *
+ * This is optionally used by the UIs to provide such features as
+ * auto-completion for type hints like "screenname."
+ *
+ * @param field     The field.
+ * @param type_hint The type hint.
+ */
+void gaim_request_field_set_type_hint(GaimRequestField *field,
+									  const char *type_hint);
+
+/**
  * Returns the type of a field.
  *
  * @param field The field.
@@ -405,6 +418,15 @@
  */
 gboolean gaim_request_field_is_visible(const GaimRequestField *field);
 
+/**
+ * Returns the field's type hint.
+ *
+ * @param field The field.
+ *
+ * @return The field's type hint.
+ */
+const char *gaim_request_field_get_type_hint(const GaimRequestField *field);
+
 /*@}*/
 
 /**************************************************************************/