[recipes] Always allow editing your own data



commit ce434135446d81473e7612f1b9c97497e9d2de6e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 18 22:22:20 2017 -0500

    Always allow editing your own data
    
    Let users edit their own chef information, even if it
    is contributed.

 src/gr-chef-dialog.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-chef-dialog.c b/src/gr-chef-dialog.c
index 9c3a468..dec39a7 100644
--- a/src/gr-chef-dialog.c
+++ b/src/gr-chef-dialog.c
@@ -287,10 +287,19 @@ static void
 gr_chef_dialog_set_chef (GrChefDialog *self,
                          GrChef       *chef)
 {
-        GrChef *old_chef = self->chef;
+        gboolean same_chef;
+        GrRecipeStore *store;
 
         revert_changes (self);
 
+        store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
+
+        same_chef = self->chef != NULL && self->chef == chef;
+
+        if (gr_chef_is_readonly (chef) &&
+            strcmp (gr_chef_get_id (chef), gr_recipe_store_get_user_key (store)) == 0)
+                g_object_set (chef, "readonly", FALSE, NULL);
+
         if (g_set_object (&self->chef, chef)) {
                 const char *fullname;
                 const char *name;
@@ -325,7 +334,7 @@ gr_chef_dialog_set_chef (GrChefDialog *self,
                 update_image (self);
         }
 
-        if (old_chef != NULL && old_chef != chef)
+        if (same_chef)
                 gtk_widget_set_sensitive (self->save_button, TRUE);
         else
                 gtk_widget_set_sensitive (self->save_button, FALSE);


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