[PATCH 3/6] gnome-control-center: Handle failure in rw_screen_new



The rw_screen_new() function may well return NULL. If it does
there is not much we can do, so we simply choose to report an
error to the user and quit.

This also allows localisation of the error dialogs when starting.

--- gnome-control-center-2.22.1/capplets/display/xrandr-capplet.c
2008-04-14 15:24:53.000000000 +0100
+++ gnome-control-center-2.22.1.new/capplets/display/xrandr-capplet.c
2008-04-14 15:25:37.000000000 +0100
@@ -1674,7 +1674,7 @@

GTK_DIALOG_DESTROY_WITH_PARENT,

GTK_MESSAGE_WARNING,
                                                     GTK_BUTTONS_OK,
-                                                    "The X Server does
not support the XRandR extension.  Runtime resolution changes to the
display size are not available."
+                                                    gettext("The X
Server does not support the XRandR extension.  Runtime resolution
changes to the display size are not available.")
                                                     );
         gtk_window_set_title (GTK_WINDOW (dialog), "");
         gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1688,7 +1688,7 @@

GTK_DIALOG_DESTROY_WITH_PARENT,

GTK_MESSAGE_WARNING,
                                                     GTK_BUTTONS_OK,
-                                                    "The version of the
XRandR extension is incompatible with this program. Runtime changes to
the display size are not available."
+                                                    gettext("The
version of the XRandR extension is incompatible with this program.
Runtime changes to the display size are not available.")
                                                     );
         gtk_window_set_title (GTK_WINDOW (dialog), "");
         gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1699,6 +1699,21 @@
     app->screen = rw_screen_new (gdk_screen_get_default(),
 				 on_screen_changed, app);
 
+    if (!(app->screen))
+    {
+        GtkWidget *dialog = gtk_message_dialog_new (
+                                                    NULL,
+
GTK_DIALOG_DESTROY_WITH_PARENT,
+
GTK_MESSAGE_WARNING,
+                                                    GTK_BUTTONS_OK,
+                                                    gettext("The X
Server does not support the XRandR extension.  Runtime resolution
changes to the display size are not available.")
+                                                    );
+        gtk_window_set_title (GTK_WINDOW (dialog), "");
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        return;
+    }
+
     app->dialog = glade_xml_get_widget (xml, "dialog");
     gtk_window_set_default_icon_name ("gnome-display-properties");
     gtk_window_set_icon_name (GTK_WINDOW (app->dialog),
"gnome-display-properties");




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