bnc472226 (RANDR) - Put the D-bus connection and proxy in the main App structure, not in local variables.

We'll need this to maintain state for the D-bus async callback.

Signed-off-by: Federico Mena Quintero <federico@novell.com>

svn path=/trunk/; revision=9241
This commit is contained in:
Federico Mena Quintero 2009-02-05 21:20:40 +00:00 committed by Federico Mena Quintero
parent 18edc5202f
commit 5e0e21f11e

View file

@ -62,6 +62,11 @@ struct App
GtkWidget *area; GtkWidget *area;
gboolean ignore_gui_changes; gboolean ignore_gui_changes;
GConfClient *client; GConfClient *client;
/* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
DBusGConnection *connection;
DBusGProxy *proxy;
}; };
static void rebuild_gui (App *app); static void rebuild_gui (App *app);
@ -1709,8 +1714,6 @@ static void
apply (App *app) apply (App *app)
{ {
GError *error = NULL; GError *error = NULL;
DBusGConnection *connection;
DBusGProxy *proxy;
gnome_rr_config_sanitize (app->current_configuration); gnome_rr_config_sanitize (app->current_configuration);
@ -1725,30 +1728,37 @@ apply (App *app)
return; return;
} }
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); g_assert (app->connection == NULL);
if (connection == NULL) { g_assert (app->proxy == NULL);
app->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (app->connection == NULL) {
error_message (app, _("Could not get session bus while applying display configuration"), error->message); error_message (app, _("Could not get session bus while applying display configuration"), error->message);
g_error_free (error); g_error_free (error);
return; return;
} }
proxy = dbus_g_proxy_new_for_name (connection, app->proxy = dbus_g_proxy_new_for_name (app->connection,
"org.gnome.SettingsDaemon", "org.gnome.SettingsDaemon",
"/org/gnome/SettingsDaemon/XRANDR", "/org/gnome/SettingsDaemon/XRANDR",
"org.gnome.SettingsDaemon.XRANDR"); "org.gnome.SettingsDaemon.XRANDR");
if (!proxy) { if (!app->proxy) {
error_message (app, _("Could not get org.gnome.SettingsDaemon.XRANDR"), NULL); error_message (app, _("Could not get org.gnome.SettingsDaemon.XRANDR"), NULL);
dbus_g_connection_unref (app->connection);
app->connection = NULL;
return; return;
} }
if (!dbus_g_proxy_call (proxy, "ApplyConfiguration", &error, G_TYPE_INVALID, G_TYPE_INVALID)) { if (!dbus_g_proxy_call (app->proxy, "ApplyConfiguration", &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
error_message (app, _("Could not apply the selected configuration"), error->message); error_message (app, _("Could not apply the selected configuration"), error->message);
g_error_free (error); g_error_free (error);
} }
g_object_unref (proxy); g_object_unref (app->proxy);
dbus_g_connection_unref (connection); app->proxy = NULL;
dbus_g_connection_unref (app->connection);
app->connection = NULL;
} }
#if 0 #if 0