[gnome-control-center/randr-hotplug: 5/5] Use the timestamp of the Apply button to change the RANDR configuration



commit 74e06ac80e3c34b416ca0a72615dfa11398b8d33
Author: Federico Mena Quintero <federico novell com>
Date:   Sat May 30 20:47:42 2009 -0500

    Use the timestamp of the Apply button to change the RANDR configuration
    
    There is no timestamp available when the dialog returns from gtk_dialog_run().
    So, we save the timestamp at the time the Apply button is clicked.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>
---
 capplets/display/display-capplet.glade |    2 +-
 capplets/display/xrandr-capplet.c      |   23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/capplets/display/display-capplet.glade b/capplets/display/display-capplet.glade
index 712cb49..d94770b 100644
--- a/capplets/display/display-capplet.glade
+++ b/capplets/display/display-capplet.glade
@@ -45,7 +45,7 @@
 	  </child>
 
 	  <child>
-	    <widget class="GtkButton" id="button1">
+	    <widget class="GtkButton" id="apply_button">
 	      <property name="visible">True</property>
 	      <property name="can_default">True</property>
 	      <property name="can_focus">True</property>
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 015feaf..8bfc303 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -59,6 +59,10 @@ struct App
     GtkWidget	   *clone_checkbox;
     GtkWidget	   *show_icon_checkbox;
 
+    /* We store the event timestamp when the Apply button is clicked */
+    GtkWidget      *apply_button;
+    guint32         apply_button_clicked_timestamp;
+
     GtkWidget      *area;
     gboolean	    ignore_gui_changes;
     GConfClient	   *client;
@@ -1886,7 +1890,7 @@ apply (App *app)
 
     gtk_widget_set_sensitive (app->dialog, FALSE);
 
-    begin_version2_apply_configuration (app, gtk_widget_get_window (app->dialog), gtk_get_current_event_time ());
+    begin_version2_apply_configuration (app, gtk_widget_get_window (app->dialog), app->apply_button_clicked_timestamp);
 }
 
 #if 0
@@ -2092,6 +2096,19 @@ hide_help_button (App *app)
 }
 
 static void
+apply_button_clicked_cb (GtkButton *button, gpointer data)
+{
+    App *app = data;
+
+    /* We simply store the timestamp at which the Apply button was clicked.
+     * We'll just wait for the dialog to return from gtk_dialog_run(), and
+     * *then* use the timestamp when applying the RANDR configuration.
+     */
+
+    app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
+}
+
+static void
 run_application (App *app)
 {
 #ifndef GLADEDIR
@@ -2194,6 +2211,10 @@ run_application (App *app)
     /* Until we have help to show, we'll just hide the Help button */
     hide_help_button (app);
 
+    app->apply_button = glade_xml_get_widget (xml, "apply_button");
+    g_signal_connect (app->apply_button, "clicked",
+		      G_CALLBACK (apply_button_clicked_cb), app);
+
     on_screen_changed (app->screen, app);
 
     g_object_unref (xml);



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