mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
visualizer-selection: add visualizer helpers
Adds a copy helper (for thread access) and a contains helper.
This commit is contained in:
@ -212,3 +212,40 @@ sp_visualizer_selection_unselect_all (SpVisualizerSelection *self)
|
|||||||
g_signal_emit (self, signals [CHANGED], 0);
|
g_signal_emit (self, signals [CHANGED], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sp_visualizer_selection_contains (SpVisualizerSelection *self,
|
||||||
|
gint64 time_at)
|
||||||
|
{
|
||||||
|
if (self == NULL || self->ranges->len == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
for (guint i = 0; i < self->ranges->len; i++)
|
||||||
|
{
|
||||||
|
const Range *range = &g_array_index (self->ranges, Range, i);
|
||||||
|
|
||||||
|
if (time_at >= range->begin && time_at <= range->end)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpVisualizerSelection *
|
||||||
|
sp_visualizer_selection_copy (const SpVisualizerSelection *self)
|
||||||
|
{
|
||||||
|
SpVisualizerSelection *copy;
|
||||||
|
|
||||||
|
if (self == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
copy = g_object_new (SP_TYPE_VISUALIZER_SELECTION, NULL);
|
||||||
|
|
||||||
|
for (guint i = 0; i < self->ranges->len; i++)
|
||||||
|
{
|
||||||
|
Range range = g_array_index (self->ranges, Range, i);
|
||||||
|
g_array_append_val (copy->ranges, range);
|
||||||
|
}
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|||||||
@ -19,13 +19,13 @@
|
|||||||
#ifndef SP_VISUALIZER_SELECTION_H
|
#ifndef SP_VISUALIZER_SELECTION_H
|
||||||
#define SP_VISUALIZER_SELECTION_H
|
#define SP_VISUALIZER_SELECTION_H
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define SP_TYPE_VISUALIZER_SELECTION (sp_visualizer_selection_get_type())
|
#define SP_TYPE_VISUALIZER_SELECTION (sp_visualizer_selection_get_type())
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (SpVisualizerSelection, sp_visualizer_selection, SP, VISUALIZER_SELECTION, GtkDrawingArea)
|
G_DECLARE_FINAL_TYPE (SpVisualizerSelection, sp_visualizer_selection, SP, VISUALIZER_SELECTION, GObject)
|
||||||
|
|
||||||
typedef void (*SpVisualizerSelectionForeachFunc) (SpVisualizerSelection *self,
|
typedef void (*SpVisualizerSelectionForeachFunc) (SpVisualizerSelection *self,
|
||||||
gint64 begin_time,
|
gint64 begin_time,
|
||||||
@ -33,6 +33,8 @@ typedef void (*SpVisualizerSelectionForeachFunc) (SpVisualizerSelection *self,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
gboolean sp_visualizer_selection_get_has_selection (SpVisualizerSelection *self);
|
gboolean sp_visualizer_selection_get_has_selection (SpVisualizerSelection *self);
|
||||||
|
gboolean sp_visualizer_selection_contains (SpVisualizerSelection *self,
|
||||||
|
gint64 time_at);
|
||||||
void sp_visualizer_selection_select_range (SpVisualizerSelection *self,
|
void sp_visualizer_selection_select_range (SpVisualizerSelection *self,
|
||||||
gint64 begin_time,
|
gint64 begin_time,
|
||||||
gint64 end_time);
|
gint64 end_time);
|
||||||
@ -43,6 +45,8 @@ void sp_visualizer_selection_unselect_all (SpVisualizerSelection
|
|||||||
void sp_visualizer_selection_foreach (SpVisualizerSelection *self,
|
void sp_visualizer_selection_foreach (SpVisualizerSelection *self,
|
||||||
SpVisualizerSelectionForeachFunc foreach_func,
|
SpVisualizerSelectionForeachFunc foreach_func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
SpVisualizerSelection *
|
||||||
|
sp_visualizer_selection_copy (const SpVisualizerSelection *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user