diff -Nur -x '*.orig' -x '*~' gnome-control-center-2.22.0/capplets/display/xrandr-capplet.c gnome-control-center-2.22.0.new/capplets/display/xrandr-capplet.c --- gnome-control-center-2.22.0/capplets/display/xrandr-capplet.c 2008-04-02 21:29:50.000000000 +0200 +++ gnome-control-center-2.22.0.new/capplets/display/xrandr-capplet.c 2008-04-02 21:40:03.000000000 +0200 @@ -19,6 +19,10 @@ * Author: Soren Sandmann */ +#include + +#include +#include #include #include #include @@ -30,6 +32,8 @@ #include #include +#define REVERT_COUNT 20 + typedef struct App App; struct App @@ -313,10 +319,10 @@ const char * name; } RotationInfo; static const RotationInfo rotations[] = { - { RW_ROTATION_0, "Normal" }, - { RW_ROTATION_90, "Left" }, - { RW_ROTATION_270, "Right" }, - { RW_ROTATION_180, "Upside Down" }, + { RW_ROTATION_0, N_("Normal") }, + { RW_ROTATION_90, N_("Left") }, + { RW_ROTATION_270, N_("Right") }, + { RW_ROTATION_180, N_("Upside Down") }, }; const char *selection; RWRotation current; @@ -351,7 +357,7 @@ app->current_output->rotation = current; if (!(selection && combo_select (app->rotation_combo, selection))) - combo_select (app->rotation_combo, "Normal"); + combo_select (app->rotation_combo, _("Normal")); } #define idle_free_printf(x) idle_free (g_strdup_printf (x)) @@ -434,11 +440,11 @@ } } - add_key (app->resolution_combo, "Off", 0, 0, 0, 0); + add_key (app->resolution_combo, _("Off"), 0, 0, 0, 0); if (!app->current_output->on) { - current = "Off"; + current = _("Off"); } else { @@ -824,18 +830,129 @@ } } -static Atom -gnome_randr_atom (void) +struct TimeoutData { + int time; + GtkLabel *label; + GtkDialog *dialog; + gboolean timed_out; +}; + +static char * +timeout_string (int time) +{ + return g_strdup_printf (_("Testing the new settings. If you don't respond in %d second the previous settings will be restored."), time); +} + +static gboolean +save_timeout_callback (gpointer _data) { - static Atom atom = None; + struct TimeoutData *data = _data; + char *str; - if (!atom) + data->time--; + + if (data->time == 0) { - atom = XInternAtom (gdk_x11_get_default_xdisplay(), - "_GNOME_RANDR_ATOM", FALSE); + gtk_dialog_response (data->dialog, GTK_RESPONSE_NO); + data->timed_out = TRUE; + return FALSE; } - return atom; + str = timeout_string (data->time); + gtk_label_set_text (data->label, str); + g_free (str); + + return TRUE; +} + +static int +run_revert_dialog () +{ + GtkWidget *dialog; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *label_sec; + GtkWidget *image; + int res; + struct TimeoutData timeout_data; + guint timeout; + char *str; + + dialog = gtk_dialog_new (); + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 12); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_window_set_title (GTK_WINDOW (dialog), _("Keep Settings")); + gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS); + + label = gtk_label_new (NULL); + str = g_strdup_printf ("%s", _("Do you want to keep these screen settings?")); + gtk_label_set_markup (GTK_LABEL (label), str); + g_free (str); + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); + + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + + str = timeout_string (REVERT_COUNT); + label_sec = gtk_label_new (str); + g_free (str); + gtk_label_set_line_wrap (GTK_LABEL (label_sec), TRUE); + gtk_label_set_selectable (GTK_LABEL (label_sec), TRUE); + gtk_misc_set_alignment (GTK_MISC (label_sec), 0.0, 0.5); + + hbox = gtk_hbox_new (FALSE, 6); + vbox = gtk_vbox_new (FALSE, 6); + + gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), label_sec, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); + gtk_dialog_add_buttons (GTK_DIALOG (dialog),_("Use _previous settings"), GTK_RESPONSE_NO, _("_Keep settings"), GTK_RESPONSE_YES, NULL); + + gtk_widget_show_all (hbox); + + timeout_data.time = REVERT_COUNT; + timeout_data.label = GTK_LABEL (label_sec); + timeout_data.dialog = GTK_DIALOG (dialog); + timeout_data.timed_out = FALSE; + + timeout = g_timeout_add (1000, save_timeout_callback, &timeout_data); + res = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (!timeout_data.timed_out) + g_source_remove (timeout); + + gtk_widget_destroy (dialog); + + return res == GTK_RESPONSE_YES; +} + +static Atom +get_x_atom (char *atom_name) +{ + return gdk_x11_atom_to_xatom (gdk_atom_intern(atom_name, FALSE)); +} + +static void +send_xrandr_update_message (char *atom_name) +{ + XEvent message; + + message.xclient.type = ClientMessage; + message.xclient.message_type = get_x_atom (atom_name); + message.xclient.format = 8; + + g_print ("Sending event (name = %s)\n",atom_name); + + XSendEvent (gdk_x11_get_default_xdisplay(), + gdk_x11_get_default_root_xwindow(), + FALSE, + StructureNotifyMask, &message); } static void @@ -843,20 +960,22 @@ { GError *err = NULL; - if (configuration_save (app->current_configuration, &err)) - { - XEvent message; + if ( ! configuration_save_test (app->current_configuration, &err)) { + g_warning("Fail to save test configuration file"); + return; + } - message.xclient.type = ClientMessage; - message.xclient.message_type = gnome_randr_atom(); - message.xclient.format = 8; + send_xrandr_update_message("_GNOME_RANDR_TEST_ATOM"); - g_print ("Sending client message\n"); + if ( ! run_revert_dialog () ) { + g_print("Reverting to original configuration\n"); + send_xrandr_update_message ("_GNOME_RANDR_ATOM"); + return; + } - XSendEvent (gdk_x11_get_default_xdisplay(), - gdk_x11_get_default_root_xwindow(), - FALSE, - StructureNotifyMask, &message); + if ( ! configuration_save (app->current_configuration, &err)) { + g_warning("Fail to save configuration file"); + return; } } @@ -892,7 +1011,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." + _("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)); @@ -906,7 +1025,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." + _("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)); @@ -995,11 +1115,9 @@ { App *app; -#if 0 - bindtextdomain (GETTEXT_PACKAGE, DESKTOPEFFECTSLOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); -#endif gtk_init (&argc, &argv); diff -Nur -x '*.orig' -x '*~' gnome-control-center-2.22.0/po/POTFILES.in gnome-control-center-2.22.0.new/po/POTFILES.in --- gnome-control-center-2.22.0/po/POTFILES.in 2008-01-29 13:56:35.000000000 +0100 +++ gnome-control-center-2.22.0.new/po/POTFILES.in 2008-04-02 21:41:49.000000000 +0200 @@ -35,8 +35,9 @@ capplets/default-applications/gnome-da-capplet.c capplets/default-applications/gnome-default-applications-properties.glade capplets/default-applications/gnome-default-applications.xml.in +capplets/display/display-capplet.glade capplets/display/display-properties.desktop.in.in -capplets/display/main.c +capplets/display/xrandr-capplet.c capplets/keybindings/00-multimedia-key.xml.in capplets/keybindings/01-desktop-key.xml.in capplets/keybindings/eggcellrendererkeys.c