summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorKristian Rietveld <kris@lanedo.com>2012-08-24 11:49:43 +0200
committerMichael Natterer <mitch@gimp.org>2012-09-11 11:19:09 +0200
commit64324a5da080bee7ca42cfe53dadea9a882a9e64 (patch)
tree70529ddd819d0c3d6643ed7ce52908571b65a442 /gtk
parent4519fb53fcb97360e3be01f5b72eb2d1dc895955 (diff)
downloadgtk+-64324a5da080bee7ca42cfe53dadea9a882a9e64.tar.gz
Implement gtk-primary-button-warps-slider GtkSetting
Make GtkRange honor the setting and implement it in the quartz backend, it proxies the "click in the scroll bar to" property from the OS X PrefPane.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkrange.c20
-rw-r--r--gtk/gtksettings.c18
2 files changed, 36 insertions, 2 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 529a8d76a9..d18cf2bbac 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2522,6 +2522,8 @@ gtk_range_button_press (GtkWidget *widget,
GtkRangePrivate *priv = range->priv;
GdkDevice *device, *source_device;
GdkInputSource source;
+ gboolean primary_warps;
+ gint page_increment_button, warp_button;
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
@@ -2540,6 +2542,20 @@ gtk_range_button_press (GtkWidget *widget,
if (gtk_range_update_mouse_location (range))
gtk_widget_queue_draw (widget);
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-primary-button-warps-slider", &primary_warps,
+ NULL);
+ if (primary_warps)
+ {
+ warp_button = GDK_BUTTON_PRIMARY;
+ page_increment_button = GDK_BUTTON_SECONDARY;
+ }
+ else
+ {
+ warp_button = GDK_BUTTON_MIDDLE;
+ page_increment_button = GDK_BUTTON_PRIMARY;
+ }
+
if (priv->mouse_location == MOUSE_SLIDER &&
gdk_event_triggers_context_menu ((GdkEvent *)event))
{
@@ -2552,7 +2568,7 @@ gtk_range_button_press (GtkWidget *widget,
if (source != GDK_SOURCE_TOUCHSCREEN &&
priv->mouse_location == MOUSE_TROUGH &&
- event->button == GDK_BUTTON_SECONDARY)
+ event->button == page_increment_button)
{
/* button 2 steps by page increment, as with button 2 on a stepper
*/
@@ -2603,7 +2619,7 @@ gtk_range_button_press (GtkWidget *widget,
}
else if ((priv->mouse_location == MOUSE_TROUGH &&
(source == GDK_SOURCE_TOUCHSCREEN ||
- event->button == GDK_BUTTON_PRIMARY)) ||
+ event->button == warp_button)) ||
priv->mouse_location == MOUSE_SLIDER)
{
gboolean need_value_update = FALSE;
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 534ef021c5..cac82bd999 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -193,6 +193,7 @@ enum {
PROP_TOOLBAR_STYLE,
PROP_TOOLBAR_ICON_SIZE,
PROP_AUTO_MNEMONICS,
+ PROP_PRIMARY_BUTTON_WARPS_SLIDER,
PROP_VISIBLE_FOCUS,
PROP_APPLICATION_PREFER_DARK_THEME,
PROP_BUTTON_IMAGES,
@@ -1145,6 +1146,23 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_assert (result == PROP_AUTO_MNEMONICS);
/**
+ * GtkSettings:gtk-primary-button-warps-slider
+ *
+ * Whether a click in a #GtkRange trough should scroll to the click position or
+ * scroll by a single page in the respective direction.
+ *
+ * Since: 2.24
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-primary-button-warps-slider",
+ P_("Primary button warps slider"),
+ P_("Whether a primary click on the trough should warp the slider into position"),
+ TRUE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_PRIMARY_BUTTON_WARPS_SLIDER);
+
+ /**
* GtkSettings:gtk-visible-focus:
*
* Whether 'focus rectangles' should be always visible, never visible,