diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-10 01:24:33 -0600 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-10 01:24:33 -0600 |
commit | 2b47dafad6610554a321ff826bad6d83dce27cf9 (patch) | |
tree | 43f79f552ebc93a5e2b1559d05e54b56ec135f72 /finch | |
parent | 5714a480d0e39787a006e05395d5fddd8e6625a4 (diff) | |
download | pidgin-2b47dafad6610554a321ff826bad6d83dce27cf9.tar.gz |
Make PurpleRequestFieldBool into a GObject
This also does an `hg cp`, though with all the renaming of the parameter names, maybe that wasn't as useful for tracking the diff.
Note, I didn't bother re-indenting some of the blocks, because they'll all eventually be moved when everything is subclassed.
Testing Done:
Compiled and opened Request Fields from Demo protocol.
Reviewed at https://reviews.imfreedom.org/r/2332/
Diffstat (limited to 'finch')
-rw-r--r-- | finch/gntrequest.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/finch/gntrequest.c b/finch/gntrequest.c index 3a78eb690d..6e10f47427 100644 --- a/finch/gntrequest.c +++ b/finch/gntrequest.c @@ -293,12 +293,12 @@ request_fields_cb(GntWidget *button, PurpleRequestPage *page) { PurpleRequestFieldType type = purple_request_field_get_field_type(field); if (!purple_request_field_is_visible(field)) continue; - if (type == PURPLE_REQUEST_FIELD_BOOLEAN) - { + if(PURPLE_IS_REQUEST_FIELD_BOOL(field)) { GntWidget *check = g_object_get_data(G_OBJECT(field), "finch-ui-data"); gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check)); - purple_request_field_bool_set_value(field, value); + purple_request_field_bool_set_value(PURPLE_REQUEST_FIELD_BOOL(field), + value); } else if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { GntWidget *entry = g_object_get_data(G_OBJECT(field), "finch-ui-data"); @@ -416,10 +416,11 @@ update_selected_account(GntEntry *username, G_GNUC_UNUSED const char *start, static GntWidget* create_boolean_field(PurpleRequestField *field) { + PurpleRequestFieldBool *boolfield = PURPLE_REQUEST_FIELD_BOOL(field); const char *label = purple_request_field_get_label(field); GntWidget *check = gnt_check_box_new(label); gnt_check_box_set_checked(GNT_CHECK_BOX(check), - purple_request_field_bool_get_default_value(field)); + purple_request_field_bool_get_default_value(boolfield)); return check; } @@ -649,8 +650,7 @@ finch_request_fields(const char *title, const char *primary, hbox = gnt_hbox_new(TRUE); /* hrm */ gnt_box_add_widget(GNT_BOX(box), hbox); - if (type != PURPLE_REQUEST_FIELD_BOOLEAN && label) - { + if(!PURPLE_IS_REQUEST_FIELD_BOOL(field) && label) { GntWidget *l; if (purple_request_field_is_required(field)) l = gnt_label_new_with_format(label, GNT_TEXT_FLAG_UNDERLINE); @@ -660,7 +660,7 @@ finch_request_fields(const char *title, const char *primary, gnt_box_add_widget(GNT_BOX(hbox), l); } - if (type == PURPLE_REQUEST_FIELD_BOOLEAN) { + if(PURPLE_IS_REQUEST_FIELD_BOOL(field)) { widget = create_boolean_field(field); } else if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { widget = create_string_field(field, &username); @@ -873,7 +873,10 @@ finch_request_save_in_prefs(G_GNUC_UNUSED gpointer data, gpointer val = NULL; const char *id = purple_request_field_get_id(field); - if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { + if(PURPLE_IS_REQUEST_FIELD_BOOL(field)) { + PurpleRequestFieldBool *bfield = PURPLE_REQUEST_FIELD_BOOL(field); + val = GINT_TO_POINTER(purple_request_field_bool_get_value(bfield)); + } else if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { PurpleRequestFieldString *sfield = PURPLE_REQUEST_FIELD_STRING(field); val = (gpointer)purple_request_field_string_get_value(sfield); } else { @@ -882,9 +885,6 @@ finch_request_save_in_prefs(G_GNUC_UNUSED gpointer data, val = purple_request_field_list_get_selected(field)->data; val = purple_request_field_list_get_data(field, val); break; - case PURPLE_REQUEST_FIELD_BOOLEAN: - val = GINT_TO_POINTER(purple_request_field_bool_get_value(field)); - break; case PURPLE_REQUEST_FIELD_INTEGER: val = GINT_TO_POINTER(purple_request_field_int_get_value(field)); break; @@ -922,15 +922,14 @@ finch_request_save_in_prefs(G_GNUC_UNUSED gpointer data, GntWidget *finch_request_field_get_widget(PurpleRequestField *field) { GntWidget *ret = NULL; - if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { + if(PURPLE_IS_REQUEST_FIELD_BOOL(field)) { + ret = create_boolean_field(field); + } else if(PURPLE_IS_REQUEST_FIELD_STRING(field)) { ret = create_string_field(field, NULL); } else if(PURPLE_IS_REQUEST_FIELD_ACCOUNT(field)) { ret = create_account_field(field); } else { switch (purple_request_field_get_field_type(field)) { - case PURPLE_REQUEST_FIELD_BOOLEAN: - ret = create_boolean_field(field); - break; case PURPLE_REQUEST_FIELD_INTEGER: ret = create_integer_field(field); break; |