[recipes] Add a default-image field to GrRecipe



commit fc6b9117f2a7e8d8f5b0b5be16957f8532d263d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 28 10:02:26 2017 +0100

    Add a default-image field to GrRecipe
    
    This will be used to mark an image as the default one to be used
    in tiles, etc.

 src/gr-recipe.c |   22 ++++++++++++++++++++++
 src/gr-recipe.h |    1 +
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe.c b/src/gr-recipe.c
index 83f28d8..3567ee6 100644
--- a/src/gr-recipe.c
+++ b/src/gr-recipe.c
@@ -38,6 +38,7 @@ struct _GrRecipe
         char *author;
         char *description;
         GArray *images;
+        int default_image;
 
         char *cuisine;
         char *season;
@@ -75,6 +76,7 @@ enum {
         PROP_AUTHOR,
         PROP_DESCRIPTION,
         PROP_IMAGES,
+        PROP_DEFAULT_IMAGE,
         PROP_CUISINE,
         PROP_SEASON,
         PROP_CATEGORY,
@@ -153,6 +155,10 @@ gr_recipe_get_property (GObject    *object,
                 g_value_set_boxed (value, self->images);
                 break;
 
+        case PROP_DEFAULT_IMAGE:
+                g_value_set_int (value, self->default_image);
+                break;
+
         case PROP_CATEGORY:
                 g_value_set_string (value, self->category);
                 break;
@@ -287,6 +293,11 @@ gr_recipe_set_property (GObject      *object,
                 update_mtime (self);
                 break;
 
+        case PROP_DEFAULT_IMAGE:
+                self->default_image = g_value_get_int (value);
+                update_mtime (self);
+                break;
+
         case PROP_CATEGORY:
                 g_free (self->category);
                 self->category = g_value_dup_string (value);
@@ -417,6 +428,11 @@ gr_recipe_class_init (GrRecipeClass *klass)
                                      G_PARAM_READWRITE);
         g_object_class_install_property (object_class, PROP_IMAGES, pspec);
 
+        pspec = g_param_spec_int ("default-image", NULL, NULL,
+                                  0, G_MAXINT, 0,
+                                  G_PARAM_READWRITE);
+        g_object_class_install_property (object_class, PROP_DEFAULT_IMAGE, pspec);
+
         pspec = g_param_spec_string ("category", NULL, NULL,
                                      NULL,
                                      G_PARAM_READWRITE);
@@ -641,6 +657,12 @@ gr_recipe_get_mtime (GrRecipe *recipe)
         return recipe->mtime;
 }
 
+int
+gr_recipe_get_default_image (GrRecipe *recipe)
+{
+        return recipe->default_image;
+}
+
 gboolean
 gr_recipe_is_readonly (GrRecipe *recipe)
 {
diff --git a/src/gr-recipe.h b/src/gr-recipe.h
index 1c5a662..daaaf44 100644
--- a/src/gr-recipe.h
+++ b/src/gr-recipe.h
@@ -50,6 +50,7 @@ gboolean        gr_recipe_contains_garlic  (GrRecipe   *recipe);
 gboolean        gr_recipe_contains_dairy   (GrRecipe   *recipe);
 gboolean        gr_recipe_contains_gluten  (GrRecipe   *recipe);
 int             gr_recipe_get_spiciness    (GrRecipe   *recipe);
+int             gr_recipe_get_default_image (GrRecipe   *recipe);
 GDateTime      *gr_recipe_get_ctime        (GrRecipe   *recipe);
 GDateTime      *gr_recipe_get_mtime        (GrRecipe   *recipe);
 gboolean        gr_recipe_is_readonly      (GrRecipe   *recipe);


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