From 03cbb1c8f65ff910ee028d28570865c86989e76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20G=C3=B6rs?= Date: Wed, 5 Dec 2012 19:04:07 +0100 Subject: [PATCH] core: disable paste detection and confirmation if bar item "input_paste" is not used in a visible bar (task #12327) --- ChangeLog | 2 ++ src/gui/gui-bar-item.c | 10 +++++++++- src/gui/gui-bar-item.h | 3 ++- src/gui/gui-bar.c | 3 ++- src/gui/gui-key.c | 24 +++++++++++++++--------- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index abb687a99..b5494797c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ v0.4.0-dev, 2012-12-05 Version 0.4.0 (under dev!) -------------------------- +* core: disable paste detection and confirmation if bar item "input_paste" is + not used in a visible bar (task #12327) * core: use high priority (50000) for commands /command and /input so that an alias will not take precedence over these commands (bug #36353) * core: execute command with higher priority when many commands with same name diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 43d5dbb53..f4efc03b0 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -221,7 +221,8 @@ gui_bar_item_used_in_bar (struct t_gui_bar *bar, const char *item_name, */ int -gui_bar_item_used_in_at_least_one_bar (const char *item_name, int partial_name) +gui_bar_item_used_in_at_least_one_bar (const char *item_name, int partial_name, + int ignore_hidden_bars) { struct t_gui_bar *ptr_bar; int i, j, length; @@ -230,6 +231,13 @@ gui_bar_item_used_in_at_least_one_bar (const char *item_name, int partial_name) for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { + /* if bar is hidden and that hidden bars are ignored, just skip it */ + if (ignore_hidden_bars + && CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])) + { + continue; + } + for (i = 0; i < ptr_bar->items_count; i++) { for (j = 0; j < ptr_bar->items_subcount[i]; j++) diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index 8e7ae338d..d011e1a4f 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -80,7 +80,8 @@ extern int gui_bar_item_used_in_bar (struct t_gui_bar *bar, const char *item_name, int partial_name); extern int gui_bar_item_used_in_at_least_one_bar (const char *item_name, - int partial_name); + int partial_name, + int ignore_hidden_bars); extern void gui_bar_item_set_prefix_name_suffix (const char *item_name, char **prefix, char **name, char **suffix); diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index eb2c4299c..66c839416 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -1842,7 +1842,8 @@ gui_bar_create_default_input () char *buf; /* search an input_text item */ - if (!gui_bar_item_used_in_at_least_one_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], 1)) + if (!gui_bar_item_used_in_at_least_one_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], + 1, 0)) { ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_INPUT); if (ptr_bar) diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 6c338eabf..16e87677a 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -45,6 +45,7 @@ #include "../plugins/plugin.h" #include "gui-key.h" #include "gui-bar.h" +#include "gui-bar-item.h" #include "gui-bar-window.h" #include "gui-buffer.h" #include "gui-chat.h" @@ -1584,16 +1585,21 @@ gui_key_paste_check (int bracketed_paste) int max_lines; max_lines = CONFIG_INTEGER(config_look_paste_max_lines); - if (max_lines >= 0) + + if ((max_lines < 0) + || !gui_bar_item_used_in_at_least_one_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE], + 0, 1)) { - if (!bracketed_paste && (max_lines == 0)) - max_lines = 1; - if (gui_key_get_paste_lines () > max_lines) - { - /* ask user what to do */ - gui_key_paste_start (); - return 1; - } + return 0; + } + + if (!bracketed_paste && (max_lines == 0)) + max_lines = 1; + if (gui_key_get_paste_lines () > max_lines) + { + /* ask user what to do */ + gui_key_paste_start (); + return 1; } return 0;