mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
css: Remove old animation code
Deprecate public API where appropriate and make it no-ops. Remove all calls to it. Get rid of the 'transition' css property. For now, this means spinners don't animate anymore.
This commit is contained in:
parent
dcd54e20d1
commit
04c5fdaca6
@ -405,7 +405,6 @@ gtk_private_h_sources = \
|
||||
gtkaccelgroupprivate.h \
|
||||
gtkaccelmapprivate.h \
|
||||
gtkallocatedbitmaskprivate.h \
|
||||
gtkanimationdescription.h \
|
||||
gtkappchooserprivate.h \
|
||||
gtkappchoosermodule.h \
|
||||
gtkappchooseronline.h \
|
||||
@ -525,7 +524,6 @@ gtk_private_h_sources = \
|
||||
gtktextutil.h \
|
||||
gtkthemingbackgroundprivate.h \
|
||||
gtkthemingengineprivate.h \
|
||||
gtktimeline.h \
|
||||
gtktoolpaletteprivate.h \
|
||||
gtktreedatalist.h \
|
||||
gtktreeprivate.h \
|
||||
@ -591,7 +589,6 @@ gtk_base_c_sources = \
|
||||
gtkappchooseronline.c \
|
||||
gtkapplication.c \
|
||||
gtkapplicationwindow.c \
|
||||
gtkanimationdescription.c \
|
||||
gtkarrow.c \
|
||||
gtkaspectframe.c \
|
||||
gtkassistant.c \
|
||||
@ -819,7 +816,6 @@ gtk_base_c_sources = \
|
||||
gtktextview.c \
|
||||
gtkthemingbackground.c \
|
||||
gtkthemingengine.c \
|
||||
gtktimeline.c \
|
||||
gtktoggleaction.c \
|
||||
gtktogglebutton.c \
|
||||
gtktoggletoolbutton.c \
|
||||
|
@ -36,10 +36,6 @@ GtkTreeView.view.expander:selected:hover {
|
||||
color: @text_color;
|
||||
}
|
||||
|
||||
.expander:active {
|
||||
transition: 200ms linear;
|
||||
}
|
||||
|
||||
*:insensitive {
|
||||
border-color: shade (@bg_color, 0.7);
|
||||
background-color: shade (@bg_color, 0.9);
|
||||
@ -295,10 +291,6 @@ GtkLabel:selected:focused {
|
||||
background-color: @selected_bg_color;
|
||||
}
|
||||
|
||||
.spinner:active {
|
||||
transition: 750ms linear loop;
|
||||
}
|
||||
|
||||
.info {
|
||||
background-color: @info_bg_color;
|
||||
color: @info_fg_color;
|
||||
|
@ -77,10 +77,6 @@ GtkFrame {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.spinner:active {
|
||||
transition: 750ms linear loop;
|
||||
}
|
||||
|
||||
.notebook > GtkScrolledWindow.frame {
|
||||
border-style: none;
|
||||
}
|
||||
@ -837,4 +833,4 @@ GtkStatusbar > GtkFrame {
|
||||
background-color: transparent;
|
||||
background-image: -gtk-win32-theme-part(status, 3 1);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
@ -1,175 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
struct GtkAnimationDescription
|
||||
{
|
||||
GtkTimelineProgressType progress_type;
|
||||
gdouble duration;
|
||||
guint loop : 1;
|
||||
guint ref_count;
|
||||
};
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_new (gdouble duration,
|
||||
GtkTimelineProgressType progress_type,
|
||||
gboolean loop)
|
||||
{
|
||||
GtkAnimationDescription *desc;
|
||||
|
||||
desc = g_slice_new (GtkAnimationDescription);
|
||||
desc->duration = duration;
|
||||
desc->progress_type = progress_type;
|
||||
desc->loop = loop;
|
||||
desc->ref_count = 1;
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
gdouble
|
||||
_gtk_animation_description_get_duration (GtkAnimationDescription *desc)
|
||||
{
|
||||
return desc->duration;
|
||||
}
|
||||
|
||||
GtkTimelineProgressType
|
||||
_gtk_animation_description_get_progress_type (GtkAnimationDescription *desc)
|
||||
{
|
||||
return desc->progress_type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_animation_description_get_loop (GtkAnimationDescription *desc)
|
||||
{
|
||||
return (desc->loop != 0);
|
||||
}
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_ref (GtkAnimationDescription *desc)
|
||||
{
|
||||
desc->ref_count++;
|
||||
return desc;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_animation_description_unref (GtkAnimationDescription *desc)
|
||||
{
|
||||
desc->ref_count--;
|
||||
|
||||
if (desc->ref_count == 0)
|
||||
g_slice_free (GtkAnimationDescription, desc);
|
||||
}
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_from_string (const gchar *str)
|
||||
{
|
||||
gchar timing_function[16] = { 0, };
|
||||
gchar duration_unit[3] = { 0, };
|
||||
gchar loop_str[5] = { 0, };
|
||||
GtkTimelineProgressType progress_type;
|
||||
guint duration = 0;
|
||||
gboolean loop;
|
||||
|
||||
if (sscanf (str, "%d%2s %15s %5s", &duration, duration_unit, timing_function, loop_str) == 4)
|
||||
loop = TRUE;
|
||||
else if (sscanf (str, "%d%2s %15s", &duration, duration_unit, timing_function) == 3)
|
||||
loop = FALSE;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (strcmp (duration_unit, "s") == 0)
|
||||
duration *= 1000;
|
||||
else if (strcmp (duration_unit, "ms") != 0)
|
||||
{
|
||||
g_warning ("Unknown duration unit: %s\n", duration_unit);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (timing_function, "linear") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_LINEAR;
|
||||
else if (strcmp (timing_function, "ease") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE;
|
||||
else if (strcmp (timing_function, "ease-in") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_IN;
|
||||
else if (strcmp (timing_function, "ease-out") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_OUT;
|
||||
else if (strcmp (timing_function, "ease-in-out") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_IN_OUT;
|
||||
else
|
||||
{
|
||||
g_warning ("Unknown timing function: %s\n", timing_function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_animation_description_new ((gdouble) duration, progress_type, loop);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_animation_description_print (GtkAnimationDescription *desc,
|
||||
GString *str)
|
||||
{
|
||||
int duration;
|
||||
|
||||
g_return_if_fail (desc != NULL);
|
||||
g_return_if_fail (str != NULL);
|
||||
|
||||
duration = desc->duration;
|
||||
if (duration % 1000 == 0)
|
||||
g_string_append_printf (str, "%ds", (int) desc->duration / 1000);
|
||||
else
|
||||
g_string_append_printf (str, "%dms", (int) desc->duration);
|
||||
|
||||
switch (desc->progress_type)
|
||||
{
|
||||
case GTK_TIMELINE_PROGRESS_LINEAR:
|
||||
g_string_append (str, " linear");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE:
|
||||
g_string_append (str, " ease");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN:
|
||||
g_string_append (str, " ease-in");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_OUT:
|
||||
g_string_append (str, " ease-out");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN_OUT:
|
||||
g_string_append (str, " ease-in-out");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (desc->loop)
|
||||
g_string_append (str, " loop");
|
||||
}
|
||||
|
||||
GType
|
||||
_gtk_animation_description_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (!type))
|
||||
type = g_boxed_type_register_static (I_("GtkAnimationDescription"),
|
||||
(GBoxedCopyFunc) _gtk_animation_description_ref,
|
||||
(GBoxedFreeFunc) _gtk_animation_description_unref);
|
||||
|
||||
return type;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_ANIMATION_DESCRIPTION_H__
|
||||
#define __GTK_ANIMATION_DESCRIPTION_H__
|
||||
|
||||
#include "gtktimeline.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Dummy typedefs */
|
||||
typedef struct GtkAnimationDescription GtkAnimationDescription;
|
||||
|
||||
#define GTK_TYPE_ANIMATION_DESCRIPTION (_gtk_animation_description_get_type ())
|
||||
|
||||
GType _gtk_animation_description_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_new (gdouble duration,
|
||||
GtkTimelineProgressType progress_type,
|
||||
gboolean loop);
|
||||
|
||||
gdouble _gtk_animation_description_get_duration (GtkAnimationDescription *desc);
|
||||
GtkTimelineProgressType _gtk_animation_description_get_progress_type (GtkAnimationDescription *desc);
|
||||
gboolean _gtk_animation_description_get_loop (GtkAnimationDescription *desc);
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_ref (GtkAnimationDescription *desc);
|
||||
void _gtk_animation_description_unref (GtkAnimationDescription *desc);
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_from_string (const gchar *str);
|
||||
void _gtk_animation_description_print (GtkAnimationDescription *desc,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ANIMATION_DESCRIPTION_H__ */
|
@ -27,7 +27,6 @@
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkcssimagegradientprivate.h"
|
||||
#include "gtkcssprovider.h"
|
||||
#include "gtkcssrgbavalueprivate.h"
|
||||
@ -602,43 +601,6 @@ theming_engine_value_print (const GValue *value,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
animation_description_value_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
GValue *value)
|
||||
{
|
||||
GtkAnimationDescription *desc;
|
||||
char *str;
|
||||
|
||||
str = _gtk_css_parser_read_value (parser);
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
desc = _gtk_animation_description_from_string (str);
|
||||
g_free (str);
|
||||
|
||||
if (desc == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Invalid animation description");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, desc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
animation_description_value_print (const GValue *value,
|
||||
GString *string)
|
||||
{
|
||||
GtkAnimationDescription *desc = g_value_get_boxed (value);
|
||||
|
||||
if (desc == NULL)
|
||||
g_string_append (string, "none");
|
||||
else
|
||||
_gtk_animation_description_print (desc, string);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
border_value_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
@ -1038,10 +1000,6 @@ gtk_css_style_funcs_init (void)
|
||||
theming_engine_value_parse,
|
||||
theming_engine_value_print,
|
||||
NULL);
|
||||
register_conversion_function (GTK_TYPE_ANIMATION_DESCRIPTION,
|
||||
animation_description_value_parse,
|
||||
animation_description_value_print,
|
||||
NULL);
|
||||
register_conversion_function (GTK_TYPE_BORDER,
|
||||
border_value_parse,
|
||||
border_value_print,
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "fallback-c89.c"
|
||||
|
||||
/* the actual parsers we have */
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkcssarrayvalueprivate.h"
|
||||
#include "gtkcssbgsizevalueprivate.h"
|
||||
@ -113,21 +112,6 @@ gtk_css_style_property_register (const char * name,
|
||||
|
||||
/*** IMPLEMENTATIONS ***/
|
||||
|
||||
static void
|
||||
query_simple (GtkCssStyleProperty *property,
|
||||
const GtkCssValue *css_value,
|
||||
GValue *value)
|
||||
{
|
||||
_gtk_css_value_init_gvalue (css_value, value);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
assign_simple (GtkCssStyleProperty *property,
|
||||
const GValue *value)
|
||||
{
|
||||
return _gtk_css_value_new_from_gvalue (value);
|
||||
}
|
||||
|
||||
static void
|
||||
query_length_as_int (GtkCssStyleProperty *property,
|
||||
const GtkCssValue *css_value,
|
||||
@ -816,27 +800,6 @@ engine_assign (GtkCssStyleProperty *property,
|
||||
return _gtk_css_engine_value_new (g_value_get_object (value));
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
transition_parse (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GtkCssValue *result;
|
||||
|
||||
g_value_init (&value, GTK_TYPE_ANIMATION_DESCRIPTION);
|
||||
if (!_gtk_css_style_parse_value (&value, parser, base))
|
||||
{
|
||||
g_value_unset (&value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = _gtk_css_value_new_from_gvalue (&value);
|
||||
g_value_unset (&value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
parse_margin (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser,
|
||||
@ -1602,17 +1565,6 @@ _gtk_css_style_property_init_properties (void)
|
||||
engine_assign,
|
||||
NULL,
|
||||
_gtk_css_engine_value_new (gtk_theming_engine_load (NULL)));
|
||||
gtk_css_style_property_register ("transition",
|
||||
GTK_CSS_PROPERTY_TRANSITION,
|
||||
GTK_TYPE_ANIMATION_DESCRIPTION,
|
||||
0,
|
||||
transition_parse,
|
||||
NULL,
|
||||
NULL,
|
||||
query_simple,
|
||||
assign_simple,
|
||||
NULL,
|
||||
_gtk_css_value_new_from_boxed (GTK_TYPE_ANIMATION_DESCRIPTION, NULL));
|
||||
|
||||
/* Private property holding the binding sets */
|
||||
gtk_css_style_property_register ("gtk-key-bindings",
|
||||
|
@ -108,7 +108,6 @@ enum { /*< skip >*/
|
||||
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
|
||||
GTK_CSS_PROPERTY_TRANSITION_DELAY,
|
||||
GTK_CSS_PROPERTY_ENGINE,
|
||||
GTK_CSS_PROPERTY_TRANSITION,
|
||||
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
|
||||
/* add more */
|
||||
GTK_CSS_PROPERTY_N_PROPERTIES
|
||||
|
@ -911,15 +911,11 @@ gtk_expander_paint (GtkExpander *expander,
|
||||
gtk_style_context_set_state (context, state);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
/* The expander is the only animatable region */
|
||||
gtk_style_context_push_animatable_region (context, GUINT_TO_POINTER (1));
|
||||
|
||||
gtk_render_expander (context, cr,
|
||||
clip.x - allocation.x,
|
||||
clip.y - allocation.y,
|
||||
size, size);
|
||||
|
||||
gtk_style_context_pop_animatable_region (context);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
@ -1709,28 +1705,9 @@ gtk_expander_set_expanded (GtkExpander *expander,
|
||||
if (priv->expanded != expanded)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (expander);
|
||||
GtkSettings *settings = gtk_widget_get_settings (widget);
|
||||
GtkStyleContext *context;
|
||||
gboolean enable_animations;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
priv->expanded = expanded;
|
||||
|
||||
g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL);
|
||||
|
||||
if (enable_animations && gtk_widget_get_realized (widget))
|
||||
{
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
gtk_style_context_notify_state_change (context,
|
||||
gtk_widget_get_window (widget),
|
||||
GUINT_TO_POINTER (1),
|
||||
GTK_STATE_ACTIVE,
|
||||
expanded);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (expander));
|
||||
|
||||
if (child)
|
||||
|
@ -33,9 +33,7 @@
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksymboliccolorprivate.h"
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtktimeline.h"
|
||||
#include "gtkiconfactory.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@ -314,7 +312,6 @@
|
||||
typedef struct GtkStyleInfo GtkStyleInfo;
|
||||
typedef struct GtkRegion GtkRegion;
|
||||
typedef struct PropertyValue PropertyValue;
|
||||
typedef struct AnimationInfo AnimationInfo;
|
||||
typedef struct StyleData StyleData;
|
||||
|
||||
struct GtkRegion
|
||||
@ -346,25 +343,6 @@ struct StyleData
|
||||
GArray *property_cache;
|
||||
};
|
||||
|
||||
struct AnimationInfo
|
||||
{
|
||||
GtkTimeline *timeline;
|
||||
|
||||
gpointer region_id;
|
||||
|
||||
/* Region stack (until region_id) at the time of
|
||||
* rendering, this is used for nested cancellation.
|
||||
*/
|
||||
GSList *parent_regions;
|
||||
|
||||
GdkWindow *window;
|
||||
GtkStateType state;
|
||||
gboolean target_value;
|
||||
|
||||
cairo_region_t *invalidation_region;
|
||||
GArray *rectangles;
|
||||
};
|
||||
|
||||
struct _GtkStyleContextPrivate
|
||||
{
|
||||
GdkScreen *screen;
|
||||
@ -378,9 +356,6 @@ struct _GtkStyleContextPrivate
|
||||
GHashTable *style_data;
|
||||
GSList *info_stack;
|
||||
|
||||
GSList *animation_regions;
|
||||
GSList *animations;
|
||||
|
||||
GtkThemingEngine *theming_engine;
|
||||
|
||||
GtkTextDirection direction;
|
||||
@ -388,7 +363,6 @@ struct _GtkStyleContextPrivate
|
||||
GtkCssChange relevant_changes;
|
||||
GtkCssChange pending_changes;
|
||||
|
||||
guint animations_invalidated : 1;
|
||||
guint invalidating_context : 1;
|
||||
guint invalid : 1;
|
||||
};
|
||||
@ -656,168 +630,11 @@ gtk_style_context_init (GtkStyleContext *style_context)
|
||||
priv->info_stack = g_slist_prepend (priv->info_stack, info);
|
||||
}
|
||||
|
||||
static void
|
||||
animation_info_free (AnimationInfo *info)
|
||||
{
|
||||
g_object_unref (info->timeline);
|
||||
g_object_unref (info->window);
|
||||
|
||||
if (info->invalidation_region)
|
||||
cairo_region_destroy (info->invalidation_region);
|
||||
|
||||
g_array_free (info->rectangles, TRUE);
|
||||
g_slist_free (info->parent_regions);
|
||||
g_slice_free (AnimationInfo, info);
|
||||
}
|
||||
|
||||
static AnimationInfo *
|
||||
animation_info_lookup_by_timeline (GtkStyleContext *context,
|
||||
GtkTimeline *timeline)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
AnimationInfo *info;
|
||||
GSList *l;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
{
|
||||
info = l->data;
|
||||
|
||||
if (info->timeline == timeline)
|
||||
return info;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
timeline_frame_cb (GtkTimeline *timeline,
|
||||
gdouble progress,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GtkStyleContext *context;
|
||||
AnimationInfo *info;
|
||||
|
||||
context = user_data;
|
||||
priv = context->priv;
|
||||
info = animation_info_lookup_by_timeline (context, timeline);
|
||||
|
||||
g_assert (info != NULL);
|
||||
|
||||
/* Cancel transition if window is gone */
|
||||
if (gdk_window_is_destroyed (info->window) ||
|
||||
!gdk_window_is_visible (info->window))
|
||||
{
|
||||
priv->animations = g_slist_remove (priv->animations, info);
|
||||
animation_info_free (info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info->invalidation_region &&
|
||||
!cairo_region_is_empty (info->invalidation_region))
|
||||
gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE);
|
||||
else
|
||||
gdk_window_invalidate_rect (info->window, NULL, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
timeline_finished_cb (GtkTimeline *timeline,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GtkStyleContext *context;
|
||||
AnimationInfo *info;
|
||||
|
||||
context = user_data;
|
||||
priv = context->priv;
|
||||
info = animation_info_lookup_by_timeline (context, timeline);
|
||||
|
||||
g_assert (info != NULL);
|
||||
|
||||
priv->animations = g_slist_remove (priv->animations, info);
|
||||
|
||||
/* Invalidate one last time the area, so the final content is painted */
|
||||
if (info->invalidation_region &&
|
||||
!cairo_region_is_empty (info->invalidation_region))
|
||||
gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE);
|
||||
else
|
||||
gdk_window_invalidate_rect (info->window, NULL, TRUE);
|
||||
|
||||
animation_info_free (info);
|
||||
}
|
||||
|
||||
static AnimationInfo *
|
||||
animation_info_new (GtkStyleContext *context,
|
||||
gpointer region_id,
|
||||
guint duration,
|
||||
GtkTimelineProgressType progress_type,
|
||||
gboolean loop,
|
||||
GtkStateType state,
|
||||
gboolean target_value,
|
||||
GdkWindow *window)
|
||||
{
|
||||
AnimationInfo *info;
|
||||
|
||||
info = g_slice_new0 (AnimationInfo);
|
||||
|
||||
info->rectangles = g_array_new (FALSE, FALSE, sizeof (cairo_rectangle_int_t));
|
||||
info->timeline = _gtk_timeline_new (duration);
|
||||
info->window = g_object_ref (window);
|
||||
info->state = state;
|
||||
info->target_value = target_value;
|
||||
info->region_id = region_id;
|
||||
|
||||
_gtk_timeline_set_progress_type (info->timeline, progress_type);
|
||||
_gtk_timeline_set_loop (info->timeline, loop);
|
||||
|
||||
if (!loop && !target_value)
|
||||
{
|
||||
_gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD);
|
||||
_gtk_timeline_rewind (info->timeline);
|
||||
}
|
||||
|
||||
g_signal_connect (info->timeline, "frame",
|
||||
G_CALLBACK (timeline_frame_cb), context);
|
||||
g_signal_connect (info->timeline, "finished",
|
||||
G_CALLBACK (timeline_finished_cb), context);
|
||||
|
||||
_gtk_timeline_start (info->timeline);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static AnimationInfo *
|
||||
animation_info_lookup (GtkStyleContext *context,
|
||||
gpointer region_id,
|
||||
GtkStateType state)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GSList *l;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
{
|
||||
AnimationInfo *info;
|
||||
|
||||
info = l->data;
|
||||
|
||||
if (info->state == state &&
|
||||
info->region_id == region_id)
|
||||
return info;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_context_finalize (GObject *object)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GtkStyleContext *style_context;
|
||||
GSList *l;
|
||||
|
||||
style_context = GTK_STYLE_CONTEXT (object);
|
||||
priv = style_context->priv;
|
||||
@ -836,13 +653,6 @@ gtk_style_context_finalize (GObject *object)
|
||||
|
||||
g_slist_free_full (priv->info_stack, (GDestroyNotify) style_info_free);
|
||||
|
||||
g_slist_free (priv->animation_regions);
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
animation_info_free ((AnimationInfo *) l->data);
|
||||
|
||||
g_slist_free (priv->animations);
|
||||
|
||||
if (priv->theming_engine)
|
||||
g_object_unref (priv->theming_engine);
|
||||
|
||||
@ -1481,22 +1291,6 @@ gtk_style_context_get_state (GtkStyleContext *context)
|
||||
return info->state_flags;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
context_has_animatable_region (GtkStyleContext *context,
|
||||
gpointer region_id)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
|
||||
/* NULL region_id means everything
|
||||
* rendered through the style context
|
||||
*/
|
||||
if (!region_id)
|
||||
return TRUE;
|
||||
|
||||
priv = context->priv;
|
||||
return g_slist_find (priv->animation_regions, region_id) != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_state_is_running:
|
||||
* @context: a #GtkStyleContext
|
||||
@ -1515,34 +1309,16 @@ context_has_animatable_region (GtkStyleContext *context,
|
||||
* Returns: %TRUE if there is a running transition animation for @state.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function always returns %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gtk_style_context_state_is_running (GtkStyleContext *context,
|
||||
GtkStateType state,
|
||||
gdouble *progress)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
AnimationInfo *info;
|
||||
GSList *l;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
{
|
||||
info = l->data;
|
||||
|
||||
if (info->state == state &&
|
||||
context_has_animatable_region (context, info->region_id))
|
||||
{
|
||||
if (progress)
|
||||
*progress = _gtk_timeline_get_progress (info->timeline);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2861,6 +2637,8 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
|
||||
* is why the style places the transition under the :hover pseudo-class.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_notify_state_change (GtkStyleContext *context,
|
||||
@ -2869,100 +2647,10 @@ gtk_style_context_notify_state_change (GtkStyleContext *context,
|
||||
GtkStateType state,
|
||||
gboolean state_value)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GtkAnimationDescription *desc;
|
||||
AnimationInfo *info;
|
||||
GtkStateFlags flags;
|
||||
GtkCssValue *v;
|
||||
StyleData *data;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
g_return_if_fail (state > GTK_STATE_NORMAL && state <= GTK_STATE_FOCUSED);
|
||||
|
||||
priv = context->priv;
|
||||
g_return_if_fail (priv->widget != NULL || priv->widget_path != NULL);
|
||||
|
||||
state_value = (state_value == TRUE);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GTK_STATE_ACTIVE:
|
||||
flags = GTK_STATE_FLAG_ACTIVE;
|
||||
break;
|
||||
case GTK_STATE_PRELIGHT:
|
||||
flags = GTK_STATE_FLAG_PRELIGHT;
|
||||
break;
|
||||
case GTK_STATE_SELECTED:
|
||||
flags = GTK_STATE_FLAG_SELECTED;
|
||||
break;
|
||||
case GTK_STATE_INSENSITIVE:
|
||||
flags = GTK_STATE_FLAG_INSENSITIVE;
|
||||
break;
|
||||
case GTK_STATE_INCONSISTENT:
|
||||
flags = GTK_STATE_FLAG_INCONSISTENT;
|
||||
break;
|
||||
case GTK_STATE_FOCUSED:
|
||||
flags = GTK_STATE_FLAG_FOCUSED;
|
||||
break;
|
||||
case GTK_STATE_NORMAL:
|
||||
default:
|
||||
flags = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Find out if there is any animation description for the given
|
||||
* state, it will fallback to the normal state as well if necessary.
|
||||
*/
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_set_state (context, flags);
|
||||
data = style_data_lookup (context);
|
||||
gtk_style_context_restore (context);
|
||||
v = _gtk_css_computed_values_get_value (data->store, GTK_CSS_PROPERTY_TRANSITION);
|
||||
if (!v)
|
||||
return;
|
||||
desc = _gtk_css_value_get_boxed (v);
|
||||
if (!desc)
|
||||
return;
|
||||
|
||||
if (_gtk_animation_description_get_duration (desc) == 0)
|
||||
return;
|
||||
|
||||
info = animation_info_lookup (context, region_id, state);
|
||||
|
||||
if (info &&
|
||||
info->target_value != state_value)
|
||||
{
|
||||
/* Target values are the opposite */
|
||||
if (!_gtk_timeline_get_loop (info->timeline))
|
||||
{
|
||||
/* Reverse the animation */
|
||||
if (_gtk_timeline_get_direction (info->timeline) == GTK_TIMELINE_DIRECTION_FORWARD)
|
||||
_gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD);
|
||||
else
|
||||
_gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_FORWARD);
|
||||
|
||||
info->target_value = state_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Take it out of its looping state */
|
||||
_gtk_timeline_set_loop (info->timeline, FALSE);
|
||||
}
|
||||
}
|
||||
else if (!info &&
|
||||
(!_gtk_animation_description_get_loop (desc) ||
|
||||
state_value))
|
||||
{
|
||||
info = animation_info_new (context, region_id,
|
||||
_gtk_animation_description_get_duration (desc),
|
||||
_gtk_animation_description_get_progress_type (desc),
|
||||
_gtk_animation_description_get_loop (desc),
|
||||
state, state_value, window);
|
||||
|
||||
priv->animations = g_slist_prepend (priv->animations, info);
|
||||
priv->animations_invalidated = TRUE;
|
||||
}
|
||||
g_return_if_fail (context->priv->widget != NULL || context->priv->widget_path != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2982,60 +2670,14 @@ gtk_style_context_notify_state_change (GtkStyleContext *context,
|
||||
* animatable regions.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_cancel_animations (GtkStyleContext *context,
|
||||
gpointer region_id)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
AnimationInfo *info;
|
||||
GSList *l;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
priv = context->priv;
|
||||
l = priv->animations;
|
||||
|
||||
while (l)
|
||||
{
|
||||
info = l->data;
|
||||
l = l->next;
|
||||
|
||||
if (!region_id ||
|
||||
info->region_id == region_id ||
|
||||
g_slist_find (info->parent_regions, region_id))
|
||||
{
|
||||
priv->animations = g_slist_remove (priv->animations, info);
|
||||
animation_info_free (info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_parent_of (GdkWindow *parent,
|
||||
GdkWindow *child)
|
||||
{
|
||||
GtkWidget *child_widget, *parent_widget;
|
||||
GdkWindow *window;
|
||||
|
||||
gdk_window_get_user_data (child, (gpointer *) &child_widget);
|
||||
gdk_window_get_user_data (parent, (gpointer *) &parent_widget);
|
||||
|
||||
if (child_widget != parent_widget &&
|
||||
!gtk_widget_is_ancestor (child_widget, parent_widget))
|
||||
return FALSE;
|
||||
|
||||
window = child;
|
||||
|
||||
while (window)
|
||||
{
|
||||
if (window == parent)
|
||||
return TRUE;
|
||||
|
||||
window = gdk_window_get_parent (window);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3052,6 +2694,8 @@ is_parent_of (GdkWindow *parent,
|
||||
* with it.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_scroll_animations (GtkStyleContext *context,
|
||||
@ -3059,26 +2703,8 @@ gtk_style_context_scroll_animations (GtkStyleContext *context,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
AnimationInfo *info;
|
||||
GSList *l;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
priv = context->priv;
|
||||
l = priv->animations;
|
||||
|
||||
while (l)
|
||||
{
|
||||
info = l->data;
|
||||
l = l->next;
|
||||
|
||||
if (info->invalidation_region &&
|
||||
(window == info->window ||
|
||||
is_parent_of (window, info->window)))
|
||||
cairo_region_translate (info->invalidation_region, dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3097,18 +2723,15 @@ gtk_style_context_scroll_animations (GtkStyleContext *context,
|
||||
* can uniquely identify rendered elements subject to a state transition.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_push_animatable_region (GtkStyleContext *context,
|
||||
gpointer region_id)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (region_id != NULL);
|
||||
|
||||
priv = context->priv;
|
||||
priv->animation_regions = g_slist_prepend (priv->animation_regions, region_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3119,150 +2742,13 @@ gtk_style_context_push_animatable_region (GtkStyleContext *context,
|
||||
* See gtk_style_context_push_animatable_region().
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: This function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_pop_animatable_region (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
priv = context->priv;
|
||||
priv->animation_regions = g_slist_delete_link (priv->animation_regions,
|
||||
priv->animation_regions);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_invalidate_animation_areas (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GSList *l;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
{
|
||||
AnimationInfo *info;
|
||||
|
||||
info = l->data;
|
||||
|
||||
/* A NULL invalidation region means it has to be recreated on
|
||||
* the next expose event, this happens usually after a widget
|
||||
* allocation change, so the next expose after it will update
|
||||
* the invalidation region.
|
||||
*/
|
||||
if (info->invalidation_region)
|
||||
{
|
||||
cairo_region_destroy (info->invalidation_region);
|
||||
info->invalidation_region = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
priv->animations_invalidated = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GSList *l;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
if (!priv->animations_invalidated)
|
||||
return;
|
||||
|
||||
l = priv->animations;
|
||||
|
||||
while (l)
|
||||
{
|
||||
AnimationInfo *info;
|
||||
gint rel_x, rel_y;
|
||||
GSList *cur;
|
||||
guint i;
|
||||
|
||||
cur = l;
|
||||
info = cur->data;
|
||||
l = l->next;
|
||||
|
||||
if (info->invalidation_region)
|
||||
continue;
|
||||
|
||||
if (info->rectangles->len == 0)
|
||||
continue;
|
||||
|
||||
info->invalidation_region = cairo_region_create ();
|
||||
_gtk_widget_get_translation_to_window (widget, info->window, &rel_x, &rel_y);
|
||||
|
||||
for (i = 0; i < info->rectangles->len; i++)
|
||||
{
|
||||
cairo_rectangle_int_t *rect;
|
||||
|
||||
rect = &g_array_index (info->rectangles, cairo_rectangle_int_t, i);
|
||||
|
||||
/* These are widget relative coordinates,
|
||||
* so have them inverted to be window relative
|
||||
*/
|
||||
rect->x -= rel_x;
|
||||
rect->y -= rel_y;
|
||||
|
||||
cairo_region_union_rectangle (info->invalidation_region, rect);
|
||||
}
|
||||
|
||||
g_array_remove_range (info->rectangles, 0, info->rectangles->len);
|
||||
}
|
||||
|
||||
priv->animations_invalidated = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
store_animation_region (GtkStyleContext *context,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GSList *l;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
if (!priv->animations_invalidated)
|
||||
return;
|
||||
|
||||
for (l = priv->animations; l; l = l->next)
|
||||
{
|
||||
AnimationInfo *info;
|
||||
|
||||
info = l->data;
|
||||
|
||||
/* The animation doesn't need updating
|
||||
* the invalidation area, bail out.
|
||||
*/
|
||||
if (info->invalidation_region)
|
||||
continue;
|
||||
|
||||
if (context_has_animatable_region (context, info->region_id))
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
rect.x = (gint) x;
|
||||
rect.y = (gint) y;
|
||||
rect.width = (gint) width;
|
||||
rect.height = (gint) height;
|
||||
|
||||
g_array_append_val (info->rectangles, rect);
|
||||
|
||||
if (!info->parent_regions)
|
||||
{
|
||||
GSList *parent_regions;
|
||||
|
||||
parent_regions = g_slist_find (priv->animation_regions, info->region_id);
|
||||
info->parent_regions = g_slist_copy (parent_regions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3772,7 +3258,6 @@ gtk_render_check (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_check (priv->theming_engine, cr,
|
||||
@ -3823,8 +3308,6 @@ gtk_render_option (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_option (priv->theming_engine, cr,
|
||||
x, y, width, height);
|
||||
@ -3875,8 +3358,6 @@ gtk_render_arrow (GtkStyleContext *context,
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
|
||||
|
||||
store_animation_region (context, x, y, size, size);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_arrow (priv->theming_engine, cr,
|
||||
angle, x, y, size);
|
||||
@ -3928,8 +3409,6 @@ gtk_render_background (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_background (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -3981,8 +3460,6 @@ gtk_render_frame (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_frame (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -4031,8 +3508,6 @@ gtk_render_expander (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_expander (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -4078,8 +3553,6 @@ gtk_render_focus (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_focus (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -4120,12 +3593,6 @@ gtk_render_layout (GtkStyleContext *context,
|
||||
|
||||
pango_layout_get_extents (layout, &extents, NULL);
|
||||
|
||||
store_animation_region (context,
|
||||
x + extents.x,
|
||||
y + extents.y,
|
||||
extents.width,
|
||||
extents.height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_layout (priv->theming_engine, cr, x, y, layout);
|
||||
|
||||
@ -4214,8 +3681,6 @@ gtk_render_slider (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation);
|
||||
|
||||
@ -4279,8 +3744,6 @@ gtk_render_frame_gap (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_frame_gap (priv->theming_engine, cr,
|
||||
x, y, width, height, gap_side,
|
||||
@ -4333,8 +3796,6 @@ gtk_render_extension (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side);
|
||||
|
||||
@ -4383,8 +3844,6 @@ gtk_render_handle (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_handle (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -4428,8 +3887,6 @@ gtk_render_activity (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context, x, y, width, height);
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_activity (priv->theming_engine, cr, x, y, width, height);
|
||||
|
||||
@ -4499,11 +3956,6 @@ gtk_render_icon (GtkStyleContext *context,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
store_animation_region (context,
|
||||
x, y,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
|
||||
_gtk_theming_engine_set_context (priv->theming_engine, context);
|
||||
engine_class->render_icon (priv->theming_engine, cr, pixbuf, x, y);
|
||||
|
||||
|
@ -741,6 +741,7 @@ void gtk_style_context_set_state (GtkStyleContext *context,
|
||||
GtkStateFlags flags);
|
||||
GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
|
||||
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
gboolean gtk_style_context_state_is_running (GtkStyleContext *context,
|
||||
GtkStateType state,
|
||||
gdouble *progress);
|
||||
@ -803,20 +804,25 @@ gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
|
||||
const gchar *color_name,
|
||||
GdkRGBA *color);
|
||||
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
void gtk_style_context_notify_state_change (GtkStyleContext *context,
|
||||
GdkWindow *window,
|
||||
gpointer region_id,
|
||||
GtkStateType state,
|
||||
gboolean state_value);
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
void gtk_style_context_cancel_animations (GtkStyleContext *context,
|
||||
gpointer region_id);
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
void gtk_style_context_scroll_animations (GtkStyleContext *context,
|
||||
GdkWindow *window,
|
||||
gint dx,
|
||||
gint dy);
|
||||
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
void gtk_style_context_push_animatable_region (GtkStyleContext *context,
|
||||
gpointer region_id);
|
||||
GDK_DEPRECATED_IN_3_6
|
||||
void gtk_style_context_pop_animatable_region (GtkStyleContext *context);
|
||||
|
||||
/* Some helper functions to retrieve most common properties */
|
||||
|
@ -39,9 +39,6 @@ void _gtk_style_context_validate (GtkStyleContext *c
|
||||
GtkCssChange change);
|
||||
void _gtk_style_context_queue_invalidate (GtkStyleContext *context,
|
||||
GtkCssChange change);
|
||||
void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
|
||||
void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
|
||||
GtkWidget *widget);
|
||||
gboolean _gtk_style_context_check_region_name (const gchar *str);
|
||||
|
||||
gboolean _gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "gtkstyleprovider.h"
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtkthemingengine.h"
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkgradient.h"
|
||||
#include "gtkcssshadowvalueprivate.h"
|
||||
#include "gtkcssshorthandpropertyprivate.h"
|
||||
|
@ -1021,10 +1021,7 @@ gtk_switch_set_active (GtkSwitch *sw,
|
||||
if (priv->is_active != is_active)
|
||||
{
|
||||
AtkObject *accessible;
|
||||
GtkWidget *widget;
|
||||
GtkStyleContext *context;
|
||||
|
||||
widget = GTK_WIDGET (sw);
|
||||
priv->is_active = is_active;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (sw), switch_props[PROP_ACTIVE]);
|
||||
@ -1038,14 +1035,6 @@ gtk_switch_set_active (GtkSwitch *sw,
|
||||
accessible = gtk_widget_get_accessible (GTK_WIDGET (sw));
|
||||
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, priv->is_active);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
{
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_notify_state_change (context,
|
||||
gtk_widget_get_window (widget),
|
||||
NULL, GTK_STATE_ACTIVE, is_active);
|
||||
}
|
||||
|
||||
if (priv->is_active)
|
||||
gtk_widget_set_state_flags (GTK_WIDGET (sw), GTK_STATE_FLAG_ACTIVE, FALSE);
|
||||
else
|
||||
|
@ -580,18 +580,17 @@ gtk_theming_engine_get_state (GtkThemingEngine *engine)
|
||||
* Returns: %TRUE if there is a running transition animation for @state.
|
||||
*
|
||||
* Since: 3.0
|
||||
*
|
||||
* Deprecated: 3.6: Always returns %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gtk_theming_engine_state_is_running (GtkThemingEngine *engine,
|
||||
GtkStateType state,
|
||||
gdouble *progress)
|
||||
{
|
||||
GtkThemingEnginePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
|
||||
|
||||
priv = engine->priv;
|
||||
return gtk_style_context_state_is_running (priv->context, state, progress);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,760 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2007 Carlos Garnacho <carlos@imendio.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtk/gtktimeline.h>
|
||||
#include <gtk/gtktypebuiltins.h>
|
||||
#include <gtk/gtksettings.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MSECS_PER_SEC 1000
|
||||
#define FRAME_INTERVAL(nframes) (MSECS_PER_SEC / nframes)
|
||||
#define DEFAULT_FPS 30
|
||||
|
||||
typedef struct GtkTimelinePriv GtkTimelinePriv;
|
||||
|
||||
struct GtkTimelinePriv
|
||||
{
|
||||
guint duration;
|
||||
guint fps;
|
||||
guint source_id;
|
||||
|
||||
GTimer *timer;
|
||||
gdouble elapsed_time;
|
||||
|
||||
gdouble progress;
|
||||
gdouble last_progress;
|
||||
|
||||
GdkScreen *screen;
|
||||
|
||||
GtkTimelineProgressType progress_type;
|
||||
|
||||
guint animations_enabled : 1;
|
||||
guint loop : 1;
|
||||
guint direction : 1;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_FPS,
|
||||
PROP_DURATION,
|
||||
PROP_LOOP,
|
||||
PROP_DIRECTION,
|
||||
PROP_SCREEN
|
||||
};
|
||||
|
||||
enum {
|
||||
STARTED,
|
||||
PAUSED,
|
||||
FINISHED,
|
||||
FRAME,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals [LAST_SIGNAL] = { 0, };
|
||||
|
||||
|
||||
static void gtk_timeline_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_timeline_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void _gtk_timeline_finalize (GObject *object);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GtkTimeline, _gtk_timeline, G_TYPE_OBJECT)
|
||||
|
||||
|
||||
static void
|
||||
_gtk_timeline_class_init (GtkTimelineClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gtk_timeline_set_property;
|
||||
object_class->get_property = gtk_timeline_get_property;
|
||||
object_class->finalize = _gtk_timeline_finalize;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_FPS,
|
||||
g_param_spec_uint ("fps",
|
||||
"FPS",
|
||||
"Frames per second for the timeline",
|
||||
1, G_MAXUINT,
|
||||
DEFAULT_FPS,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_DURATION,
|
||||
g_param_spec_uint ("duration",
|
||||
"Animation Duration",
|
||||
"Animation Duration",
|
||||
0, G_MAXUINT,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LOOP,
|
||||
g_param_spec_boolean ("loop",
|
||||
"Loop",
|
||||
"Whether the timeline loops or not",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SCREEN,
|
||||
g_param_spec_object ("screen",
|
||||
"Screen",
|
||||
"Screen to get the settings from",
|
||||
GDK_TYPE_SCREEN,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
signals[STARTED] =
|
||||
g_signal_new ("started",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkTimelineClass, started),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[PAUSED] =
|
||||
g_signal_new ("paused",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkTimelineClass, paused),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[FINISHED] =
|
||||
g_signal_new ("finished",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkTimelineClass, finished),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[FRAME] =
|
||||
g_signal_new ("frame",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkTimelineClass, frame),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__DOUBLE,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_DOUBLE);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GtkTimelinePriv));
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_timeline_init (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
priv = timeline->priv = G_TYPE_INSTANCE_GET_PRIVATE (timeline,
|
||||
GTK_TYPE_TIMELINE,
|
||||
GtkTimelinePriv);
|
||||
|
||||
priv->fps = DEFAULT_FPS;
|
||||
priv->duration = 0.0;
|
||||
priv->direction = GTK_TIMELINE_DIRECTION_FORWARD;
|
||||
priv->screen = gdk_screen_get_default ();
|
||||
|
||||
priv->last_progress = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_timeline_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkTimeline *timeline;
|
||||
|
||||
timeline = GTK_TIMELINE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FPS:
|
||||
_gtk_timeline_set_fps (timeline, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_DURATION:
|
||||
_gtk_timeline_set_duration (timeline, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_LOOP:
|
||||
_gtk_timeline_set_loop (timeline, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_DIRECTION:
|
||||
_gtk_timeline_set_direction (timeline, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_SCREEN:
|
||||
_gtk_timeline_set_screen (timeline,
|
||||
GDK_SCREEN (g_value_get_object (value)));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_timeline_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkTimeline *timeline;
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
timeline = GTK_TIMELINE (object);
|
||||
priv = timeline->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FPS:
|
||||
g_value_set_uint (value, priv->fps);
|
||||
break;
|
||||
case PROP_DURATION:
|
||||
g_value_set_uint (value, priv->duration);
|
||||
break;
|
||||
case PROP_LOOP:
|
||||
g_value_set_boolean (value, priv->loop);
|
||||
break;
|
||||
case PROP_DIRECTION:
|
||||
g_value_set_enum (value, priv->direction);
|
||||
break;
|
||||
case PROP_SCREEN:
|
||||
g_value_set_object (value, priv->screen);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_timeline_finalize (GObject *object)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
GtkTimeline *timeline;
|
||||
|
||||
timeline = (GtkTimeline *) object;
|
||||
priv = timeline->priv;
|
||||
|
||||
if (priv->source_id)
|
||||
{
|
||||
g_source_remove (priv->source_id);
|
||||
priv->source_id = 0;
|
||||
}
|
||||
|
||||
if (priv->timer)
|
||||
g_timer_destroy (priv->timer);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_timeline_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gdouble
|
||||
calculate_progress (gdouble linear_progress,
|
||||
GtkTimelineProgressType progress_type)
|
||||
{
|
||||
gdouble progress;
|
||||
|
||||
progress = linear_progress;
|
||||
|
||||
switch (progress_type)
|
||||
{
|
||||
case GTK_TIMELINE_PROGRESS_LINEAR:
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN_OUT:
|
||||
progress *= 2;
|
||||
|
||||
if (progress < 1)
|
||||
progress = pow (progress, 3) / 2;
|
||||
else
|
||||
progress = (pow (progress - 2, 3) + 2) / 2;
|
||||
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE:
|
||||
progress = (sin ((progress - 0.5) * G_PI) + 1) / 2;
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN:
|
||||
progress = pow (progress, 3);
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_OUT:
|
||||
progress = pow (progress - 1, 3) + 1;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Timeline progress type not implemented");
|
||||
}
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_timeline_run_frame (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
gdouble delta_progress, progress;
|
||||
|
||||
/* the user may unref us during the signals, so save ourselves */
|
||||
g_object_ref (timeline);
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
priv->elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
|
||||
g_timer_start (priv->timer);
|
||||
|
||||
if (priv->animations_enabled)
|
||||
{
|
||||
delta_progress = (gdouble) priv->elapsed_time / priv->duration;
|
||||
progress = priv->last_progress;
|
||||
|
||||
if (priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD)
|
||||
progress -= delta_progress;
|
||||
else
|
||||
progress += delta_progress;
|
||||
|
||||
priv->last_progress = progress;
|
||||
|
||||
progress = CLAMP (progress, 0., 1.);
|
||||
}
|
||||
else
|
||||
progress = (priv->direction == GTK_TIMELINE_DIRECTION_FORWARD) ? 1.0 : 0.0;
|
||||
|
||||
priv->progress = progress;
|
||||
g_signal_emit (timeline, signals [FRAME], 0,
|
||||
calculate_progress (progress, priv->progress_type));
|
||||
|
||||
if ((priv->direction == GTK_TIMELINE_DIRECTION_FORWARD && progress == 1.0) ||
|
||||
(priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD && progress == 0.0))
|
||||
{
|
||||
gboolean loop;
|
||||
|
||||
loop = priv->loop && priv->animations_enabled;
|
||||
|
||||
if (loop)
|
||||
_gtk_timeline_rewind (timeline);
|
||||
else
|
||||
{
|
||||
if (priv->source_id)
|
||||
{
|
||||
g_source_remove (priv->source_id);
|
||||
priv->source_id = 0;
|
||||
}
|
||||
g_timer_stop (priv->timer);
|
||||
g_signal_emit (timeline, signals [FINISHED], 0);
|
||||
g_object_unref (timeline);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (timeline);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_new:
|
||||
* @duration: duration in milliseconds for the timeline
|
||||
*
|
||||
* Creates a new #GtkTimeline with the specified number of frames.
|
||||
*
|
||||
* Return Value: the newly created #GtkTimeline
|
||||
*/
|
||||
GtkTimeline *
|
||||
_gtk_timeline_new (guint duration)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_TIMELINE,
|
||||
"duration", duration,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GtkTimeline *
|
||||
_gtk_timeline_new_for_screen (guint duration,
|
||||
GdkScreen *screen)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_TIMELINE,
|
||||
"duration", duration,
|
||||
"screen", screen,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_start:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Runs the timeline from the current frame.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_start (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
GtkSettings *settings;
|
||||
gboolean enable_animations = FALSE;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (!priv->source_id)
|
||||
{
|
||||
if (priv->timer)
|
||||
g_timer_continue (priv->timer);
|
||||
else
|
||||
priv->timer = g_timer_new ();
|
||||
|
||||
/* sanity check */
|
||||
g_assert (priv->fps > 0);
|
||||
|
||||
if (priv->screen)
|
||||
{
|
||||
settings = gtk_settings_get_for_screen (priv->screen);
|
||||
g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL);
|
||||
}
|
||||
|
||||
priv->animations_enabled = enable_animations;
|
||||
|
||||
g_signal_emit (timeline, signals [STARTED], 0);
|
||||
|
||||
if (enable_animations)
|
||||
priv->source_id = gdk_threads_add_timeout (FRAME_INTERVAL (priv->fps),
|
||||
(GSourceFunc) gtk_timeline_run_frame,
|
||||
timeline);
|
||||
else
|
||||
priv->source_id = gdk_threads_add_idle ((GSourceFunc) gtk_timeline_run_frame,
|
||||
timeline);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_pause:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Pauses the timeline.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_pause (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (priv->source_id)
|
||||
{
|
||||
g_timer_stop (priv->timer);
|
||||
g_source_remove (priv->source_id);
|
||||
priv->source_id = 0;
|
||||
g_signal_emit (timeline, signals [PAUSED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_rewind:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Rewinds the timeline.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_rewind (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (_gtk_timeline_get_direction (timeline) != GTK_TIMELINE_DIRECTION_FORWARD)
|
||||
priv->progress = priv->last_progress = 1.;
|
||||
else
|
||||
priv->progress = priv->last_progress = 0.;
|
||||
|
||||
/* reset timer */
|
||||
if (priv->timer)
|
||||
{
|
||||
g_timer_start (priv->timer);
|
||||
|
||||
if (!priv->source_id)
|
||||
g_timer_stop (priv->timer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_is_running:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Returns whether the timeline is running or not.
|
||||
*
|
||||
* Return Value: %TRUE if the timeline is running
|
||||
*/
|
||||
gboolean
|
||||
_gtk_timeline_is_running (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), FALSE);
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
return (priv->source_id != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_get_elapsed_time:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Returns the elapsed time since the last GtkTimeline::frame signal
|
||||
*
|
||||
* Return Value: elapsed time in milliseconds since the last frame
|
||||
*/
|
||||
guint
|
||||
_gtk_timeline_get_elapsed_time (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->elapsed_time;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_get_fps:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Returns the number of frames per second.
|
||||
*
|
||||
* Return Value: frames per second
|
||||
*/
|
||||
guint
|
||||
_gtk_timeline_get_fps (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 1);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->fps;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_set_fps:
|
||||
* @timeline: A #GtkTimeline
|
||||
* @fps: frames per second
|
||||
*
|
||||
* Sets the number of frames per second that
|
||||
* the timeline will play.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_set_fps (GtkTimeline *timeline,
|
||||
guint fps)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
g_return_if_fail (fps > 0);
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
priv->fps = fps;
|
||||
|
||||
if (_gtk_timeline_is_running (timeline))
|
||||
{
|
||||
g_source_remove (priv->source_id);
|
||||
priv->source_id = gdk_threads_add_timeout (FRAME_INTERVAL (priv->fps),
|
||||
(GSourceFunc) gtk_timeline_run_frame,
|
||||
timeline);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (timeline), "fps");
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_get_loop:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Returns whether the timeline loops to the
|
||||
* beginning when it has reached the end.
|
||||
*
|
||||
* Return Value: %TRUE if the timeline loops
|
||||
*/
|
||||
gboolean
|
||||
_gtk_timeline_get_loop (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), FALSE);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->loop;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_set_loop:
|
||||
* @timeline: A #GtkTimeline
|
||||
* @loop: %TRUE to make the timeline loop
|
||||
*
|
||||
* Sets whether the timeline loops to the beginning
|
||||
* when it has reached the end.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_set_loop (GtkTimeline *timeline,
|
||||
gboolean loop)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (loop != priv->loop)
|
||||
{
|
||||
priv->loop = loop;
|
||||
g_object_notify (G_OBJECT (timeline), "loop");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_timeline_set_duration (GtkTimeline *timeline,
|
||||
guint duration)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (duration != priv->duration)
|
||||
{
|
||||
priv->duration = duration;
|
||||
g_object_notify (G_OBJECT (timeline), "duration");
|
||||
}
|
||||
}
|
||||
|
||||
guint
|
||||
_gtk_timeline_get_duration (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0);
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
return priv->duration;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_set_direction:
|
||||
* @timeline: A #GtkTimeline
|
||||
* @direction: direction
|
||||
*
|
||||
* Sets the direction of the timeline.
|
||||
*/
|
||||
void
|
||||
_gtk_timeline_set_direction (GtkTimeline *timeline,
|
||||
GtkTimelineDirection direction)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
priv->direction = direction;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_timeline_get_direction:
|
||||
* @timeline: A #GtkTimeline
|
||||
*
|
||||
* Returns the direction of the timeline.
|
||||
*
|
||||
* Return Value: direction
|
||||
*/
|
||||
GtkTimelineDirection
|
||||
_gtk_timeline_get_direction (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), GTK_TIMELINE_DIRECTION_FORWARD);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->direction;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_timeline_set_screen (GtkTimeline *timeline,
|
||||
GdkScreen *screen)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
|
||||
priv = timeline->priv;
|
||||
|
||||
if (priv->screen)
|
||||
g_object_unref (priv->screen);
|
||||
|
||||
priv->screen = g_object_ref (screen);
|
||||
|
||||
g_object_notify (G_OBJECT (timeline), "screen");
|
||||
}
|
||||
|
||||
GdkScreen *
|
||||
_gtk_timeline_get_screen (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), NULL);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->screen;
|
||||
}
|
||||
|
||||
gdouble
|
||||
_gtk_timeline_get_progress (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0.);
|
||||
|
||||
priv = timeline->priv;
|
||||
return calculate_progress (priv->progress, priv->progress_type);
|
||||
}
|
||||
|
||||
GtkTimelineProgressType
|
||||
_gtk_timeline_get_progress_type (GtkTimeline *timeline)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), GTK_TIMELINE_PROGRESS_LINEAR);
|
||||
|
||||
priv = timeline->priv;
|
||||
return priv->progress_type;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_timeline_set_progress_type (GtkTimeline *timeline,
|
||||
GtkTimelineProgressType progress_type)
|
||||
{
|
||||
GtkTimelinePriv *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_TIMELINE (timeline));
|
||||
|
||||
priv = timeline->priv;
|
||||
priv->progress_type = progress_type;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2007 Carlos Garnacho <carlos@imendio.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_TIMELINE_H__
|
||||
#define __GTK_TIMELINE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_TIMELINE (_gtk_timeline_get_type ())
|
||||
#define GTK_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TIMELINE, GtkTimeline))
|
||||
#define GTK_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TIMELINE, GtkTimelineClass))
|
||||
#define GTK_IS_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TIMELINE))
|
||||
#define GTK_IS_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TIMELINE))
|
||||
#define GTK_TIMELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TIMELINE, GtkTimelineClass))
|
||||
|
||||
typedef struct GtkTimeline GtkTimeline;
|
||||
typedef struct GtkTimelineClass GtkTimelineClass;
|
||||
|
||||
typedef enum {
|
||||
GTK_TIMELINE_DIRECTION_FORWARD,
|
||||
GTK_TIMELINE_DIRECTION_BACKWARD
|
||||
} GtkTimelineDirection;
|
||||
|
||||
typedef enum {
|
||||
GTK_TIMELINE_PROGRESS_LINEAR,
|
||||
GTK_TIMELINE_PROGRESS_EASE,
|
||||
GTK_TIMELINE_PROGRESS_EASE_IN,
|
||||
GTK_TIMELINE_PROGRESS_EASE_OUT,
|
||||
GTK_TIMELINE_PROGRESS_EASE_IN_OUT
|
||||
} GtkTimelineProgressType;
|
||||
|
||||
struct GtkTimeline
|
||||
{
|
||||
GObject parent_instance;
|
||||
gpointer priv;
|
||||
};
|
||||
|
||||
struct GtkTimelineClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* started) (GtkTimeline *timeline);
|
||||
void (* finished) (GtkTimeline *timeline);
|
||||
void (* paused) (GtkTimeline *timeline);
|
||||
|
||||
void (* frame) (GtkTimeline *timeline,
|
||||
gdouble progress);
|
||||
|
||||
void (* __gtk_reserved1) (void);
|
||||
void (* __gtk_reserved2) (void);
|
||||
void (* __gtk_reserved3) (void);
|
||||
void (* __gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
|
||||
GType _gtk_timeline_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkTimeline * _gtk_timeline_new (guint duration);
|
||||
GtkTimeline * _gtk_timeline_new_for_screen (guint duration,
|
||||
GdkScreen *screen);
|
||||
|
||||
void _gtk_timeline_start (GtkTimeline *timeline);
|
||||
void _gtk_timeline_pause (GtkTimeline *timeline);
|
||||
void _gtk_timeline_rewind (GtkTimeline *timeline);
|
||||
|
||||
gboolean _gtk_timeline_is_running (GtkTimeline *timeline);
|
||||
guint _gtk_timeline_get_elapsed_time (GtkTimeline *timeline);
|
||||
|
||||
guint _gtk_timeline_get_fps (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_fps (GtkTimeline *timeline,
|
||||
guint fps);
|
||||
|
||||
gboolean _gtk_timeline_get_loop (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_loop (GtkTimeline *timeline,
|
||||
gboolean loop);
|
||||
|
||||
guint _gtk_timeline_get_duration (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_duration (GtkTimeline *timeline,
|
||||
guint duration);
|
||||
|
||||
GdkScreen * _gtk_timeline_get_screen (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_screen (GtkTimeline *timeline,
|
||||
GdkScreen *screen);
|
||||
|
||||
GtkTimelineDirection _gtk_timeline_get_direction (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_direction (GtkTimeline *timeline,
|
||||
GtkTimelineDirection direction);
|
||||
|
||||
gdouble _gtk_timeline_get_progress (GtkTimeline *timeline);
|
||||
|
||||
GtkTimelineProgressType _gtk_timeline_get_progress_type (GtkTimeline *timeline);
|
||||
void _gtk_timeline_set_progress_type (GtkTimeline *timeline,
|
||||
GtkTimelineProgressType progress_type);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TIMELINE_H__ */
|
@ -303,14 +303,10 @@ gtk_tool_item_group_header_draw_cb (GtkWidget *widget,
|
||||
y = 0;
|
||||
}
|
||||
|
||||
/* The expander is the only animatable region */
|
||||
gtk_style_context_push_animatable_region (context, GUINT_TO_POINTER (1));
|
||||
|
||||
gtk_render_expander (context, cr, x, y,
|
||||
priv->expander_size,
|
||||
priv->expander_size);
|
||||
|
||||
gtk_style_context_pop_animatable_region (context);
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
return FALSE;
|
||||
@ -1909,8 +1905,6 @@ gtk_tool_item_group_set_collapsed (GtkToolItemGroup *group,
|
||||
GTK_WIDGET (group));
|
||||
if (collapsed != priv->collapsed)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
if (priv->animation)
|
||||
{
|
||||
if (priv->animation_timeout)
|
||||
@ -1923,19 +1917,6 @@ gtk_tool_item_group_set_collapsed (GtkToolItemGroup *group,
|
||||
gtk_tool_item_group_animation_cb,
|
||||
group, NULL);
|
||||
g_source_attach (priv->animation_timeout, NULL);
|
||||
|
||||
context = gtk_widget_get_style_context (gtk_bin_get_child (GTK_BIN (priv->header)));
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
gtk_style_context_notify_state_change (context,
|
||||
gtk_widget_get_window (priv->header),
|
||||
GUINT_TO_POINTER (1),
|
||||
GTK_STATE_FLAG_ACTIVE,
|
||||
!collapsed);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
else
|
||||
gtk_tool_item_group_force_expose (group);
|
||||
|
@ -2299,7 +2299,6 @@ gtk_tree_view_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
|
||||
GtkTreeViewPrivate *priv = tree_view->priv;
|
||||
GtkStyleContext *context;
|
||||
GList *list;
|
||||
|
||||
if (priv->scroll_timeout != 0)
|
||||
@ -2320,9 +2319,6 @@ gtk_tree_view_unrealize (GtkWidget *widget)
|
||||
priv->open_dest_timeout = 0;
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_cancel_animations (context, NULL);
|
||||
|
||||
if (priv->presize_handler_timer != 0)
|
||||
{
|
||||
g_source_remove (priv->presize_handler_timer);
|
||||
@ -9009,7 +9005,6 @@ gtk_tree_view_row_deleted (GtkTreeModel *model,
|
||||
gboolean selection_changed = FALSE, cursor_changed = FALSE;
|
||||
GtkRBTree *cursor_tree = NULL;
|
||||
GtkRBNode *cursor_node = NULL;
|
||||
GtkStyleContext *context;
|
||||
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
@ -9114,10 +9109,6 @@ gtk_tree_view_row_deleted (GtkTreeModel *model,
|
||||
tree_view->priv->top_row = NULL;
|
||||
}
|
||||
|
||||
/* Cancel any ongoing animation happening within the row */
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
|
||||
gtk_style_context_cancel_animations (context, node);
|
||||
|
||||
install_scroll_sync_handler (tree_view);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
|
||||
@ -10140,13 +10131,10 @@ gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
|
||||
gtk_style_context_set_state (context, state);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
gtk_style_context_push_animatable_region (context, node);
|
||||
|
||||
gtk_render_expander (context, cr,
|
||||
area.x, area.y,
|
||||
area.width, area.height);
|
||||
|
||||
gtk_style_context_pop_animatable_region (context);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
@ -11255,7 +11243,6 @@ gtk_tree_view_adjustment_changed (GtkAdjustment *adjustment,
|
||||
{
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
gint dy;
|
||||
|
||||
gdk_window_move (tree_view->priv->bin_window,
|
||||
@ -11298,9 +11285,6 @@ gtk_tree_view_adjustment_changed (GtkAdjustment *adjustment,
|
||||
}
|
||||
gdk_window_scroll (tree_view->priv->bin_window, 0, dy);
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
|
||||
gtk_style_context_scroll_animations (context, tree_view->priv->bin_window, 0, dy);
|
||||
|
||||
if (tree_view->priv->dy != (int) gtk_adjustment_get_value (tree_view->priv->vadjustment))
|
||||
{
|
||||
/* update our dy and top_row */
|
||||
@ -11395,14 +11379,10 @@ gtk_tree_view_set_model (GtkTreeView *tree_view,
|
||||
if (tree_view->priv->model)
|
||||
{
|
||||
GList *tmplist = tree_view->priv->columns;
|
||||
GtkStyleContext *context;
|
||||
|
||||
gtk_tree_view_unref_and_check_selection_tree (tree_view, tree_view->priv->tree);
|
||||
gtk_tree_view_stop_editing (tree_view, TRUE);
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
|
||||
gtk_style_context_cancel_animations (context, NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (tree_view->priv->model,
|
||||
gtk_tree_view_row_changed,
|
||||
tree_view);
|
||||
@ -12794,22 +12774,6 @@ gtk_tree_view_real_expand_row (GtkTreeView *tree_view,
|
||||
tree, node,
|
||||
GTK_CELL_RENDERER_EXPANDED);
|
||||
|
||||
if (animate)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
gtk_style_context_notify_state_change (context, tree_view->priv->bin_window,
|
||||
node, GTK_STATE_ACTIVE, TRUE);
|
||||
|
||||
_gtk_style_context_invalidate_animation_areas (context);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
install_presize_handler (tree_view);
|
||||
|
||||
g_signal_emit (tree_view, tree_view_signals[ROW_EXPANDED], 0, &iter, path);
|
||||
@ -12973,22 +12937,6 @@ gtk_tree_view_real_collapse_row (GtkTreeView *tree_view,
|
||||
if (selection_changed)
|
||||
g_signal_emit_by_name (tree_view->priv->selection, "changed");
|
||||
|
||||
if (animate)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
|
||||
|
||||
gtk_style_context_notify_state_change (context, tree_view->priv->bin_window,
|
||||
node, GTK_STATE_ACTIVE, FALSE);
|
||||
|
||||
_gtk_style_context_invalidate_animation_areas (context);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (tree_view)))
|
||||
{
|
||||
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
|
||||
|
119
gtk/gtkwidget.c
119
gtk/gtkwidget.c
@ -56,7 +56,6 @@
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtkcssprovider.h"
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkmodifierstyle.h"
|
||||
#include "gtkversion.h"
|
||||
#include "gtkdebug.h"
|
||||
@ -4177,82 +4176,6 @@ gtk_widget_show_all (GtkWidget *widget)
|
||||
class->show_all (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_widget_notify_state_change (GtkWidget *widget,
|
||||
GtkStateFlags flag,
|
||||
gboolean target)
|
||||
{
|
||||
GtkStateType state;
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
case GTK_STATE_FLAG_ACTIVE:
|
||||
state = GTK_STATE_ACTIVE;
|
||||
break;
|
||||
case GTK_STATE_FLAG_PRELIGHT:
|
||||
state = GTK_STATE_PRELIGHT;
|
||||
break;
|
||||
case GTK_STATE_FLAG_SELECTED:
|
||||
state = GTK_STATE_SELECTED;
|
||||
break;
|
||||
case GTK_STATE_FLAG_INSENSITIVE:
|
||||
state = GTK_STATE_INSENSITIVE;
|
||||
break;
|
||||
case GTK_STATE_FLAG_INCONSISTENT:
|
||||
state = GTK_STATE_INCONSISTENT;
|
||||
break;
|
||||
case GTK_STATE_FLAG_FOCUSED:
|
||||
state = GTK_STATE_FOCUSED;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_style_context_notify_state_change (widget->priv->context,
|
||||
gtk_widget_get_window (widget),
|
||||
NULL, state, target);
|
||||
}
|
||||
|
||||
/* Initializes state transitions for those states that
|
||||
* were enabled before mapping and have a looping animation.
|
||||
*/
|
||||
static void
|
||||
_gtk_widget_start_state_transitions (GtkWidget *widget)
|
||||
{
|
||||
GtkStateFlags state, flag;
|
||||
|
||||
if (!widget->priv->context)
|
||||
return;
|
||||
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
flag = GTK_STATE_FLAG_FOCUSED;
|
||||
|
||||
while (flag)
|
||||
{
|
||||
GtkAnimationDescription *animation_desc;
|
||||
|
||||
if ((state & flag) == 0)
|
||||
{
|
||||
flag >>= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
gtk_style_context_get (widget->priv->context, state,
|
||||
"transition", &animation_desc,
|
||||
NULL);
|
||||
|
||||
if (animation_desc)
|
||||
{
|
||||
if (_gtk_animation_description_get_loop (animation_desc))
|
||||
_gtk_widget_notify_state_change (widget, flag, TRUE);
|
||||
|
||||
_gtk_animation_description_unref (animation_desc);
|
||||
}
|
||||
|
||||
flag >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_map:
|
||||
* @widget: a #GtkWidget
|
||||
@ -4284,8 +4207,6 @@ gtk_widget_map (GtkWidget *widget)
|
||||
gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
|
||||
|
||||
gtk_widget_pop_verify_invariants (widget);
|
||||
|
||||
_gtk_widget_start_state_transitions (widget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4316,9 +4237,6 @@ gtk_widget_unmap (GtkWidget *widget)
|
||||
|
||||
gtk_widget_pop_verify_invariants (widget);
|
||||
|
||||
if (priv->context)
|
||||
gtk_style_context_cancel_animations (priv->context, NULL);
|
||||
|
||||
/* Unset pointer/window info */
|
||||
g_object_set_qdata (G_OBJECT (widget), quark_pointer_window, NULL);
|
||||
}
|
||||
@ -5024,14 +4942,6 @@ gtk_widget_size_allocate (GtkWidget *widget,
|
||||
cairo_region_destroy (invalidate);
|
||||
}
|
||||
}
|
||||
|
||||
if (size_changed || position_changed)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
_gtk_style_context_invalidate_animation_areas (context);
|
||||
}
|
||||
}
|
||||
|
||||
if ((size_changed || position_changed) && priv->parent &&
|
||||
@ -5807,8 +5717,6 @@ _gtk_widget_draw_internal (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gboolean clip_to_size)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
if (!gtk_widget_is_drawable (widget))
|
||||
return;
|
||||
|
||||
@ -5844,9 +5752,6 @@ _gtk_widget_draw_internal (GtkWidget *widget,
|
||||
cairo_status_to_string (cairo_status (cr)));
|
||||
}
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
_gtk_style_context_coalesce_animation_areas (context, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -11024,30 +10929,6 @@ gtk_widget_propagate_state (GtkWidget *widget,
|
||||
&child_data);
|
||||
}
|
||||
|
||||
/* Trigger state change transitions for the widget */
|
||||
if (priv->context &&
|
||||
gtk_widget_get_mapped (widget))
|
||||
{
|
||||
gint diff, flag = 1;
|
||||
|
||||
diff = old_flags ^ new_flags;
|
||||
|
||||
while (diff != 0)
|
||||
{
|
||||
if ((diff & flag) != 0)
|
||||
{
|
||||
gboolean target;
|
||||
|
||||
target = ((new_flags & flag) != 0);
|
||||
_gtk_widget_notify_state_change (widget, flag, target);
|
||||
|
||||
diff &= ~flag;
|
||||
}
|
||||
|
||||
flag <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +151,6 @@ draw_cb_activity (GtkWidget *widget, cairo_t *cr)
|
||||
GtkWidgetPath *path;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_notify_state_change (context,
|
||||
gtk_widget_get_window (widget),
|
||||
NULL,
|
||||
GTK_STATE_FLAG_ACTIVE,
|
||||
TRUE);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
|
||||
path = gtk_widget_path_new ();
|
||||
|
Loading…
Reference in New Issue
Block a user