[sysprof/wip/visualizers] visualizer: add set_time_range() and get_time_range()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] visualizer: add set_time_range() and get_time_range()
- Date: Sun, 25 Sep 2016 22:46:57 +0000 (UTC)
commit 5ceff81d5dd29cc0dddd2e725fb023e43bc4a900
Author: Christian Hergert <chergert redhat com>
Date: Sun Sep 25 15:35:14 2016 -0700
visualizer: add set_time_range() and get_time_range()
This allows the row to be notified of the visible range, which
can result from changing the zoom or a new reader being set.
lib/sp-visualizer-row.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
lib/sp-visualizer-row.h | 25 ++++++++++++++++++++++-
2 files changed, 71 insertions(+), 3 deletions(-)
---
diff --git a/lib/sp-visualizer-row.c b/lib/sp-visualizer-row.c
index c601888..155b0e5 100644
--- a/lib/sp-visualizer-row.c
+++ b/lib/sp-visualizer-row.c
@@ -18,7 +18,13 @@
#include "sp-visualizer-row.h"
-G_DEFINE_ABSTRACT_TYPE (SpVisualizerRow, sp_visualizer_row, GTK_TYPE_LIST_BOX_ROW)
+typedef struct
+{
+ gint64 begin_time;
+ gint64 end_time;
+} SpVisualizerRowPrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SpVisualizerRow, sp_visualizer_row, GTK_TYPE_LIST_BOX_ROW)
static void
sp_visualizer_row_class_init (SpVisualizerRowClass *klass)
@@ -39,3 +45,44 @@ sp_visualizer_row_set_reader (SpVisualizerRow *self,
if (SP_VISUALIZER_ROW_GET_CLASS (self)->set_reader)
SP_VISUALIZER_ROW_GET_CLASS (self)->set_reader (self, reader);
}
+
+void
+sp_visualizer_row_set_time_range (SpVisualizerRow *self,
+ gint64 begin_time,
+ gint64 end_time)
+{
+ SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
+
+ g_return_if_fail (SP_IS_VISUALIZER_ROW (self));
+
+ if (begin_time > end_time)
+ {
+ gint64 tmp = begin_time;
+ begin_time = end_time;
+ end_time = tmp;
+ }
+
+ priv->begin_time = begin_time;
+ priv->end_time = end_time;
+
+ if (SP_VISUALIZER_ROW_GET_CLASS (self)->set_time_range)
+ SP_VISUALIZER_ROW_GET_CLASS (self)->set_time_range (self, begin_time, end_time);
+}
+
+void
+sp_visualizer_row_get_time_range (SpVisualizerRow *self,
+ gint64 *begin_time,
+ gint64 *end_time)
+{
+ SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
+
+ g_return_if_fail (SP_IS_VISUALIZER_ROW (self));
+ g_return_if_fail (begin_time != NULL);
+ g_return_if_fail (end_time != NULL);
+
+ if (begin_time != NULL)
+ *begin_time = priv->begin_time;
+
+ if (end_time != NULL)
+ *end_time = priv->end_time;
+}
diff --git a/lib/sp-visualizer-row.h b/lib/sp-visualizer-row.h
index fb01565..49c828f 100644
--- a/lib/sp-visualizer-row.h
+++ b/lib/sp-visualizer-row.h
@@ -43,6 +43,21 @@ struct _SpVisualizerRowClass
void (*set_reader) (SpVisualizerRow *self,
SpCaptureReader *reader);
+ /**
+ * SpVisualizerRow::set_time_range:
+ * @self: A #SpVisualizerRow
+ * @begin_time: the beginning time for the row.
+ * @end_time: the end time for the row.
+ *
+ * This function is used to notify the row that the range the
+ * row should be displaying has changed. This might happen when
+ * the user has altered the zoom level, selected a region, in or
+ * a new capture was loaded.
+ */
+ void (*set_time_range) (SpVisualizerRow *self,
+ gint64 begin_time,
+ gint64 end_time);
+
gpointer _reserved1;
gpointer _reserved2;
gpointer _reserved3;
@@ -61,8 +76,14 @@ struct _SpVisualizerRowClass
gpointer _reserved16;
};
-void sp_visualizer_row_set_reader (SpVisualizerRow *self,
- SpCaptureReader *reader);
+void sp_visualizer_row_set_reader (SpVisualizerRow *self,
+ SpCaptureReader *reader);
+void sp_visualizer_row_get_time_range (SpVisualizerRow *self,
+ gint64 *begin_time,
+ gint64 *end_time);
+void sp_visualizer_row_set_time_range (SpVisualizerRow *self,
+ gint64 begin_time,
+ gint64 end_time);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]