[gtk+] Revert "Deprecate and ignore the cursor blink settings"
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Revert "Deprecate and ignore the cursor blink settings"
- Date: Sat, 17 Aug 2013 02:46:27 +0000 (UTC)
commit f8412eca34be6e2e655ad3e09bd97fa2bdcbdae0
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Aug 16 22:45:13 2013 -0400
Revert "Deprecate and ignore the cursor blink settings"
This reverts commit b2e666bf8f297eb998331fa8ce0062ce7a5198fa.
We need to keep cursor blinking configurable for accessibility
reasons.
https://bugzilla.gnome.org/show_bug.cgi?id=704134
Conflicts:
gdk/win32/gdkproperty-win32.c
gdk/x11/gdksettings.c
gtk/gtksettings.c
gtk/gtktextview.c
gdk/wayland/gdkscreen-wayland.c | 3 ++
gdk/win32/gdkproperty-win32.c | 3 ++
gdk/x11/gdksettings.c | 3 ++
gtk/gtkentry.c | 51 ++++++++++++++++++++++++++++++--------
gtk/gtksettings.c | 13 +--------
gtk/gtktextview.c | 52 +++++++++++++++++++++++++++++++-------
6 files changed, 93 insertions(+), 32 deletions(-)
---
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 8144383..d25a954 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -497,6 +497,9 @@ static TranslationEntry translations[] = {
{ "org.gnome.desktop.interface", "cursor-theme", "gtk-cursor-theme-name", G_TYPE_STRING, { .s = "Adwaita"
} },
{ "org.gnome.desktop.interface", "cursor-size", "gtk-cursor-theme-size", G_TYPE_INT, { .i = 32 } },
{ "org.gnome.desktop.interface", "font-name", "gtk-font-name", G_TYPE_STRING, { .s = "Cantarell 11" } },
+ { "org.gnome.desktop.interface", "cursor-blink", "gtk-cursor-blink", G_TYPE_BOOLEAN, { .b = TRUE } },
+ { "org.gnome.desktop.interface", "cursor-blink-time", "gtk-cursor-blink-time", G_TYPE_INT, { .i = 1200 } },
+ { "org.gnome.desktop.interface", "cursor-blink-timeout", "gtk-cursor-blink-timeout", G_TYPE_INT, { .i =
3600 } },
{ "org.gnome.desktop.interface", "gtk-im-module", "gtk-im-module", G_TYPE_STRING, { .s = "simple" } },
{ "org.gnome.desktop.interface", "enable-animations", "gtk-enable-animations", G_TYPE_BOOLEAN, { .b = TRUE
} },
{ "org.gnome.settings-daemon.peripherals.mouse", "double-click", "gtk-double-click-time", G_TYPE_INT, { .i
= 250 } },
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index 59ab2c8..72e7512 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -303,12 +303,15 @@ _gdk_win32_window_delete_property (GdkWindow *window,
"Net/DoubleClickTime\0" "gtk-double-click-time\0"
"Net/DoubleClickDistance\0" "gtk-double-click-distance\0"
"Net/DndDragThreshold\0" "gtk-dnd-drag-threshold\0"
+ "Net/CursorBlink\0" "gtk-cursor-blink\0"
+ "Net/CursorBlinkTime\0" "gtk-cursor-blink-time\0"
"Net/ThemeName\0" "gtk-theme-name\0"
"Net/IconThemeName\0" "gtk-icon-theme-name\0"
"Gtk/ColorPalette\0" "gtk-color-palette\0"
"Gtk/FontName\0" "gtk-font-name\0"
"Gtk/KeyThemeName\0" "gtk-key-theme-name\0"
"Gtk/Modules\0" "gtk-modules\0"
+ "Gtk/CursorBlinkTimeout\0" "gtk-cursor-blink-timeout\0"
"Gtk/CursorThemeName\0" "gtk-cursor-theme-name\0"
"Gtk/CursorThemeSize\0" "gtk-cursor-theme-size\0"
"Gtk/ColorScheme\0" "gtk-color-scheme\0"
diff --git a/gdk/x11/gdksettings.c b/gdk/x11/gdksettings.c
index b9e6532..fd7aacd 100644
--- a/gdk/x11/gdksettings.c
+++ b/gdk/x11/gdksettings.c
@@ -28,6 +28,8 @@ static const struct {
{"Net/DoubleClickTime", "gtk-double-click-time"},
{"Net/DoubleClickDistance", "gtk-double-click-distance"},
{"Net/DndDragThreshold", "gtk-dnd-drag-threshold"},
+ {"Net/CursorBlink", "gtk-cursor-blink"},
+ {"Net/CursorBlinkTime", "gtk-cursor-blink-time"},
{"Net/ThemeName", "gtk-theme-name"},
{"Net/IconThemeName", "gtk-icon-theme-name"},
{"Gtk/ColorPalette", "gtk-color-palette"},
@@ -50,6 +52,7 @@ static const struct {
{"Net/SoundThemeName", "gtk-sound-theme-name"},
{"Net/EnableInputFeedbackSounds", "gtk-enable-input-feedback-sounds"},
{"Net/EnableEventSounds", "gtk-enable-event-sounds"},
+ {"Gtk/CursorBlinkTimeout", "gtk-cursor-blink-timeout"},
{"Gtk/ShellShowsAppMenu", "gtk-shell-shows-app-menu"},
{"Gtk/ShellShowsMenubar", "gtk-shell-shows-menubar"},
{"Gtk/EnablePrimaryPaste", "gtk-enable-primary-paste"},
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 9283d8b..7df6538 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -121,9 +121,6 @@
#define MAX_ICONS 2
-#define CURSOR_BLINK_TIME 1200
-#define CURSOR_BLINK_TIMEOUT_SEC 10
-
#define IS_VALID_ICON_POSITION(pos) \
((pos) == GTK_ENTRY_ICON_PRIMARY || \
(pos) == GTK_ENTRY_ICON_SECONDARY)
@@ -9760,7 +9757,15 @@ cursor_blinks (GtkEntry *entry)
if (gtk_widget_has_focus (GTK_WIDGET (entry)) &&
priv->editable &&
priv->selection_bound == priv->current_pos)
- return TRUE;
+ {
+ GtkSettings *settings;
+ gboolean blink;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (entry));
+ g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
+
+ return blink;
+ }
else
return FALSE;
}
@@ -9777,6 +9782,28 @@ get_middle_click_paste (GtkEntry *entry)
return paste;
}
+static gint
+get_cursor_time (GtkEntry *entry)
+{
+ GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (entry));
+ gint time;
+
+ g_object_get (settings, "gtk-cursor-blink-time", &time, NULL);
+
+ return time;
+}
+
+static gint
+get_cursor_blink_timeout (GtkEntry *entry)
+{
+ GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (entry));
+ gint timeout;
+
+ g_object_get (settings, "gtk-cursor-blink-timeout", &timeout, NULL);
+
+ return timeout;
+}
+
static void
show_cursor (GtkEntry *entry)
{
@@ -9817,6 +9844,7 @@ blink_cb (gpointer data)
{
GtkEntry *entry;
GtkEntryPrivate *priv;
+ gint blink_timeout;
entry = GTK_ENTRY (data);
priv = entry->priv;
@@ -9834,8 +9862,9 @@ blink_cb (gpointer data)
g_assert (priv->selection_bound == priv->current_pos);
- if (priv->blink_time > 1000 * CURSOR_BLINK_TIMEOUT_SEC &&
- CURSOR_BLINK_TIMEOUT_SEC < G_MAXINT/1000)
+ blink_timeout = get_cursor_blink_timeout (entry);
+ if (priv->blink_time > 1000 * blink_timeout &&
+ blink_timeout < G_MAXINT/1000)
{
/* we've blinked enough without the user doing anything, stop blinking */
show_cursor (entry);
@@ -9844,15 +9873,15 @@ blink_cb (gpointer data)
else if (priv->cursor_visible)
{
hide_cursor (entry);
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_OFF_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_OFF_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
entry);
}
else
{
show_cursor (entry);
- priv->blink_time += CURSOR_BLINK_TIME;
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_time += get_cursor_time (entry);
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
entry);
}
@@ -9871,7 +9900,7 @@ gtk_entry_check_cursor_blink (GtkEntry *entry)
if (!priv->blink_timeout)
{
show_cursor (entry);
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
entry);
}
@@ -9898,7 +9927,7 @@ gtk_entry_pend_cursor_blink (GtkEntry *entry)
if (priv->blink_timeout != 0)
g_source_remove (priv->blink_timeout);
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_PEND_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (entry) * CURSOR_PEND_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
entry);
show_cursor (entry);
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index a32ae77..2095bfb 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -369,7 +369,8 @@ gtk_settings_class_init (GtkSettingsClass *class)
*
* Whether the cursor should blink.
*
- * Deprecated: 3.10: This setting is ignored.
+ * Also see the #GtkSettings:gtk-cursor-blink-timeout setting,
+ * which allows more flexible control over cursor blinking.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-cursor-blink",
@@ -379,14 +380,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
GTK_PARAM_READWRITE | G_PARAM_DEPRECATED),
NULL);
g_assert (result == PROP_CURSOR_BLINK);
-
- /**
- * GtkSettings:gtk-cursor-blink-time:
- *
- * Length of the cursor blink cycle, in milliseconds.
- *
- * Deprecated: 3.10: This setting is ignored.
- */
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-cursor-blink-time",
P_("Cursor Blink Time"),
@@ -406,8 +399,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
* #GtkSettings:gtk-cursor-blink to %FALSE.
*
* Since: 2.12
- *
- * Deprecated: 3.10: This setting is ignored.
*/
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-cursor-blink-timeout",
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 3aa1047..999e9da 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -118,8 +118,7 @@
#define SPACE_FOR_CURSOR 1
-#define CURSOR_BLINK_TIME 1200
-#define CURSOR_BLINK_TIMEOUT_SEC 10
+#define GTK_TEXT_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_TEXT_VIEW,
GtkTextViewPrivate))
typedef struct _GtkTextWindow GtkTextWindow;
typedef struct _GtkTextPendingScroll GtkTextPendingScroll;
@@ -5416,12 +5415,20 @@ gtk_text_view_forall (GtkContainer *container,
static gboolean
cursor_blinks (GtkTextView *text_view)
{
+ GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
+ gboolean blink;
+
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
#endif
if (gtk_get_debug_flags () & GTK_DEBUG_UPDATES)
return FALSE;
+ g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
+
+ if (!blink)
+ return FALSE;
+
if (text_view->priv->editable)
{
GtkTextMark *insert;
@@ -5431,7 +5438,7 @@ cursor_blinks (GtkTextView *text_view)
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, insert);
if (gtk_text_iter_editable (&iter, text_view->priv->editable))
- return TRUE;
+ return blink;
}
return FALSE;
@@ -5449,6 +5456,29 @@ get_middle_click_paste (GtkTextView *text_view)
return paste;
}
+static gint
+get_cursor_time (GtkTextView *text_view)
+{
+ GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
+ gint time;
+
+ g_object_get (settings, "gtk-cursor-blink-time", &time, NULL);
+
+ return time;
+}
+
+static gint
+get_cursor_blink_timeout (GtkTextView *text_view)
+{
+ GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
+ gint time;
+
+ g_object_get (settings, "gtk-cursor-blink-timeout", &time, NULL);
+
+ return time;
+}
+
+
/*
* Blink!
*/
@@ -5459,6 +5489,7 @@ blink_cb (gpointer data)
GtkTextView *text_view;
GtkTextViewPrivate *priv;
gboolean visible;
+ gint blink_timeout;
text_view = GTK_TEXT_VIEW (data);
priv = text_view->priv;
@@ -5479,23 +5510,24 @@ blink_cb (gpointer data)
visible = gtk_text_layout_get_cursor_visible (priv->layout);
- if (priv->blink_time > 1000 * CURSOR_BLINK_TIMEOUT_SEC &&
- CURSOR_BLINK_TIMEOUT_SEC < G_MAXINT/1000)
+ blink_timeout = get_cursor_blink_timeout (text_view);
+ if (priv->blink_time > 1000 * blink_timeout &&
+ blink_timeout < G_MAXINT/1000)
{
/* we've blinked enough without the user doing anything, stop blinking */
visible = 0;
priv->blink_timeout = 0;
}
else if (visible)
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_OFF_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (text_view) * CURSOR_OFF_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
text_view);
else
{
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (text_view) * CURSOR_ON_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
text_view);
- priv->blink_time += CURSOR_BLINK_TIME;
+ priv->blink_time += get_cursor_time (text_view);
}
/* Block changed_handler while changing the layout's cursor visibility
@@ -5542,7 +5574,7 @@ gtk_text_view_check_cursor_blink (GtkTextView *text_view)
{
gtk_text_layout_set_cursor_visible (priv->layout, TRUE);
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_OFF_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (text_view) *
CURSOR_OFF_MULTIPLIER / CURSOR_DIVIDER,
blink_cb,
text_view);
}
@@ -5573,7 +5605,7 @@ gtk_text_view_pend_cursor_blink (GtkTextView *text_view)
gtk_text_view_stop_cursor_blink (text_view);
gtk_text_layout_set_cursor_visible (priv->layout, TRUE);
- priv->blink_timeout = gdk_threads_add_timeout (CURSOR_BLINK_TIME * CURSOR_PEND_MULTIPLIER /
CURSOR_DIVIDER,
+ priv->blink_timeout = gdk_threads_add_timeout (get_cursor_time (text_view) * CURSOR_PEND_MULTIPLIER /
CURSOR_DIVIDER,
blink_cb,
text_view);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]