[sysprof] marks: add group to visualizer row



commit 14d2554c35332147366b3a355a4452ee036070f8
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 15 17:16:37 2018 +0100

    marks: add group to visualizer row
    
    This will allow us to filter events that we do not care about for a given
    row. We add a visualizer row per-group.

 lib/visualizers/sp-mark-visualizer-row.c |   50 ++++++++++++++++++++++++++---
 lib/visualizers/sp-mark-visualizer-row.h |   10 ++---
 lib/visualizers/sp-visualizer-list.c     |    1 +
 3 files changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/lib/visualizers/sp-mark-visualizer-row.c b/lib/visualizers/sp-mark-visualizer-row.c
index 87b1133..d221099 100644
--- a/lib/visualizers/sp-mark-visualizer-row.c
+++ b/lib/visualizers/sp-mark-visualizer-row.c
@@ -28,6 +28,13 @@ typedef struct
   SpCaptureReader *reader;
 
   /*
+   * The group we care about for displaying marks. The idea is that we only
+   * show one group per-row, so tooling from separate systems can either be
+   * displayed together or not, based on usefulness.
+   */
+  gchar *group;
+
+  /*
    * A sorted array of MarkInfo about marks we care to render.
    */
   GArray *marks;
@@ -46,6 +53,7 @@ typedef struct
 
 enum {
   PROP_0,
+  PROP_GROUP,
   PROP_TITLE,
   N_PROPS
 };
@@ -189,6 +197,7 @@ sp_mark_visualizer_row_finalize (GObject *object)
   SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)object;
   SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
 
+  g_clear_pointer (&priv->group, g_free);
   g_clear_pointer (&priv->marks, g_array_unref);
 
   G_OBJECT_CLASS (sp_mark_visualizer_row_parent_class)->finalize (object);
@@ -205,6 +214,10 @@ sp_mark_visualizer_row_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_GROUP:
+      g_value_set_string (value, sp_mark_visualizer_row_get_group (self));
+      break;
+
     case PROP_TITLE:
       g_value_set_string (value, gtk_label_get_label (priv->label));
       break;
@@ -225,6 +238,10 @@ sp_mark_visualizer_row_set_property (GObject      *object,
 
   switch (prop_id)
     {
+    case PROP_GROUP:
+      sp_mark_visualizer_row_set_group (self, g_value_get_string (value));
+      break;
+
     case PROP_TITLE:
       gtk_label_set_label (priv->label, g_value_get_string (value));
       break;
@@ -249,6 +266,13 @@ sp_mark_visualizer_row_class_init (SpMarkVisualizerRowClass *klass)
 
   visualizer_class->set_reader = sp_mark_visualizer_row_set_reader;
 
+  properties [PROP_GROUP] =
+    g_param_spec_string ("group",
+                         "Group",
+                         "The group of the row",
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_TITLE] =
     g_param_spec_string ("title",
                          "Title",
@@ -286,14 +310,28 @@ sp_mark_visualizer_row_new (void)
   return g_object_new (SP_TYPE_MARK_VISUALIZER_ROW, NULL);
 }
 
+const gchar *
+sp_mark_visualizer_row_get_group (SpMarkVisualizerRow *self)
+{
+  SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
+
+  g_return_val_if_fail (SP_IS_MARK_VISUALIZER_ROW (self), NULL);
+
+  return priv->group;
+}
+
 void
-sp_mark_visualizer_row_add_mark (SpMarkVisualizerRow *self,
-                                 GPid                 pid,
-                                 GPid                 tid,
-                                 const gchar         *name,
-                                 const GdkRGBA       *color)
+sp_mark_visualizer_row_set_group (SpMarkVisualizerRow *self,
+                                  const gchar         *group)
 {
+  SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
+
   g_return_if_fail (SP_IS_MARK_VISUALIZER_ROW (self));
-  g_return_if_fail (name != NULL);
 
+  if (g_strcmp0 (priv->group, group) != 0)
+    {
+      g_free (priv->group);
+      priv->group = g_strdup (group);
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_GROUP]);
+    }
 }
diff --git a/lib/visualizers/sp-mark-visualizer-row.h b/lib/visualizers/sp-mark-visualizer-row.h
index f6c0f7c..2194ac8 100644
--- a/lib/visualizers/sp-mark-visualizer-row.h
+++ b/lib/visualizers/sp-mark-visualizer-row.h
@@ -34,11 +34,9 @@ struct _SpMarkVisualizerRowClass
   gpointer _reserved[16];
 };
 
-GtkWidget *sp_mark_visualizer_row_new      (void);
-void       sp_mark_visualizer_row_add_mark (SpMarkVisualizerRow *self,
-                                            GPid                 pid,
-                                            GPid                 tid,
-                                            const gchar         *name,
-                                            const GdkRGBA       *color);
+GtkWidget   *sp_mark_visualizer_row_new       (void);
+const gchar *sp_mark_visualizer_row_get_group (SpMarkVisualizerRow *self);
+void         sp_mark_visualizer_row_set_group (SpMarkVisualizerRow *self,
+                                               const gchar         *group);
 
 G_END_DECLS
diff --git a/lib/visualizers/sp-visualizer-list.c b/lib/visualizers/sp-visualizer-list.c
index 0054653..5da2547 100644
--- a/lib/visualizers/sp-visualizer-list.c
+++ b/lib/visualizers/sp-visualizer-list.c
@@ -270,6 +270,7 @@ handle_capture_results (GObject      *object,
   while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
     {
       GtkWidget *row = g_object_new (SP_TYPE_MARK_VISUALIZER_ROW,
+                                     "group", key,
                                      "title", key,
                                      "height-request", 75,
                                      "selectable", FALSE,


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