changeset 22005:829d054f4f1a

Add a function to get a widget for a request field.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 06 Jan 2008 18:53:47 +0000
parents f9dcdc0e89a5
children 1278280fa0b6
files ChangeLog.API finch/gntrequest.c finch/gntrequest.h
diffstat 3 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sun Jan 06 18:52:15 2008 +0000
+++ b/ChangeLog.API	Sun Jan 06 18:53:47 2008 +0000
@@ -41,6 +41,9 @@
 		* PIDGIN_DIALOG
 
 	Finch:
+		* finch_request_field_get_widget to get the widget for a request
+		  field.
+
 		libgnt:
 		* Added gnt_tree_set_row_color to set the color for a row in a tree.
 		* Added gnt_style_get_string_list
--- a/finch/gntrequest.c	Sun Jan 06 18:52:15 2008 +0000
+++ b/finch/gntrequest.c	Sun Jan 06 18:53:47 2008 +0000
@@ -36,6 +36,7 @@
 
 #include "finch.h"
 #include "gntrequest.h"
+#include "debug.h"
 #include "util.h"
 
 typedef struct
@@ -824,3 +825,32 @@
 	}
 }
 
+GntWidget *finch_request_field_get_widget(PurpleRequestField *field)
+{
+	GntWidget *ret = NULL;
+	switch (purple_request_field_get_type(field)) {
+		case PURPLE_REQUEST_FIELD_BOOLEAN:
+			ret = create_boolean_field(field);
+			break;
+		case PURPLE_REQUEST_FIELD_STRING:
+			ret = create_string_field(field, NULL);
+			break;
+		case PURPLE_REQUEST_FIELD_INTEGER:
+			ret = create_integer_field(field);
+			break;
+		case PURPLE_REQUEST_FIELD_CHOICE:
+			ret = create_choice_field(field);
+			break;
+		case PURPLE_REQUEST_FIELD_LIST:
+			ret = create_list_field(field);
+			break;
+		case PURPLE_REQUEST_FIELD_ACCOUNT:
+			ret = create_account_field(field);
+			break;
+		default:
+			purple_debug_error("GntRequest", "Unimplemented request-field %d\n", purple_request_field_get_type(field));
+			break;
+	}
+	return ret;
+}
+
--- a/finch/gntrequest.h	Sun Jan 06 18:52:15 2008 +0000
+++ b/finch/gntrequest.h	Sun Jan 06 18:53:47 2008 +0000
@@ -27,6 +27,7 @@
 #define _GNT_REQUEST_H
 
 #include "request.h"
+#include "gnt.h"
 
 /**********************************************************************
  * @name GNT Request API
@@ -56,6 +57,15 @@
  */
 void finch_request_save_in_prefs(gpointer null, PurpleRequestFields *fields);
 
+/**
+ * Create a widget field for a request-field.
+ *
+ * @param field   The request field.
+ *
+ * @return A GntWidget for the request field.
+ * @since 2.4.0
+ */
+GntWidget *finch_request_field_get_widget(PurpleRequestField *field);
 /*@}*/
 
 #endif