Transfer the Mac SDK bockbuild profiles & resources inside the Mono repository.
[mono.git] / bockbuild / mac-sdk / patches / gtk / 0007-Implement-gtk-enable-overlay-scrollbars-GtkSetting.patch
1 From 4c79075b4d396ba009b0f0e70d05c1c253cc3da6 Mon Sep 17 00:00:00 2001
2 From: Kristian Rietveld <kris@lanedo.com>
3 Date: Fri, 24 Aug 2012 12:12:04 +0200
4 Subject: [PATCH 07/68] Implement gtk-enable-overlay-scrollbars GtkSetting
5
6 And set this up such that on OS X
7 NSPreferredScrollerDidChangeNotification is followed.
8 ---
9  gdk/quartz/gdkevents-quartz.c |   56 ++++++++++++++++++++++++++++++++++++++++-
10  gtk/gtksettings.c             |   20 ++++++++++++++-
11  2 files changed, 74 insertions(+), 2 deletions(-)
12
13 diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
14 index 53f1962..c99a2c9 100644
15 --- a/gdk/quartz/gdkevents-quartz.c
16 +++ b/gdk/quartz/gdkevents-quartz.c
17 @@ -85,6 +85,10 @@ gdk_quartz_ns_notification_callback (CFNotificationCenterRef  center,
18                         CFSTR("AppleNoRedisplayAppearancePreferenceChanged"),
19                         0) == kCFCompareEqualTo)
20      new_event.setting.name = "gtk-primary-button-warps-slider";
21 +  else if (CFStringCompare (name,
22 +                            CFSTR("NSPreferredScrollerStyleDidChangeNotification"),
23 +                            0) == kCFCompareEqualTo)
24 +    new_event.setting.name = "gtk-enable-overlay-scrollbars";
25
26    if (!new_event.setting.name)
27      return;
28 @@ -114,6 +118,20 @@ gdk_quartz_events_init_notifications (void)
29                                     CFSTR ("AppleNoRedisplayAppearancePreferenceChanged"),
30                                     NULL,
31                                     CFNotificationSuspensionBehaviorDeliverImmediately);
32 +
33 +  /* The preferred scroller notification and property are only available on Lion
34 +   * and higher. Also, beware that the notification will only start working after the
35 +   * property has been queried for the first time!.
36 +   */
37 +  if (gdk_quartz_osx_version () >= GDK_OSX_LION)
38 +    {
39 +      CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter (),
40 +                                       NULL,
41 +                                       &gdk_quartz_ns_notification_callback,
42 +                                       CFSTR ("NSPreferredScrollerStyleDidChangeNotification"),
43 +                                       NULL,
44 +                                       CFNotificationSuspensionBehaviorDeliverImmediately);
45 +    }
46  }
47
48  void
49 @@ -1686,7 +1704,43 @@ gdk_screen_get_setting (GdkScreen   *screen,
50
51        return TRUE;
52      }
53 -
54 +  else if (strcmp (name, "gtk-enable-overlay-scrollbars") == 0)
55 +    {
56 +      gboolean enabled = FALSE;
57 +
58 +      GDK_QUARTZ_ALLOC_POOL;
59 +
60 +      if (gdk_quartz_osx_version () >= GDK_OSX_LION)
61 +        {
62 +          /* Use an integer instead of NSScrollerStyle to allow things to be compiled
63 +           * on < 10.7 systems.
64 +           */
65 +          int setting = (int)[NSScroller preferredScrollerStyle];
66 +
67 +          if (setting == 1)
68 +            /* 1 == NSScrollerStyleOverlay */
69 +            enabled = TRUE;
70 +          else
71 +            enabled = FALSE;
72 +        }
73 +      else
74 +        {
75 +          /* On systems prior to Lion, default to legacy scrolling. */
76 +          enabled = FALSE;
77 +        }
78 +
79 +      g_value_set_boolean (value, enabled);
80 +
81 +      /* Initialize after quering the property for the first theme,
82 +       * notifications are otherwise not received!
83 +       */
84 +      gdk_quartz_events_init_notifications ();
85 +
86 +      GDK_QUARTZ_RELEASE_POOL;
87 +
88 +      return TRUE;
89 +    }
90 +
91    /* FIXME: Add more settings */
92
93    return FALSE;
94 diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
95 index 3fbbf00..1455db1 100644
96 --- a/gtk/gtksettings.c
97 +++ b/gtk/gtksettings.c
98 @@ -139,7 +139,8 @@ enum {
99    PROP_LABEL_SELECT_ON_FOCUS,
100    PROP_COLOR_PALETTE,
101    PROP_IM_PREEDIT_STYLE,
102 -  PROP_IM_STATUS_STYLE
103 +  PROP_IM_STATUS_STYLE,
104 +  PROP_ENABLE_OVERLAY_SCROLLBARS
105  };
106
107  /* --- prototypes --- */
108 @@ -1205,6 +1206,23 @@ gtk_settings_class_init (GtkSettingsClass *class)
109                                                                  GTK_PARAM_READWRITE),
110                                               gtk_rc_property_parse_enum);
111    g_assert (result == PROP_IM_STATUS_STYLE);
112 +
113 +  /**
114 +   * GtkSettings:gtk-enable-overlay-scrollbars:
115 +   *
116 +   * Whether overlay scrollbars should be enabled.
117 +   *
118 +   * Since: Xamarin specific API.
119 +   */
120 +  result = settings_install_property_parser (class,
121 +                                             g_param_spec_boolean ("gtk-enable-overlay-scrollbars",
122 +                                                                   P_("Enable Overlay Scrollbars"),
123 +                                                                   P_("Whether to enable overlay scrollbars."),
124 +                                                                   FALSE,
125 +                                                                   GTK_PARAM_READWRITE),
126 +                                             NULL);
127 +
128 +  g_assert (result == PROP_ENABLE_OVERLAY_SCROLLBARS);
129  }
130
131  static void
132 --
133 1.7.10.2 (Apple Git-33)