~jbicha/ubuntu/oneiric/gnome-shell/oneiric-3.2.2.1

« back to all changes in this revision

Viewing changes to src/st/st-scroll-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-07-20 14:46:28 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20110720144628-ipirjtz8od4uktpg
Tags: 3.1.3-0ubuntu1
* New upstream release
* debian/control.in:
  - Update dependency versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
  gfloat        row_size;
98
98
  gfloat        column_size;
99
99
 
100
 
  gboolean      vfade;
101
100
  StScrollViewFade *vfade_effect;
102
101
 
103
102
  gboolean      row_size_set : 1;
114
113
  PROP_VSCROLL,
115
114
  PROP_HSCROLLBAR_POLICY,
116
115
  PROP_VSCROLLBAR_POLICY,
 
116
  PROP_HSCROLLBAR_VISIBLE,
 
117
  PROP_VSCROLLBAR_VISIBLE,
117
118
  PROP_MOUSE_SCROLL,
118
 
  PROP_VFADE
119
119
};
120
120
 
121
121
static void
140
140
    case PROP_VSCROLLBAR_POLICY:
141
141
      g_value_set_enum (value, priv->vscrollbar_policy);
142
142
      break;
 
143
    case PROP_HSCROLLBAR_VISIBLE:
 
144
      g_value_set_boolean (value, priv->hscrollbar_visible);
 
145
      break;
 
146
    case PROP_VSCROLLBAR_VISIBLE:
 
147
      g_value_set_boolean (value, priv->vscrollbar_visible);
 
148
      break;
143
149
    case PROP_MOUSE_SCROLL:
144
150
      g_value_set_boolean (value, priv->mouse_scroll);
145
151
      break;
146
 
    case PROP_VFADE:
147
 
      g_value_set_boolean (value, priv->vfade);
148
 
      break;
149
152
    default:
150
153
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
151
154
    }
152
155
}
153
156
 
154
157
/**
155
 
 * st_scroll_view_set_vfade:
 
158
 * st_scroll_view_update_vfade_effect:
156
159
 * @self: a #StScrollView
157
 
 * @vfade: Whether to enable the vertical fade effect
 
160
 * @fade_offset: The length of the fade effect, in pixels.
158
161
 *
159
 
 * Sets whether to fade the content at the top and bottom of the area when not
160
 
 * fully scrolled to that edge.
 
162
 * Sets the height of the fade area area in pixels. A value of 0
 
163
 * disables the effect.
161
164
 */
162
 
void
163
 
st_scroll_view_set_vfade (StScrollView *self,
164
 
                          gboolean vfade)
 
165
static void
 
166
st_scroll_view_update_vfade_effect (StScrollView *self,
 
167
                                    float fade_offset)
165
168
{
166
169
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
167
170
 
168
 
  vfade = vfade != FALSE;
169
 
  if (priv->vfade == vfade)
170
 
    return;
171
 
 
172
 
  priv->vfade = vfade;
173
 
 
174
 
  if (vfade)
 
171
  /* A fade amount of more than 0 enables the effect. */
 
172
  if (fade_offset > 0.)
175
173
    {
176
 
      if (priv->vfade_effect == NULL)
 
174
      if (priv->vfade_effect == NULL) {
177
175
        priv->vfade_effect = g_object_new (ST_TYPE_SCROLL_VIEW_FADE, NULL);
178
176
 
179
 
      clutter_actor_add_effect_with_name (CLUTTER_ACTOR (self), "vfade",
180
 
                                          CLUTTER_EFFECT (priv->vfade_effect));
 
177
        clutter_actor_add_effect_with_name (CLUTTER_ACTOR (self), "vfade",
 
178
                                            CLUTTER_EFFECT (priv->vfade_effect));
 
179
      }
 
180
 
 
181
      g_object_set (priv->vfade_effect,
 
182
                    "fade-offset", fade_offset,
 
183
                    NULL);
181
184
    }
182
185
   else
183
186
    {
184
 
      clutter_actor_remove_effect (CLUTTER_ACTOR (self), CLUTTER_EFFECT (priv->vfade_effect));
185
 
      priv->vfade_effect = NULL;
 
187
      if (priv->vfade_effect != NULL) {
 
188
        clutter_actor_remove_effect (CLUTTER_ACTOR (self), CLUTTER_EFFECT (priv->vfade_effect));
 
189
        priv->vfade_effect = NULL;
 
190
      }
186
191
    }
187
192
 
188
193
  clutter_actor_queue_redraw (CLUTTER_ACTOR (self));
189
 
 
190
 
  g_object_notify (G_OBJECT (self), "vfade");
191
194
}
192
195
 
193
196
static void
201
204
 
202
205
  switch (property_id)
203
206
    {
204
 
    case PROP_VFADE:
205
 
      st_scroll_view_set_vfade (self, g_value_get_boolean (value));
206
 
      break;
207
207
    case PROP_MOUSE_SCROLL:
208
208
      st_scroll_view_set_mouse_scrolling (self,
209
209
                                          g_value_get_boolean (value));
654
654
  if (priv->child)
655
655
    clutter_actor_allocate (priv->child, &child_box, flags);
656
656
 
657
 
  priv->hscrollbar_visible = hscrollbar_visible;
658
 
  priv->vscrollbar_visible = vscrollbar_visible;
 
657
  if (priv->hscrollbar_visible != hscrollbar_visible)
 
658
    {
 
659
      g_object_freeze_notify (G_OBJECT (actor));
 
660
      priv->hscrollbar_visible = hscrollbar_visible;
 
661
      g_object_notify (G_OBJECT (actor), "hscrollbar-visible");
 
662
      g_object_thaw_notify (G_OBJECT (actor));
 
663
    }
 
664
 
 
665
  if (priv->vscrollbar_visible != vscrollbar_visible)
 
666
    {
 
667
      g_object_freeze_notify (G_OBJECT (actor));
 
668
      priv->vscrollbar_visible = vscrollbar_visible;
 
669
      g_object_notify (G_OBJECT (actor), "vscrollbar-visible");
 
670
      g_object_thaw_notify (G_OBJECT (actor));
 
671
    }
 
672
 
659
673
}
660
674
 
661
675
static void
662
676
st_scroll_view_style_changed (StWidget *widget)
663
677
{
664
 
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (widget)->priv;
 
678
  StScrollView *self = ST_SCROLL_VIEW (widget);
 
679
  StScrollViewPrivate *priv = self->priv;
 
680
 
 
681
  StThemeNode *theme_node = st_widget_get_theme_node (widget);
 
682
  gdouble fade_offset = st_theme_node_get_length (theme_node, "-st-vfade-offset");
 
683
  st_scroll_view_update_vfade_effect (self, fade_offset);
665
684
 
666
685
  st_widget_style_changed (ST_WIDGET (priv->hscroll));
667
686
  st_widget_style_changed (ST_WIDGET (priv->vscroll));
789
808
                             G_PARAM_READWRITE);
790
809
  g_object_class_install_property (object_class, PROP_HSCROLLBAR_POLICY, pspec);
791
810
 
 
811
  pspec = g_param_spec_boolean ("hscrollbar-visible",
 
812
                                "Horizontal Scrollbar Visibility",
 
813
                                "Whether the horizontal scrollbar is visible",
 
814
                                TRUE,
 
815
                                G_PARAM_READABLE);
 
816
  g_object_class_install_property (object_class, PROP_HSCROLLBAR_VISIBLE, pspec);
 
817
 
 
818
  pspec = g_param_spec_boolean ("vscrollbar-visible",
 
819
                                "Vertical Scrollbar Visibility",
 
820
                                "Whether the vertical scrollbar is visible",
 
821
                                TRUE,
 
822
                                G_PARAM_READABLE);
 
823
  g_object_class_install_property (object_class, PROP_VSCROLLBAR_VISIBLE, pspec);
 
824
 
792
825
  pspec = g_param_spec_boolean ("enable-mouse-scrolling",
793
826
                                "Enable Mouse Scrolling",
794
827
                                "Enable automatic mouse wheel scrolling",
798
831
                                   PROP_MOUSE_SCROLL,
799
832
                                   pspec);
800
833
 
801
 
  pspec = g_param_spec_boolean ("vfade",
802
 
                                "Vertical Shadows",
803
 
                                "Fade the content at the top and and bottom of the area unless fully scrolled to that edge",
804
 
                                FALSE,
805
 
                                G_PARAM_READWRITE);
806
 
  g_object_class_install_property (object_class,
807
 
                                   PROP_VFADE,
808
 
                                   pspec);
809
834
}
810
835
 
811
836
static void