mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Show form fields after updating
This commit is contained in:
parent
6b575aa8fc
commit
f494faac99
@ -1858,15 +1858,15 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
case FIELD_TEXT_PRIVATE:
|
case FIELD_TEXT_PRIVATE:
|
||||||
case FIELD_JID_SINGLE:
|
case FIELD_JID_SINGLE:
|
||||||
form_set_value(current->form, tag, value);
|
form_set_value(current->form, tag, value);
|
||||||
ui_current_print_line("%s set to %s", tag, value);
|
ui_show_form_field(current, current->form, tag);
|
||||||
break;
|
break;
|
||||||
case FIELD_BOOLEAN:
|
case FIELD_BOOLEAN:
|
||||||
if (g_strcmp0(value, "on") == 0) {
|
if (g_strcmp0(value, "on") == 0) {
|
||||||
form_set_value(current->form, tag, "1");
|
form_set_value(current->form, tag, "1");
|
||||||
ui_current_print_line("%s set to %s", tag, value);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else if (g_strcmp0(value, "off") == 0) {
|
} else if (g_strcmp0(value, "off") == 0) {
|
||||||
form_set_value(current->form, tag, "0");
|
form_set_value(current->form, tag, "0");
|
||||||
ui_current_print_line("%s set to %s", tag, value);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Value %s not valid for boolean field: %s", value, tag);
|
ui_current_print_line("Value %s not valid for boolean field: %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -1875,7 +1875,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
valid = form_field_contains_option(current->form, tag, value);
|
valid = form_field_contains_option(current->form, tag, value);
|
||||||
if (valid == TRUE) {
|
if (valid == TRUE) {
|
||||||
form_set_value(current->form, tag, value);
|
form_set_value(current->form, tag, value);
|
||||||
ui_current_print_line("%s set to %s", tag, value);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Value %s not a valid option for field: %s", value, tag);
|
ui_current_print_line("Value %s not a valid option for field: %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -1916,7 +1916,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
added = form_add_unique_value(current->form, tag, value);
|
added = form_add_unique_value(current->form, tag, value);
|
||||||
if (added) {
|
if (added) {
|
||||||
ui_current_print_line("Added %s to %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Value %s already selected for %s", value, tag);
|
ui_current_print_line("Value %s already selected for %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -1926,12 +1926,12 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
break;
|
break;
|
||||||
case FIELD_TEXT_MULTI:
|
case FIELD_TEXT_MULTI:
|
||||||
form_add_value(current->form, tag, value);
|
form_add_value(current->form, tag, value);
|
||||||
ui_current_print_line("Added %s to %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
break;
|
break;
|
||||||
case FIELD_JID_MULTI:
|
case FIELD_JID_MULTI:
|
||||||
added = form_add_unique_value(current->form, tag, value);
|
added = form_add_unique_value(current->form, tag, value);
|
||||||
if (added) {
|
if (added) {
|
||||||
ui_current_print_line("Added %s to %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("JID %s already exists in %s", value, tag);
|
ui_current_print_line("JID %s already exists in %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -1972,7 +1972,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
if (valid == TRUE) {
|
if (valid == TRUE) {
|
||||||
removed = form_remove_value(current->form, tag, value);
|
removed = form_remove_value(current->form, tag, value);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
ui_current_print_line("Removed %s from %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Value %s is not currently set for %s", value, tag);
|
ui_current_print_line("Value %s is not currently set for %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -1998,7 +1998,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
|
|
||||||
removed = form_remove_text_multi_value(current->form, tag, index);
|
removed = form_remove_text_multi_value(current->form, tag, index);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
ui_current_print_line("Removed %s from %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Could not remove %s from %s", value, tag);
|
ui_current_print_line("Could not remove %s from %s", value, tag);
|
||||||
}
|
}
|
||||||
@ -2006,7 +2006,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
case FIELD_JID_MULTI:
|
case FIELD_JID_MULTI:
|
||||||
removed = form_remove_value(current->form, tag, value);
|
removed = form_remove_value(current->form, tag, value);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
ui_current_print_line("Removed %s from %s", value, tag);
|
ui_show_form_field(current, current->form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_current_print_line("Field %s does not contain %s", tag, value);
|
ui_current_print_line("Field %s does not contain %s", tag, value);
|
||||||
}
|
}
|
||||||
|
@ -2054,6 +2054,14 @@ TODO add command to get help for a field
|
|||||||
win_save_println(window, "");
|
win_save_println(window, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_show_form_field(ProfWin *window, DataForm *form, char *tag)
|
||||||
|
{
|
||||||
|
FormField *field = form_get_field_by_tag(form, tag);
|
||||||
|
_ui_handle_form_field(window, tag, field);
|
||||||
|
win_save_println(window, "");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_handle_room_configuration(const char * const room, DataForm *form)
|
_ui_handle_room_configuration(const char * const room, DataForm *form)
|
||||||
{
|
{
|
||||||
@ -2317,4 +2325,5 @@ ui_init_module(void)
|
|||||||
ui_handle_room_config_submit_result = _ui_handle_room_config_submit_result;
|
ui_handle_room_config_submit_result = _ui_handle_room_config_submit_result;
|
||||||
ui_win_has_unsaved_form = _ui_win_has_unsaved_form;
|
ui_win_has_unsaved_form = _ui_win_has_unsaved_form;
|
||||||
ui_show_form = _ui_show_form;
|
ui_show_form = _ui_show_form;
|
||||||
|
ui_show_form_field = _ui_show_form_field;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,7 @@ void (*ui_handle_room_join_error)(const char * const room, const char * const er
|
|||||||
void (*ui_handle_room_configuration)(const char * const room, DataForm *form);
|
void (*ui_handle_room_configuration)(const char * const room, DataForm *form);
|
||||||
void (*ui_handle_room_config_submit_result)(void);
|
void (*ui_handle_room_config_submit_result)(void);
|
||||||
void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form);
|
void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form);
|
||||||
|
void (*ui_show_form_field)(ProfWin *window, DataForm *form, char *tag);
|
||||||
|
|
||||||
// contact status functions
|
// contact status functions
|
||||||
void (*ui_status_room)(const char * const contact);
|
void (*ui_status_room)(const char * const contact);
|
||||||
|
@ -593,6 +593,23 @@ _form_field_contains_option(DataForm *form, const char * const tag, char *value)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FormField *
|
||||||
|
_form_get_field_by_tag(DataForm *form, const char * const tag)
|
||||||
|
{
|
||||||
|
char *var = g_hash_table_lookup(form->tag_to_var, tag);
|
||||||
|
if (var != NULL) {
|
||||||
|
GSList *curr = form->fields;
|
||||||
|
while (curr != NULL) {
|
||||||
|
FormField *field = curr->data;
|
||||||
|
if (g_strcmp0(field->var, var) == 0) {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
curr = g_slist_next(curr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
form_init_module(void)
|
form_init_module(void)
|
||||||
{
|
{
|
||||||
@ -607,4 +624,5 @@ form_init_module(void)
|
|||||||
form_field_contains_option = _form_field_contains_option;
|
form_field_contains_option = _form_field_contains_option;
|
||||||
form_tag_exists = _form_tag_exists;
|
form_tag_exists = _form_tag_exists;
|
||||||
form_get_value_count = _form_get_value_count;
|
form_get_value_count = _form_get_value_count;
|
||||||
|
form_get_field_by_tag = _form_get_field_by_tag;
|
||||||
}
|
}
|
||||||
|
@ -218,5 +218,6 @@ gboolean (*form_tag_exists)(DataForm *form, const char * const tag);
|
|||||||
form_field_type_t (*form_get_field_type)(DataForm *form, const char * const tag);
|
form_field_type_t (*form_get_field_type)(DataForm *form, const char * const tag);
|
||||||
gboolean (*form_field_contains_option)(DataForm *form, const char * const tag, char *value);
|
gboolean (*form_field_contains_option)(DataForm *form, const char * const tag, char *value);
|
||||||
int (*form_get_value_count)(DataForm *form, const char * const tag);
|
int (*form_get_value_count)(DataForm *form, const char * const tag);
|
||||||
|
FormField* (*form_get_field_by_tag)(DataForm *form, const char * const tag);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user