Index: src/vte-private.h
===================================================================
--- src/vte-private.h	(révision 2021)
+++ src/vte-private.h	(copie de travail)
@@ -293,10 +293,11 @@ struct _VteTerminalPrivate {
 
 	/* Cursor blinking. */
 	gboolean cursor_blink_state;
-	gboolean cursor_blinks;
-	guint cursor_blink_tag;
-	gint cursor_blink_timeout;
-	gint64 cursor_blink_time;
+	guint cursor_blink_tag;    /* cursor blinking timeout ID */
+	gboolean cursor_blinks;    /* gtk-cursor-blink */
+        gint cursor_blink_cycle;   /* gtk-cursor-blink-time / 2 */
+	gint cursor_blink_timeout; /* gtk-cursor-blink-timeout */
+	gint64 cursor_blink_time;  /* how long the cursor has been blinking yet */
 	gboolean cursor_visible;
 
 	/* Input device options. */
Index: src/vte.c
===================================================================
--- src/vte.c	(révision 2021)
+++ src/vte.c	(copie de travail)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include "../config.h"
+#include <config.h>
 
 #include <math.h>
 
@@ -122,6 +122,7 @@ static void vte_terminal_add_process_tim
 static void add_update_timeout (VteTerminal *terminal);
 static void remove_update_timeout (VteTerminal *terminal);
 static void reset_update_regions (VteTerminal *terminal);
+static void vte_terminal_set_cursor_blinks_internal(VteTerminal *terminal, gboolean blink);
 
 static gboolean process_timeout (gpointer data);
 static gboolean update_timeout (gpointer data);
@@ -732,64 +733,27 @@ _vte_invalidate_cursor_once(VteTerminal 
 static gboolean
 vte_invalidate_cursor_periodic (VteTerminal *terminal)
 {
-	GtkSettings *settings;
-	int blink_cycle = 1000;
-	int timeout = INT_MAX;
-	static gboolean have_timeout;
-	static gboolean have_queried_timeout;
-
-	settings = gtk_widget_get_settings (&terminal->widget);
+        VteTerminalPrivate *pvt = terminal->pvt;
 
-	terminal->pvt->cursor_blink_state = !terminal->pvt->cursor_blink_state;
-	terminal->pvt->cursor_blink_time += terminal->pvt->cursor_blink_timeout;
+	pvt->cursor_blink_state = !pvt->cursor_blink_state;
+	pvt->cursor_blink_time += pvt->cursor_blink_cycle;
 
 	_vte_invalidate_cursor_once(terminal, TRUE);
 
-	if (settings == NULL)
-		return TRUE;
-
-	/* Temporary hack to prevent GObject complaining about missing
-	 * properties on the GtkSettings object.  This hack should be
-	 * removed once VTE depends on a version of GTK which includes
-	 * gtk-cursor-blink-timeout.
-	 */
-	if (!have_queried_timeout)
-	{
-		GObjectClass *oclass;
-		GParamSpec *param;
-
-		oclass = G_OBJECT_GET_CLASS (settings);
-		param = g_object_class_find_property (oclass,
-					      "gtk-cursor-blink-timeout");
-
-		have_timeout = (param != NULL);
-		have_queried_timeout = TRUE;
-	}
-
-	if (have_timeout)
-		g_object_get (G_OBJECT (settings), "gtk-cursor-blink-timeout",
-			      &timeout, NULL);
-
 	/* only disable the blink if the cursor is currently shown.
 	 * else, wait until next time.
 	 */
-	if (terminal->pvt->cursor_blink_time / 1000 >= timeout &&
-	    terminal->pvt->cursor_blink_state)
+	if (pvt->cursor_blink_time / 1000 >= pvt->cursor_blink_timeout &&
+	    pvt->cursor_blink_state) {
+                pvt->cursor_blink_tag = 0;
 		return FALSE;
+        }
 
-	g_object_get (G_OBJECT (settings), "gtk-cursor-blink-time",
-		      &blink_cycle, NULL);
-	blink_cycle /= 2;
-
-	if (terminal->pvt->cursor_blink_timeout == blink_cycle)
-		return TRUE;
-
-	terminal->pvt->cursor_blink_timeout = blink_cycle;
-	terminal->pvt->cursor_blink_tag = g_timeout_add_full(G_PRIORITY_LOW,
-							     terminal->pvt->cursor_blink_timeout,
-							     (GSourceFunc)vte_invalidate_cursor_periodic,
-							     terminal,
-							     NULL);
+	pvt->cursor_blink_tag = g_timeout_add_full(G_PRIORITY_LOW,
+						   terminal->pvt->cursor_blink_cycle,
+						   (GSourceFunc)vte_invalidate_cursor_periodic,
+						   terminal,
+						   NULL);
 	return FALSE;
 }
 
@@ -4122,20 +4086,9 @@ vte_terminal_style_changed(GtkWidget *wi
 static void
 add_cursor_timeout (VteTerminal *terminal)
 {
-	GtkSettings *settings;
-
-	/* Setup cursor blink */
-	settings = gtk_widget_get_settings(&terminal->widget);
-	if (settings != NULL) {
-		gint blink_cycle = 1000;
-		g_object_get(G_OBJECT(settings), "gtk-cursor-blink-time",
-			     &blink_cycle, NULL);
-		terminal->pvt->cursor_blink_timeout = blink_cycle / 2;
-	}
-
 	terminal->pvt->cursor_blink_time = 0;
 	terminal->pvt->cursor_blink_tag = g_timeout_add_full(G_PRIORITY_LOW,
-							     terminal->pvt->cursor_blink_timeout,
+							     terminal->pvt->cursor_blink_cycle,
 							     (GSourceFunc)vte_invalidate_cursor_periodic,
 							     terminal,
 							     NULL);
@@ -7777,6 +7730,64 @@ vte_terminal_unrealize(GtkWidget *widget
 	GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
 }
 
+static void
+vte_terminal_sync_settings (GtkSettings *settings,
+                            GParamSpec *pspec,
+                            VteTerminal *terminal)
+{
+        VteTerminalPrivate *pvt = terminal->pvt;
+        gboolean blink;
+        int blink_time = 1000;
+        int blink_timeout = G_MAXINT;
+
+        g_object_get (G_OBJECT (settings),
+                      "gtk-cursor-blink", &blink,
+#if GTK_CHECK_VERSION (2, 12, 0)
+                      "gtk-cursor-blink-time", &blink_time,
+                      "gtk-cursor-blink-timeout", &blink_timeout,
+#endif
+                      NULL);
+
+	pvt->cursor_blink_cycle = blink_time / 2;
+        pvt->cursor_blink_timeout = blink_timeout;
+
+        vte_terminal_set_cursor_blinks_internal (terminal, blink);
+}
+
+static void
+vte_terminal_screen_changed (GtkWidget *widget, GdkScreen *previous_screen)
+{
+        GdkScreen *screen;
+        GtkSettings *settings;
+
+        screen = gtk_widget_get_screen (widget);
+        if (previous_screen != NULL &&
+            (screen != previous_screen || screen == NULL)) {
+                settings = gtk_settings_get_for_screen (previous_screen);
+                g_signal_handlers_disconnect_matched (settings, G_SIGNAL_MATCH_DATA,
+                                                      0, 0, NULL, NULL,
+                                                      widget);
+        }
+
+        if (GTK_WIDGET_CLASS (vte_terminal_parent_class)->screen_changed) {
+                GTK_WIDGET_CLASS (vte_terminal_parent_class)->screen_changed (widget, previous_screen);
+        }
+
+        if (screen == previous_screen)
+                return;
+
+        settings = gtk_widget_get_settings (widget);
+        vte_terminal_sync_settings (settings, NULL, VTE_TERMINAL (widget));
+        g_signal_connect (settings, "notify::gtk-cursor-blink",
+                          G_CALLBACK (vte_terminal_sync_settings), widget);
+#if GTK_CHECK_VERSION (2, 12, 0)
+        g_signal_connect (settings, "notify::gtk-cursor-blink-time",
+                          G_CALLBACK (vte_terminal_sync_settings), widget);
+        g_signal_connect (settings, "notify::gtk-cursor-blink-timeout",
+                          G_CALLBACK (vte_terminal_sync_settings), widget);
+#endif
+}
+
 /* Perform final cleanups for the widget before it's freed. */
 static void
 vte_terminal_finalize(GObject *object)
@@ -7784,6 +7795,7 @@ vte_terminal_finalize(GObject *object)
 	VteTerminal *terminal;
 	GtkWidget *toplevel;
 	GtkClipboard *clipboard;
+        GtkSettings *settings;
 	struct vte_match_regex *regex;
 	guint i;
 
@@ -7947,6 +7959,11 @@ vte_terminal_finalize(GObject *object)
 		g_object_unref(terminal->adjustment);
 	}
 
+        settings = gtk_widget_get_settings (GTK_WIDGET (terminal));
+        g_signal_handlers_disconnect_matched (settings, G_SIGNAL_MATCH_DATA,
+                                              0, 0, NULL, NULL,
+                                              terminal);
+
 	/* Call the inherited finalize() method. */
 	G_OBJECT_CLASS(vte_terminal_parent_class)->finalize(object);
 }
@@ -10475,6 +10492,7 @@ vte_terminal_class_init(VteTerminalClass
 	widget_class->size_request = vte_terminal_size_request;
 	widget_class->size_allocate = vte_terminal_size_allocate;
 	widget_class->get_accessible = vte_terminal_get_accessible;
+        widget_class->screen_changed = vte_terminal_screen_changed;
 
 	/* Initialize default handlers. */
 	klass->eof = NULL;
@@ -11397,17 +11446,8 @@ vte_terminal_get_using_xft(VteTerminal *
 	return _vte_draw_get_using_fontconfig(terminal->pvt->draw);
 }
 
-/**
- * vte_terminal_set_cursor_blinks:
- * @terminal: a #VteTerminal
- * @blink: %TRUE if the cursor should blink
- *
- * Sets whether or not the cursor will blink.  The length of the blinking cycle
- * is controlled by the "gtk-cursor-blink-time" GTK+ setting.
- *
- */
-void
-vte_terminal_set_cursor_blinks(VteTerminal *terminal, gboolean blink)
+static void
+vte_terminal_set_cursor_blinks_internal(VteTerminal *terminal, gboolean blink)
 {
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
@@ -11428,6 +11468,20 @@ vte_terminal_set_cursor_blinks(VteTermin
 }
 
 /**
+ * vte_terminal_set_cursor_blinks:
+ * @terminal: a #VteTerminal
+ * @blink: %TRUE if the cursor should blink
+ *
+ * No-op. Whether or not the cursor blinks is controlled by the
+ * #GtkSettings::gtk-cursor-blink setting.
+ */
+void
+vte_terminal_set_cursor_blinks(VteTerminal *terminal, gboolean blink)
+{
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+}
+
+/**
  * vte_terminal_set_scrollback_lines:
  * @terminal: a #VteTerminal
  * @lines: the length of the history buffer

