35
35
#include <gdk/gdkx.h>
36
36
#include <X11/Xlib.h>
37
37
#include <glib/gi18n.h>
38
#include <dbus/dbus-glib.h>
39
#include <dbus/dbus-glib-bindings.h>
40
38
#include <gdesktop-enums.h>
42
40
G_DEFINE_DYNAMIC_TYPE (CcDisplayPanel, cc_display_panel, CC_TYPE_PANEL)
114
110
static void select_current_output_from_dialog_position (CcDisplayPanel *self);
115
111
static void monitor_switch_active_cb (GObject *object, GParamSpec *pspec, gpointer data);
116
112
static void get_geometry (GnomeRROutputInfo *output, int *w, int *h);
117
static void apply_configuration_returned_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, void *data);
113
static void apply_configuration_returned_cb (GObject *proxy, GAsyncResult *res, gpointer data);
118
114
static gboolean get_clone_size (GnomeRRScreen *screen, int *width, int *height);
119
115
static gboolean output_info_supports_mode (CcDisplayPanel *self, GnomeRROutputInfo *info, int width, int height);
120
116
static char *make_resolution_string (int width, int height);
474
470
const char * name;
476
472
static const RotationInfo rotations[] = {
477
{ GNOME_RR_ROTATION_0, N_("Normal") },
478
{ GNOME_RR_ROTATION_90, N_("Counterclockwise") },
479
{ GNOME_RR_ROTATION_270, N_("Clockwise") },
480
{ GNOME_RR_ROTATION_180, N_("180 Degrees") },
473
{ GNOME_RR_ROTATION_0, NC_("display panel, rotation", "Normal") },
474
{ GNOME_RR_ROTATION_90, NC_("display panel, rotation", "Counterclockwise") },
475
{ GNOME_RR_ROTATION_270, NC_("display panel, rotation", "Clockwise") },
476
{ GNOME_RR_ROTATION_180, NC_("display panel, rotation", "180 Degrees") },
482
478
const char *selection;
483
479
GnomeRRRotation current;
513
509
gnome_rr_output_info_set_rotation (self->priv->current_output, current);
515
511
if (!(selection && combo_select (self->priv->rotation_combo, selection)))
516
combo_select (self->priv->rotation_combo, _(rotations[0].name));
512
gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->rotation_combo), 0);
2250
2246
begin_version2_apply_configuration (CcDisplayPanel *self, GdkWindow *parent_window, guint32 timestamp)
2252
2248
XID parent_window_xid;
2249
GError *error = NULL;
2254
2251
parent_window_xid = GDK_WINDOW_XID (parent_window);
2256
self->priv->proxy = dbus_g_proxy_new_for_name (self->priv->connection,
2257
"org.gnome.SettingsDaemon",
2258
"/org/gnome/SettingsDaemon/XRANDR",
2259
"org.gnome.SettingsDaemon.XRANDR_2");
2260
g_assert (self->priv->proxy != NULL); /* that call does not fail unless we pass bogus names */
2253
self->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
2254
G_DBUS_PROXY_FLAGS_NONE,
2256
"org.gnome.SettingsDaemon",
2257
"/org/gnome/SettingsDaemon/XRANDR",
2258
"org.gnome.SettingsDaemon.XRANDR_2",
2261
if (self->priv->proxy == NULL) {
2262
error_message (self, _("Failed to apply configuration: %s"), error->message);
2263
g_error_free (error);
2262
self->priv->proxy_call = dbus_g_proxy_begin_call (self->priv->proxy, "ApplyConfiguration",
2263
apply_configuration_returned_cb, self,
2265
G_TYPE_INT64, (gint64) parent_window_xid,
2266
G_TYPE_INT64, (gint64) timestamp,
2269
/* FIXME: we don't check for self->priv->proxy_call == NULL, which could happen if
2270
* the connection was disconnected. This is left as an exercise for the
2267
g_dbus_proxy_call (self->priv->proxy,
2268
"ApplyConfiguration",
2269
g_variant_new ("(xx)", (gint64) parent_window_xid, (gint64) timestamp),
2270
G_DBUS_CALL_FLAGS_NONE,
2273
apply_configuration_returned_cb,
2298
2300
g_object_unref (rr_screen);
2301
/* Callback for dbus_g_proxy_begin_call() */
2303
apply_configuration_returned_cb (DBusGProxy *proxy,
2304
DBusGProxyCall *call_id,
2304
apply_configuration_returned_cb (GObject *proxy,
2307
2308
CcDisplayPanel *self = data;
2311
g_assert (call_id == self->priv->proxy_call);
2314
success = dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
2317
/* We don't pop up an error message; gnome-settings-daemon already does that
2318
* in case the selected RANDR configuration could not be applied.
2320
g_error_free (error);
2310
GError *error = NULL;
2312
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error);
2314
error_message (self, _("Failed to apply configuration: %s"), error->message);
2315
g_clear_error (&error);
2317
g_variant_unref (result);
2323
2319
g_object_unref (self->priv->proxy);
2324
2320
self->priv->proxy = NULL;
2326
dbus_g_connection_unref (self->priv->connection);
2327
self->priv->connection = NULL;
2328
self->priv->proxy_call = NULL;
2330
2322
gtk_widget_set_sensitive (self->priv->panel, TRUE);
2366
2357
if (!sanitize_and_save_configuration (self))
2369
g_assert (self->priv->connection == NULL);
2370
2360
g_assert (self->priv->proxy == NULL);
2371
g_assert (self->priv->proxy_call == NULL);
2373
self->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
2374
if (self->priv->connection == NULL) {
2375
error_message (self, _("Could not get session bus while applying display configuration"), error->message);
2376
g_error_free (error);
2380
2362
gtk_widget_set_sensitive (self->priv->panel, FALSE);