[gtk+] cssprovider: Return void, not TRUE



commit 4322b69528203d0f3c9e725af8d72597c101ef99
Author: Benjamin Otte <otte redhat com>
Date:   Mon Oct 17 17:41:03 2016 +0200

    cssprovider: Return void, not TRUE
    
    Parsing a css file always succeeds as CSS can recover from parsing
    errors.

 gtk/gtkcssprovider.c                   |   87 +++++--------------------------
 gtk/gtkcssprovider.h                   |    6 +-
 tests/testiconview-keynav.c            |    5 +--
 testsuite/css/api.c                    |    2 +-
 testsuite/css/parser/test-css-parser.c |    2 +-
 testsuite/css/style/test-css-style.c   |    3 +-
 testsuite/gtk/stylecontext.c           |    4 +-
 testsuite/reftests/gtk-reftest.c       |    3 +-
 8 files changed, 23 insertions(+), 89 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index d138949..139ef86 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -150,7 +150,7 @@ static void gtk_css_style_provider_emit_error (GtkStyleProviderPrivate *provider
                                                GtkCssSection           *section,
                                                const GError            *error);
 
-static gboolean
+static void
 gtk_css_provider_load_internal (GtkCssProvider *css_provider,
                                 GtkCssScanner  *scanner,
                                 GFile          *file,
@@ -966,37 +966,6 @@ gtk_css_provider_reset (GtkCssProvider *css_provider)
 
 }
 
-static void
-gtk_css_provider_propagate_error (GtkCssProvider  *provider,
-                                  GtkCssSection   *section,
-                                  const GError    *error,
-                                  GError         **propagate_to)
-{
-
-  char *s;
-
-  /* don't fail for deprecations */
-  if (g_error_matches (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_DEPRECATED))
-    {
-      s = _gtk_css_section_to_string (section);
-      g_warning ("Theme parsing error: %s: %s", s, error->message);
-      g_free (s);
-      return;
-    }
-
-  /* we already set an error. And we'd like to keep the first one */
-  if (*propagate_to)
-    return;
-
-  *propagate_to = g_error_copy (error);
-  if (section)
-    {
-      s = _gtk_css_section_to_string (section);
-      g_prefix_error (propagate_to, "%s", s);
-      g_free (s);
-    }
-}
-
 static gboolean
 parse_import (GtkCssScanner *scanner)
 {
@@ -1713,7 +1682,7 @@ gtk_css_provider_postprocess (GtkCssProvider *css_provider)
 #endif
 }
 
-static gboolean
+static void
 gtk_css_provider_load_internal (GtkCssProvider *css_provider,
                                 GtkCssScanner  *parent,
                                 GFile          *file,
@@ -1780,8 +1749,6 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
     }
 
   g_free (free_data);
-
-  return TRUE;
 }
 
 /**
@@ -1794,22 +1761,16 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
  *
  * Loads @data into @css_provider, and by doing so clears any previously loaded
  * information.
- *
- * Returns: %TRUE. The return value is deprecated and %FALSE will only be
- *     returned for backwards compatibility reasons if an @error is not 
- *     %NULL and a loading error occurred. To track errors while loading
- *     CSS, connect to the #GtkCssProvider::parsing-error signal.
  **/
-gboolean
+void
 gtk_css_provider_load_from_data (GtkCssProvider  *css_provider,
                                  const gchar     *data,
                                  gssize           length)
 {
   char *free_data;
-  gboolean ret;
 
-  g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
-  g_return_val_if_fail (data != NULL, FALSE);
+  g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
+  g_return_if_fail (data != NULL);
 
   if (length < 0)
     {
@@ -1824,13 +1785,11 @@ gtk_css_provider_load_from_data (GtkCssProvider  *css_provider,
 
   gtk_css_provider_reset (css_provider);
 
-  ret = gtk_css_provider_load_internal (css_provider, NULL, NULL, data);
+  gtk_css_provider_load_internal (css_provider, NULL, NULL, data);
 
   g_free (free_data);
 
   _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
-
-  return ret;
 }
 
 /**
@@ -1840,61 +1799,43 @@ gtk_css_provider_load_from_data (GtkCssProvider  *css_provider,
  *
  * Loads the data contained in @file into @css_provider, making it
  * clear any previously loaded information.
- *
- * Returns: %TRUE. The return value is deprecated and %FALSE will only be
- *     returned for backwards compatibility reasons if an @error is not 
- *     %NULL and a loading error occurred. To track errors while loading
- *     CSS, connect to the #GtkCssProvider::parsing-error signal.
  **/
-gboolean
+void
 gtk_css_provider_load_from_file (GtkCssProvider  *css_provider,
                                  GFile           *file)
 {
-  gboolean success;
-
-  g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
-  g_return_val_if_fail (G_IS_FILE (file), FALSE);
+  g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
+  g_return_if_fail (G_IS_FILE (file));
 
   gtk_css_provider_reset (css_provider);
 
-  success = gtk_css_provider_load_internal (css_provider, NULL, file, NULL);
+  gtk_css_provider_load_internal (css_provider, NULL, file, NULL);
 
   _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
-
-  return success;
 }
 
 /**
  * gtk_css_provider_load_from_path:
  * @css_provider: a #GtkCssProvider
  * @path: the path of a filename to load, in the GLib filename encoding
- * @error: (out) (allow-none): return location for a #GError, or %NULL
  *
  * Loads the data contained in @path into @css_provider, making it clear
  * any previously loaded information.
- *
- * Returns: %TRUE. The return value is deprecated and %FALSE will only be
- *     returned for backwards compatibility reasons if an @error is not 
- *     %NULL and a loading error occurred. To track errors while loading
- *     CSS, connect to the #GtkCssProvider::parsing-error signal.
  **/
-gboolean
+void
 gtk_css_provider_load_from_path (GtkCssProvider  *css_provider,
                                  const gchar     *path)
 {
   GFile *file;
-  gboolean result;
 
-  g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
-  g_return_val_if_fail (path != NULL, FALSE);
+  g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
+  g_return_if_fail (path != NULL);
 
   file = g_file_new_for_path (path);
   
-  result = gtk_css_provider_load_from_file (css_provider, file);
+  gtk_css_provider_load_from_file (css_provider, file);
 
   g_object_unref (file);
-
-  return result;
 }
 
 /**
diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h
index 4ed011a..a77c418 100644
--- a/gtk/gtkcssprovider.h
+++ b/gtk/gtkcssprovider.h
@@ -95,14 +95,14 @@ GDK_AVAILABLE_IN_3_2
 char *           gtk_css_provider_to_string      (GtkCssProvider  *provider);
 
 GDK_AVAILABLE_IN_ALL
-gboolean         gtk_css_provider_load_from_data (GtkCssProvider  *css_provider,
+void             gtk_css_provider_load_from_data (GtkCssProvider  *css_provider,
                                                   const gchar     *data,
                                                   gssize           length);
 GDK_AVAILABLE_IN_ALL
-gboolean         gtk_css_provider_load_from_file (GtkCssProvider  *css_provider,
+void             gtk_css_provider_load_from_file (GtkCssProvider  *css_provider,
                                                   GFile           *file);
 GDK_AVAILABLE_IN_ALL
-gboolean         gtk_css_provider_load_from_path (GtkCssProvider  *css_provider,
+void             gtk_css_provider_load_from_path (GtkCssProvider  *css_provider,
                                                   const gchar     *path);
 
 GDK_AVAILABLE_IN_3_16
diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c
index f38c453..98f662a 100644
--- a/tests/testiconview-keynav.c
+++ b/tests/testiconview-keynav.c
@@ -220,10 +220,7 @@ set_styles (void)
 
   provider = gtk_css_provider_new ();
 
-  if (!gtk_css_provider_load_from_data (provider, CSS, -1))
-    {
-      g_assert_not_reached ();
-    }
+  gtk_css_provider_load_from_data (provider, CSS, -1);
 
   screen = gdk_display_get_default_screen (gdk_display_get_default ());
 
diff --git a/testsuite/css/api.c b/testsuite/css/api.c
index 7f0b660..c44caa2 100644
--- a/testsuite/css/api.c
+++ b/testsuite/css/api.c
@@ -28,7 +28,7 @@ gtk_css_provider_load_data_not_null_terminated (void)
 
   p = gtk_css_provider_new();
 
-  gtk_css_provider_load_from_data(p, data, sizeof (data), NULL);
+  gtk_css_provider_load_from_data(p, data, sizeof (data));
 
   g_object_unref (p);
 }
diff --git a/testsuite/css/parser/test-css-parser.c b/testsuite/css/parser/test-css-parser.c
index a5bb173..ff63409 100644
--- a/testsuite/css/parser/test-css-parser.c
+++ b/testsuite/css/parser/test-css-parser.c
@@ -174,7 +174,7 @@ parse_css_file (GFile *file, gboolean generate)
                     "parsing-error",
                     G_CALLBACK (parsing_error_cb),
                     errors);
-  gtk_css_provider_load_from_path (provider, css_file, NULL);
+  gtk_css_provider_load_from_path (provider, css_file);
 
   css = gtk_css_provider_to_string (provider);
 
diff --git a/testsuite/css/style/test-css-style.c b/testsuite/css/style/test-css-style.c
index 53fac07..130132a 100644
--- a/testsuite/css/style/test-css-style.c
+++ b/testsuite/css/style/test-css-style.c
@@ -111,8 +111,7 @@ load_ui_file (GFile *file, gboolean generate)
   g_assert (css_file != NULL);
 
   provider = gtk_css_provider_new ();
-  gtk_css_provider_load_from_path (provider, css_file, &error);
-  g_assert_no_error (error);
+  gtk_css_provider_load_from_path (provider, css_file);
   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                              GTK_STYLE_PROVIDER (provider),
                                              GTK_STYLE_PROVIDER_PRIORITY_FORCE);
diff --git a/testsuite/gtk/stylecontext.c b/testsuite/gtk/stylecontext.c
index 91d6b8d..a32f104 100644
--- a/testsuite/gtk/stylecontext.c
+++ b/testsuite/gtk/stylecontext.c
@@ -11,7 +11,6 @@ static void
 test_parse_selectors (void)
 {
   GtkCssProvider *provider;
-  gboolean res;
   gint i;
   const gchar *valid[] = {
     "* {}",
@@ -60,8 +59,7 @@ test_parse_selectors (void)
   for (i = 0; valid[i]; i++)
     {
       provider = gtk_css_provider_new ();
-      res = gtk_css_provider_load_from_data (provider, valid[i], -1);
-      g_assert (res);
+      gtk_css_provider_load_from_data (provider, valid[i], -1);
 
       g_object_unref (provider);
    }
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index 4930af8..d8d82d6 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -219,8 +219,7 @@ add_extra_css (const char *testname,
 
   provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
   gtk_css_provider_load_from_path (GTK_CSS_PROVIDER (provider),
-                                   css_file,
-                                   NULL);
+                                   css_file);
   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                              provider,
                                              GTK_STYLE_PROVIDER_PRIORITY_FORCE);


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