[recipes] Populate the my chef dialog from account portal



commit 128b2728b5e9829f323d83916cbc54d431db4a6b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 12 17:53:36 2017 -0500

    Populate the my chef dialog from account portal
    
    This is using the new account information api.

 src/gr-window.c |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index 8cf498f..e089336 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -39,6 +39,7 @@
 #include "gr-query-editor.h"
 #include "gr-recipe-importer.h"
 #include "gr-about-dialog.h"
+#include "gr-account.h"
 
 
 struct _GrWindow
@@ -685,6 +686,36 @@ chef_done (GrChefDialog *dialog,
         gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
+static void
+present_my_chef_dialog (GrWindow *window,
+                        GrChef   *chef)
+{
+        window->chef_dialog = (GtkWidget *)gr_chef_dialog_new (chef, FALSE);
+        gtk_window_set_title (GTK_WINDOW (window->chef_dialog), _("My Chef Information"));
+        g_signal_connect (window->chef_dialog, "done", G_CALLBACK (chef_done), window);
+        gr_window_present_dialog (window, GTK_WINDOW (window->chef_dialog));
+}
+
+static void
+got_account_info (const char  *id,
+                  const char  *name,
+                  const char  *image_path,
+                  gpointer     data,
+                  GError     **error)
+{
+        g_autoptr(GrChef) chef = NULL;
+        GrWindow *window = data;
+
+        chef = gr_chef_new ();
+        g_object_set (chef,
+                      "id", id,
+                      "fullname", name,
+                      "image-path", image_path,
+                      NULL);
+
+        present_my_chef_dialog (window, chef);
+}
+
 void
 gr_window_show_my_chef_information (GrWindow *window)
 {
@@ -702,14 +733,12 @@ gr_window_show_my_chef_information (GrWindow *window)
         if (id != NULL && id[0] != '\0')
                 chef = gr_recipe_store_get_chef (store, id);
 
-        if (chef == NULL)
-                chef = gr_chef_new ();
-
-        window->chef_dialog = (GtkWidget *)gr_chef_dialog_new (chef, FALSE);
-        gtk_window_set_title (GTK_WINDOW (window->chef_dialog), _("My Chef Information"));
-        g_signal_connect (window->chef_dialog, "done", G_CALLBACK (chef_done), window);
+        if (chef) {
+                present_my_chef_dialog (window, chef);
+                return;
+        }
 
-        gr_window_present_dialog (window, GTK_WINDOW (window->chef_dialog));
+        gr_account_get_information (GTK_WINDOW (window), got_account_info, window, NULL);
 }
 
 void


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