1 --- gtk+-2.6.4/gtk/gtktoolbar.c 2004-11-23 06:11:15.000000000 +0200
2 +++ gtk+-2.6.4/gtk/gtktoolbar.c 2005-04-06 16:19:38.166736136 +0300
5 #define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
6 #define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
7 +#define DEFAULT_ANIMATION_STATE FALSE
9 +#define DEFAULT_MAX_CHILD_SPACING G_MAXINT
10 #define MAX_HOMOGENEOUS_N_CHARS 13 /* Items that are wider than this do not participate
11 * in the homogeneous game. In units of
12 * pango_font_get_estimated_char_width().
17 + guint animation_connection;
22 guint need_rebuild : 1; /* whether the overflow menu should be regenerated */
23 + guint animation_set : 1;
24 + guint animation : 1;
27 static void gtk_toolbar_init (GtkToolbar *toolbar);
29 static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
30 static gboolean gtk_toolbar_check_new_api (GtkToolbar *toolbar);
31 static gboolean gtk_toolbar_check_old_api (GtkToolbar *toolbar);
32 +static void gtk_toolbar_update_animation_state (GtkToolbar *toolbar);
34 static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
35 static gint get_internal_padding (GtkToolbar *toolbar);
36 +static gint get_max_child_expand (GtkToolbar *toolbar);
37 static GtkShadowType get_shadow_type (GtkToolbar *toolbar);
38 static gint get_space_size (GtkToolbar *toolbar);
39 static GtkToolbarSpaceStyle get_space_style (GtkToolbar *toolbar);
43 gtk_widget_class_install_style_property (widget_class,
44 + g_param_spec_int ("max_child_expand",
45 + P_("Maximum toolbar item spacing"),
46 + P_("Maximum space between the toolbar items."),
49 + DEFAULT_MAX_CHILD_SPACING,
52 + gtk_widget_class_install_style_property (widget_class,
53 g_param_spec_enum ("space_style",
55 P_("Whether spacers are vertical lines or just blank"),
61 + gtk_settings_install_property (g_param_spec_boolean ("gtk-toolbar-animation",
62 + P_("Toolbar animation"),
63 + P_("Are we using toolbar animation"),
64 + DEFAULT_ANIMATION_STATE,
65 + G_PARAM_READWRITE));
67 binding_set = gtk_binding_set_by_class (klass);
70 toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
71 toolbar->style = DEFAULT_TOOLBAR_STYLE;
72 toolbar->icon_size = DEFAULT_ICON_SIZE;
73 + priv->animation = DEFAULT_ANIMATION_STATE;
74 toolbar->tooltips = gtk_tooltips_new ();
75 g_object_ref (toolbar->tooltips);
76 gtk_object_sink (GTK_OBJECT (toolbar->tooltips));
81 -position (gint from, gint to, gdouble elapsed)
82 +position (GtkToolbar *toolbar, gint from, gint to, gdouble elapsed)
86 @@ -978,11 +1002,20 @@
87 n_pixels = (SLIDE_SPEED / ACCEL_THRESHOLD) * elapsed * elapsed -
88 SLIDE_SPEED * elapsed + SLIDE_SPEED * ACCEL_THRESHOLD;
92 - return MIN (from + n_pixels, to);
94 - return MAX (from - n_pixels, to);
95 + if (GTK_TOOLBAR_GET_PRIVATE (toolbar)->animation) {
97 + return MIN (from + n_pixels, to);
99 + return MAX (from - n_pixels, to);
104 +static GtkSettings *
105 +toolbar_get_settings (GtkToolbar *toolbar)
107 + GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
108 + return priv->settings;
112 @@ -994,12 +1027,12 @@
113 GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
114 gdouble elapsed = g_timer_elapsed (priv->timer, NULL);
116 - intermediate->x = position (start->x, goal->x, elapsed);
117 - intermediate->y = position (start->y, goal->y, elapsed);
118 + intermediate->x = position (toolbar, start->x, goal->x, elapsed);
119 + intermediate->y = position (toolbar, start->y, goal->y, elapsed);
120 intermediate->width =
121 - position (start->x + start->width, goal->x + goal->width, elapsed) - intermediate->x;
122 + position (toolbar, start->x + start->width, goal->x + goal->width, elapsed) - intermediate->x;
123 intermediate->height =
124 - position (start->y + start->height, goal->y + goal->height, elapsed) - intermediate->y;
125 + position (toolbar, start->y + start->height, goal->y + goal->height, elapsed) - intermediate->y;
129 @@ -1047,6 +1080,32 @@
134 +gtk_toolbar_update_animation_state (GtkToolbar *toolbar)
136 + gboolean animation_state;
137 + GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
139 + g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
141 + if (priv->animation_set)
143 + GtkSettings *settings = toolbar_get_settings (toolbar);
147 + g_object_get (settings,
148 + "gtk-toolbar-animation", &animation_state,
152 + animation_state = DEFAULT_ANIMATION_STATE;
154 + priv->animation = animation_state;
155 + priv->animation_set = FALSE;
160 slide_idle_handler (gpointer data)
162 @@ -1537,10 +1596,14 @@
164 if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
166 + gint mexpand = get_max_child_expand(toolbar);
167 gint extra = size / n_expand_items;
168 if (size % n_expand_items != 0)
171 + if (extra > mexpand) {
175 allocations[i].width += extra;
178 @@ -1932,11 +1995,16 @@
182 -static GtkSettings *
183 -toolbar_get_settings (GtkToolbar *toolbar)
185 +animation_change_notify (GtkToolbar *toolbar)
187 GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
188 - return priv->settings;
189 + if (!priv->animation_set)
191 + /* pretend it was set, then unset, thus reverting to new default */
192 + priv->animation_set = TRUE;
193 + gtk_toolbar_update_animation_state (toolbar);
198 @@ -1960,6 +2028,7 @@
200 g_signal_handler_disconnect (old_settings, toolbar->style_set_connection);
201 g_signal_handler_disconnect (old_settings, toolbar->icon_size_connection);
202 + g_signal_handler_disconnect (old_settings, priv->animation_connection);
204 g_object_unref (old_settings);
206 @@ -1976,6 +2045,11 @@
207 "notify::gtk-toolbar-icon-size",
208 G_CALLBACK (icon_size_change_notify),
210 + priv->animation_connection =
211 + g_signal_connect_swapped (settings,
212 + "notify::gtk-toolbar-animation",
213 + G_CALLBACK (animation_change_notify),
216 g_object_ref (settings);
217 priv->settings = settings;
218 @@ -1985,6 +2059,7 @@
220 style_change_notify (toolbar);
221 icon_size_change_notify (toolbar);
222 + animation_change_notify (toolbar);
226 @@ -2913,7 +2988,7 @@
227 * gtk_toolbar_get_icon_size:
228 * @toolbar: a #GtkToolbar
230 - * Retrieves the icon size fo the toolbar. See gtk_toolbar_set_icon_size().
231 + * Retrieves the icon size for the toolbar. See gtk_toolbar_set_icon_size().
233 * Return value: the current icon size for the icons on the toolbar.
235 @@ -4642,6 +4717,17 @@
240 +get_max_child_expand (GtkToolbar *toolbar)
242 + gint mexpand = DEFAULT_MAX_CHILD_SPACING;
244 + gtk_widget_style_get (GTK_WIDGET (toolbar),
245 + "max_child_expand", &mexpand,
251 get_shadow_type (GtkToolbar *toolbar)