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



commit f92242517fc85c3f784826e9e46690912a91a487
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 3e0db78..e731dc5 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -735,6 +735,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")) {
@@ -786,23 +787,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) {
@@ -977,6 +969,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]