[gtk+/multitouch: 9/121] gtksettings: Set animation for press-and-hold through GtkStyleProvider



commit f9bc5e65ce2a2fdf48b7a2d92705bce8ed426bdf
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 1 02:48:40 2011 +0100

    gtksettings: Set animation for press-and-hold through GtkStyleProvider
    
    The "gtk-press-and-hold-timeout" setting has also been added, to control
    its duration.

 gtk/gtksettings.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index ac90cdd..feeefaf 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -34,6 +34,7 @@
 #include "gtkcssproviderprivate.h"
 #include "gtkstyleproviderprivate.h"
 #include "gtksymboliccolor.h"
+#include "gtkanimationdescription.h"
 #include "gtktypebuiltins.h"
 #include "gtkversion.h"
 
@@ -97,9 +98,10 @@
  */
 
 
-#define DEFAULT_TIMEOUT_INITIAL 200
-#define DEFAULT_TIMEOUT_REPEAT   20
-#define DEFAULT_TIMEOUT_EXPAND  500
+#define DEFAULT_TIMEOUT_INITIAL        200
+#define DEFAULT_TIMEOUT_REPEAT         20
+#define DEFAULT_TIMEOUT_EXPAND         500
+#define DEFAULT_TIMEOUT_PRESS_AND_HOLD 800
 
 typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
 typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
@@ -1445,6 +1447,33 @@ gtk_settings_get_style (GtkStyleProvider *provider,
 
   settings_ensure_style (settings);
 
+  /* Set animation for press and hold */
+  if (gtk_widget_path_iter_has_class (path, 0, GTK_STYLE_CLASS_PRESS_AND_HOLD))
+    {
+      GtkAnimationDescription *anim_desc;
+      GtkStyleProperties *copy;
+      gint duration;
+
+      copy = gtk_style_properties_new ();
+      gtk_style_properties_merge (copy, settings->priv->style, TRUE);
+
+      g_object_get (settings,
+                    "gtk-press-and-hold-timeout", &duration,
+                    NULL);
+
+      anim_desc = _gtk_animation_description_new (duration,
+                                                  GTK_TIMELINE_PROGRESS_LINEAR,
+                                                  FALSE);
+      gtk_style_properties_set (copy,
+                                GTK_STATE_FLAG_ACTIVE,
+                                "transition", anim_desc,
+                                NULL);
+
+      _gtk_animation_description_unref (anim_desc);
+
+      return copy;
+    }
+
   return g_object_ref (settings->priv->style);
 }
 



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