pidgin.next.minor: 97e3cbbb: Hide the PurpleRequestField struct. I f...
rlaager at pidgin.im
rlaager at pidgin.im
Tue Nov 18 00:40:22 EST 2008
-----------------------------------------------------------------
Revision: 97e3cbbb75e7334c6259ac1cc62f861b13c47a49
Ancestor: 47f11164916de26498f6ca991fdfaa9c8a190162
Author: rlaager at pidgin.im
Date: 2008-11-18T05:35:45
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/97e3cbbb75e7334c6259ac1cc62f861b13c47a49
Modified files:
ChangeLog.API finch/gntrequest.c libpurple/request.c
libpurple/request.h pidgin/gtkrequest.c
ChangeLog:
Hide the PurpleRequestField struct. I figured this one would be easy and
I really needed to see one get fully hidden.
-------------- next part --------------
============================================================
--- ChangeLog.API 35b5a6bb65c152fcc2be752b53e7d41d1099c951
+++ ChangeLog.API d0e2af7ff9f7e15b0d0344a0a9461e8e1e30b271
@@ -18,6 +18,9 @@ version 2.6.0 (??/??/????):
* PURPLE_CONTACT
* PURPLE_BUDDY
* PURPLE_CHAT
+ * purple_request_field_get_group
+ * purple_request_field_get_ui_data
+ * purple_request_field_set_ui_data
Deprecated:
* purple_buddy_get_local_alias
============================================================
--- finch/gntrequest.c 1284387951c9d16333313ce60bfb91e28cacf5e5
+++ finch/gntrequest.c 735ecb2f87753b8ae80dceeb7367cc7ccef1249e
@@ -313,26 +313,26 @@ request_fields_cb(GntWidget *button, Pur
PurpleRequestFieldType type = purple_request_field_get_type(field);
if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
{
- GntWidget *check = FINCH_GET_DATA(field);
+ GntWidget *check = purple_request_field_get_ui_data(field);
gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check));
purple_request_field_bool_set_value(field, value);
}
else if (type == PURPLE_REQUEST_FIELD_STRING)
{
- GntWidget *entry = FINCH_GET_DATA(field);
+ GntWidget *entry = purple_request_field_get_ui_data(field);
const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
purple_request_field_string_set_value(field, (text && *text) ? text : NULL);
}
else if (type == PURPLE_REQUEST_FIELD_INTEGER)
{
- GntWidget *entry = FINCH_GET_DATA(field);
+ GntWidget *entry = purple_request_field_get_ui_data(field);
const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
int value = (text && *text) ? atoi(text) : 0;
purple_request_field_int_set_value(field, value);
}
else if (type == PURPLE_REQUEST_FIELD_CHOICE)
{
- GntWidget *combo = FINCH_GET_DATA(field);
+ GntWidget *combo = purple_request_field_get_ui_data(field);
int id;
id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
purple_request_field_choice_set_value(field, id);
@@ -343,7 +343,7 @@ request_fields_cb(GntWidget *button, Pur
if (purple_request_field_list_get_multi_select(field))
{
GList *iter;
- GntWidget *tree = FINCH_GET_DATA(field);
+ GntWidget *tree = purple_request_field_get_ui_data(field);
iter = purple_request_field_list_get_items(field);
for (; iter; iter = iter->next)
@@ -356,7 +356,7 @@ request_fields_cb(GntWidget *button, Pur
}
else
{
- GntWidget *combo = FINCH_GET_DATA(field);
+ GntWidget *combo = purple_request_field_get_ui_data(field);
gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
list = g_list_append(list, data);
}
@@ -366,7 +366,7 @@ request_fields_cb(GntWidget *button, Pur
}
else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
{
- GntWidget *combo = FINCH_GET_DATA(field);
+ GntWidget *combo = purple_request_field_get_ui_data(field);
PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
purple_request_field_account_set_value(field, acc);
}
@@ -613,35 +613,36 @@ finch_request_fields(const char *title,
if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
{
- FINCH_SET_DATA(field, create_boolean_field(field));
+ purple_request_field_set_ui_data(field, create_boolean_field(field));
}
else if (type == PURPLE_REQUEST_FIELD_STRING)
{
- FINCH_SET_DATA(field, create_string_field(field, &screenname));
+ purple_request_field_set_ui_data(field, create_string_field(field, &screenname));
}
else if (type == PURPLE_REQUEST_FIELD_INTEGER)
{
- FINCH_SET_DATA(field, create_integer_field(field));
+ purple_request_field_set_ui_data(field, create_integer_field(field));
}
else if (type == PURPLE_REQUEST_FIELD_CHOICE)
{
- FINCH_SET_DATA(field, create_choice_field(field));
+ purple_request_field_set_ui_data(field, create_choice_field(field));
}
else if (type == PURPLE_REQUEST_FIELD_LIST)
{
- FINCH_SET_DATA(field, create_list_field(field));
+ purple_request_field_set_ui_data(field, create_list_field(field));
}
else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
{
- accountlist = FINCH_SET_DATA(field, create_account_field(field));
+ accountlist = create_account_field(field);
+ purple_request_field_set_ui_data(field, accountlist);
}
else
{
- FINCH_SET_DATA(field, gnt_label_new_with_format(_("Not implemented yet."),
- GNT_TEXT_FLAG_BOLD));
+ purple_request_field_set_ui_data(field, gnt_label_new_with_format(_("Not implemented yet."),
+ GNT_TEXT_FLAG_BOLD));
}
gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
- gnt_box_add_widget(GNT_BOX(hbox), GNT_WIDGET(FINCH_GET_DATA(field)));
+ gnt_box_add_widget(GNT_BOX(hbox), GNT_WIDGET(purple_request_field_get_ui_data(field)));
}
if (grlist->next)
gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
============================================================
--- libpurple/request.c e86343376dc7ccb6922a25824ebdf02897f82bde
+++ libpurple/request.c be6d3d2409bd595a6b13f0f0277f742d3334a550
@@ -23,6 +23,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
+#define _PURPLE_REQUEST_C_
+
#include "internal.h"
#include "notify.h"
@@ -137,6 +139,23 @@ purple_request_fields_is_field_required(
return purple_request_field_is_required(field);
}
+gpointer
+purple_request_field_get_ui_data(const PurpleRequestField *field)
+{
+ g_return_val_if_fail(field != NULL, NULL);
+
+ return field->ui_data;
+}
+
+void
+purple_request_field_set_ui_data(PurpleRequestField *field,
+ gpointer ui_data)
+{
+ g_return_if_fail(field != NULL);
+
+ field->ui_data = ui_data;
+}
+
gboolean
purple_request_fields_all_required_filled(const PurpleRequestFields *fields)
{
@@ -443,6 +462,14 @@ purple_request_field_get_type(const Purp
return field->type;
}
+PurpleRequestFieldGroup *
+purple_request_field_get_group(const PurpleRequestField *field)
+{
+ g_return_val_if_fail(field != NULL, NULL);
+
+ return field->group;
+}
+
const char *
purple_request_field_get_id(const PurpleRequestField *field)
{
============================================================
--- libpurple/request.h dba31fd34a54648e6140e75fe3f847f6d30f7d4b
+++ libpurple/request.h 67473fde8f962eccb12874d50fe747e304fbcbb8
@@ -30,6 +30,9 @@
#include <glib-object.h>
#include <glib.h>
+/** @copydoc _PurpleRequestField */
+typedef struct _PurpleRequestField PurpleRequestField;
+
#include "account.h"
#define PURPLE_DEFAULT_ACTION_NONE -1
@@ -93,10 +96,11 @@ typedef struct
} PurpleRequestFieldGroup;
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_REQUEST_C_)
/**
* A request field.
*/
-typedef struct
+struct _PurpleRequestField
{
PurpleRequestFieldType type;
PurpleRequestFieldGroup *group;
@@ -176,7 +180,8 @@ typedef struct
void *ui_data;
-} PurpleRequestField;
+};
+#endif
/**
* Request UI operations.
@@ -521,6 +526,16 @@ PurpleRequestFieldType purple_request_fi
PurpleRequestFieldType purple_request_field_get_type(const PurpleRequestField *field);
/**
+ * Returns the group for the field.
+ *
+ * @param field The field.
+ *
+ * @return The UI data.
+ * @since 2.6.0
+ */
+PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field);
+
+/**
* Returns the ID of a field.
*
* @param field The field.
@@ -565,6 +580,28 @@ gboolean purple_request_field_is_require
*/
gboolean purple_request_field_is_required(const PurpleRequestField *field);
+/**
+ * Returns the ui_data for a field.
+ *
+ * @param field The field.
+ *
+ * @return The UI data.
+ * @since 2.6.0
+ */
+gpointer purple_request_field_get_ui_data(const PurpleRequestField *field);
+
+/**
+ * Sets the ui_data for a field.
+ *
+ * @param field The field.
+ * @param ui_data The UI data.
+ *
+ * @return The UI data.
+ * @since 2.6.0
+ */
+void purple_request_field_set_ui_data(PurpleRequestField *field,
+ gpointer ui_data);
+
/*@}*/
/**************************************************************************/
============================================================
--- pidgin/gtkrequest.c 1042456ad81552b5eca35413c526a8136185cb9f
+++ pidgin/gtkrequest.c 69e8a89871f1ecceb28914f8087b269e4880beb6
@@ -680,15 +680,17 @@ req_entry_field_changed_cb(GtkWidget *en
static void
req_entry_field_changed_cb(GtkWidget *entry, PurpleRequestField *field)
{
+ PurpleRequestFieldGroup *group;
PidginRequestData *req_data;
const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
purple_request_field_string_set_value(field, (*text == '\0' ? NULL : text));
- req_data = (PidginRequestData *)field->group->fields_list->ui_data;
+ group = purple_request_field_get_group(field);
+ req_data = (PidginRequestData *)group->fields_list->ui_data;
gtk_widget_set_sensitive(req_data->ok_button,
- purple_request_fields_all_required_filled(field->group->fields_list));
+ purple_request_fields_all_required_filled(group->fields_list));
}
static void
@@ -709,7 +711,8 @@ setup_entry_field(GtkWidget *entry, Purp
if (purple_str_has_prefix(type_hint, "screenname"))
{
GtkWidget *optmenu = NULL;
- GList *fields = field->group->fields;
+ PurpleRequestFieldGroup *group = purple_request_field_get_group(field);
+ GList *fields = group->fields;
while (fields)
{
PurpleRequestField *fld = fields->data;
@@ -720,9 +723,11 @@ setup_entry_field(GtkWidget *entry, Purp
const char *type_hint = purple_request_field_get_type_hint(fld);
if (type_hint != NULL && strcmp(type_hint, "account") == 0)
{
- if (fld->ui_data == NULL)
- fld->ui_data = create_account_field(fld);
- optmenu = GTK_WIDGET(fld->ui_data);
+ optmenu = GTK_WIDGET(purple_request_field_get_ui_data(fld));
+ if (optmenu == NULL) {
+ optmenu = GTK_WIDGET(create_account_field(fld));
+ purple_request_field_set_ui_data(field, optmenu);
+ }
break;
}
}
@@ -1335,24 +1340,26 @@ pidgin_request_fields(const char *title,
gtk_widget_show(label);
}
- if (field->ui_data != NULL)
- widget = GTK_WIDGET(field->ui_data);
- else if (type == PURPLE_REQUEST_FIELD_STRING)
- widget = create_string_field(field);
- else if (type == PURPLE_REQUEST_FIELD_INTEGER)
- widget = create_int_field(field);
- else if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
- widget = create_bool_field(field);
- else if (type == PURPLE_REQUEST_FIELD_CHOICE)
- widget = create_choice_field(field);
- else if (type == PURPLE_REQUEST_FIELD_LIST)
- widget = create_list_field(field);
- else if (type == PURPLE_REQUEST_FIELD_IMAGE)
- widget = create_image_field(field);
- else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
- widget = create_account_field(field);
- else
- continue;
+ widget = GTK_WIDGET(purple_request_field_get_ui_data(field));
+ if (widget == NULL)
+ {
+ if (type == PURPLE_REQUEST_FIELD_STRING)
+ widget = create_string_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_INTEGER)
+ widget = create_int_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
+ widget = create_bool_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_CHOICE)
+ widget = create_choice_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_LIST)
+ widget = create_list_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_IMAGE)
+ widget = create_image_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
+ widget = create_account_field(field);
+ else
+ continue;
+ }
if (label)
gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
@@ -1397,7 +1404,7 @@ pidgin_request_fields(const char *title,
gtk_widget_show(widget);
- field->ui_data = widget;
+ purple_request_field_set_ui_data(field, widget);
}
}
}
More information about the Commits
mailing list