From 3d01f29bd9ce1322a0dc6043ba01d9ba9b4ef7ab Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 7 Sep 2015 12:43:19 -0400 Subject: [PATCH] builder: Move a function Move _gtk_builder_boolean_from_string in the same source file as the other _from_functions. --- gtk/gtkbuilder.c | 46 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkbuilderparser.c | 46 ------------------------------------------ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index caf7610ec4..0f04ed72e8 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -2265,6 +2265,52 @@ _gtk_builder_flags_from_string (GType type, return ret; } +gboolean +_gtk_builder_boolean_from_string (const gchar *string, + gboolean *value, + GError **error) +{ + gboolean retval = TRUE; + int length; + + g_assert (string != NULL); + length = strlen (string); + + if (length == 0) + retval = FALSE; + else if (length == 1) + { + gchar c = g_ascii_tolower (string[0]); + if (c == 'y' || c == 't' || c == '1') + *value = TRUE; + else if (c == 'n' || c == 'f' || c == '0') + *value = FALSE; + else + retval = FALSE; + } + else + { + gchar *lower = g_ascii_strdown (string, length); + + if (strcmp (lower, "yes") == 0 || strcmp (lower, "true") == 0) + *value = TRUE; + else if (strcmp (lower, "no") == 0 || strcmp (lower, "false") == 0) + *value = FALSE; + else + retval = FALSE; + g_free (lower); + } + + if (!retval) + g_set_error (error, + GTK_BUILDER_ERROR, + GTK_BUILDER_ERROR_INVALID_VALUE, + "Could not parse boolean '%s'", + string); + + return retval; +} + /** * gtk_builder_get_type_from_name: * @builder: a #GtkBuilder diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 0f34d3a4c3..49c04d25f3 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -120,52 +120,6 @@ error_unhandled_tag (ParserData *data, data->filename, line, col, tag); } -gboolean -_gtk_builder_boolean_from_string (const gchar *string, - gboolean *value, - GError **error) -{ - gboolean retval = TRUE; - int length; - - g_assert (string != NULL); - length = strlen (string); - - if (length == 0) - retval = FALSE; - else if (length == 1) - { - gchar c = g_ascii_tolower (string[0]); - if (c == 'y' || c == 't' || c == '1') - *value = TRUE; - else if (c == 'n' || c == 'f' || c == '0') - *value = FALSE; - else - retval = FALSE; - } - else - { - gchar *lower = g_ascii_strdown (string, length); - - if (strcmp (lower, "yes") == 0 || strcmp (lower, "true") == 0) - *value = TRUE; - else if (strcmp (lower, "no") == 0 || strcmp (lower, "false") == 0) - *value = FALSE; - else - retval = FALSE; - g_free (lower); - } - - if (!retval) - g_set_error (error, - GTK_BUILDER_ERROR, - GTK_BUILDER_ERROR_INVALID_VALUE, - "Could not parse boolean '%s'", - string); - - return retval; -} - static GObject * builder_construct (ParserData *data, ObjectInfo *object_info,