mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change the background colours of the import-main-matcher
Use the same procedure as that used in the dense calendar to change the background colours in the import main matcher to be based on the brightness of the foreground colour.
This commit is contained in:
parent
659d3b9582
commit
b81a4a559d
@ -4,16 +4,32 @@
|
||||
|
||||
|
||||
/* Import Matcher, amount of intervention required */
|
||||
@define-color intervention-required_bg_color brown1;
|
||||
@define-color intervention-probably-required_bg_color gold;
|
||||
@define-color intervention-not-required_bg_color DarkSeaGreen1;
|
||||
|
||||
.intervention-required {
|
||||
background-color: brown1;
|
||||
background-color: @intervention-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-probably-required {
|
||||
background-color: gold;
|
||||
background-color: @intervention-probably-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-not-required {
|
||||
background-color: DarkSeaGreen1;
|
||||
background-color: @intervention-not-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-required-dark {
|
||||
background-color: shade (@intervention-required_bg_color, 0.7);
|
||||
}
|
||||
|
||||
.intervention-probably-required-dark {
|
||||
background-color: shade (@intervention-probably-required_bg_color, 0.8);
|
||||
}
|
||||
|
||||
.intervention-not-required-dark {
|
||||
background-color: shade (@intervention-not-required_bg_color, 0.3);
|
||||
}
|
||||
|
||||
/* Negative value label colors */
|
||||
|
@ -60,6 +60,7 @@ struct _main_matcher_info
|
||||
GtkTreeView *view;
|
||||
GNCImportSettings *user_settings;
|
||||
int selected_row;
|
||||
gboolean dark_theme;
|
||||
GNCTransactionProcessedCB transaction_processed_cb;
|
||||
gpointer user_data;
|
||||
GNCImportPendingMatches *pending_matches;
|
||||
@ -206,6 +207,8 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
GNCImportMainMatcher *info = user_data;
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *help_dialog, *box;
|
||||
gchar *int_required_class, *int_prob_required_class, *int_not_required_class;
|
||||
gchar *class_extension = NULL;
|
||||
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
|
||||
@ -214,14 +217,21 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help_dialog");
|
||||
|
||||
if (info->dark_theme == TRUE)
|
||||
class_extension = "-dark";
|
||||
|
||||
int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), CSS_INT_REQUIRED_CLASS);
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_required_class);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_probably_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), CSS_INT_PROB_REQUIRED_CLASS);
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_prob_required_class);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_not_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), CSS_INT_NOT_REQUIRED_CLASS);
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_not_required_class);
|
||||
|
||||
help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help_dialog"));
|
||||
gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
|
||||
@ -232,6 +242,10 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
|
||||
g_free (int_required_class);
|
||||
g_free (int_prob_required_class);
|
||||
g_free (int_not_required_class);
|
||||
|
||||
gtk_widget_show(help_dialog);
|
||||
}
|
||||
|
||||
@ -497,6 +511,20 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info,
|
||||
G_CALLBACK(gnc_gen_trans_row_changed_cb), info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_color_light (GdkRGBA *color)
|
||||
{
|
||||
gboolean is_light = FALSE;
|
||||
|
||||
// Counting the perceptive luminance - human eye favors green color...
|
||||
double a = (0.299 * color->red + 0.587 * color->green + 0.114 * color->blue);
|
||||
|
||||
if (a > 0.5)
|
||||
is_light = TRUE;
|
||||
|
||||
return is_light;
|
||||
}
|
||||
|
||||
GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
const gchar* heading,
|
||||
gboolean all_from_same_account,
|
||||
@ -507,6 +535,8 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
GtkWidget *heading_label;
|
||||
GtkWidget *box, *pbox;
|
||||
gboolean show_update;
|
||||
GtkStyleContext *stylectxt;
|
||||
GdkRGBA color;
|
||||
|
||||
info = g_new0 (GNCImportMainMatcher, 1);
|
||||
info->pending_matches = gnc_import_PendingMatches_new();
|
||||
@ -515,6 +545,10 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
info->user_settings = gnc_import_Settings_new ();
|
||||
gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
|
||||
|
||||
stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
|
||||
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
|
||||
info->dark_theme = is_color_light (&color);
|
||||
|
||||
/* Initialize the GtkDialog. */
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_dialog");
|
||||
@ -538,7 +572,7 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
|
||||
/* if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (info->dialog),
|
||||
GTK_WINDOW (parent));*/
|
||||
GTK_WINDOW (parent));*/
|
||||
|
||||
if (heading)
|
||||
gtk_label_set_text (GTK_LABEL (heading_label), heading);
|
||||
@ -570,6 +604,8 @@ GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent,
|
||||
GtkWidget *heading_label;
|
||||
GtkWidget *box;
|
||||
gboolean show_update;
|
||||
GtkStyleContext *stylectxt;
|
||||
GdkRGBA color;
|
||||
|
||||
info = g_new0 (GNCImportMainMatcher, 1);
|
||||
info->pending_matches = gnc_import_PendingMatches_new();
|
||||
@ -578,6 +614,10 @@ GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent,
|
||||
info->user_settings = gnc_import_Settings_new ();
|
||||
gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
|
||||
|
||||
stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
|
||||
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
|
||||
info->dark_theme = is_color_light (&color);
|
||||
|
||||
/* load the interface */
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
|
||||
@ -681,6 +721,8 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
GtkTreeSelection *selection;
|
||||
gchar *tmp, *imbalance, *text, *color;
|
||||
const gchar *ro_text;
|
||||
gchar *int_required_class, *int_prob_required_class, *int_not_required_class;
|
||||
gchar *class_extension = NULL;
|
||||
Split *split;
|
||||
g_assert (gui);
|
||||
g_assert (model);
|
||||
@ -690,6 +732,13 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
store = GTK_LIST_STORE(model);
|
||||
gtk_list_store_set(store, iter, DOWNLOADED_COL_DATA, info, -1);
|
||||
|
||||
if (gui->dark_theme == TRUE)
|
||||
class_extension = "-dark";
|
||||
|
||||
int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
|
||||
|
||||
/*Account:*/
|
||||
split = gnc_import_TransInfo_get_fsplit (info);
|
||||
g_assert(split); // Must not be NULL
|
||||
@ -726,7 +775,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
if (gnc_import_TransInfo_is_balanced(info) == TRUE)
|
||||
{
|
||||
ro_text = _("New, already balanced");
|
||||
color = get_required_color (CSS_INT_NOT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_not_required_class);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -742,7 +791,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
TRUE) ));
|
||||
if (gnc_import_TransInfo_get_destacc (info) != NULL)
|
||||
{
|
||||
color = get_required_color (CSS_INT_NOT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_not_required_class);
|
||||
tmp = gnc_account_get_full_name
|
||||
(gnc_import_TransInfo_get_destacc (info));
|
||||
if (gnc_import_TransInfo_get_destacc_selected_manually(info)
|
||||
@ -767,7 +816,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = get_required_color (CSS_INT_PROB_REQUIRED_CLASS);
|
||||
color = get_required_color (int_prob_required_class);
|
||||
text =
|
||||
/* Translators: %s is the amount to be transferred. */
|
||||
g_strdup_printf(_("New, UNBALANCED (need acct to transfer %s)!"),
|
||||
@ -779,7 +828,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
case GNCImport_CLEAR:
|
||||
if (gnc_import_TransInfo_get_selected_match(info))
|
||||
{
|
||||
color = get_required_color (CSS_INT_NOT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_not_required_class);
|
||||
if (gnc_import_TransInfo_get_match_selected_manually(info) == TRUE)
|
||||
{
|
||||
ro_text = _("Reconcile (manual) match");
|
||||
@ -791,14 +840,14 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = get_required_color (CSS_INT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Match missing!");
|
||||
}
|
||||
break;
|
||||
case GNCImport_UPDATE:
|
||||
if (gnc_import_TransInfo_get_selected_match(info))
|
||||
{
|
||||
color = get_required_color (CSS_INT_NOT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_not_required_class);
|
||||
if (gnc_import_TransInfo_get_match_selected_manually(info) == TRUE)
|
||||
{
|
||||
ro_text = _("Update and reconcile (manual) match");
|
||||
@ -810,12 +859,12 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = get_required_color (CSS_INT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Match missing!");
|
||||
}
|
||||
break;
|
||||
case GNCImport_SKIP:
|
||||
color = get_required_color (CSS_INT_REQUIRED_CLASS);
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Do not import (no action selected)");
|
||||
break;
|
||||
default:
|
||||
@ -831,6 +880,10 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
if (text)
|
||||
g_free(text);
|
||||
|
||||
g_free (int_required_class);
|
||||
g_free (int_prob_required_class);
|
||||
g_free (int_not_required_class);
|
||||
|
||||
/* Set the pixmaps */
|
||||
gtk_list_store_set(store, iter,
|
||||
DOWNLOADED_COL_ACTION_ADD,
|
||||
|
Loading…
Reference in New Issue
Block a user