gnome-settings-daemon r799 - in trunk: . plugins/xrandr



Author: federico
Date: Wed Mar 25 21:12:00 2009
New Revision: 799
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=799&view=rev

Log:
(RANDR) - Centralize handling of GNOME_RR_ERROR_NO_MATCHING_CONFIG, as that is not really an error

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

Modified:
   trunk/ChangeLog
   trunk/plugins/xrandr/gsd-xrandr-manager.c

Modified: trunk/plugins/xrandr/gsd-xrandr-manager.c
==============================================================================
--- trunk/plugins/xrandr/gsd-xrandr-manager.c	(original)
+++ trunk/plugins/xrandr/gsd-xrandr-manager.c	Wed Mar 25 21:12:00 2009
@@ -109,6 +109,33 @@
 
 static gpointer manager_object = NULL;
 
+/* Filters out GNOME_RR_ERROR_NO_MATCHING_CONFIG from
+ * gnome_rr_config_apply_from_filename(), since that is not usually an error.
+ */
+static gboolean
+apply_configuration_from_filename (GsdXrandrManager *manager, const char *filename, GError **error)
+{
+        struct GsdXrandrManagerPrivate *priv = manager->priv;
+        GError *my_error;
+        gboolean success;
+
+        my_error = NULL;
+        success = gnome_rr_config_apply_from_filename (priv->rw_screen, filename, &my_error);
+        if (success)
+                return TRUE;
+
+        if (g_error_matches (my_error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_MATCHING_CONFIG)) {
+                /* This is not an error; the user probably changed his monitors
+                 * and so they don't match any of the stored configurations.
+                 */
+                g_error_free (my_error);
+                return TRUE;
+        }
+
+        g_propagate_error (error, my_error);
+        return FALSE;
+}
+
 static void
 restore_backup_configuration_without_messages (const char *backup_filename, const char *intended_filename)
 {
@@ -127,7 +154,7 @@
                 GError *error;
 
                 error = NULL;
-                if (!gnome_rr_config_apply_from_filename (priv->rw_screen, intended_filename, &error)) {
+                if (!apply_configuration_from_filename (manager, intended_filename, &error)) {
                         error_message (manager, _("Could not restore the display's configuration"), error, NULL);
 
                         if (error)
@@ -257,7 +284,7 @@
         backup_filename = gnome_rr_config_get_backup_filename ();
         intended_filename = gnome_rr_config_get_intended_filename ();
 
-        result = gnome_rr_config_apply_from_filename (priv->rw_screen, intended_filename, error);
+        result = apply_configuration_from_filename (manager, intended_filename, error);
         if (!result) {
                 error_message (manager, _("The selected configuration for displays could not be applied"), error ? *error : NULL, NULL);
                 restore_backup_configuration_without_messages (backup_filename, intended_filename);
@@ -1320,14 +1347,9 @@
         GError *my_error;
 
         my_error = NULL;
-        if (!gnome_rr_config_apply_from_filename (manager->priv->rw_screen, intended_filename, &my_error)) {
+        if (!apply_configuration_from_filename (manager, intended_filename, &my_error)) {
                 if (my_error) {
-                        if (g_error_matches (my_error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_MATCHING_CONFIG)) {
-                                /* This is not an error; the user probably
-                                 * changed his monitors and then logged in
-                                 * again, thus restarting gnome-settings-daemon.
-                                 */
-                        } else if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+                        if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
                                 error_message (manager, _("Could not apply the stored configuration for monitors"), my_error, NULL);
 
                         g_error_free (my_error);
@@ -1354,7 +1376,7 @@
 
         my_error = NULL;
 
-        success = gnome_rr_config_apply_from_filename (manager->priv->rw_screen, backup_filename, &my_error);
+        success = apply_configuration_from_filename (manager, backup_filename, &my_error);
         if (success) {
                 /* The backup configuration existed, and could be applied
                  * successfully, so we must restore it on top of the



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]