[libchamplain] Eliminate TidyScrollable
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Eliminate TidyScrollable
- Date: Sat, 26 Feb 2011 12:58:24 +0000 (UTC)
commit 154e8aeed74c8d0091271aa2d0894184c58438ca
Author: JiÅ?Ã Techet <techet gmail com>
Date: Thu Feb 24 22:09:01 2011 +0100
Eliminate TidyScrollable
As TidyViewport is the only class implementing it, having an extra
interface is not necessary.
champlain/champlain-view.c | 3 +-
tidy/Makefile.am | 2 -
tidy/tidy-finger-scroll.c | 15 ++++----
tidy/tidy-scrollable.c | 87 --------------------------------------------
tidy/tidy-scrollable.h | 63 --------------------------------
tidy/tidy-viewport.c | 82 ++++++++++++++++++-----------------------
tidy/tidy-viewport.h | 9 +++++
7 files changed, 54 insertions(+), 207 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index bfeeb5a..b43e889 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -70,7 +70,6 @@
#include <tidy-finger-scroll.h>
#include <tidy-viewport.h>
#include <tidy-adjustment.h>
-#include <tidy-scrollable.h>
//#define VIEW_LOG
#ifdef VIEW_LOG
@@ -336,7 +335,7 @@ resize_viewport (ChamplainView *view)
ChamplainViewPrivate *priv = view->priv;
- tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->viewport), &hadjust,
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (priv->viewport), &hadjust,
&vadjust);
if (priv->zoom_level < 8)
diff --git a/tidy/Makefile.am b/tidy/Makefile.am
index ff13837..d2917b7 100644
--- a/tidy/Makefile.am
+++ b/tidy/Makefile.am
@@ -7,14 +7,12 @@ EXTRA_DIST =
tidy_headers_public = \
$(srcdir)/tidy-adjustment.h \
$(srcdir)/tidy-finger-scroll.h \
- $(srcdir)/tidy-scrollable.h \
$(srcdir)/tidy-viewport.h \
$(srcdir)/tidy-private.h
tidy_sources = \
$(srcdir)/tidy-adjustment.c \
$(srcdir)/tidy-finger-scroll.c \
- $(srcdir)/tidy-scrollable.c \
$(srcdir)/tidy-viewport.c
diff --git a/tidy/tidy-finger-scroll.c b/tidy/tidy-finger-scroll.c
index 5ea3ee8..7152e4f 100644
--- a/tidy/tidy-finger-scroll.c
+++ b/tidy/tidy-finger-scroll.c
@@ -23,7 +23,8 @@
#include "tidy-finger-scroll.h"
#include "tidy-enum-types.h"
#include "tidy-marshal.h"
-#include "tidy-scrollable.h"
+#include "tidy-adjustment.h"
+#include "tidy-viewport.h"
#include <clutter/clutter.h>
#include <math.h>
@@ -318,7 +319,7 @@ tidy_finger_scroll_add_actor (ClutterContainer *container,
}
else
{
- if (TIDY_IS_SCROLLABLE(actor))
+ if (TIDY_IS_VIEWPORT(actor))
{
priv->child = actor;
clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
@@ -332,7 +333,7 @@ tidy_finger_scroll_add_actor (ClutterContainer *container,
{
g_warning ("Attempting to add an actor to "
"a TidyFingerScroll, but the actor does "
- "not implement TidyScrollable.");
+ "not implement TidyViewport.");
}
}
}
@@ -427,7 +428,7 @@ motion_event_cb (ClutterActor *actor,
gdouble dx, dy;
TidyAdjustment *hadjust, *vadjust;
- tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->child),
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (priv->child),
&hadjust,
&vadjust);
@@ -471,7 +472,7 @@ clamp_adjustments (TidyFingerScroll *scroll)
TidyAdjustment *hadj, *vadj;
gboolean snap;
- tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->child),
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (priv->child),
&hadj, &vadj);
/* FIXME: Hard-coded value here */
@@ -537,7 +538,7 @@ deceleration_new_frame_cb (ClutterTimeline *timeline,
gint i;
gboolean stop = TRUE;
- tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->child),
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (priv->child),
&hadjust,
&vadjust);
@@ -660,7 +661,7 @@ button_release_event_cb (ClutterActor *actor,
priv->dy = (y_origin - y) / frac;
/* Get adjustments to do step-increment snapping */
- tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->child),
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (priv->child),
&hadjust,
&vadjust);
diff --git a/tidy/tidy-viewport.c b/tidy/tidy-viewport.c
index d30d1c5..63258e6 100644
--- a/tidy/tidy-viewport.c
+++ b/tidy/tidy-viewport.c
@@ -27,23 +27,10 @@
#include <clutter/clutter.h>
#include "tidy-viewport.h"
-#include "tidy-adjustment.h"
-#include "tidy-scrollable.h"
#include "tidy-private.h"
-static void scrollable_interface_init (TidyScrollableInterface *iface);
-static void scrollable_set_adjustments (TidyScrollable *scrollable,
- TidyAdjustment *hadjustment,
- TidyAdjustment *vadjustment);
-
-static void scrollable_get_adjustments (TidyScrollable *scrollable,
- TidyAdjustment **hadjustment,
- TidyAdjustment **vadjustment);
-
-G_DEFINE_TYPE_WITH_CODE (TidyViewport, tidy_viewport, CLUTTER_TYPE_GROUP,
- G_IMPLEMENT_INTERFACE (TIDY_TYPE_SCROLLABLE,
- scrollable_interface_init))
+G_DEFINE_TYPE (TidyViewport, tidy_viewport, CLUTTER_TYPE_GROUP)
#define VIEWPORT_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TIDY_TYPE_VIEWPORT, \
@@ -70,7 +57,7 @@ enum
PROP_Z_ORIGIN,
PROP_HADJUST,
PROP_VADJUST,
- PROP_SYNC_ADJUST
+ PROP_SYNC_ADJUST,
};
static void
@@ -98,12 +85,12 @@ tidy_viewport_get_property (GObject *object,
break;
case PROP_HADJUST :
- scrollable_get_adjustments (TIDY_SCROLLABLE (object), &adjustment, NULL);
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (object), &adjustment, NULL);
g_value_set_object (value, adjustment);
break;
case PROP_VADJUST :
- scrollable_get_adjustments (TIDY_SCROLLABLE (object), NULL, &adjustment);
+ tidy_viewport_get_adjustments (TIDY_VIEWPORT (object), NULL, &adjustment);
g_value_set_object (value, adjustment);
break;
@@ -150,13 +137,13 @@ tidy_viewport_set_property (GObject *object,
break;
case PROP_HADJUST :
- scrollable_set_adjustments (TIDY_SCROLLABLE (object),
+ tidy_viewport_set_adjustments (TIDY_VIEWPORT (object),
g_value_get_object (value),
priv->vadjustment);
break;
case PROP_VADJUST :
- scrollable_set_adjustments (TIDY_SCROLLABLE (object),
+ tidy_viewport_set_adjustments (TIDY_VIEWPORT (object),
priv->hadjustment,
g_value_get_object (value));
break;
@@ -321,13 +308,22 @@ tidy_viewport_class_init (TidyViewportClass *klass)
TRUE,
G_PARAM_READWRITE));
- g_object_class_override_property (gobject_class,
- PROP_HADJUST,
- "hadjustment");
+ g_object_class_install_property (gobject_class,
+ PROP_HADJUST,
+ g_param_spec_object ("hadjustment",
+ "TidyAdjustment",
+ "Horizontal adjustment",
+ TIDY_TYPE_ADJUSTMENT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_VADJUST,
+ g_param_spec_object ("vadjustment",
+ "TidyAdjustment",
+ "Vertical adjustment",
+ TIDY_TYPE_ADJUSTMENT,
+ G_PARAM_READWRITE));
- g_object_class_override_property (gobject_class,
- PROP_VADJUST,
- "vadjustment");
}
static void
@@ -361,12 +357,12 @@ vadjustment_value_notify_cb (TidyAdjustment *adjustment, GParamSpec *arg1,
priv->z);
}
-static void
-scrollable_set_adjustments (TidyScrollable *scrollable,
+void
+tidy_viewport_set_adjustments (TidyViewport *viewport,
TidyAdjustment *hadjustment,
TidyAdjustment *vadjustment)
{
- TidyViewportPrivate *priv = TIDY_VIEWPORT (scrollable)->priv;
+ TidyViewportPrivate *priv = TIDY_VIEWPORT (viewport)->priv;
if (hadjustment != priv->hadjustment)
{
@@ -374,7 +370,7 @@ scrollable_set_adjustments (TidyScrollable *scrollable,
{
g_signal_handlers_disconnect_by_func (priv->hadjustment,
hadjustment_value_notify_cb,
- scrollable);
+ viewport);
g_object_unref (priv->hadjustment);
}
@@ -383,7 +379,7 @@ scrollable_set_adjustments (TidyScrollable *scrollable,
g_object_ref (hadjustment);
g_signal_connect (hadjustment, "notify::value",
G_CALLBACK (hadjustment_value_notify_cb),
- scrollable);
+ viewport);
}
priv->hadjustment = hadjustment;
@@ -395,7 +391,7 @@ scrollable_set_adjustments (TidyScrollable *scrollable,
{
g_signal_handlers_disconnect_by_func (priv->vadjustment,
vadjustment_value_notify_cb,
- scrollable);
+ viewport);
g_object_unref (priv->vadjustment);
}
@@ -404,23 +400,23 @@ scrollable_set_adjustments (TidyScrollable *scrollable,
g_object_ref (vadjustment);
g_signal_connect (vadjustment, "notify::value",
G_CALLBACK (vadjustment_value_notify_cb),
- scrollable);
+ viewport);
}
priv->vadjustment = vadjustment;
}
}
-static void
-scrollable_get_adjustments (TidyScrollable *scrollable,
+void
+tidy_viewport_get_adjustments (TidyViewport *viewport,
TidyAdjustment **hadjustment,
TidyAdjustment **vadjustment)
{
TidyViewportPrivate *priv;
- g_return_if_fail (TIDY_IS_VIEWPORT (scrollable));
+ g_return_if_fail (TIDY_IS_VIEWPORT (viewport));
- priv = ((TidyViewport *)scrollable)->priv;
+ priv = ((TidyViewport *)viewport)->priv;
if (hadjustment)
{
@@ -431,7 +427,7 @@ scrollable_get_adjustments (TidyScrollable *scrollable,
TidyAdjustment *adjustment;
guint width, stage_width, increment;
- width = clutter_actor_get_width (CLUTTER_ACTOR(scrollable));
+ width = clutter_actor_get_width (CLUTTER_ACTOR(viewport));
stage_width = clutter_actor_get_width (clutter_stage_get_default ());
increment = MAX (1, MIN(stage_width, width));
@@ -441,7 +437,7 @@ scrollable_get_adjustments (TidyScrollable *scrollable,
1,
increment,
increment);
- scrollable_set_adjustments (scrollable,
+ tidy_viewport_set_adjustments (viewport,
adjustment,
priv->vadjustment);
*hadjustment = adjustment;
@@ -457,7 +453,7 @@ scrollable_get_adjustments (TidyScrollable *scrollable,
TidyAdjustment *adjustment;
guint height, stage_height, increment;
- height = clutter_actor_get_height (CLUTTER_ACTOR(scrollable));
+ height = clutter_actor_get_height (CLUTTER_ACTOR(viewport));
stage_height = clutter_actor_get_height (clutter_stage_get_default ());
increment = MAX (1, MIN(stage_height, height));
@@ -467,7 +463,7 @@ scrollable_get_adjustments (TidyScrollable *scrollable,
1,
increment,
increment);
- scrollable_set_adjustments (scrollable,
+ tidy_viewport_set_adjustments (viewport,
priv->hadjustment,
adjustment);
*vadjustment = adjustment;
@@ -475,12 +471,6 @@ scrollable_get_adjustments (TidyScrollable *scrollable,
}
}
-static void
-scrollable_interface_init (TidyScrollableInterface *iface)
-{
- iface->set_adjustments = scrollable_set_adjustments;
- iface->get_adjustments = scrollable_get_adjustments;
-}
static void
clip_notify_cb (ClutterActor *actor,
diff --git a/tidy/tidy-viewport.h b/tidy/tidy-viewport.h
index 1ee9b35..d1e4efd 100644
--- a/tidy/tidy-viewport.h
+++ b/tidy/tidy-viewport.h
@@ -25,6 +25,7 @@
#include <glib-object.h>
#include <clutter/clutter.h>
+#include "tidy-adjustment.h"
G_BEGIN_DECLS
@@ -66,6 +67,14 @@ void tidy_viewport_get_origin (TidyViewport *viewport,
gfloat *z);
void tidy_viewport_stop (TidyViewport *viewport);
+void tidy_viewport_get_adjustments (TidyViewport *viewport,
+ TidyAdjustment **hadjustment,
+ TidyAdjustment **vadjustment);
+
+void tidy_viewport_set_adjustments (TidyViewport *viewport,
+ TidyAdjustment *hadjustment,
+ TidyAdjustment *vadjustment);
+
G_END_DECLS
#endif /* __TIDY_VIEWPORT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]