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



commit fbb70becef287ff34f1cd85dee5189b85c3e28e4
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 508b4db..0aea4c6 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -33,6 +33,7 @@
 #include "gtkprivate.h"
 #include "gtkcssproviderprivate.h"
 #include "gtksymboliccolor.h"
+#include "gtkanimationdescription.h"
 #include "gtktypebuiltins.h"
 #include "gtkversion.h"
 
@@ -96,9 +97,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;
@@ -1441,6 +1443,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]