[gtk+] cssstylechange: Add helper function to print change
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssstylechange: Add helper function to print change
- Date: Sun, 7 Feb 2016 18:20:57 +0000 (UTC)
commit d3a0dfe81a67ec39e12652f022fc43c16b421a67
Author: Timm Bäder <mail baedert org>
Date: Fri Feb 5 10:28:13 2016 +0100
cssstylechange: Add helper function to print change
So I don't have to print both styles to the console, paste them both
into a file and then run diff on the 2 files anymore.
gtk/gtkcssstylechange.c | 44 ++++++++++++++++++++++++++++++++++++++++
gtk/gtkcssstylechangeprivate.h | 2 +
2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssstylechange.c b/gtk/gtkcssstylechange.c
index 0ce6120..400dfe8 100644
--- a/gtk/gtkcssstylechange.c
+++ b/gtk/gtkcssstylechange.c
@@ -110,3 +110,47 @@ gtk_css_style_change_changes_property (GtkCssStyleChange *change,
return _gtk_bitmask_get (change->changes, id);
}
+void
+gtk_css_style_change_print (GtkCssStyleChange *change,
+ GString *string)
+{
+ int i;
+ GtkCssStyle *old = gtk_css_style_change_get_old_style (change);
+ GtkCssStyle *new = gtk_css_style_change_get_new_style (change);
+
+ for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i ++)
+ {
+ if (gtk_css_style_change_changes_property (change, i))
+ {
+ GtkCssStyleProperty *prop;
+ GtkCssValue *value;
+ const char *name;
+
+ prop = _gtk_css_style_property_lookup_by_id (i);
+ name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop));
+
+ value = gtk_css_style_get_value (old, i);
+ _gtk_css_value_print (value, string);
+
+ g_string_append_printf (string, "%s: ", name);
+ _gtk_css_value_print (value, string);
+ g_string_append (string, "\n");
+
+ g_string_append_printf (string, "%s: ", name);
+ value = gtk_css_style_get_value (new, i);
+ _gtk_css_value_print (value, string);
+ g_string_append (string, "\n");
+ }
+ }
+
+}
+
+char *
+gtk_css_style_change_to_string (GtkCssStyleChange *change)
+{
+ GString *string = g_string_new ("");
+
+ gtk_css_style_change_print (change, string);
+
+ return g_string_free (string, FALSE);
+}
diff --git a/gtk/gtkcssstylechangeprivate.h b/gtk/gtkcssstylechangeprivate.h
index 078dee0..85b9a32 100644
--- a/gtk/gtkcssstylechangeprivate.h
+++ b/gtk/gtkcssstylechangeprivate.h
@@ -47,7 +47,9 @@ gboolean gtk_css_style_change_affects (GtkCssStyleChange
GtkCssAffects affects);
gboolean gtk_css_style_change_changes_property (GtkCssStyleChange *change,
guint id);
+void gtk_css_style_change_print (GtkCssStyleChange *change, GString *string);
+char * gtk_css_style_change_to_string (GtkCssStyleChange *change);
G_END_DECLS
#endif /* __GTK_CSS_STYLE_CHANGE_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]