[libhandy] carousel: Remove indicators



commit 181f2f58ca6835bf529096f280d39dd94ed6bf1f
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Jul 14 00:55:33 2020 +0500

    carousel: Remove indicators
    
    They have been split into separate widgets, so can be removed now.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 debian/libhandy-1-0.symbols |   7 -
 glade/glade-hdy-carousel.c  |  28 ---
 glade/libhandy.xml          |  10 -
 src/hdy-carousel-box.c      |  49 ----
 src/hdy-carousel.c          | 574 +-------------------------------------------
 src/hdy-carousel.h          |  25 --
 src/hdy-carousel.ui         |  42 +---
 src/hdy-enums.c.in          |   1 -
 src/meson.build             |   1 -
 tests/test-carousel.c       |  84 -------
 10 files changed, 13 insertions(+), 808 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index d90cebdd..045461c6 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -27,9 +27,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_avatar_set_text@LIBHANDY_1_0 0.80.0
  hdy_carousel_get_allow_mouse_drag@LIBHANDY_1_0 0.80.0
  hdy_carousel_get_animation_duration@LIBHANDY_1_0 0.80.0
- hdy_carousel_get_center_content@LIBHANDY_1_0 0.80.0
- hdy_carousel_get_indicator_spacing@LIBHANDY_1_0 0.80.0
- hdy_carousel_get_indicator_style@LIBHANDY_1_0 0.80.0
  hdy_carousel_get_interactive@LIBHANDY_1_0 0.80.0
  hdy_carousel_get_n_pages@LIBHANDY_1_0 0.80.0
  hdy_carousel_get_position@LIBHANDY_1_0 0.80.0
@@ -44,7 +41,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_carousel_indicator_lines_get_carousel@LIBHANDY_1_0 0.90.0
  hdy_carousel_indicator_lines_new@LIBHANDY_1_0 0.90.0
  hdy_carousel_indicator_lines_set_carousel@LIBHANDY_1_0 0.90.0
- hdy_carousel_indicator_style_get_type@LIBHANDY_1_0 0.80.0
  hdy_carousel_insert@LIBHANDY_1_0 0.80.0
  hdy_carousel_new@LIBHANDY_1_0 0.80.0
  hdy_carousel_prepend@LIBHANDY_1_0 0.80.0
@@ -53,9 +49,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_carousel_scroll_to_full@LIBHANDY_1_0 0.80.0
  hdy_carousel_set_allow_mouse_drag@LIBHANDY_1_0 0.80.0
  hdy_carousel_set_animation_duration@LIBHANDY_1_0 0.80.0
- hdy_carousel_set_center_content@LIBHANDY_1_0 0.80.0
- hdy_carousel_set_indicator_spacing@LIBHANDY_1_0 0.80.0
- hdy_carousel_set_indicator_style@LIBHANDY_1_0 0.80.0
  hdy_carousel_set_interactive@LIBHANDY_1_0 0.80.0
  hdy_carousel_set_reveal_duration@LIBHANDY_1_0 0.81.0
  hdy_carousel_set_spacing@LIBHANDY_1_0 0.80.0
diff --git a/glade/glade-hdy-carousel.c b/glade/glade-hdy-carousel.c
index 90518c0f..c06a4e43 100644
--- a/glade/glade-hdy-carousel.c
+++ b/glade/glade-hdy-carousel.c
@@ -18,8 +18,6 @@
 
 #include <math.h>
 
-#define CENTER_CONTENT_INSENSITIVE_MSG _("This property does not apply unless Show Indicators is set.")
-
 static gint
 hdy_carousel_get_page (HdyCarousel *carousel)
 {
@@ -141,11 +139,6 @@ glade_hdy_carousel_post_create (GladeWidgetAdaptor *adaptor,
 
   g_signal_connect (G_OBJECT (container), "notify::position",
                     G_CALLBACK (position_changed_cb), gwidget);
-
-  glade_widget_property_set_sensitive (gwidget, "indicator-spacing",
-                                       FALSE, CENTER_CONTENT_INSENSITIVE_MSG);
-  glade_widget_property_set_sensitive (gwidget, "center-content",
-                                       FALSE, CENTER_CONTENT_INSENSITIVE_MSG);
 }
 
 void
@@ -262,24 +255,6 @@ set_page (GObject      *object,
     hdy_carousel_scroll_to (HDY_CAROUSEL (object), child);
 }
 
-static void
-set_indicator_style (GObject      *container,
-                     const GValue *value)
-{
-  GladeWidget *gwidget;
-  HdyCarouselIndicatorStyle style;
-
-  gwidget = glade_widget_get_from_gobject (container);
-  style = g_value_get_enum (value);
-
-  glade_widget_property_set_sensitive (gwidget, "indicator-spacing",
-                                       style != HDY_CAROUSEL_INDICATOR_STYLE_NONE,
-                                       CENTER_CONTENT_INSENSITIVE_MSG);
-  glade_widget_property_set_sensitive (gwidget, "center-content",
-                                       style != HDY_CAROUSEL_INDICATOR_STYLE_NONE,
-                                       CENTER_CONTENT_INSENSITIVE_MSG);
-}
-
 void
 glade_hdy_carousel_set_property (GladeWidgetAdaptor *adaptor,
                                  GObject            *object,
@@ -291,9 +266,6 @@ glade_hdy_carousel_set_property (GladeWidgetAdaptor *adaptor,
   else if (!strcmp (id, "page"))
     set_page (object, value);
   else {
-    if (!strcmp (id, "indicator-style"))
-      set_indicator_style (object, value);
-
     GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
   }
 }
diff --git a/glade/libhandy.xml b/glade/libhandy.xml
index 21a07103..7f601186 100644
--- a/glade/libhandy.xml
+++ b/glade/libhandy.xml
@@ -62,16 +62,6 @@
           </parameter-spec>
           <tooltip>Set the currently active page to edit, this property will not be saved</tooltip>
         </property>
-        <property id="indicator-style">
-          <displayable-values>
-            <!-- HdyCarouselIndicatorStyle enumeration value -->
-            <value id="HDY_CAROUSEL_INDICATOR_STYLE_NONE" name="None"/>
-            <!-- HdyCarouselIndicatorStyle enumeration value -->
-            <value id="HDY_CAROUSEL_INDICATOR_STYLE_DOTS" name="Dots"/>
-            <!-- HdyCarouselIndicatorStyle enumeration value -->
-            <value id="HDY_CAROUSEL_INDICATOR_STYLE_LINES" name="Lines"/>
-          </displayable-values>
-        </property>
         <property id="above-child" disabled="True" />
         <property id="visible-window" disabled="True" />
       </properties>
diff --git a/src/hdy-carousel-box.c b/src/hdy-carousel-box.c
index b06e045b..1e0355fb 100644
--- a/src/hdy-carousel-box.c
+++ b/src/hdy-carousel-box.c
@@ -96,8 +96,6 @@ static GParamSpec *props[LAST_PROP];
 enum {
   SIGNAL_ANIMATION_STOPPED,
   SIGNAL_POSITION_SHIFTED,
-  SIGNAL_PAGE_ADDED,
-  SIGNAL_PAGE_REMOVED,
   SIGNAL_LAST_SIGNAL,
 };
 static guint signals[SIGNAL_LAST_SIGNAL];
@@ -932,14 +930,11 @@ hdy_carousel_box_remove (GtkContainer *container,
 {
   HdyCarouselBox *self = HDY_CAROUSEL_BOX (container);
   HdyCarouselBoxChildInfo *info;
-  gint index;
 
   info = find_child_info (self, widget);
   if (!info)
     return;
 
-  index = g_list_index (self->children, info);
-
   info->removing = TRUE;
 
   gtk_widget_unparent (widget);
@@ -952,8 +947,6 @@ hdy_carousel_box_remove (GtkContainer *container,
   if (!gtk_widget_in_destruction (GTK_WIDGET (container)))
     animate_child (self, info, 0, self->reveal_duration);
 
-  g_signal_emit (self, signals[SIGNAL_PAGE_REMOVED], 0, index);
-
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_N_PAGES]);
 }
 
@@ -1190,44 +1183,6 @@ hdy_carousel_box_class_init (HdyCarouselBoxClass *klass)
                   G_TYPE_NONE,
                   1,
                   G_TYPE_DOUBLE);
-
-  /**
-   * HdyCarouselBox::page-added:
-   * @self: The #HdyCarouselBox instance
-   * @index: The index of the new page
-   *
-   * This signal is emitted when a page has been added at @index.
-   *
-   * Since: 1.0
-   */
-  signals[SIGNAL_PAGE_ADDED] =
-    g_signal_new ("page-added",
-                  G_TYPE_FROM_CLASS (klass),
-                  G_SIGNAL_RUN_LAST,
-                  0,
-                  NULL, NULL, NULL,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_UINT);
-
-  /**
-   * HdyCarouselBox::page-removed:
-   * @self: The #HdyCarouselBox instance
-   * @index: The index of the new page
-   *
-   * This signal is emitted when a page has been removed at @index.
-   *
-   * Since: 1.0
-   */
-  signals[SIGNAL_PAGE_REMOVED] =
-    g_signal_new ("page-removed",
-                  G_TYPE_FROM_CLASS (klass),
-                  G_SIGNAL_RUN_LAST,
-                  0,
-                  NULL, NULL, NULL,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_UINT);
 }
 
 static void
@@ -1276,7 +1231,6 @@ hdy_carousel_box_insert (HdyCarouselBox *self,
 {
   HdyCarouselBoxChildInfo *info;
   GList *prev_link;
-  gint index;
 
   g_return_if_fail (HDY_IS_CAROUSEL_BOX (self));
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -1304,9 +1258,6 @@ hdy_carousel_box_insert (HdyCarouselBox *self,
 
   invalidate_drawing_cache (self);
 
-  index = g_list_index (self->children, info);
-  g_signal_emit (self, signals[SIGNAL_PAGE_ADDED], 0, index);
-
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_N_PAGES]);
 }
 
diff --git a/src/hdy-carousel.c b/src/hdy-carousel.c
index a24e22a4..7d8db553 100644
--- a/src/hdy-carousel.c
+++ b/src/hdy-carousel.c
@@ -17,19 +17,6 @@
 
 #include <math.h>
 
-#define DOTS_RADIUS 3
-#define DOTS_RADIUS_SELECTED 4
-#define DOTS_OPACITY 0.3
-#define DOTS_OPACITY_SELECTED 0.9
-#define DOTS_SPACING 7
-#define DOTS_MARGIN 6
-
-#define LINE_WIDTH 3
-#define LINE_LENGTH 35
-#define LINE_SPACING 5
-#define LINE_OPACITY 0.3
-#define LINE_OPACITY_ACTIVE 0.9
-#define LINE_MARGIN 2
 #define DEFAULT_DURATION 250
 
 /**
@@ -39,7 +26,7 @@
  * @See_also: #HdyCarouselIndicatorDots, #HdyCarouselIndicatorLines
  *
  * The #HdyCarousel widget can be used to display a set of pages with
- * swipe-based navigation between them and optional indicators.
+ * swipe-based navigation between them.
  *
  * # CSS nodes
  *
@@ -48,40 +35,19 @@
  * Since: 1.0
  */
 
-/**
- * HdyCarouselIndicatorStyle
- * @HDY_CAROUSEL_INDICATOR_STYLE_NONE: No indicators
- * @HDY_CAROUSEL_INDICATOR_STYLE_DOTS: Each page is represented by a dot. Active dot gradually becomes 
larger and more opaque.
- * @HDY_CAROUSEL_INDICATOR_STYLE_LINES: Each page is represented by a thin and long line, and active view is 
shown with another line that moves between them
- *
- * These enumeration values describe the possible page indicator styles in a
- * #HdyCarousel widget.
- *
- * New values may be added to this enumeration over time.
- */
-
 struct _HdyCarousel
 {
   GtkEventBox parent_instance;
 
-  GtkBox *box;
-  GtkBox *empty_box;
   HdyCarouselBox *scrolling_box;
-  GtkDrawingArea *indicators;
 
   HdySwipeTracker *tracker;
 
-  HdyCarouselIndicatorStyle indicator_style;
-  guint indicator_spacing;
-  gboolean center_content;
   GtkOrientation orientation;
   guint animation_duration;
 
   gulong scroll_timeout_id;
   gboolean can_scroll;
-
-  guint tick_cb_id;
-  guint64 end_time;
 };
 
 static void hdy_carousel_swipeable_init (HdySwipeableInterface *iface);
@@ -95,9 +61,6 @@ enum {
   PROP_N_PAGES,
   PROP_POSITION,
   PROP_INTERACTIVE,
-  PROP_INDICATOR_STYLE,
-  PROP_INDICATOR_SPACING,
-  PROP_CENTER_CONTENT,
   PROP_SPACING,
   PROP_ANIMATION_DURATION,
   PROP_ALLOW_MOUSE_DRAG,
@@ -117,56 +80,6 @@ enum {
 static guint signals[SIGNAL_LAST_SIGNAL];
 
 
-static gboolean
-indicators_animation_cb (GtkWidget     *widget,
-                         GdkFrameClock *frame_clock,
-                         gpointer       user_data)
-{
-  HdyCarousel *self = HDY_CAROUSEL (widget);
-  gint64 frame_time;
-
-  g_assert (self->tick_cb_id > 0);
-
-  gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
-
-  frame_time = gdk_frame_clock_get_frame_time (frame_clock) / 1000;
-
-  if (frame_time >= self->end_time ||
-      !hdy_get_enable_animations (GTK_WIDGET (self))) {
-    self->tick_cb_id = 0;
-    return G_SOURCE_REMOVE;
-  }
-
-  return G_SOURCE_CONTINUE;
-}
-
-static void
-animate_indicators (HdyCarousel *self,
-                    gint64       duration)
-{
-  GdkFrameClock *frame_clock;
-  gint64 frame_time;
-
-  if (duration <= 0 || !hdy_get_enable_animations (GTK_WIDGET (self))) {
-    gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
-    return;
-  }
-
-  frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
-  if (!frame_clock) {
-    gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
-    return;
-  }
-
-  frame_time = gdk_frame_clock_get_frame_time (frame_clock);
-
-  self->end_time = MAX (self->end_time, frame_time / 1000 + duration);
-  if (self->tick_cb_id == 0)
-    self->tick_cb_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
-                                                     indicators_animation_cb,
-                                                     NULL, NULL);
-}
-
 static void
 hdy_carousel_switch_child (HdySwipeable *swipeable,
                            guint         index,
@@ -257,7 +170,6 @@ notify_n_pages_cb (HdyCarousel *self,
                    GObject     *object)
 {
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_N_PAGES]);
-  gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
 }
 
 static void
@@ -266,7 +178,6 @@ notify_position_cb (HdyCarousel *self,
                     GObject     *object)
 {
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_POSITION]);
-  gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
 }
 
 static void
@@ -304,259 +215,6 @@ position_shifted_cb (HdyCarousel    *self,
   hdy_swipe_tracker_shift_position (self->tracker, delta);
 }
 
-static GdkRGBA
-get_color (GtkWidget *widget)
-{
-  GtkStyleContext *context;
-  GtkStateFlags flags;
-  GdkRGBA color;
-
-  context = gtk_widget_get_style_context (widget);
-  flags = gtk_widget_get_state_flags (widget);
-  gtk_style_context_get_color (context, flags, &color);
-
-  return color;
-}
-
-static void
-draw_indicators_lines (GtkWidget      *widget,
-                       cairo_t        *cr,
-                       GtkOrientation  orientation,
-                       gdouble         position,
-                       gdouble        *sizes,
-                       guint           n_pages)
-{
-  GdkRGBA color;
-  gint i, widget_length;
-  gdouble indicator_length, full_size, line_size, pos;
-
-  color = get_color (widget);
-
-  line_size = LINE_LENGTH + LINE_SPACING;
-  indicator_length = 0;
-  for (i = 0; i < n_pages; i++)
-    indicator_length += line_size * sizes[i];
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    widget_length = gtk_widget_get_allocated_width (widget);
-  else
-    widget_length = gtk_widget_get_allocated_height (widget);
-
-  /* Ensure the indicators are aligned to pixel grid when not animating */
-  full_size = round (indicator_length / line_size) * line_size;
-  if ((widget_length - (gint) full_size) % 2 == 0)
-    widget_length--;
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL) {
-    cairo_translate (cr, (widget_length - indicator_length) / 2.0, 0);
-    cairo_scale (cr, 1, LINE_WIDTH);
-  } else {
-    cairo_translate (cr, 0, (widget_length - indicator_length) / 2.0);
-    cairo_scale (cr, LINE_WIDTH, 1);
-  }
-
-  pos = 0;
-  cairo_set_source_rgba (cr, color.red, color.green, color.blue,
-                         color.alpha * LINE_OPACITY);
-  for (i = 0; i < n_pages; i++) {
-    gdouble length;
-
-    length = (LINE_LENGTH + LINE_SPACING) * sizes[i] - LINE_SPACING;
-
-    if (length > 0) {
-      if (orientation == GTK_ORIENTATION_HORIZONTAL)
-        cairo_rectangle (cr, LINE_SPACING / 2.0 + pos, 0, length, 1);
-      else
-        cairo_rectangle (cr, 0, LINE_SPACING / 2.0 + pos, 1, length);
-    }
-
-    cairo_fill (cr);
-
-    pos += (LINE_LENGTH + LINE_SPACING) * sizes[i];
-  }
-
-  cairo_set_source_rgba (cr, color.red, color.green, color.blue,
-                         color.alpha * LINE_OPACITY_ACTIVE);
-
-  pos = LINE_SPACING / 2.0 + position * (LINE_LENGTH + LINE_SPACING);
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    cairo_rectangle (cr, pos, 0, LINE_LENGTH, 1);
-  else
-    cairo_rectangle (cr, 0, pos, 1, LINE_LENGTH);
-  cairo_fill (cr);
-}
-
-static void
-draw_indicators_dots (GtkWidget      *widget,
-                      cairo_t        *cr,
-                      GtkOrientation  orientation,
-                      gdouble         position,
-                      gdouble        *sizes,
-                      guint           n_pages)
-{
-  GdkRGBA color;
-  gint i, widget_length;
-  gdouble x, y, indicator_length, dot_size, full_size;
-  gdouble current_position, remaining_progress;
-
-  color = get_color (widget);
-  dot_size = 2 * DOTS_RADIUS_SELECTED + DOTS_SPACING;
-
-  indicator_length = 0;
-  for (i = 0; i < n_pages; i++)
-    indicator_length += dot_size * sizes[i];
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    widget_length = gtk_widget_get_allocated_width (widget);
-  else
-    widget_length = gtk_widget_get_allocated_height (widget);
-
-  /* Ensure the indicators are aligned to pixel grid when not animating */
-  full_size = round (indicator_length / dot_size) * dot_size;
-  if ((widget_length - (gint) full_size) % 2 == 0)
-    widget_length--;
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    cairo_translate (cr, (widget_length - indicator_length) / 2.0, DOTS_RADIUS_SELECTED);
-  else
-    cairo_translate (cr, DOTS_RADIUS_SELECTED, (widget_length - indicator_length) / 2.0);
-
-  x = 0;
-  y = 0;
-
-  current_position = 0;
-  remaining_progress = 1;
-
-  for (i = 0; i < n_pages; i++) {
-    gdouble progress, radius, opacity;
-
-    if (orientation == GTK_ORIENTATION_HORIZONTAL)
-      x += dot_size * sizes[i] / 2.0;
-    else
-      y += dot_size * sizes[i] / 2.0;
-
-    current_position += sizes[i];
-
-    progress = CLAMP (current_position - position, 0, remaining_progress);
-    remaining_progress -= progress;
-
-    radius = hdy_lerp (DOTS_RADIUS, DOTS_RADIUS_SELECTED, progress) * sizes[i];
-    opacity = hdy_lerp (DOTS_OPACITY, DOTS_OPACITY_SELECTED, progress) * sizes[i];
-
-    cairo_set_source_rgba (cr, color.red, color.green, color.blue,
-                           color.alpha * opacity);
-    cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
-    cairo_fill (cr);
-
-    if (orientation == GTK_ORIENTATION_HORIZONTAL)
-      x += dot_size * sizes[i] / 2.0;
-    else
-      y += dot_size * sizes[i] / 2.0;
-  }
-}
-
-static void
-page_added_cb (HdyCarousel    *self,
-               guint           index,
-               HdyCarouselBox *box)
-{
-  animate_indicators (self, hdy_carousel_get_reveal_duration (self));
-}
-
-static void
-page_removed_cb (HdyCarousel    *self,
-                 guint           index,
-                 HdyCarouselBox *box)
-{
-  animate_indicators (self, hdy_carousel_get_reveal_duration (self));
-}
-
-static gboolean
-draw_indicators_cb (HdyCarousel *self,
-                    cairo_t     *cr,
-                    GtkWidget   *widget)
-{
-  gint i, n_points;
-  gdouble position, lower;
-  gdouble *points, *sizes;
-
-  points = hdy_carousel_box_get_snap_points (self->scrolling_box, &n_points);
-  position = hdy_carousel_box_get_position (self->scrolling_box);
-  hdy_carousel_box_get_range (self->scrolling_box, &lower, NULL);
-
-  if (n_points < 2)
-    return GDK_EVENT_PROPAGATE;
-
-  if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
-      gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-    position = points[n_points - 1] - position;
-
-  sizes = g_new0 (gdouble, n_points);
-
-  sizes[0] = points[0] + 1;
-  for (i = 1; i < n_points; i++)
-    sizes[i] = points[i] - points[i - 1];
-
-  g_free (points);
-
-  switch (self->indicator_style){
-  case HDY_CAROUSEL_INDICATOR_STYLE_NONE:
-    break;
-
-  case HDY_CAROUSEL_INDICATOR_STYLE_DOTS:
-    draw_indicators_dots (widget, cr, self->orientation, position, sizes, n_points);
-    break;
-
-  case HDY_CAROUSEL_INDICATOR_STYLE_LINES:
-    draw_indicators_lines (widget, cr, self->orientation, position, sizes, n_points);
-    break;
-
-  default:
-    g_assert_not_reached ();
-  }
-
-  g_free (sizes);
-
-  return GDK_EVENT_PROPAGATE;
-}
-
-static void
-update_indicators (HdyCarousel *self)
-{
-  gboolean show_indicators;
-  gint size, margin;
-
-  show_indicators = (self->indicator_style != HDY_CAROUSEL_INDICATOR_STYLE_NONE);
-  gtk_widget_set_visible (GTK_WIDGET (self->indicators), show_indicators);
-  gtk_widget_set_visible (GTK_WIDGET (self->empty_box),
-                          show_indicators && self->center_content);
-
-  if (!show_indicators)
-    return;
-
-  switch (self->indicator_style) {
-  case HDY_CAROUSEL_INDICATOR_STYLE_DOTS:
-    size = 2 * DOTS_RADIUS_SELECTED;
-    margin = DOTS_MARGIN;
-    break;
-
-  case HDY_CAROUSEL_INDICATOR_STYLE_LINES:
-    size = LINE_WIDTH;
-    margin = LINE_MARGIN;
-    break;
-
-  case HDY_CAROUSEL_INDICATOR_STYLE_NONE:
-  default:
-    g_assert_not_reached ();
-  }
-
-  g_object_set (self->indicators,
-                "margin", margin,
-                "width-request", size,
-                "height-request", size,
-                NULL);
-}
-
 /* Copied from GtkOrientable. Orientable widgets are supposed
  * to do this manually via a private GTK function. */
 static void
@@ -586,27 +244,20 @@ set_orientable_style_classes (GtkOrientable *orientable)
 static void
 update_orientation (HdyCarousel *self)
 {
-  GtkOrientation opposite;
   gboolean reversed;
 
   if (!self->scrolling_box)
     return;
 
-  opposite = (self->orientation == GTK_ORIENTATION_HORIZONTAL) ?
-    GTK_ORIENTATION_VERTICAL :
-    GTK_ORIENTATION_HORIZONTAL;
   reversed = self->orientation == GTK_ORIENTATION_HORIZONTAL &&
     gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
 
   g_object_set (self->scrolling_box, "orientation", self->orientation, NULL);
   g_object_set (self->tracker, "orientation", self->orientation,
                 "reversed", reversed, NULL);
-  g_object_set (self->box, "orientation", opposite, NULL);
 
   set_orientable_style_classes (GTK_ORIENTABLE (self));
   set_orientable_style_classes (GTK_ORIENTABLE (self->scrolling_box));
-
-  gtk_widget_queue_draw (GTK_WIDGET (self->indicators));
 }
 
 static gboolean
@@ -712,9 +363,9 @@ hdy_carousel_destroy (GtkWidget *widget)
 {
   HdyCarousel *self = HDY_CAROUSEL (widget);
 
-  if (self->box) {
-    gtk_widget_destroy (GTK_WIDGET (self->box));
-    self->box = NULL;
+  if (self->scrolling_box) {
+    gtk_widget_destroy (GTK_WIDGET (self->scrolling_box));
+    self->scrolling_box = NULL;
   }
 
   GTK_WIDGET_CLASS (hdy_carousel_parent_class)->destroy (widget);
@@ -762,7 +413,7 @@ hdy_carousel_forall (GtkContainer *container,
   HdyCarousel *self = HDY_CAROUSEL (container);
 
   if (include_internals)
-    (* callback) (GTK_WIDGET (self->box), callback_data);
+    (* callback) (GTK_WIDGET (self->scrolling_box), callback_data);
   else if (self->scrolling_box)
     gtk_container_foreach (GTK_CONTAINER (self->scrolling_box),
                            callback, callback_data);
@@ -814,18 +465,6 @@ hdy_carousel_get_property (GObject    *object,
     g_value_set_boolean (value, hdy_carousel_get_interactive (self));
     break;
 
-  case PROP_INDICATOR_STYLE:
-    g_value_set_enum (value, hdy_carousel_get_indicator_style (self));
-    break;
-
-  case PROP_INDICATOR_SPACING:
-    g_value_set_uint (value, hdy_carousel_get_indicator_spacing (self));
-    break;
-
-  case PROP_CENTER_CONTENT:
-    g_value_set_boolean (value, hdy_carousel_get_center_content (self));
-    break;
-
   case PROP_SPACING:
     g_value_set_uint (value, hdy_carousel_get_spacing (self));
     break;
@@ -864,18 +503,6 @@ hdy_carousel_set_property (GObject      *object,
     hdy_carousel_set_interactive (self, g_value_get_boolean (value));
     break;
 
-  case PROP_INDICATOR_STYLE:
-    hdy_carousel_set_indicator_style (self, g_value_get_enum (value));
-    break;
-
-  case PROP_INDICATOR_SPACING:
-    hdy_carousel_set_indicator_spacing (self, g_value_get_uint (value));
-    break;
-
-  case PROP_CENTER_CONTENT:
-    hdy_carousel_set_center_content (self, g_value_get_boolean (value));
-    break;
-
   case PROP_SPACING:
     hdy_carousel_set_spacing (self, g_value_get_uint (value));
     break;
@@ -984,57 +611,6 @@ hdy_carousel_class_init (HdyCarouselClass *klass)
                           TRUE,
                           G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
-  /**
-   * HdyCarousel:indicator-style:
-   *
-   * The style of page indicators. Depending on orientation, they are displayed
-   * below or besides the pages. If the pages are meant to be centered,
-   * #HdyCarousel:center-content can be used to compensate for that.
-   *
-   * Since: 1.0
-   */
-  props[PROP_INDICATOR_STYLE] =
-    g_param_spec_enum ("indicator-style",
-                       _("Indicator style"),
-                       _("Page indicator style"),
-                       HDY_TYPE_CAROUSEL_INDICATOR_STYLE,
-                       HDY_CAROUSEL_INDICATOR_STYLE_NONE,
-                       G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * HdyCarousel:indicator-spacing:
-   *
-   * Spacing between content and page indicators. Does nothing if
-   * #HdyCarousel:indicator-style is @HDY_CAROUSEL_INDICATOR_STYLE_NONE.
-   *
-   * Since: 1.0
-   */
-  props[PROP_INDICATOR_SPACING] =
-    g_param_spec_uint ("indicator-spacing",
-                       _("Indicator spacing"),
-                       _("Spacing between content and indicators"),
-                       0,
-                       G_MAXUINT,
-                       0,
-                       G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * HdyCarousel:center-content:
-   *
-   * Whether the #HdyCarousel is centering pages. If
-   * #HdyCarousel:indicator-style is @HDY_CAROUSEL_INDICATOR_STYLE_NONE,
-   * centering does nothing, otherwise it adds whitespace to the left or above
-   * the pages to compensate for the indicators.
-   *
-   * Since: 1.0
-   */
-  props[PROP_CENTER_CONTENT] =
-    g_param_spec_boolean ("center-content",
-                          _("Center content"),
-                          _("Whether to center pages to compensate for indicators"),
-                          FALSE,
-                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
   /**
    * HdyCarousel:spacing:
    *
@@ -1125,20 +701,14 @@ hdy_carousel_class_init (HdyCarouselClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/sm/puri/handy/ui/hdy-carousel.ui");
-  gtk_widget_class_bind_template_child (widget_class, HdyCarousel, box);
-  gtk_widget_class_bind_template_child (widget_class, HdyCarousel, empty_box);
   gtk_widget_class_bind_template_child (widget_class, HdyCarousel, scrolling_box);
-  gtk_widget_class_bind_template_child (widget_class, HdyCarousel, indicators);
   gtk_widget_class_bind_template_callback (widget_class, scroll_event_cb);
-  gtk_widget_class_bind_template_callback (widget_class, draw_indicators_cb);
   gtk_widget_class_bind_template_callback (widget_class, notify_n_pages_cb);
   gtk_widget_class_bind_template_callback (widget_class, notify_position_cb);
   gtk_widget_class_bind_template_callback (widget_class, notify_spacing_cb);
   gtk_widget_class_bind_template_callback (widget_class, notify_reveal_duration_cb);
   gtk_widget_class_bind_template_callback (widget_class, animation_stopped_cb);
   gtk_widget_class_bind_template_callback (widget_class, position_shifted_cb);
-  gtk_widget_class_bind_template_callback (widget_class, page_added_cb);
-  gtk_widget_class_bind_template_callback (widget_class, page_removed_cb);
 
   gtk_widget_class_set_css_name (widget_class, "carousel");
 }
@@ -1369,140 +939,6 @@ hdy_carousel_set_interactive (HdyCarousel *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_INTERACTIVE]);
 }
 
-/**
- * hdy_carousel_get_indicator_style
- * @self: a #HdyCarousel
- *
- * Gets the current page indicator style.
- *
- * Returns: the current indicator style
- *
- * Since: 1.0
- */
-HdyCarouselIndicatorStyle
-hdy_carousel_get_indicator_style (HdyCarousel *self)
-{
-  g_return_val_if_fail (HDY_IS_CAROUSEL (self), FALSE);
-
-  return self->indicator_style;
-}
-
-/**
- * hdy_carousel_set_indicator_style
- * @self: a #HdyCarousel
- * @style: indicator style to use
- *
- * Sets style of page indicators. Depending on orientation, they are displayed
- * below or besides the pages. If the pages are meant to be centered,
- * #HdyCarousel:center-content can be used to compensate for that.
- *
- * Since: 1.0
- */
-void
-hdy_carousel_set_indicator_style (HdyCarousel               *self,
-                                  HdyCarouselIndicatorStyle  style)
-{
-  g_return_if_fail (HDY_IS_CAROUSEL (self));
-
-  if (self->indicator_style == style)
-    return;
-
-  self->indicator_style = style;
-  update_indicators (self);
-
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_INDICATOR_STYLE]);
-}
-
-/**
- * hdy_carousel_get_indicator_spacing:
- * @self: a #HdyCarousel
- *
- * Gets spacing between content and page indicators.
- *
- * Returns: Spacing between content and indicators
- *
- * Since: 1.0
- */
-guint
-hdy_carousel_get_indicator_spacing (HdyCarousel *self)
-{
-  g_return_val_if_fail (HDY_IS_CAROUSEL (self), 0);
-
-  return self->indicator_spacing;
-}
-
-/**
- * hdy_carousel_set_indicator_spacing:
- * @self: a #HdyCarousel
- * @spacing: the new spacing value
- *
- * Sets spacing between content and page indicators. Does nothing if
- * #HdyCarousel:indicator-style is @HDY_CAROUSEL_INDICATOR_STYLE_NONE.
- *
- * Since: 1.0
- */
-void
-hdy_carousel_set_indicator_spacing (HdyCarousel *self,
-                                    guint        spacing)
-{
-  g_return_if_fail (HDY_IS_CAROUSEL (self));
-
-  if (self->indicator_spacing == spacing)
-    return;
-
-  self->indicator_spacing = spacing;
-  gtk_box_set_spacing (self->box, spacing);
-
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_INDICATOR_SPACING]);
-}
-
-/**
- * hdy_carousel_get_center_content
- * @self: a #HdyCarousel
- *
- * Sets whether @self is centering pages.
- *
- * Returns: %TRUE if @self is centering pages
- *
- * Since: 1.0
- */
-gboolean
-hdy_carousel_get_center_content (HdyCarousel *self)
-{
-  g_return_val_if_fail (HDY_IS_CAROUSEL (self), FALSE);
-
-  return self->center_content;
-}
-
-/**
- * hdy_carousel_set_center_content
- * @self: a #HdyCarousel
- * @center_content: whether @self should center contents
- *
- * Sets whether @self is centering content. If #HdyCarousel:indicator-style is
- * @HDY_CAROUSEL_INDICATOR_STYLE_NONE, centering does nothing, otherwise it
- * adds whitespace to the left or above the pages to compensate for the
- * indicators.
- *
- * Since: 1.0
- */
-void
-hdy_carousel_set_center_content (HdyCarousel *self,
-                                 gboolean     center_content)
-{
-  g_return_if_fail (HDY_IS_CAROUSEL (self));
-
-  center_content = !!center_content;
-
-  if (self->center_content == center_content)
-    return;
-
-  self->center_content = center_content;
-  update_indicators (self);
-
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CENTER_CONTENT]);
-}
-
 /**
  * hdy_carousel_get_spacing:
  * @self: a #HdyCarousel
diff --git a/src/hdy-carousel.h b/src/hdy-carousel.h
index 50beba80..4318b653 100644
--- a/src/hdy-carousel.h
+++ b/src/hdy-carousel.h
@@ -13,7 +13,6 @@
 #include "hdy-version.h"
 
 #include <gtk/gtk.h>
-#include "hdy-enums.h"
 
 G_BEGIN_DECLS
 
@@ -22,12 +21,6 @@ G_BEGIN_DECLS
 HDY_AVAILABLE_IN_ALL
 G_DECLARE_FINAL_TYPE (HdyCarousel, hdy_carousel, HDY, CAROUSEL, GtkEventBox)
 
-typedef enum {
-  HDY_CAROUSEL_INDICATOR_STYLE_NONE,
-  HDY_CAROUSEL_INDICATOR_STYLE_DOTS,
-  HDY_CAROUSEL_INDICATOR_STYLE_LINES,
-} HdyCarouselIndicatorStyle;
-
 HDY_AVAILABLE_IN_ALL
 GtkWidget      *hdy_carousel_new (void);
 
@@ -62,24 +55,6 @@ HDY_AVAILABLE_IN_ALL
 void            hdy_carousel_set_interactive (HdyCarousel *self,
                                               gboolean     interactive);
 
-HDY_AVAILABLE_IN_ALL
-HdyCarouselIndicatorStyle hdy_carousel_get_indicator_style (HdyCarousel *self);
-HDY_AVAILABLE_IN_ALL
-void            hdy_carousel_set_indicator_style (HdyCarousel               *self,
-                                                  HdyCarouselIndicatorStyle  style);
-
-HDY_AVAILABLE_IN_ALL
-guint           hdy_carousel_get_indicator_spacing (HdyCarousel *self);
-HDY_AVAILABLE_IN_ALL
-void            hdy_carousel_set_indicator_spacing (HdyCarousel *self,
-                                                    guint        spacing);
-
-HDY_AVAILABLE_IN_ALL
-gboolean        hdy_carousel_get_center_content (HdyCarousel *self);
-HDY_AVAILABLE_IN_ALL
-void            hdy_carousel_set_center_content (HdyCarousel *self,
-                                                 gboolean     center_content);
-
 HDY_AVAILABLE_IN_ALL
 guint           hdy_carousel_get_spacing (HdyCarousel *self);
 HDY_AVAILABLE_IN_ALL
diff --git a/src/hdy-carousel.ui b/src/hdy-carousel.ui
index e0b177a4..c9bf5535 100644
--- a/src/hdy-carousel.ui
+++ b/src/hdy-carousel.ui
@@ -6,42 +6,16 @@
     <property name="orientation">horizontal</property>
     <signal name="scroll-event" handler="scroll_event_cb"/>
     <child>
-      <object class="GtkBox" id="box">
+      <object class="HdyCarouselBox" id="scrolling_box">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkBox" id="empty_box">
-            <property name="visible">False</property>
-          </object>
-        </child>
-        <child>
-          <object class="HdyCarouselBox" id="scrolling_box">
-            <property name="visible">True</property>
-            <property name="expand">True</property>
-            <signal name="notify::n-pages" handler="notify_n_pages_cb" swapped="true"/>
-            <signal name="notify::position" handler="notify_position_cb" swapped="true"/>
-            <signal name="notify::spacing" handler="notify_spacing_cb" swapped="true"/>
-            <signal name="notify::reveal-duration" handler="notify_reveal_duration_cb" swapped="true"/>
-            <signal name="animation-stopped" handler="animation_stopped_cb" swapped="true"/>
-            <signal name="position-shifted" handler="position_shifted_cb" swapped="true"/>
-            <signal name="page-added" handler="page_added_cb" swapped="true"/>
-            <signal name="page-removed" handler="page_removed_cb" swapped="true"/>
-          </object>
-        </child>
-        <child>
-          <object class="GtkDrawingArea" id="indicators">
-            <property name="visible">False</property>
-            <signal name="draw" handler="draw_indicators_cb" swapped="true"/>
-          </object>
-        </child>
+        <property name="expand">True</property>
+        <signal name="notify::n-pages" handler="notify_n_pages_cb" swapped="true"/>
+        <signal name="notify::position" handler="notify_position_cb" swapped="true"/>
+        <signal name="notify::spacing" handler="notify_spacing_cb" swapped="true"/>
+        <signal name="notify::reveal-duration" handler="notify_reveal_duration_cb" swapped="true"/>
+        <signal name="animation-stopped" handler="animation_stopped_cb" swapped="true"/>
+        <signal name="position-shifted" handler="position_shifted_cb" swapped="true"/>
       </object>
     </child>
   </template>
-  <object class="GtkSizeGroup" id="sizegroup">
-    <property name="mode">both</property>
-    <widgets>
-      <widget name="empty_box"/>
-      <widget name="indicators"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/src/hdy-enums.c.in b/src/hdy-enums.c.in
index 9a9fe407..a6305554 100644
--- a/src/hdy-enums.c.in
+++ b/src/hdy-enums.c.in
@@ -1,7 +1,6 @@
 /*** BEGIN file-header ***/
 
 #include "config.h"
-#include "hdy-carousel.h"
 #include "hdy-deck.h"
 #include "hdy-enums.h"
 #include "hdy-header-bar.h"
diff --git a/src/meson.build b/src/meson.build
index 18a1fc67..8b79ec12 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -8,7 +8,6 @@ libhandy_resources = gnome.compile_resources(
 )
 
 hdy_public_enum_headers = [
-  'hdy-carousel.h',
   'hdy-deck.h',
   'hdy-header-bar.h',
   'hdy-header-group.h',
diff --git a/tests/test-carousel.c b/tests/test-carousel.c
index 25ccb3e6..7e430ea5 100644
--- a/tests/test-carousel.c
+++ b/tests/test-carousel.c
@@ -125,87 +125,6 @@ test_hdy_carousel_interactive (void)
   g_assert_cmpint (notified, ==, 2);
 }
 
-static void
-test_hdy_carousel_indicator_style (void)
-{
-  HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ());
-  HdyCarouselIndicatorStyle indicator_style;
-
-  notified = 0;
-  g_signal_connect (carousel, "notify::indicator-style", G_CALLBACK (notify_cb), NULL);
-
-  /* Accessors */
-  g_assert_cmpint (hdy_carousel_get_indicator_style (carousel), ==, HDY_CAROUSEL_INDICATOR_STYLE_NONE);
-  hdy_carousel_set_indicator_style (carousel, HDY_CAROUSEL_INDICATOR_STYLE_DOTS);
-  g_assert_cmpint (hdy_carousel_get_indicator_style (carousel), ==, HDY_CAROUSEL_INDICATOR_STYLE_DOTS);
-  g_assert_cmpint (notified, ==, 1);
-  hdy_carousel_set_indicator_style (carousel, HDY_CAROUSEL_INDICATOR_STYLE_LINES);
-  g_assert_cmpint (hdy_carousel_get_indicator_style (carousel), ==, HDY_CAROUSEL_INDICATOR_STYLE_LINES);
-  g_assert_cmpint (notified, ==, 2);
-
-  /* Property */
-  g_object_set (carousel, "indicator-style", HDY_CAROUSEL_INDICATOR_STYLE_DOTS, NULL);
-  g_object_get (carousel, "indicator-style", &indicator_style, NULL);
-  g_assert_cmpint (indicator_style, ==, HDY_CAROUSEL_INDICATOR_STYLE_DOTS);
-  g_assert_cmpint (notified, ==, 3);
-
-  /* Setting the same value should not notify */
-  hdy_carousel_set_indicator_style (carousel, HDY_CAROUSEL_INDICATOR_STYLE_DOTS);
-  g_assert_cmpint (notified, ==, 3);
-}
-
-static void
-test_hdy_carousel_indicator_spacing (void)
-{
-  HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ());
-  guint spacing;
-
-  notified = 0;
-  g_signal_connect (carousel, "notify::indicator-spacing", G_CALLBACK (notify_cb), NULL);
-
-  /* Accessors */
-  g_assert_cmpuint (hdy_carousel_get_indicator_spacing (carousel), ==, 0);
-  hdy_carousel_set_indicator_spacing (carousel, 12);
-  g_assert_cmpuint (hdy_carousel_get_indicator_spacing (carousel), ==, 12);
-  g_assert_cmpint (notified, ==, 1);
-
-  /* Property */
-  g_object_set (carousel, "indicator-spacing", 6, NULL);
-  g_object_get (carousel, "indicator-spacing", &spacing, NULL);
-  g_assert_cmpuint (spacing, ==, 6);
-  g_assert_cmpint (notified, ==, 2);
-
-  /* Setting the same value should not notify */
-  hdy_carousel_set_indicator_spacing (carousel, 6);
-  g_assert_cmpint (notified, ==, 2);
-}
-
-static void
-test_hdy_carousel_center_content (void)
-{
-  HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ());
-  gboolean center_content;
-
-  notified = 0;
-  g_signal_connect (carousel, "notify::center-content", G_CALLBACK (notify_cb), NULL);
-
-  /* Accessors */
-  g_assert_false (hdy_carousel_get_center_content (carousel));
-  hdy_carousel_set_center_content (carousel, TRUE);
-  g_assert_true (hdy_carousel_get_center_content (carousel));
-  g_assert_cmpint (notified, ==, 1);
-
-  /* Property */
-  g_object_set (carousel, "center-content", FALSE, NULL);
-  g_object_get (carousel, "center-content", &center_content, NULL);
-  g_assert_false (center_content);
-  g_assert_cmpint (notified, ==, 2);
-
-  /* Setting the same value should not notify */
-  hdy_carousel_set_center_content (carousel, FALSE);
-  g_assert_cmpint (notified, ==, 2);
-}
-
 static void
 test_hdy_carousel_spacing (void)
 {
@@ -320,9 +239,6 @@ main (gint argc,
   g_test_add_func("/Handy/Carousel/add_remove", test_hdy_carousel_add_remove);
   g_test_add_func("/Handy/Carousel/scroll_to", test_hdy_carousel_scroll_to);
   g_test_add_func("/Handy/Carousel/interactive", test_hdy_carousel_interactive);
-  g_test_add_func("/Handy/Carousel/indicator_style", test_hdy_carousel_indicator_style);
-  g_test_add_func("/Handy/Carousel/indicator_spacing", test_hdy_carousel_indicator_spacing);
-  g_test_add_func("/Handy/Carousel/center_content", test_hdy_carousel_center_content);
   g_test_add_func("/Handy/Carousel/spacing", test_hdy_carousel_spacing);
   g_test_add_func("/Handy/Carousel/animation_duration", test_hdy_carousel_animation_duration);
   g_test_add_func("/Handy/Carousel/allow_mouse_drag", test_hdy_carousel_allow_mouse_drag);



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