[gnome-shell/T27795: 62/138] shell-app: Propagate errors when activating an application



commit 13fc78c83904cbc4a7286d1e0987c22c6d7de2ed
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Tue Jul 9 12:48:27 2013 -0700

    shell-app: Propagate errors when activating an application
    
    This way we can e.g. avoid showing a splash page when launching fails.
    
    [endlessm/eos-shell#528]

 src/shell-app.c | 18 +++++++++++-------
 src/shell-app.h |  6 ++++--
 2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 49946fafda..5e39c121e1 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -470,14 +470,16 @@ shell_app_update_window_actions (ShellApp *app, MetaWindow *window)
 /**
  * shell_app_activate:
  * @app: a #ShellApp
+ * @error: a #GError
  *
  * Like shell_app_activate_full(), but using the default workspace and
  * event timestamp.
  */
 void
-shell_app_activate (ShellApp      *app)
+shell_app_activate (ShellApp      *app,
+                    GError       **error)
 {
-  return shell_app_activate_full (app, -1, 0);
+  return shell_app_activate_full (app, -1, 0, error);
 }
 
 /**
@@ -486,6 +488,7 @@ shell_app_activate (ShellApp      *app)
  * @workspace: launch on this workspace, or -1 for default. Ignored if
  *   activating an existing window
  * @timestamp: Event timestamp
+ * @error: a #GError
  *
  * Perform an appropriate default action for operating on this application,
  * dependent on its current state.  For example, if the application is not
@@ -496,7 +499,8 @@ shell_app_activate (ShellApp      *app)
 void
 shell_app_activate_full (ShellApp      *app,
                          int            workspace,
-                         guint32        timestamp)
+                         guint32        timestamp,
+                         GError       **error)
 {
   ShellGlobal *global;
 
@@ -509,16 +513,16 @@ shell_app_activate_full (ShellApp      *app,
     {
       case SHELL_APP_STATE_STOPPED:
         {
-          GError *error = NULL;
-          if (!shell_app_launch (app, timestamp, workspace, FALSE, &error))
+          GError *my_error = NULL;
+          if (!shell_app_launch (app, timestamp, workspace, FALSE, &my_error))
             {
               char *msg;
               msg = g_strdup_printf (_("Failed to launch ā€œ%sā€"), shell_app_get_name (app));
               shell_global_notify_error (global,
                                          msg,
-                                         error->message);
+                                         my_error->message);
               g_free (msg);
-              g_clear_error (&error);
+              g_propagate_error (error, my_error);
             }
         }
         break;
diff --git a/src/shell-app.h b/src/shell-app.h
index 8a09b642dc..6c3f30f9eb 100644
--- a/src/shell-app.h
+++ b/src/shell-app.h
@@ -29,11 +29,13 @@ gboolean shell_app_is_window_backed (ShellApp *app);
 
 void shell_app_activate_window (ShellApp *app, MetaWindow *window, guint32 timestamp);
 
-void shell_app_activate (ShellApp      *app);
+void shell_app_activate (ShellApp      *app,
+                         GError       **error);
 
 void shell_app_activate_full (ShellApp      *app,
                               int            workspace,
-                              guint32        timestamp);
+                              guint32        timestamp,
+                              GError       **error);
 
 void shell_app_open_new_window (ShellApp *app,
                                 int       workspace);


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