[gnome-shell] shell-app: don't recreate a session proxy every time



commit b8830f4a0920ce8d47a69fca5cf60f1e7640927b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Apr 3 14:15:17 2013 -0400

    shell-app: don't recreate a session proxy every time
    
    Cache the connection inside the ShellAppRunningState structure instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697207

 src/shell-app.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 1f8d6f0..5462573 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -42,7 +42,8 @@ typedef struct {
   /* See GApplication documentation */
   GDBusMenuModel   *remote_menu;
   GActionMuxer     *muxer;
-  char * unique_bus_name;
+  char             *unique_bus_name;
+  GDBusConnection  *session;
 } ShellAppRunningState;
 
 /**
@@ -554,7 +555,7 @@ shell_app_update_window_actions (ShellApp *app, MetaWindow *window)
       actions = g_object_get_data (G_OBJECT (window), "actions");
       if (actions == NULL)
         {
-          actions = G_ACTION_GROUP (g_dbus_action_group_get (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
+          actions = G_ACTION_GROUP (g_dbus_action_group_get (app->running_state->session,
                                                              meta_window_get_gtk_unique_bus_name (window),
                                                              object_path));
           g_object_set_data_full (G_OBJECT (window), "actions", actions, g_object_unref);
@@ -1218,6 +1219,8 @@ create_running_state (ShellApp *app)
   app->running_state->workspace_switch_id =
     g_signal_connect (screen, "workspace-switched", G_CALLBACK(shell_app_on_ws_switch), app);
 
+  app->running_state->session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+  g_assert (app->running_state->session != NULL);
   app->running_state->muxer = g_action_muxer_new ();
 }
 
@@ -1244,7 +1247,6 @@ shell_app_update_app_menu (ShellApp   *app,
     {
       const gchar *application_object_path;
       const gchar *app_menu_object_path;
-      GDBusConnection *session;
       GDBusActionGroup *actions;
 
       application_object_path = meta_window_get_gtk_application_object_path (window);
@@ -1253,16 +1255,13 @@ shell_app_update_app_menu (ShellApp   *app,
       if (application_object_path == NULL || app_menu_object_path == NULL || unique_bus_name == NULL)
         return;
 
-      session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-      g_assert (session != NULL);
       g_clear_pointer (&app->running_state->unique_bus_name, g_free);
       app->running_state->unique_bus_name = g_strdup (unique_bus_name);
       g_clear_object (&app->running_state->remote_menu);
-      app->running_state->remote_menu = g_dbus_menu_model_get (session, unique_bus_name, 
app_menu_object_path);
-      actions = g_dbus_action_group_get (session, unique_bus_name, application_object_path);
+      app->running_state->remote_menu = g_dbus_menu_model_get (app->running_state->session, unique_bus_name, 
app_menu_object_path);
+      actions = g_dbus_action_group_get (app->running_state->session, unique_bus_name, 
application_object_path);
       g_action_muxer_insert (app->running_state->muxer, "app", G_ACTION_GROUP (actions));
       g_object_unref (actions);
-      g_object_unref (session);
     }
 }
 
@@ -1282,6 +1281,7 @@ unref_running_state (ShellAppRunningState *state)
 
   g_clear_object (&state->remote_menu);
   g_clear_object (&state->muxer);
+  g_clear_object (&state->session);
   g_clear_pointer (&state->unique_bus_name, g_free);
   g_clear_pointer (&state->remote_menu, g_free);
 


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