[gnome-builder] greeter: show error message on open failure



commit f87a724c91b21aae75d287942be65ee1a76eecfe
Author: Christian Hergert <chergert redhat com>
Date:   Sat Dec 5 02:06:56 2015 -0800

    greeter: show error message on open failure

 libide/greeter/ide-greeter-perspective.c |   35 +++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/libide/greeter/ide-greeter-perspective.c b/libide/greeter/ide-greeter-perspective.c
index ff94242..aeb12f1 100644
--- a/libide/greeter/ide-greeter-perspective.c
+++ b/libide/greeter/ide-greeter-perspective.c
@@ -409,6 +409,35 @@ ide_greeter_perspective_filter_row (GtkListBoxRow *row,
 }
 
 static void
+ide_greeter_perspective_open_project_cb (GObject      *object,
+                                         GAsyncResult *result,
+                                         gpointer      user_data)
+{
+  IdeWorkbench *workbench = (IdeWorkbench *)object;
+  g_autoptr(GError) error = NULL;
+
+  g_assert (IDE_IS_WORKBENCH (workbench));
+
+  if (!ide_workbench_open_project_finish (workbench, result, &error))
+    {
+      GtkWidget *dialog;
+
+      dialog = gtk_message_dialog_new (NULL,
+                                       GTK_DIALOG_USE_HEADER_BAR,
+                                       GTK_MESSAGE_ERROR,
+                                       GTK_BUTTONS_CLOSE,
+                                       _("Failed to load the project"));
+      g_object_set (dialog,
+                    "secondary-text", error->message,
+                    NULL);
+
+      gtk_dialog_run (GTK_DIALOG (dialog));
+      gtk_widget_destroy (dialog);
+      gtk_widget_destroy (GTK_WIDGET (workbench));
+    }
+}
+
+static void
 ide_greeter_perspective__row_activated (IdeGreeterPerspective *self,
                                         IdeGreeterProjectRow  *row,
                                         GtkListBox            *list_box)
@@ -441,7 +470,11 @@ ide_greeter_perspective__row_activated (IdeGreeterPerspective *self,
    */
 
   workbench = ide_widget_get_workbench (GTK_WIDGET (self));
-  ide_workbench_open_project_async (workbench, project_file, NULL, NULL, NULL);
+  ide_workbench_open_project_async (workbench,
+                                    project_file,
+                                    NULL,
+                                    ide_greeter_perspective_open_project_cb,
+                                    NULL);
 
   ide_project_info_set_is_recent (project_info, TRUE);
 }


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