[recipes] Add api to get nicknames for chefs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add api to get nicknames for chefs
- Date: Wed, 14 Dec 2016 02:12:50 +0000 (UTC)
commit 44af372de7df1dff7efcb875d0f6e45a511d3c63
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 13 21:11:18 2016 -0500
Add api to get nicknames for chefs
Storage still tbh.
src/gr-chef.c | 31 +++++++++++++++++++++++++++++++
src/gr-chef.h | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-chef.c b/src/gr-chef.c
index 7475617..a431b06 100644
--- a/src/gr-chef.c
+++ b/src/gr-chef.c
@@ -31,6 +31,7 @@
typedef struct
{
char *name;
+ char *nickname;
char *fullname;
char *description;
char *image_path;
@@ -41,6 +42,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GrChef, gr_chef, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_NAME,
+ PROP_NICKNAME,
PROP_FULLNAME,
PROP_DESCRIPTION,
PROP_IMAGE_PATH,
@@ -54,6 +56,7 @@ gr_chef_finalize (GObject *object)
GrChefPrivate *priv = gr_chef_get_instance_private (self);
g_free (priv->name);
+ g_free (priv->nickname);
g_free (priv->fullname);
g_free (priv->description);
g_free (priv->image_path);
@@ -75,6 +78,10 @@ gr_chef_get_property (GObject *object,
g_value_set_string (value, priv->name);
break;
+ case PROP_NICKNAME:
+ g_value_set_string (value, priv->nickname);
+ break;
+
case PROP_FULLNAME:
g_value_set_string (value, priv->fullname);
break;
@@ -107,6 +114,11 @@ gr_chef_set_property (GObject *object,
priv->name = g_value_dup_string (value);
break;
+ case PROP_NICKNAME:
+ g_free (priv->nickname);
+ priv->nickname = g_value_dup_string (value);
+ break;
+
case PROP_FULLNAME:
g_free (priv->fullname);
priv->fullname = g_value_dup_string (value);
@@ -141,6 +153,11 @@ gr_chef_class_init (GrChefClass *klass)
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_NAME, pspec);
+ pspec = g_param_spec_string ("nickname", NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_NICKNAME, pspec);
+
pspec = g_param_spec_string ("fullname", NULL, NULL,
NULL,
G_PARAM_READWRITE);
@@ -177,6 +194,20 @@ gr_chef_get_name (GrChef *chef)
}
const char *
+gr_chef_get_nickname (GrChef *chef)
+{
+ GrChefPrivate *priv = gr_chef_get_instance_private (chef);
+
+ if (!priv->nickname) {
+ g_auto(GStrv) strv = NULL;
+ strv = g_strsplit (priv->fullname, " ", 0);
+ priv->nickname = g_strdup (strv[0]);
+ }
+
+ return priv->nickname;
+}
+
+const char *
gr_chef_get_fullname (GrChef *chef)
{
GrChefPrivate *priv = gr_chef_get_instance_private (chef);
diff --git a/src/gr-chef.h b/src/gr-chef.h
index d636193..96d8366 100644
--- a/src/gr-chef.h
+++ b/src/gr-chef.h
@@ -35,6 +35,7 @@ struct _GrChefClass
GrChef *gr_chef_new (void);
const char *gr_chef_get_name (GrChef *chef);
+const char *gr_chef_get_nickname (GrChef *chef);
const char *gr_chef_get_fullname (GrChef *chef);
const char *gr_chef_get_description (GrChef *chef);
const char *gr_chef_get_image (GrChef *chef);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]