Commit 7655dd72 authored by Ell's avatar Ell

app: make error-console highlighting criterion configurable

Currently, the error console is highlighted (shown/blinked) only
upon errors; however, warnings, which are not shown on the
statusbar while the error console is open, often also contain
important information.

Allow the user to configure which message types (errors, warnings,
and regular messages) highlight the error console, using a new
"highlight" submenu in the error-console menu.  Add corresponding
config options, saved in sessionrc.  By default, highlight the
error console unpon both errors and warnings.
parent b2bc33bd
......@@ -24,6 +24,10 @@
#include "actions-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimphelp-ids.h"
......@@ -50,7 +54,11 @@ static const GimpActionEntry error_console_actions[] =
NC_("error-console-action", "Select _All"), "",
NC_("error-console-action", "Select all error messages"),
G_CALLBACK (error_console_select_all_cmd_callback),
GIMP_HELP_ERRORS_SELECT_ALL }
GIMP_HELP_ERRORS_SELECT_ALL },
{ "error-console-highlight", NULL,
NC_("error-console-action", "_Highlight"), NULL, NULL, NULL,
GIMP_HELP_ERRORS_HIGHLIGHT }
};
static const GimpEnumActionEntry error_console_save_actions[] =
......@@ -68,6 +76,30 @@ static const GimpEnumActionEntry error_console_save_actions[] =
GIMP_HELP_ERRORS_SAVE }
};
static const GimpToggleActionEntry error_console_highlight_actions[] =
{
{ "error-console-highlight-error", NULL,
NC_("error-console-action", "_Errors"), NULL,
NC_("error-console-action", "Highlight error console on errors"),
G_CALLBACK (error_console_highlight_error_cmd_callback),
FALSE,
GIMP_HELP_ERRORS_HIGHLIGHT },
{ "error-console-highlight-warning", NULL,
NC_("error-console-action", "_Warnings"), NULL,
NC_("error-console-action", "Highlight error console on warnings"),
G_CALLBACK (error_console_highlight_warning_cmd_callback),
FALSE,
GIMP_HELP_ERRORS_HIGHLIGHT },
{ "error-console-highlight-info", NULL,
NC_("error-console-action", "_Messages"), NULL,
NC_("error-console-action", "Highlight error console on messages"),
G_CALLBACK (error_console_highlight_info_cmd_callback),
FALSE,
GIMP_HELP_ERRORS_HIGHLIGHT }
};
void
error_console_actions_setup (GimpActionGroup *group)
......@@ -80,6 +112,10 @@ error_console_actions_setup (GimpActionGroup *group)
error_console_save_actions,
G_N_ELEMENTS (error_console_save_actions),
G_CALLBACK (error_console_save_cmd_callback));
gimp_action_group_add_toggle_actions (group, "error-console-action",
error_console_highlight_actions,
G_N_ELEMENTS (error_console_highlight_actions));
}
void
......@@ -87,11 +123,14 @@ error_console_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
GimpGuiConfig *config = GIMP_GUI_CONFIG (console->gimp->config);
gboolean selection;
selection = gtk_text_buffer_get_selection_bounds (console->text_buffer,
NULL, NULL);
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......@@ -99,6 +138,20 @@ error_console_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("error-console-select-all", TRUE);
SET_SENSITIVE ("error-console-save-all", TRUE);
SET_SENSITIVE ("error-console-save-selection", selection);
SET_SENSITIVE ("error-console-highlight", TRUE);
SET_SENSITIVE ("error-console-highlight-error", TRUE);
SET_ACTIVE ("error-console-highlight-error",
config->error_console_highlight[GIMP_MESSAGE_ERROR]);
SET_SENSITIVE ("error-console-highlight-warning", TRUE);
SET_ACTIVE ("error-console-highlight-warning",
config->error_console_highlight[GIMP_MESSAGE_WARNING]);
SET_SENSITIVE ("error-console-highlight-info", TRUE);
SET_ACTIVE ("error-console-highlight-info",
config->error_console_highlight[GIMP_MESSAGE_INFO]);
#undef SET_ACTIVE
#undef SET_SENSITIVE
}
......@@ -131,6 +131,48 @@ error_console_save_cmd_callback (GtkAction *action,
gtk_window_present (GTK_WINDOW (console->file_dialog));
}
void
error_console_highlight_error_cmd_callback (GtkAction *action,
gpointer data)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (console->gimp->config,
"error-console-highlight-error", active,
NULL);
}
void
error_console_highlight_warning_cmd_callback (GtkAction *action,
gpointer data)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (console->gimp->config,
"error-console-highlight-warning", active,
NULL);
}
void
error_console_highlight_info_cmd_callback (GtkAction *action,
gpointer data)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (console->gimp->config,
"error-console-highlight-info", active,
NULL);
}
/* private functions */
......
......@@ -19,13 +19,20 @@
#define __ERROR_CONSOLE_COMMANDS_H__
void error_console_clear_cmd_callback (GtkAction *action,
gpointer data);
void error_console_select_all_cmd_callback (GtkAction *action,
gpointer data);
void error_console_save_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void error_console_clear_cmd_callback (GtkAction *action,
gpointer data);
void error_console_select_all_cmd_callback (GtkAction *action,
gpointer data);
void error_console_save_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void error_console_highlight_error_cmd_callback (GtkAction *action,
gpointer data);
void error_console_highlight_warning_cmd_callback (GtkAction *action,
gpointer data);
void error_console_highlight_info_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __ERROR_CONSOLE_COMMANDS_H__ */
......@@ -96,6 +96,9 @@ enum
PROP_SINGLE_WINDOW_MODE,
PROP_TABS_POSITION,
PROP_LAST_TIP_SHOWN,
PROP_ERROR_CONSOLE_HIGHLIGHT_ERROR,
PROP_ERROR_CONSOLE_HIGHLIGHT_WARNING,
PROP_ERROR_CONSOLE_HIGHLIGHT_INFO,
/* ignored, only for backward compatibility: */
PROP_CURSOR_FORMAT,
......@@ -459,6 +462,30 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ERROR_CONSOLE_HIGHLIGHT_ERROR,
g_param_spec_boolean ("error-console-highlight-error",
NULL,
ERROR_CONSOLE_HIGHLIGHT_ERROR_BLURB,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ERROR_CONSOLE_HIGHLIGHT_WARNING,
g_param_spec_boolean ("error-console-highlight-warning",
NULL,
ERROR_CONSOLE_HIGHLIGHT_WARNING_BLURB,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ERROR_CONSOLE_HIGHLIGHT_INFO,
g_param_spec_boolean ("error-console-highlight-info",
NULL,
ERROR_CONSOLE_HIGHLIGHT_INFO_BLURB,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_PARAM_STATIC_STRINGS));
/* only for backward compatibility: */
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CURSOR_FORMAT,
......@@ -712,6 +739,15 @@ gimp_gui_config_set_property (GObject *object,
case PROP_LAST_TIP_SHOWN:
gui_config->last_tip_shown = g_value_get_int (value);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_ERROR:
gui_config->error_console_highlight[GIMP_MESSAGE_ERROR] = g_value_get_boolean (value);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_WARNING:
gui_config->error_console_highlight[GIMP_MESSAGE_WARNING] = g_value_get_boolean (value);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_INFO:
gui_config->error_console_highlight[GIMP_MESSAGE_INFO] = g_value_get_boolean (value);
break;
case PROP_CURSOR_FORMAT:
case PROP_INFO_WINDOW_PER_DISPLAY:
......@@ -869,6 +905,15 @@ gimp_gui_config_get_property (GObject *object,
case PROP_LAST_TIP_SHOWN:
g_value_set_int (value, gui_config->last_tip_shown);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_ERROR:
g_value_set_boolean (value, gui_config->error_console_highlight[GIMP_MESSAGE_ERROR]);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_WARNING:
g_value_set_boolean (value, gui_config->error_console_highlight[GIMP_MESSAGE_WARNING]);
break;
case PROP_ERROR_CONSOLE_HIGHLIGHT_INFO:
g_value_set_boolean (value, gui_config->error_console_highlight[GIMP_MESSAGE_INFO]);
break;
case PROP_CURSOR_FORMAT:
case PROP_INFO_WINDOW_PER_DISPLAY:
......
......@@ -87,6 +87,7 @@ struct _GimpGuiConfig
gboolean single_window_mode;
GimpPosition tabs_position;
gint last_tip_shown;
gboolean error_console_highlight[GIMP_MESSAGE_ERROR + 1];
};
struct _GimpGuiConfigClass
......
......@@ -126,6 +126,15 @@ _("The window type hint that is set on dock windows and the toolbox " \
#define ENVIRON_PATH_BLURB \
"Sets the environ search path."
#define ERROR_CONSOLE_HIGHLIGHT_ERROR_BLURB \
"Highlight error console on errors"
#define ERROR_CONSOLE_HIGHLIGHT_INFO_BLURB \
"Highlight error console on messages"
#define ERROR_CONSOLE_HIGHLIGHT_WARNING_BLURB \
"Highlight error console on warnings"
#define FRACTALEXPLORER_PATH_BLURB \
"Where to search for fractals used by the Fractal Explorer plug-in."
......
......@@ -153,10 +153,11 @@ gui_message_error_console (Gimp *gimp,
const gchar *domain,
const gchar *message)
{
GtkWidget *dockable = NULL;
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
GtkWidget *dockable = NULL;
/* try to avoid raising the error console for not so severe messages */
if (severity < GIMP_MESSAGE_ERROR)
/* avoid raising the error console for unhighlighted messages */
if (! config->error_console_highlight[severity])
{
GtkWidget *widget =
gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
......
......@@ -52,7 +52,10 @@ enum
HIDE_DOCKS,
SINGLE_WINDOW_MODE,
TABS_POSITION,
LAST_TIP_SHOWN
LAST_TIP_SHOWN,
ERROR_CONSOLE_HIGHLIGHT_ERROR,
ERROR_CONSOLE_HIGHLIGHT_WARNING,
ERROR_CONSOLE_HIGHLIGHT_INFO
};
......@@ -110,6 +113,12 @@ session_init (Gimp *gimp)
GINT_TO_POINTER (TABS_POSITION));
g_scanner_scope_add_symbol (scanner, 0, "last-tip-shown",
GINT_TO_POINTER (LAST_TIP_SHOWN));
g_scanner_scope_add_symbol (scanner, 0, "error-console-highlight-error",
GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_ERROR));
g_scanner_scope_add_symbol (scanner, 0, "error-console-highlight-warning",
GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_WARNING));
g_scanner_scope_add_symbol (scanner, 0, "error-console-highlight-info",
GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_INFO));
token = G_TOKEN_LEFT_PAREN;
......@@ -272,6 +281,45 @@ session_init (Gimp *gimp)
"last-tip-shown", last_tip_shown,
NULL);
}
else if (scanner->value.v_symbol == GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_ERROR))
{
gboolean error_console_highlight_error;
token = G_TOKEN_IDENTIFIER;
if (! gimp_scanner_parse_boolean (scanner, &error_console_highlight_error))
break;
g_object_set (gimp->config,
"error-console-highlight-error", error_console_highlight_error,
NULL);
}
else if (scanner->value.v_symbol == GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_WARNING))
{
gboolean error_console_highlight_warning;
token = G_TOKEN_IDENTIFIER;
if (! gimp_scanner_parse_boolean (scanner, &error_console_highlight_warning))
break;
g_object_set (gimp->config,
"error-console-highlight-warning", error_console_highlight_warning,
NULL);
}
else if (scanner->value.v_symbol == GINT_TO_POINTER (ERROR_CONSOLE_HIGHLIGHT_INFO))
{
gboolean error_console_highlight_info;
token = G_TOKEN_IDENTIFIER;
if (! gimp_scanner_parse_boolean (scanner, &error_console_highlight_info))
break;
g_object_set (gimp->config,
"error-console-highlight-info", error_console_highlight_info,
NULL);
}
token = G_TOKEN_RIGHT_PAREN;
break;
......@@ -395,6 +443,24 @@ session_save (Gimp *gimp,
GIMP_GUI_CONFIG (gimp->config)->last_tip_shown);
gimp_config_writer_close (writer);
gimp_config_writer_open (writer, "error-console-highlight-error");
gimp_config_writer_identifier (writer,
GIMP_GUI_CONFIG (gimp->config)->error_console_highlight[GIMP_MESSAGE_ERROR] ?
"yes" : "no");
gimp_config_writer_close (writer);
gimp_config_writer_open (writer, "error-console-highlight-warning");
gimp_config_writer_identifier (writer,
GIMP_GUI_CONFIG (gimp->config)->error_console_highlight[GIMP_MESSAGE_WARNING] ?
"yes" : "no");
gimp_config_writer_close (writer);
gimp_config_writer_open (writer, "error-console-highlight-info");
gimp_config_writer_identifier (writer,
GIMP_GUI_CONFIG (gimp->config)->error_console_highlight[GIMP_MESSAGE_INFO] ?
"yes" : "no");
gimp_config_writer_close (writer);
if (! gimp_config_writer_finish (writer, "end of sessionrc", &error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
......
......@@ -591,6 +591,7 @@
#define GIMP_HELP_TOOL_OPTIONS_RESET "gimp-tool-options-reset"
#define GIMP_HELP_ERRORS_DIALOG "gimp-errors-dialog"
#define GIMP_HELP_ERRORS_HIGHLIGHT "gimp-errors-highlight"
#define GIMP_HELP_ERRORS_CLEAR "gimp-errors-clear"
#define GIMP_HELP_ERRORS_SAVE "gimp-errors-save"
#define GIMP_HELP_ERRORS_SELECT_ALL "gimp-errors-select-all"
......
......@@ -8,5 +8,11 @@
<separator />
<menuitem action="error-console-save-all" />
<menuitem action="error-console-save-selection" />
<separator />
<menu action="error-console-highlight">
<menuitem action="error-console-highlight-error" />
<menuitem action="error-console-highlight-warning" />
<menuitem action="error-console-highlight-info" />
</menu>
</popup>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment