[gnome-settings-daemon/docking-stations] Extract function to apply a stored configuration or auto-configure the outputs
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/docking-stations] Extract function to apply a stored configuration or auto-configure the outputs
- Date: Wed, 9 Nov 2011 23:30:53 +0000 (UTC)
commit efc7c5e2c3d4e16e54bbeafdde67dfc2bd1bf3b5
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Nov 9 17:19:28 2011 -0600
Extract function to apply a stored configuration or auto-configure the outputs
We'll need this shortly.
Signed-off-by: Federico Mena Quintero <federico gnome org>
plugins/xrandr/gsd-xrandr-manager.c | 82 +++++++++++++++++++----------------
1 files changed, 44 insertions(+), 38 deletions(-)
---
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 169cd5e..7938181 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -1578,6 +1578,49 @@ auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp)
}
static void
+use_stored_configuration_or_auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp)
+{
+ GsdXrandrManagerPrivate *priv = manager->priv;
+ char *intended_filename;
+ GError *error;
+ gboolean success;
+
+ intended_filename = gnome_rr_config_get_intended_filename ();
+
+ error = NULL;
+ success = apply_configuration_from_filename (manager, intended_filename, TRUE, timestamp, &error);
+ g_free (intended_filename);
+
+ if (!success) {
+ /* We don't bother checking the error type.
+ *
+ * Both G_FILE_ERROR_NOENT and
+ * GNOME_RR_ERROR_NO_MATCHING_CONFIG would mean, "there
+ * was no configuration to apply, or none that matched
+ * the current outputs", and in that case we need to run
+ * our fallback.
+ *
+ * Any other error means "we couldn't do the smart thing
+ * of using a previously- saved configuration, anyway,
+ * for some other reason. In that case, we also need to
+ * run our fallback to avoid leaving the user with a
+ * bogus configuration.
+ */
+
+ if (error)
+ g_error_free (error);
+
+ if (timestamp != priv->last_config_timestamp) {
+ priv->last_config_timestamp = timestamp;
+ auto_configure_outputs (manager, timestamp);
+ log_msg (" Automatically configured outputs\n");
+ } else
+ log_msg (" Ignored autoconfiguration as old and new config timestamps are the same\n");
+ } else
+ log_msg ("Applied stored configuration\n");
+}
+
+static void
on_randr_event (GnomeRRScreen *screen, gpointer data)
{
GsdXrandrManager *manager = GSD_XRANDR_MANAGER (data);
@@ -1626,45 +1669,8 @@ on_randr_event (GnomeRRScreen *screen, gpointer data)
* outputs in a sane way.
*/
- char *intended_filename;
- GError *error;
- gboolean success;
-
show_timestamps_dialog (manager, "need to deal with reconfiguration, as config > change");
-
- intended_filename = gnome_rr_config_get_intended_filename ();
-
- error = NULL;
- success = apply_configuration_from_filename (manager, intended_filename, TRUE, config_timestamp, &error);
- g_free (intended_filename);
-
- if (!success) {
- /* We don't bother checking the error type.
- *
- * Both G_FILE_ERROR_NOENT and
- * GNOME_RR_ERROR_NO_MATCHING_CONFIG would mean, "there
- * was no configuration to apply, or none that matched
- * the current outputs", and in that case we need to run
- * our fallback.
- *
- * Any other error means "we couldn't do the smart thing
- * of using a previously- saved configuration, anyway,
- * for some other reason. In that case, we also need to
- * run our fallback to avoid leaving the user with a
- * bogus configuration.
- */
-
- if (error)
- g_error_free (error);
-
- if (config_timestamp != priv->last_config_timestamp) {
- priv->last_config_timestamp = config_timestamp;
- auto_configure_outputs (manager, config_timestamp);
- log_msg (" Automatically configured outputs to deal with event\n");
- } else
- log_msg (" Ignored event as old and new config timestamps are the same\n");
- } else
- log_msg ("Applied stored configuration to deal with event\n");
+ use_stored_configuration_or_auto_configure_outputs (manager, config_timestamp);
}
log_close ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]