mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added form to WIN_MUC_CONFIG type
This commit is contained in:
parent
0ce924465f
commit
7b44ac97cc
@ -1666,8 +1666,8 @@ cmd_reset_autocomplete()
|
|||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC_CONFIG) {
|
if (ui_current_win_type() == WIN_MUC_CONFIG) {
|
||||||
ProfWin *window = wins_get_current();
|
ProfWin *window = wins_get_current();
|
||||||
if (window && window->form) {
|
if (window && window->wins.conf.form) {
|
||||||
form_reset_autocompleters(window->form);
|
form_reset_autocompleters(window->wins.conf.form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2455,10 +2455,14 @@ _resource_autocomplete(char *input, int *size)
|
|||||||
static char *
|
static char *
|
||||||
_form_autocomplete(char *input, int *size)
|
_form_autocomplete(char *input, int *size)
|
||||||
{
|
{
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
if (current->type != WIN_MUC_CONFIG) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
ProfWin *current = wins_get_current();
|
DataForm *form = current->wins.conf.form;
|
||||||
DataForm *form = current->form;
|
|
||||||
if (form) {
|
if (form) {
|
||||||
found = autocomplete_param_with_ac(input, size, "/form help", form->tag_ac, TRUE);
|
found = autocomplete_param_with_ac(input, size, "/form help", form->tag_ac, TRUE);
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
@ -2477,11 +2481,14 @@ _form_autocomplete(char *input, int *size)
|
|||||||
static char *
|
static char *
|
||||||
_form_field_autocomplete(char *input, int *size)
|
_form_field_autocomplete(char *input, int *size)
|
||||||
{
|
{
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
if (current->type != WIN_MUC_CONFIG) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
ProfWin *current = wins_get_current();
|
DataForm *form = current->wins.conf.form;
|
||||||
DataForm *form = current->form;
|
|
||||||
|
|
||||||
if (form == NULL) {
|
if (form == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1985,7 +1985,11 @@ gboolean
|
|||||||
cmd_form_field(char *tag, gchar **args)
|
cmd_form_field(char *tag, gchar **args)
|
||||||
{
|
{
|
||||||
ProfWin *current = wins_get_current();
|
ProfWin *current = wins_get_current();
|
||||||
DataForm *form = current->form;
|
if (current->type != WIN_MUC_CONFIG) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataForm *form = current->wins.conf.form;
|
||||||
if (form) {
|
if (form) {
|
||||||
if (!form_tag_exists(form, tag)) {
|
if (!form_tag_exists(form, tag)) {
|
||||||
ui_current_print_line("Form does not contain a field with tag %s", tag);
|
ui_current_print_line("Form does not contain a field with tag %s", tag);
|
||||||
@ -2177,10 +2181,10 @@ cmd_form_field(char *tag, gchar **args)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (g_strcmp0(args[0], "remove") == 0) {
|
if (g_strcmp0(args[0], "remove") == 0) {
|
||||||
removed = form_remove_value(current->form, tag, value);
|
removed = form_remove_value(form, tag, value);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
ui_current_print_line("Field updated...");
|
ui_current_print_line("Field updated...");
|
||||||
ui_show_form_field(current, current->form, tag);
|
ui_show_form_field(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);
|
||||||
}
|
}
|
||||||
@ -2225,7 +2229,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
char *room = split_recipient[0];
|
char *room = split_recipient[0];
|
||||||
|
|
||||||
if (g_strcmp0(args[0], "show") == 0) {
|
if (g_strcmp0(args[0], "show") == 0) {
|
||||||
ui_show_form(current, room, current->form);
|
ui_show_form(current, room, current->wins.conf.form);
|
||||||
g_strfreev(split_recipient);
|
g_strfreev(split_recipient);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -2233,9 +2237,9 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
if (g_strcmp0(args[0], "help") == 0) {
|
if (g_strcmp0(args[0], "help") == 0) {
|
||||||
char *tag = args[1];
|
char *tag = args[1];
|
||||||
if (tag != NULL) {
|
if (tag != NULL) {
|
||||||
ui_show_form_field_help(current, current->form, tag);
|
ui_show_form_field_help(current, current->wins.conf.form, tag);
|
||||||
} else {
|
} else {
|
||||||
ui_show_form_help(current, current->form);
|
ui_show_form_help(current, current->wins.conf.form);
|
||||||
|
|
||||||
const gchar **help_text = NULL;
|
const gchar **help_text = NULL;
|
||||||
Command *command = g_hash_table_lookup(commands, "/form");
|
Command *command = g_hash_table_lookup(commands, "/form");
|
||||||
@ -2252,7 +2256,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0(args[0], "submit") == 0) {
|
if (g_strcmp0(args[0], "submit") == 0) {
|
||||||
iq_submit_room_config(room, current->form);
|
iq_submit_room_config(room, current->wins.conf.form);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2261,8 +2265,8 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((g_strcmp0(args[0], "submit") == 0) || (g_strcmp0(args[0], "cancel") == 0)) {
|
if ((g_strcmp0(args[0], "submit") == 0) || (g_strcmp0(args[0], "cancel") == 0)) {
|
||||||
if (current->form) {
|
if (current->wins.conf.form) {
|
||||||
cmd_autocomplete_remove_form_fields(current->form);
|
cmd_autocomplete_remove_form_fields(current->wins.conf.form);
|
||||||
}
|
}
|
||||||
wins_close_current();
|
wins_close_current();
|
||||||
current = wins_get_by_recipient(room);
|
current = wins_get_by_recipient(room);
|
||||||
|
@ -754,10 +754,11 @@ _ui_win_has_unsaved_form(int num)
|
|||||||
if (window->type != WIN_MUC_CONFIG) {
|
if (window->type != WIN_MUC_CONFIG) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (window->form == NULL) {
|
if (window->wins.conf.form == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return window->form->modified;
|
|
||||||
|
return window->wins.conf.form->modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString *
|
GString *
|
||||||
@ -784,12 +785,12 @@ _ui_switch_win(const int i)
|
|||||||
if (ui_win_exists(i)) {
|
if (ui_win_exists(i)) {
|
||||||
ProfWin *old_current = wins_get_current();
|
ProfWin *old_current = wins_get_current();
|
||||||
if (old_current->type == WIN_MUC_CONFIG) {
|
if (old_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_remove_form_fields(old_current->form);
|
cmd_autocomplete_remove_form_fields(old_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *new_current = wins_get_by_num(i);
|
ProfWin *new_current = wins_get_by_num(i);
|
||||||
if (new_current->type == WIN_MUC_CONFIG) {
|
if (new_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_add_form_fields(new_current->form);
|
cmd_autocomplete_add_form_fields(new_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
wins_set_current_by_num(i);
|
wins_set_current_by_num(i);
|
||||||
@ -818,12 +819,12 @@ _ui_previous_win(void)
|
|||||||
{
|
{
|
||||||
ProfWin *old_current = wins_get_current();
|
ProfWin *old_current = wins_get_current();
|
||||||
if (old_current->type == WIN_MUC_CONFIG) {
|
if (old_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_remove_form_fields(old_current->form);
|
cmd_autocomplete_remove_form_fields(old_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *new_current = wins_get_previous();
|
ProfWin *new_current = wins_get_previous();
|
||||||
if (new_current->type == WIN_MUC_CONFIG) {
|
if (new_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_add_form_fields(new_current->form);
|
cmd_autocomplete_add_form_fields(new_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = wins_get_num(new_current);
|
int i = wins_get_num(new_current);
|
||||||
@ -849,12 +850,12 @@ _ui_next_win(void)
|
|||||||
{
|
{
|
||||||
ProfWin *old_current = wins_get_current();
|
ProfWin *old_current = wins_get_current();
|
||||||
if (old_current->type == WIN_MUC_CONFIG) {
|
if (old_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_remove_form_fields(old_current->form);
|
cmd_autocomplete_remove_form_fields(old_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *new_current = wins_get_next();
|
ProfWin *new_current = wins_get_next();
|
||||||
if (new_current->type == WIN_MUC_CONFIG) {
|
if (new_current->type == WIN_MUC_CONFIG) {
|
||||||
cmd_autocomplete_add_form_fields(new_current->form);
|
cmd_autocomplete_add_form_fields(new_current->wins.conf.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = wins_get_num(new_current);
|
int i = wins_get_num(new_current);
|
||||||
@ -1073,8 +1074,8 @@ _ui_close_win(int index)
|
|||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_num(index);
|
ProfWin *window = wins_get_by_num(index);
|
||||||
if (window) {
|
if (window) {
|
||||||
if (window->type == WIN_MUC_CONFIG && window->form) {
|
if (window->type == WIN_MUC_CONFIG && window->wins.conf.form) {
|
||||||
cmd_autocomplete_remove_form_fields(window->form);
|
cmd_autocomplete_remove_form_fields(window->wins.conf.form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2652,7 +2653,7 @@ _ui_handle_room_configuration(const char * const room, DataForm *form)
|
|||||||
ProfWin *window = wins_new(title->str, WIN_MUC_CONFIG);
|
ProfWin *window = wins_new(title->str, WIN_MUC_CONFIG);
|
||||||
g_string_free(title, TRUE);
|
g_string_free(title, TRUE);
|
||||||
|
|
||||||
window->form = form;
|
window->wins.conf.form = form;
|
||||||
|
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
ui_switch_win(num);
|
ui_switch_win(num);
|
||||||
|
@ -189,7 +189,7 @@ _title_bar_draw(void)
|
|||||||
wprintw(win, " (typing...)");
|
wprintw(win, " (typing...)");
|
||||||
}
|
}
|
||||||
} else if (current && current->type == WIN_MUC_CONFIG) {
|
} else if (current && current->type == WIN_MUC_CONFIG) {
|
||||||
if (current->form && current->form->modified) {
|
if (current->wins.conf.form && current->wins.conf.form->modified) {
|
||||||
wprintw(win, " *");
|
wprintw(win, " *");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,10 @@ win_create(const char * const title, win_type_t type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_win->type == WIN_MUC_CONFIG) {
|
||||||
|
new_win->wins.conf.form = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
new_win->from = strdup(title);
|
new_win->from = strdup(title);
|
||||||
new_win->buffer = buffer_create();
|
new_win->buffer = buffer_create();
|
||||||
new_win->y_pos = 0;
|
new_win->y_pos = 0;
|
||||||
@ -115,7 +119,6 @@ win_create(const char * const title, win_type_t type)
|
|||||||
new_win->type = type;
|
new_win->type = type;
|
||||||
new_win->is_otr = FALSE;
|
new_win->is_otr = FALSE;
|
||||||
new_win->is_trusted = FALSE;
|
new_win->is_trusted = FALSE;
|
||||||
new_win->form = NULL;
|
|
||||||
new_win->chat_resource = NULL;
|
new_win->chat_resource = NULL;
|
||||||
scrollok(new_win->win, TRUE);
|
scrollok(new_win->win, TRUE);
|
||||||
|
|
||||||
@ -198,7 +201,11 @@ win_free(ProfWin* window)
|
|||||||
|
|
||||||
free(window->chat_resource);
|
free(window->chat_resource);
|
||||||
free(window->from);
|
free(window->from);
|
||||||
form_destroy(window->form);
|
|
||||||
|
if (window->type == WIN_MUC_CONFIG) {
|
||||||
|
form_destroy(window->wins.conf.form);
|
||||||
|
}
|
||||||
|
|
||||||
free(window);
|
free(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ typedef struct prof_win_t {
|
|||||||
gboolean is_trusted;
|
gboolean is_trusted;
|
||||||
int unread;
|
int unread;
|
||||||
int history_shown;
|
int history_shown;
|
||||||
DataForm *form;
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
// WIN_CONSOLE
|
// WIN_CONSOLE
|
||||||
@ -100,6 +99,7 @@ typedef struct prof_win_t {
|
|||||||
|
|
||||||
// WIN_MUC_CONFIG
|
// WIN_MUC_CONFIG
|
||||||
struct {
|
struct {
|
||||||
|
DataForm *form;
|
||||||
} conf;
|
} conf;
|
||||||
|
|
||||||
// WIN_PRIVATE
|
// WIN_PRIVATE
|
||||||
|
@ -656,7 +656,7 @@ wins_create_summary(void)
|
|||||||
case WIN_MUC_CONFIG:
|
case WIN_MUC_CONFIG:
|
||||||
muc_config_string = g_string_new("");
|
muc_config_string = g_string_new("");
|
||||||
g_string_printf(muc_config_string, "%d: %s", ui_index, window->from);
|
g_string_printf(muc_config_string, "%d: %s", ui_index, window->from);
|
||||||
if ((window->form != NULL) && (window->form->modified)) {
|
if ((window->wins.conf.form) && (window->wins.conf.form->modified)) {
|
||||||
g_string_append(muc_config_string, " *");
|
g_string_append(muc_config_string, " *");
|
||||||
}
|
}
|
||||||
result = g_slist_append(result, strdup(muc_config_string->str));
|
result = g_slist_append(result, strdup(muc_config_string->str));
|
||||||
|
Loading…
Reference in New Issue
Block a user