gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Tue Jun 4 08:21:45 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/cc12fcf3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a22ad2e0 (commit)
	from  https://github.com/Gnucash/gnucash/commit/9056b14d (commit)



commit cc12fcf32203c2067b6dff843c5423decb163004
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue Jun 4 10:33:30 2019 +0100

    Add new function named similar to remove class function
    
    The existing function name to add CSS classes for style contexts was
    not correct so add a new function gnc_widget_style_context_add_class
    named similar to remove function and use it for the existing
    'gnc-class-highlight'. Change old function to use this new one with the
    old one being removed in master.

diff --git a/gnucash/gnome-utils/dialog-utils.c b/gnucash/gnome-utils/dialog-utils.c
index 834f47802..b1e94e999 100644
--- a/gnucash/gnome-utils/dialog-utils.c
+++ b/gnucash/gnome-utils/dialog-utils.c
@@ -72,12 +72,12 @@ gnc_set_label_color(GtkWidget *label, gnc_numeric value)
     if (deficit)
     {
         gnc_widget_style_context_remove_class (GTK_WIDGET(label), "default-color");
-        gnc_widget_set_style_context (GTK_WIDGET(label), "negative-numbers");
+        gnc_widget_style_context_add_class (GTK_WIDGET(label), "negative-numbers");
     }
     else
     {
         gnc_widget_style_context_remove_class (GTK_WIDGET(label), "negative-numbers");
-        gnc_widget_set_style_context (GTK_WIDGET(label), "default-color");
+        gnc_widget_style_context_add_class (GTK_WIDGET(label), "default-color");
     }
 }
 
@@ -369,6 +369,12 @@ gnc_tree_view_get_grid_lines_pref (void)
 \********************************************************************/
 void
 gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class)
+{
+    gnc_widget_style_context_add_class (widget, gnc_class);
+}
+
+void
+gnc_widget_style_context_add_class (GtkWidget *widget, const char *gnc_class)
 {
     GtkStyleContext *context = gtk_widget_get_style_context (widget);
     gtk_style_context_add_class (context, gnc_class);
diff --git a/gnucash/gnome-utils/dialog-utils.h b/gnucash/gnome-utils/dialog-utils.h
index 942ffb1f7..c30571d18 100644
--- a/gnucash/gnome-utils/dialog-utils.h
+++ b/gnucash/gnome-utils/dialog-utils.h
@@ -90,6 +90,7 @@ GtkTreeViewGridLines gnc_tree_view_get_grid_lines_pref (void);
  * Returns:  nothing                                                *
 \********************************************************************/
 void gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class);
+void gnc_widget_style_context_add_class (GtkWidget *widget, const char *gnc_class);
 
 /********************************************************************\
  * Remove a style context class from a Widget                       *
diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index d1ae2447b..573293926 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -2313,7 +2313,7 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
     iw->paid_label = GTK_WIDGET (gtk_builder_get_object (builder, "paid_label"));
 
     // Set the style context for this label so it can be easily manipulated with css
-    gnc_widget_set_style_context (GTK_WIDGET(iw->paid_label), "gnc-class-highlight");
+    gnc_widget_style_context_add_class (GTK_WIDGET(iw->paid_label), "gnc-class-highlight");
 
     /* grab the project widgets */
     iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder, "page_proj_frame"));
diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c
index d85998953..8d8f3b6f6 100644
--- a/gnucash/gnome/dialog-trans-assoc.c
+++ b/gnucash/gnome/dialog-trans-assoc.c
@@ -528,7 +528,7 @@ gnc_assoc_dialog_create (GtkWindow *parent, AssocDialog *assoc_dialog)
     }
 
     // Set the style context for this label so it can be easily manipulated with css
-    gnc_widget_set_style_context (GTK_WIDGET(path_head), "gnc-class-highlight");
+    gnc_widget_style_context_add_class (GTK_WIDGET(path_head), "gnc-class-highlight");
 
     /* Need to add toggle renderers here to get the xalign to work. */
     tree_column = gtk_tree_view_column_new();
diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c
index 5f7f0767c..a15c5ef7b 100644
--- a/gnucash/gnome/gnc-split-reg.c
+++ b/gnucash/gnome/gnc-split-reg.c
@@ -1096,7 +1096,7 @@ gsr_default_associate_handler_file (GNCSplitReg *gsr, Transaction *trans, gboole
             gtk_label_set_ellipsize (GTK_LABEL(label), PANGO_ELLIPSIZE_START);
 
             // Set the style context for this label so it can be easily manipulated with css
-            gnc_widget_set_style_context (GTK_WIDGET(label), "gnc-class-highlight");
+            gnc_widget_style_context_add_class (GTK_WIDGET(label), "gnc-class-highlight");
             gtk_file_chooser_set_uri (GTK_FILE_CHOOSER(dialog), file_uri);
 
             g_free (uri_label);
@@ -2311,8 +2311,8 @@ gsr_create_summary_bar( GNCSplitReg *gsr )
     gsr->sort_arrow = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_SMALL_TOOLBAR);
     gsr->sort_label = add_summary_label (summarybar, FALSE, _("Sort By: "), gsr->sort_arrow);
 
-    gnc_widget_set_style_context (GTK_WIDGET(gsr->filter_label), "gnc-class-highlight");
-    gnc_widget_set_style_context (GTK_WIDGET(gsr->sort_arrow), "gnc-class-highlight");
+    gnc_widget_style_context_add_class (GTK_WIDGET(gsr->filter_label), "gnc-class-highlight");
+    gnc_widget_style_context_add_class (GTK_WIDGET(gsr->sort_arrow), "gnc-class-highlight");
 
     gsr->summarybar = summarybar;
 

commit a22ad2e0b82f440634fd96debbbeacadcd9c850b
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue Jun 4 10:28:03 2019 +0100

    Bug 797246 - Cleared Balance Remains Red After Turning Positive
    
    When changing the negative numbers to red a CSS class is added to set
    the colour but it is not removed when changing the number becomes
    positive. Add function to remove a CSS class if present and use in the
    gnc_set_label_color function.

diff --git a/gnucash/gnome-utils/dialog-utils.c b/gnucash/gnome-utils/dialog-utils.c
index caf2b26aa..834f47802 100644
--- a/gnucash/gnome-utils/dialog-utils.c
+++ b/gnucash/gnome-utils/dialog-utils.c
@@ -70,9 +70,15 @@ gnc_set_label_color(GtkWidget *label, gnc_numeric value)
     deficit = gnc_numeric_negative_p (value);
 
     if (deficit)
+    {
+        gnc_widget_style_context_remove_class (GTK_WIDGET(label), "default-color");
         gnc_widget_set_style_context (GTK_WIDGET(label), "negative-numbers");
+    }
     else
+    {
+        gnc_widget_style_context_remove_class (GTK_WIDGET(label), "negative-numbers");
         gnc_widget_set_style_context (GTK_WIDGET(label), "default-color");
+    }
 }
 
 
@@ -368,6 +374,22 @@ gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class)
     gtk_style_context_add_class (context, gnc_class);
 }
 
+/********************************************************************\
+ * Remove a style context class from a Widget                       *
+ *                                                                  *
+ * Args:    widget - widget to remove style class from              *
+ *       gnc_class - character string for css class name            *
+ * Returns:  nothing                                                *
+\********************************************************************/
+void
+gnc_widget_style_context_remove_class (GtkWidget *widget, const char *gnc_class)
+{
+    GtkStyleContext *context = gtk_widget_get_style_context (widget);
+
+    if (gtk_style_context_has_class (context, gnc_class))
+        gtk_style_context_remove_class (context, gnc_class);
+}
+
 /********************************************************************\
  * Draw an arrow on a Widget so it can be altered with css          *
  *                                                                  *
diff --git a/gnucash/gnome-utils/dialog-utils.h b/gnucash/gnome-utils/dialog-utils.h
index 908b7e6aa..942ffb1f7 100644
--- a/gnucash/gnome-utils/dialog-utils.h
+++ b/gnucash/gnome-utils/dialog-utils.h
@@ -91,6 +91,15 @@ GtkTreeViewGridLines gnc_tree_view_get_grid_lines_pref (void);
 \********************************************************************/
 void gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class);
 
+/********************************************************************\
+ * Remove a style context class from a Widget                       *
+ *                                                                  *
+ * Args:    widget - widget to remove style class from              *
+ *       gnc_class - character string for css class name            *
+ * Returns:  nothing                                                *
+\********************************************************************/
+void gnc_widget_style_context_remove_class (GtkWidget *widget, const char *gnc_class);
+
 /********************************************************************\
  * Draw an arrow on a Widget so it can be altered with css          *
  *                                                                  *



Summary of changes:
 gnucash/gnome-utils/dialog-utils.c | 32 ++++++++++++++++++++++++++++++--
 gnucash/gnome-utils/dialog-utils.h | 10 ++++++++++
 gnucash/gnome/dialog-invoice.c     |  2 +-
 gnucash/gnome/dialog-trans-assoc.c |  2 +-
 gnucash/gnome/gnc-split-reg.c      |  6 +++---
 5 files changed, 45 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list