[recipes] Simplify the chef dialog api



commit 29ca46594fdafe05e532231a7a208a3fb6dbd0cd
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 9 19:25:33 2017 -0500

    Simplify the chef dialog api
    
    No need to pass the window into the constructor, and no
    need for an extra can_create setter.

 src/gr-chef-dialog.c |   31 +++++++++++++++----------------
 src/gr-chef-dialog.h |    4 +---
 src/gr-edit-page.c   |    6 +++---
 3 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/src/gr-chef-dialog.c b/src/gr-chef-dialog.c
index 2228434..ab1ca06 100644
--- a/src/gr-chef-dialog.c
+++ b/src/gr-chef-dialog.c
@@ -326,21 +326,6 @@ gr_chef_dialog_class_init (GrChefDialogClass *klass)
         gtk_widget_class_bind_template_callback (widget_class, field_changed);
 }
 
-GrChefDialog *
-gr_chef_dialog_new (GtkWindow *win,
-                    GrChef    *chef)
-{
-        GrChefDialog *dialog;
-
-        dialog = g_object_new (GR_TYPE_CHEF_DIALOG,
-                               "transient-for", win,
-                               NULL);
-
-        gr_chef_dialog_set_chef (dialog, chef);
-
-        return dialog;
-}
-
 static void
 add_chef_row (GrChefDialog *dialog,
               GrChef       *chef)
@@ -401,7 +386,7 @@ populate_chef_list (GrChefDialog *dialog)
         add_chef_row (dialog, NULL);
 }
 
-void
+static void
 gr_chef_dialog_can_create (GrChefDialog *dialog,
                            gboolean      create)
 {
@@ -419,6 +404,20 @@ gr_chef_dialog_can_create (GrChefDialog *dialog,
         }
 }
 
+GrChefDialog *
+gr_chef_dialog_new (GrChef   *chef,
+                    gboolean  create)
+{
+        GrChefDialog *dialog;
+
+        dialog = g_object_new (GR_TYPE_CHEF_DIALOG, NULL);
+
+        gr_chef_dialog_set_chef (dialog, chef);
+        gr_chef_dialog_can_create (dialog, create);
+
+        return dialog;
+}
+
 GrChef *
 gr_chef_dialog_get_chef (GrChefDialog *dialog)
 {
diff --git a/src/gr-chef-dialog.h b/src/gr-chef-dialog.h
index bb55998..13bcf82 100644
--- a/src/gr-chef-dialog.h
+++ b/src/gr-chef-dialog.h
@@ -30,9 +30,7 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GrChefDialog, gr_chef_dialog, GR, CHEF_DIALOG, GtkWindow)
 
-GrChefDialog *gr_chef_dialog_new (GtkWindow *win,
-                                  GrChef    *chef);
-void          gr_chef_dialog_can_create (GrChefDialog *dialog,
+GrChefDialog *gr_chef_dialog_new        (GrChef       *chef,
                                          gboolean      create);
 GrChef       *gr_chef_dialog_get_chef   (GrChefDialog *dialog);
 
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index 69ae7be..a6dd7b5 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -46,6 +46,7 @@
 #include "gr-unit.h"
 #include "gr-chef-dialog.h"
 #include "gr-cooking-view.h"
+#include "gr-window.h"
 
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
@@ -1149,12 +1150,11 @@ edit_chef (GrEditPage *page)
         author = page->author;
         chef = gr_recipe_store_get_chef (store, author ? author : "");
 
-        dialog = gr_chef_dialog_new (GTK_WINDOW (win), chef);
-        gr_chef_dialog_can_create (dialog, TRUE);
+        dialog = gr_chef_dialog_new (chef, TRUE);
         g_signal_connect (dialog, "done", G_CALLBACK (chef_done), page);
 
         gtk_window_set_title (GTK_WINDOW (dialog), _("Recipe Author"));
-        gtk_window_present (GTK_WINDOW (dialog));
+        gr_window_present_dialog (GR_WINDOW (win), GTK_WINDOW (dialog));
 
         return TRUE;
 }


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