[gnome-control-center/wip/wayland-display: 1/2] Adapt to GnomeRR DBus rewrite
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/wayland-display: 1/2] Adapt to GnomeRR DBus rewrite
- Date: Fri, 26 Jul 2013 16:41:50 +0000 (UTC)
commit ed6b7bb970df83c65661699154e586733b17edd7
Author: Giovanni Campagna <gcampagn redhat com>
Date: Fri Jul 26 15:45:04 2013 +0200
Adapt to GnomeRR DBus rewrite
A number of APIs were changed to adapt GnomeRR to the new
mutter DBus API.
panels/display/cc-display-panel.c | 118 +++----------------------------------
panels/wacom/gsd-wacom-device.c | 73 +++++++++--------------
2 files changed, 38 insertions(+), 153 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 94e9263..7f4e92e 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -94,9 +94,6 @@ struct _CcDisplayPanelPrivate
GtkWidget *area;
gboolean ignore_gui_changes;
gboolean dragging_top_bar;
-
- /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
- GDBusProxy *proxy;
};
typedef struct
@@ -113,7 +110,6 @@ static gboolean output_overlaps (GnomeRROutputInfo *output, GnomeRRConfig *confi
static void select_current_output_from_dialog_position (CcDisplayPanel *self);
static void monitor_switch_active_cb (GObject *object, GParamSpec *pspec, gpointer data);
static void get_geometry (GnomeRROutputInfo *output, int *w, int *h);
-static void apply_configuration_returned_cb (GObject *proxy, GAsyncResult *res, gpointer data);
static gboolean get_clone_size (GnomeRRScreen *screen, int *width, int *height);
static gboolean output_info_supports_mode (CcDisplayPanel *self, GnomeRROutputInfo *info, int width, int
height);
static char *make_resolution_string (int width, int height);
@@ -2281,128 +2277,32 @@ check_required_virtual_size (CcDisplayPanel *self)
}
static void
-begin_version2_apply_configuration (CcDisplayPanel *self, GdkWindow *parent_window, guint32 timestamp)
-{
- XID parent_window_xid;
- GError *error = NULL;
-
- parent_window_xid = GDK_WINDOW_XID (parent_window);
-
- self->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "org.gnome.SettingsDaemon",
- "/org/gnome/SettingsDaemon/XRANDR",
- "org.gnome.SettingsDaemon.XRANDR_2",
- NULL,
- &error);
- if (self->priv->proxy == NULL) {
- error_message (self, _("Failed to apply configuration: %s"), error->message);
- g_error_free (error);
- return;
- }
-
- g_dbus_proxy_call (self->priv->proxy,
- "ApplyConfiguration",
- g_variant_new ("(xx)", (gint64) parent_window_xid, (gint64) timestamp),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- apply_configuration_returned_cb,
- self);
-}
-
-static void
-ensure_current_configuration_is_saved (void)
+sanitize_configuration (CcDisplayPanel *self)
{
- GnomeRRScreen *rr_screen;
- GnomeRRConfig *rr_config;
-
- /* Normally, gnome_rr_config_save() creates a backup file based on the
- * old monitors.xml. However, if *that* file didn't exist, there is
- * nothing from which to create a backup. So, here we'll save the
- * current/unchanged configuration and then let our caller call
- * gnome_rr_config_save() again with the new/changed configuration, so
- * that there *will* be a backup file in the end.
- */
-
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL); /* NULL-GError */
- if (!rr_screen)
- return;
-
- rr_config = gnome_rr_config_new_current (rr_screen, NULL);
- gnome_rr_config_ensure_primary (rr_config);
- gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
-
- g_object_unref (rr_config);
- g_object_unref (rr_screen);
-}
-
-static void
-apply_configuration_returned_cb (GObject *proxy,
- GAsyncResult *res,
- gpointer data)
-{
- CcDisplayPanel *self = data;
- GVariant *result;
- GError *error = NULL;
-
- result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error);
- if (error)
- error_message (self, _("Failed to apply configuration: %s"), error->message);
- g_clear_error (&error);
- if (result)
- g_variant_unref (result);
-
- g_object_unref (self->priv->proxy);
- self->priv->proxy = NULL;
-
- gtk_widget_set_sensitive (self->priv->panel, TRUE);
-}
-
-static gboolean
-sanitize_and_save_configuration (CcDisplayPanel *self)
-{
- GError *error;
-
gnome_rr_config_sanitize (self->priv->current_configuration);
gnome_rr_config_ensure_primary (self->priv->current_configuration);
check_required_virtual_size (self);
foo_scroll_area_invalidate (FOO_SCROLL_AREA (self->priv->area));
-
- ensure_current_configuration_is_saved ();
-
- error = NULL;
- if (!gnome_rr_config_save (self->priv->current_configuration, &error))
- {
- error_message (self, _("Could not save the monitor configuration"), error->message);
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
}
static void
apply (CcDisplayPanel *self)
{
- GdkWindow *window;
+ GError *error;
self->priv->apply_button_clicked_timestamp = gtk_get_current_event_time ();
- if (!sanitize_and_save_configuration (self))
- return;
+ sanitize_configuration (self);
- g_assert (self->priv->proxy == NULL);
-
- gtk_widget_set_sensitive (self->priv->panel, FALSE);
-
- window = gtk_widget_get_window (gtk_widget_get_toplevel (self->priv->panel));
+ error = NULL;
+ gnome_rr_config_apply_persistent (self->priv->current_configuration,
+ self->priv->screen, &error);
- begin_version2_apply_configuration (self, window,
- self->priv->apply_button_clicked_timestamp);
+ if (error)
+ error_message (self, _("Failed to apply configuration"), error->message);
+ g_clear_error (&error);
}
#if 0
diff --git a/panels/wacom/gsd-wacom-device.c b/panels/wacom/gsd-wacom-device.c
index e90371a..8a11477 100644
--- a/panels/wacom/gsd-wacom-device.c
+++ b/panels/wacom/gsd-wacom-device.c
@@ -523,35 +523,26 @@ find_output_by_edid (GnomeRRScreen *rr_screen, const gchar *vendor, const gchar
rr_outputs = gnome_rr_screen_list_outputs (rr_screen);
for (i = 0; rr_outputs[i] != NULL; i++) {
- gchar *o_vendor_s;
- gchar *o_product_s;
- int o_product;
- gchar *o_serial_s;
- int o_serial;
+ gchar *o_vendor;
+ gchar *o_product;
+ gchar *o_serial;
gboolean match;
- if (!gnome_rr_output_is_connected (rr_outputs[i]))
- continue;
-
- if (!gnome_rr_output_get_ids_from_edid (rr_outputs[i],
- &o_vendor_s,
- &o_product,
- &o_serial))
- continue;
-
- o_product_s = g_strdup_printf ("%d", o_product);
- o_serial_s = g_strdup_printf ("%d", o_serial);
+ gnome_rr_output_get_ids_from_edid (rr_outputs[i],
+ &o_vendor,
+ &o_product,
+ &o_serial);
g_debug ("Checking for match between '%s','%s','%s' and '%s','%s','%s'", \
- vendor, product, serial, o_vendor_s, o_product_s, o_serial_s);
+ vendor, product, serial, o_vendor, o_product, o_serial);
- match = (vendor == NULL || g_strcmp0 (vendor, o_vendor_s) == 0) && \
- (product == NULL || g_strcmp0 (product, o_product_s) == 0) && \
- (serial == NULL || g_strcmp0 (serial, o_serial_s) == 0);
+ match = (vendor == NULL || g_strcmp0 (vendor, o_vendor) == 0) && \
+ (product == NULL || g_strcmp0 (product, o_product) == 0) && \
+ (serial == NULL || g_strcmp0 (serial, o_serial) == 0);
- g_free (o_vendor_s);
- g_free (o_product_s);
- g_free (o_serial_s);
+ g_free (o_vendor);
+ g_free (o_product);
+ g_free (o_serial);
if (match) {
retval = rr_outputs[i];
@@ -575,9 +566,6 @@ find_builtin_output (GnomeRRScreen *rr_screen)
rr_outputs = gnome_rr_screen_list_outputs (rr_screen);
for (i = 0; rr_outputs[i] != NULL; i++) {
- if (!gnome_rr_output_is_connected (rr_outputs[i]))
- continue;
-
if (gnome_rr_output_is_builtin_display(rr_outputs[i])) {
retval = rr_outputs[i];
break;
@@ -701,8 +689,7 @@ set_display_by_output (GsdWacomDevice *device,
GVariant *c_array;
GVariant *n_array;
gsize nvalues;
- gchar *o_vendor_s, *o_product_s, *o_serial_s;
- int o_product, o_serial;
+ gchar *o_vendor, *o_product, *o_serial;
const gchar *values[3];
tablet = gsd_wacom_device_get_settings (device);
@@ -713,28 +700,26 @@ set_display_by_output (GsdWacomDevice *device,
return;
}
- if (rr_output == NULL ||
- !gnome_rr_output_get_ids_from_edid (rr_output,
- &o_vendor_s,
- &o_product,
- &o_serial)) {
- o_vendor_s = g_strdup ("");
- o_product_s = g_strdup ("");
- o_serial_s = g_strdup ("");
+ if (rr_output == NULL) {
+ o_vendor = g_strdup ("");
+ o_product = g_strdup ("");
+ o_serial = g_strdup ("");
} else {
- o_product_s = g_strdup_printf ("%d", o_product);
- o_serial_s = g_strdup_printf ("%d", o_serial);
+ gnome_rr_output_get_ids_from_edid (rr_output,
+ &o_vendor,
+ &o_product,
+ &o_serial);
}
- values[0] = o_vendor_s;
- values[1] = o_product_s;
- values[2] = o_serial_s;
+ values[0] = o_vendor;
+ values[1] = o_product;
+ values[2] = o_serial;
n_array = g_variant_new_strv ((const gchar * const *) &values, 3);
g_settings_set_value (tablet, "display", n_array);
- g_free (o_vendor_s);
- g_free (o_product_s);
- g_free (o_serial_s);
+ g_free (o_vendor);
+ g_free (o_product);
+ g_free (o_serial);
}
static GsdWacomRotation
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]