Commit 924fb4ec authored by Debarshi Ray's avatar Debarshi Ray

Don't freeze the UI when launching Settings -> Online Accounts

The UI freezes for a moment when launching Settings -> Online Accounts
because g_application_register does slow I/O. After creating the
GApplication's GDBusActionGroup, it queries the list of remote actions
from the primary application instance over D-Bus to populate it.
Fortunately, it's not necessary to fill in the GDBusActionGroup for
activating a GAction. Therefore, this can be solved by directly using
a GDBusActionGroup instead of going via a launcher GApplication.

This does lose the platform data that the launcher GApplication would
have passed when invoking the remote GAction, but hopefully that
won't prove crucial.

The loss of error handling doesn't matter. g_application_register was
the only fallible step, and it could have only failed while querying
the list of actions from the primary, something that's not needed
anyway. If anything, it simplifies the code.

Fallout from 556a9f30
parent 0b05ddd4
...@@ -55,16 +55,7 @@ photos_empty_results_box_activate_link (PhotosEmptyResultsBox *self, const gchar ...@@ -55,16 +55,7 @@ photos_empty_results_box_activate_link (PhotosEmptyResultsBox *self, const gchar
if (g_strcmp0 (uri, "system-settings") != 0) if (g_strcmp0 (uri, "system-settings") != 0)
goto out; goto out;
{ photos_utils_launch_online_accounts (NULL);
g_autoptr (GError) error = NULL;
if (!photos_utils_launch_online_accounts (NULL, &error))
{
g_warning ("Unable to open Online Accounts panel: %s", error->message);
goto out;
}
}
ret_val = TRUE; ret_val = TRUE;
out: out:
......
...@@ -94,19 +94,7 @@ photos_source_notification_settings_clicked (PhotosSourceNotification *self) ...@@ -94,19 +94,7 @@ photos_source_notification_settings_clicked (PhotosSourceNotification *self)
account = goa_object_peek_account (object); account = goa_object_peek_account (object);
id = goa_account_get_id (account); id = goa_account_get_id (account);
photos_utils_launch_online_accounts (id);
{
g_autoptr (GError) error = NULL;
if (!photos_utils_launch_online_accounts (id, &error))
{
g_warning ("Unable to open Online Accounts panel: %s", error->message);
goto out;
}
}
out:
return;
} }
......
...@@ -1077,19 +1077,18 @@ photos_utils_get_version (void) ...@@ -1077,19 +1077,18 @@ photos_utils_get_version (void)
} }
gboolean void
photos_utils_launch_online_accounts (const gchar *account_id, GError **error) photos_utils_launch_online_accounts (const gchar *account_id)
{ {
g_autoptr (GApplication) control_center = NULL; GApplication *app;
g_autoptr (GDBusActionGroup) control_center = NULL;
GDBusConnection *connection;
GVariant *parameters; GVariant *parameters;
g_auto (GVariantBuilder) panel_parameters = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("av")); g_auto (GVariantBuilder) panel_parameters = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("av"));
gboolean ret_val = FALSE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); app = g_application_get_default ();
connection = g_application_get_dbus_connection (app);
control_center = g_application_new ("org.gnome.ControlCenter", G_APPLICATION_IS_LAUNCHER); control_center = g_dbus_action_group_get (connection, "org.gnome.ControlCenter", "/org/gnome/ControlCenter");
if (!g_application_register (control_center, NULL, error))
goto out;
if (account_id != NULL && account_id[0] != '\0') if (account_id != NULL && account_id[0] != '\0')
{ {
...@@ -1101,11 +1100,6 @@ photos_utils_launch_online_accounts (const gchar *account_id, GError **error) ...@@ -1101,11 +1100,6 @@ photos_utils_launch_online_accounts (const gchar *account_id, GError **error)
parameters = g_variant_new ("(s@av)", "online-accounts", g_variant_builder_end (&panel_parameters)); parameters = g_variant_new ("(s@av)", "online-accounts", g_variant_builder_end (&panel_parameters));
g_action_group_activate_action (G_ACTION_GROUP (control_center), "launch-panel", parameters); g_action_group_activate_action (G_ACTION_GROUP (control_center), "launch-panel", parameters);
ret_val = TRUE;
out:
return ret_val;
} }
......
...@@ -146,7 +146,7 @@ GList *photos_utils_get_urns_from_items (GList *items); ...@@ -146,7 +146,7 @@ GList *photos_utils_get_urns_from_items (GList *items);
const gchar *photos_utils_get_version (void); const gchar *photos_utils_get_version (void);
gboolean photos_utils_launch_online_accounts (const gchar *account_id, GError **error); void photos_utils_launch_online_accounts (const gchar *account_id);
void photos_utils_list_box_header_func (GtkListBoxRow *row, void photos_utils_list_box_header_func (GtkListBoxRow *row,
GtkListBoxRow *before, GtkListBoxRow *before,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment