[recipes/wip/clone: 2/2] details: Add a "Copy" button
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/wip/clone: 2/2] details: Add a "Copy" button
- Date: Wed, 24 May 2017 02:45:13 +0000 (UTC)
commit 14a1cdc52f69e9e69768de29318e681f4b2ea12a
Author: Matthias Clasen <mclasen redhat com>
Date: Tue May 23 22:43:50 2017 -0400
details: Add a "Copy" button
This lets us make a copy of a recipe. We change the name
by appending '(copy)' and we make the current user the
author of the recipe.
src/gr-details-page.c | 21 +++++++++++++++++++++
src/gr-details-page.ui | 9 +++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 87b1d01..f632f0a 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -118,6 +118,26 @@ delete_recipe (GrDetailsPage *page)
}
static void
+copy_recipe (GrDetailsPage *page)
+{
+ GrRecipeStore *store;
+ GtkWidget *window;
+ g_autoptr(GrRecipe) clone = NULL;
+ g_autoptr(GError) error = NULL;
+
+ store = gr_recipe_store_get ();
+
+ clone = gr_recipe_clone (page->recipe, gr_recipe_store_get_user_key (store));
+ if (!gr_recipe_store_add_recipe (store, clone, &error)) {
+ g_warning ("Failed to add cloned recipe: %s", error->message);
+ return;
+ }
+
+ window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
+ gr_window_edit_recipe (GR_WINDOW (window), clone);
+}
+
+static void
edit_recipe (GrDetailsPage *page)
{
GtkWidget *window;
@@ -408,6 +428,7 @@ gr_details_page_class_init (GrDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, error_label);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, error_revealer);
+ gtk_widget_class_bind_template_callback (widget_class, copy_recipe);
gtk_widget_class_bind_template_callback (widget_class, edit_recipe);
gtk_widget_class_bind_template_callback (widget_class, delete_recipe);
gtk_widget_class_bind_template_callback (widget_class, more_recipes);
diff --git a/src/gr-details-page.ui b/src/gr-details-page.ui
index 1803c7c..4dd6059 100644
--- a/src/gr-details-page.ui
+++ b/src/gr-details-page.ui
@@ -481,6 +481,15 @@
</object>
</child>
<child>
+ <object class="GtkButton" id="copy_button">
+ <property name="visible">1</property>
+ <property name="use-underline">1</property>
+ <property name="focus-on-click">0</property>
+ <property name="label" translatable="yes">_Copy</property>
+ <signal name="clicked" handler="copy_recipe" swapped="true"/>
+ </object>
+ </child>
+ <child>
<object class="GtkButton" id="delete_button">
<property name="visible">1</property>
<property name="use-underline">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]