[gtk+] Deprecate and ignore gtk-menu popup and popdown delay settings



commit 76936193d59baf3b744061ef5219c7500e44abaf
Author: William Jon McCann <william jon mccann gmail com>
Date:   Wed Jun 26 14:08:37 2013 -0400

    Deprecate and ignore gtk-menu popup and popdown delay settings
    
    Just pick good defaults. The a11y team confirmed that they don't
    rely on them.

 gtk/gtkmenu.c      |   19 +++++--------------
 gtk/gtkmenubar.c   |   10 +++-------
 gtk/gtkmenuitem.c  |   16 ++++------------
 gtk/gtkmenushell.c |   18 ++++--------------
 gtk/gtksettings.c  |   21 +++++++++++++++++++++
 5 files changed, 37 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 1be4f76..feed5e3 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -130,6 +130,9 @@
 #define MENU_SCROLL_TIMEOUT1  50
 #define MENU_SCROLL_TIMEOUT2  20
 
+#define MENU_POPUP_DELAY     225
+#define MENU_POPDOWN_DELAY  1000
+
 #define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
 #define ATTACHED_MENUS "gtk-attached-menus"
 
@@ -4318,8 +4321,6 @@ gtk_menu_set_submenu_navigation_region (GtkMenu          *menu,
 
   if (event->x >= 0 && event->x < width)
     {
-      gint popdown_delay;
-
       gtk_menu_stop_navigating_submenu (menu);
 
       /* The navigation region is the triangle closest to the x/y
@@ -4358,16 +4359,12 @@ gtk_menu_set_submenu_navigation_region (GtkMenu          *menu,
             return;
         }
 
-      g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu)),
-                    "gtk-menu-popdown-delay", &popdown_delay,
-                    NULL);
-
       popdown_data = g_new (GtkMenuPopdownData, 1);
       popdown_data->menu = menu;
       popdown_data->device = gdk_event_get_device ((GdkEvent *) event);
 
       priv->navigation_timeout = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT,
-                                                               popdown_delay,
+                                                               MENU_POPDOWN_DELAY,
                                                                gtk_menu_stop_navigating_submenu_cb,
                                                                popdown_data,
                                                                (GDestroyNotify) g_free);
@@ -5093,13 +5090,7 @@ gtk_menu_attach (GtkMenu   *menu,
 static gint
 gtk_menu_get_popup_delay (GtkMenuShell *menu_shell)
 {
-  gint popup_delay;
-
-  g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
-                "gtk-menu-popup-delay", &popup_delay,
-                NULL);
-
-  return popup_delay;
+  return MENU_POPUP_DELAY;
 }
 
 static GtkWidget *
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index ec67a11..0a49fed 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -52,6 +52,8 @@
 #include "gtktypebuiltins.h"
 #include "gtkwidgetprivate.h"
 
+#define MENU_BAR_POPUP_DELAY 0
+
 /* Properties */
 enum {
   PROP_0,
@@ -862,13 +864,7 @@ get_shadow_type (GtkMenuBar *menubar)
 static gint
 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
 {
-  gint popup_delay;
-  
-  g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
-               "gtk-menu-bar-popup-delay", &popup_delay,
-               NULL);
-
-  return popup_delay;
+  return MENU_BAR_POPUP_DELAY;
 }
 
 static void
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 8286c6b..da3c623 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -45,6 +45,8 @@
 #include "a11y/gtkmenuitemaccessible.h"
 #include "deprecated/gtktearoffmenuitem.h"
 
+#define MENU_POPUP_DELAY     225
+
 /**
  * SECTION:gtkmenuitem
  * @Short_description: The widget used for item in menus
@@ -1953,19 +1955,9 @@ get_popup_delay (GtkWidget *widget)
 
   parent = gtk_widget_get_parent (widget);
   if (GTK_IS_MENU_SHELL (parent))
-    {
-      return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (parent));
-    }
+    return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (parent));
   else
-    {
-      gint popup_delay;
-
-      g_object_get (gtk_widget_get_settings (widget),
-                    "gtk-menu-popup-delay", &popup_delay,
-                    NULL);
-
-      return popup_delay;
-    }
+    return MENU_POPUP_DELAY;
 }
 
 void
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 91c93e5..06e68f7 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -60,6 +60,8 @@
 
 
 #define MENU_SHELL_TIMEOUT   500
+#define MENU_POPUP_DELAY     225
+#define MENU_POPDOWN_DELAY   1000
 
 #define PACK_DIRECTION(m)                                 \
    (GTK_IS_MENU_BAR (m)                                   \
@@ -837,14 +839,9 @@ gtk_menu_shell_button_release (GtkWidget      *widget,
               else if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement != GTK_TOP_BOTTOM ||
                        priv->activated_submenu)
                 {
-                  gint popdown_delay;
                   GTimeVal *popup_time;
                   gint64 usec_since_popup = 0;
 
-                  g_object_get (gtk_widget_get_settings (widget),
-                                "gtk-menu-popdown-delay", &popdown_delay,
-                                NULL);
-
                   popup_time = g_object_get_data (G_OBJECT (submenu),
                                                   "gtk-menu-exact-popup-time");
 
@@ -870,7 +867,7 @@ gtk_menu_shell_button_release (GtkWidget      *widget,
                    */
                   if (!priv->activated_submenu &&
                       (usec_since_popup == 0 ||
-                       usec_since_popup > popdown_delay * 1000))
+                       usec_since_popup > MENU_POPDOWN_DELAY * 1000))
                     {
                       _gtk_menu_item_popdown_submenu (menu_item);
                     }
@@ -1745,14 +1742,7 @@ _gtk_menu_shell_get_popup_delay (GtkMenuShell *menu_shell)
     }
   else
     {
-      gint popup_delay;
-      GtkWidget *widget = GTK_WIDGET (menu_shell);
-
-      g_object_get (gtk_widget_get_settings (widget),
-                    "gtk-menu-popup-delay", &popup_delay,
-                    NULL);
-
-      return popup_delay;
+      return MENU_POPUP_DELAY;
     }
 }
 
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 6ddc86d..9a3e5e9 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1312,6 +1312,13 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                              NULL);
   g_assert (result == PROP_MENU_IMAGES);
 
+  /**
+   * GtkSettings:gtk-menu-bar-popup-delay:
+   *
+   * Delay before the submenus of a menu bar appear.
+   *
+   * Deprecated: 3.10: This setting is ignored.
+   */
   result = settings_install_property_parser (class,
                                              g_param_spec_int ("gtk-menu-bar-popup-delay",
                                                                P_("Delay before drop down menus appear"),
@@ -1358,6 +1365,13 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                              NULL);
   g_assert (result == PROP_CAN_CHANGE_ACCELS);
 
+  /**
+   * GtkSettings:gtk-menu-popup-delay:
+   *
+   * Minimum time the pointer must stay over a menu item before the submenu appear.
+   *
+   * Deprecated: 3.10: This setting is ignored.
+   */
   result = settings_install_property_parser (class,
                                              g_param_spec_int ("gtk-menu-popup-delay",
                                                                P_("Delay before submenus appear"),
@@ -1368,6 +1382,13 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                              NULL);
   g_assert (result == PROP_MENU_POPUP_DELAY);
 
+  /**
+   * GtkSettings:gtk-menu-popdown-delay:
+   *
+   * The time before hiding a submenu when the pointer is moving towards the submenu.
+   *
+   * Deprecated: 3.10: This setting is ignored.
+   */
   result = settings_install_property_parser (class,
                                              g_param_spec_int ("gtk-menu-popdown-delay",
                                                                P_("Delay before hiding a submenu"),


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