[vte/vte-next: 74/114] vteapp: Build the CSS string first and add the provider later



commit ccaa7c81d5c71b51d9492bdbcee24a4218c31b75
Author: Christian Persch <chpe gnome org>
Date:   Tue May 17 21:36:59 2011 +0200

    vteapp: Build the CSS string first and add the provider later
    
    This allows building up the string.

 src/vteapp.c |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/vteapp.c b/src/vteapp.c
index 5fb14f8..eb4eb95 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -740,6 +740,7 @@ main(int argc, char **argv)
 	VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
 	GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
 	VtePtyFlags pty_flags = VTE_PTY_DEFAULT;
+        GString *css_string;
 
 	/* Have to do this early. */
 	if (getenv("VTE_PROFILE_MEMORY")) {
@@ -791,23 +792,14 @@ main(int argc, char **argv)
                         g_error_free(err);
                 }
                 g_object_unref(provider);
+                provider = NULL;
                 g_free(css_file);
         }
-        if (css) {
-                GtkCssProvider *provider;
-                GError *err = NULL;
 
-                provider = gtk_css_provider_new();
-                if (gtk_css_provider_load_from_data(provider, css, -1, &err)) {
-                        gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
-                                                                  GTK_STYLE_PROVIDER(provider),
-                                                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-                } else {
-                        g_printerr("Failed to parse CSS: %s\n", err->message);
-                        g_error_free(err);
-                }
-                g_object_unref(provider);
-                g_free(css_file);
+        css_string = g_string_new (NULL);
+        if (css) {
+                g_string_append (css_string, css);
+                g_string_append_c (css_string, '\n');
         }
 
 	if (!reverse) {
@@ -982,6 +974,24 @@ main(int argc, char **argv)
                 vte_terminal_set_font_from_string(terminal, font);
         }
 
+        if (css_string->len > 0) {
+                GtkCssProvider *provider;
+                GError *err = NULL;
+
+                provider = gtk_css_provider_new();
+                if (gtk_css_provider_load_from_data(provider, css_string->str, css_string->len, &err)) {
+                        gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
+                                                                  GTK_STYLE_PROVIDER(provider),
+                                                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+                } else {
+                        g_printerr("Failed to parse CSS: %s\n", err->message);
+                        g_error_free(err);
+                }
+                g_object_unref(provider);
+                g_free(css_file);
+                g_string_free (css_string, TRUE);
+        }
+
 	/* Match "abcdefg". */
 	if (dingus) {
 		int id;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]