Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ZenWalker
Glade
Commits
d2045f1f
Commit
d2045f1f
authored
Nov 18, 2017
by
Juan Pablo Ugarte
Browse files
Add glade_utils_boolean_from_string() to the zoo
parent
16c7d337
Changes
2
Hide whitespace changes
Inline
Side-by-side
gladeui/glade-utils.c
View file @
d2045f1f
...
...
@@ -1587,6 +1587,53 @@ glade_utils_value_from_string (GType type,
return
NULL
;
}
/**
* glade_utils_boolean_from_string:
* @string: the string to convert
* @value: return location
*
* Parse a boolean value
*
* Returns: True if there was an error on the conversion.
*/
gboolean
glade_utils_boolean_from_string
(
const
gchar
*
string
,
gboolean
*
value
)
{
if
(
string
)
{
const
gchar
*
c
=
string
;
/* Skip white spaces */
while
(
g_ascii_isspace
(
*
c
))
c
++
;
/* We only need the first char */
switch
(
*
c
)
{
case
'1'
:
case
't'
:
case
'T'
:
case
'y'
:
case
'Y'
:
if
(
value
)
*
value
=
TRUE
;
return
FALSE
;
break
;
case
'0'
:
case
'f'
:
case
'F'
:
case
'n'
:
case
'N'
:
if
(
value
)
*
value
=
FALSE
;
return
FALSE
;
break
;
}
}
return
TRUE
;
}
/**
* glade_utils_string_from_value:
...
...
gladeui/glade-utils.h
View file @
d2045f1f
...
...
@@ -67,6 +67,8 @@ GValue *glade_utils_value_from_string (GType type,
const
gchar
*
string
,
GladeProject
*
project
);
gchar
*
glade_utils_string_from_value
(
const
GValue
*
value
);
gboolean
glade_utils_boolean_from_string
(
const
gchar
*
string
,
gboolean
*
value
);
/* Devhelp */
gboolean
glade_util_have_devhelp
(
void
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment