mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 23:20:54 +00:00
selection: rename SpVisualizerSelection to SpSelection
We want this in sysprof.h (without UI components) so that we can use it to filter things in profilers. Therefore, we don't need to make it namespaced to "visualizers" since a time range selection is a fairly straightforward, and non-UI confined implementation.
This commit is contained in:
@ -66,9 +66,9 @@ headers_DATA = \
|
|||||||
sp-proc-source.h \
|
sp-proc-source.h \
|
||||||
sp-profile.h \
|
sp-profile.h \
|
||||||
sp-profiler.h \
|
sp-profiler.h \
|
||||||
|
sp-selection.h \
|
||||||
sp-source.h \
|
sp-source.h \
|
||||||
sp-symbol-resolver.h \
|
sp-symbol-resolver.h \
|
||||||
sp-visualizer-selection.h \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libsysprof_@API_VERSION@_la_SOURCES = \
|
libsysprof_@API_VERSION@_la_SOURCES = \
|
||||||
@ -100,9 +100,9 @@ libsysprof_@API_VERSION@_la_SOURCES = \
|
|||||||
sp-proc-source.c \
|
sp-proc-source.c \
|
||||||
sp-profile.c \
|
sp-profile.c \
|
||||||
sp-profiler.c \
|
sp-profiler.c \
|
||||||
|
sp-selection.c \
|
||||||
sp-source.c \
|
sp-source.c \
|
||||||
sp-symbol-resolver.c \
|
sp-symbol-resolver.c \
|
||||||
sp-visualizer-selection.c \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libsysprof_@API_VERSION@_la_CFLAGS = \
|
libsysprof_@API_VERSION@_la_CFLAGS = \
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
#include "sp-jitmap-symbol-resolver.h"
|
#include "sp-jitmap-symbol-resolver.h"
|
||||||
#include "sp-map-lookaside.h"
|
#include "sp-map-lookaside.h"
|
||||||
#include "sp-kernel-symbol-resolver.h"
|
#include "sp-kernel-symbol-resolver.h"
|
||||||
#include "sp-visualizer-selection.h"
|
#include "sp-selection.h"
|
||||||
|
|
||||||
#include "stackstash.h"
|
#include "stackstash.h"
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ struct _SpCallgraphProfile
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
SpCaptureReader *reader;
|
SpCaptureReader *reader;
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
StackStash *stash;
|
StackStash *stash;
|
||||||
GStringChunk *symbols;
|
GStringChunk *symbols;
|
||||||
GHashTable *tags;
|
GHashTable *tags;
|
||||||
@ -66,7 +66,7 @@ struct _SpCallgraphProfile
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SpCaptureReader *reader;
|
SpCaptureReader *reader;
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
} Generate;
|
} Generate;
|
||||||
|
|
||||||
static void profile_iface_init (SpProfileInterface *iface);
|
static void profile_iface_init (SpProfileInterface *iface);
|
||||||
@ -89,7 +89,7 @@ sp_callgraph_profile_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpProfile *
|
SpProfile *
|
||||||
sp_callgraph_profile_new_with_selection (SpVisualizerSelection *selection)
|
sp_callgraph_profile_new_with_selection (SpSelection *selection)
|
||||||
{
|
{
|
||||||
return g_object_new (SP_TYPE_CALLGRAPH_PROFILE,
|
return g_object_new (SP_TYPE_CALLGRAPH_PROFILE,
|
||||||
"selection", selection,
|
"selection", selection,
|
||||||
@ -161,7 +161,7 @@ sp_callgraph_profile_class_init (SpCallgraphProfileClass *klass)
|
|||||||
g_param_spec_object ("selection",
|
g_param_spec_object ("selection",
|
||||||
"Selection",
|
"Selection",
|
||||||
"The selection for filtering the callgraph",
|
"The selection for filtering the callgraph",
|
||||||
SP_TYPE_VISUALIZER_SELECTION,
|
SP_TYPE_SELECTION,
|
||||||
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
@ -220,7 +220,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
|
|||||||
SpCallgraphProfile *self = source_object;
|
SpCallgraphProfile *self = source_object;
|
||||||
Generate *gen = task_data;
|
Generate *gen = task_data;
|
||||||
SpCaptureReader *reader;
|
SpCaptureReader *reader;
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
g_autoptr(GArray) resolved = NULL;
|
g_autoptr(GArray) resolved = NULL;
|
||||||
g_autoptr(GHashTable) maps_by_pid = NULL;
|
g_autoptr(GHashTable) maps_by_pid = NULL;
|
||||||
g_autoptr(GHashTable) cmdlines = NULL;
|
g_autoptr(GHashTable) cmdlines = NULL;
|
||||||
@ -325,7 +325,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
|
|||||||
if (NULL == (sample = sp_capture_reader_read_sample (reader)))
|
if (NULL == (sample = sp_capture_reader_read_sample (reader)))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
if (!sp_visualizer_selection_contains (selection, sample->frame.time))
|
if (!sp_selection_contains (selection, sample->frame.time))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cmdline = g_hash_table_lookup (cmdlines, GINT_TO_POINTER (sample->frame.pid));
|
cmdline = g_hash_table_lookup (cmdlines, GINT_TO_POINTER (sample->frame.pid));
|
||||||
@ -444,7 +444,7 @@ sp_callgraph_profile_generate (SpProfile *profile,
|
|||||||
|
|
||||||
gen = g_slice_new0 (Generate);
|
gen = g_slice_new0 (Generate);
|
||||||
gen->reader = sp_capture_reader_copy (self->reader);
|
gen->reader = sp_capture_reader_copy (self->reader);
|
||||||
gen->selection = sp_visualizer_selection_copy (self->selection);
|
gen->selection = sp_selection_copy (self->selection);
|
||||||
|
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
g_task_set_task_data (task, gen, (GDestroyNotify)generate_free);
|
g_task_set_task_data (task, gen, (GDestroyNotify)generate_free);
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#define SP_CALLGRAPH_PROFILE_H
|
#define SP_CALLGRAPH_PROFILE_H
|
||||||
|
|
||||||
#include "sp-profile.h"
|
#include "sp-profile.h"
|
||||||
#include "sp-visualizer-selection.h"
|
#include "sp-selection.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ G_BEGIN_DECLS
|
|||||||
G_DECLARE_FINAL_TYPE (SpCallgraphProfile, sp_callgraph_profile, SP, CALLGRAPH_PROFILE, GObject)
|
G_DECLARE_FINAL_TYPE (SpCallgraphProfile, sp_callgraph_profile, SP, CALLGRAPH_PROFILE, GObject)
|
||||||
|
|
||||||
SpProfile *sp_callgraph_profile_new (void);
|
SpProfile *sp_callgraph_profile_new (void);
|
||||||
SpProfile *sp_callgraph_profile_new_with_selection (SpVisualizerSelection *selection);
|
SpProfile *sp_callgraph_profile_new_with_selection (SpSelection *selection);
|
||||||
GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self,
|
GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self,
|
||||||
const gchar *symbol);
|
const gchar *symbol);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* sp-visualizer-selection.c
|
/* sp-selection.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Christian Hergert <chergert@redhat.com>
|
* Copyright (C) 2016 Christian Hergert <chergert@redhat.com>
|
||||||
*
|
*
|
||||||
@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define G_LOG_DOMAIN "sp-visualizer-selection"
|
#define G_LOG_DOMAIN "sp-selection"
|
||||||
|
|
||||||
#include "sp-visualizer-selection.h"
|
#include "sp-selection.h"
|
||||||
|
|
||||||
struct _SpVisualizerSelection
|
struct _SpSelection
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
GArray *ranges;
|
GArray *ranges;
|
||||||
@ -32,7 +32,7 @@ typedef struct
|
|||||||
gint64 end;
|
gint64 end;
|
||||||
} Range;
|
} Range;
|
||||||
|
|
||||||
G_DEFINE_TYPE (SpVisualizerSelection, sp_visualizer_selection, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (SpSelection, sp_selection, G_TYPE_OBJECT)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -61,27 +61,27 @@ int64_swap (gint64 *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sp_visualizer_selection_finalize (GObject *object)
|
sp_selection_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
SpVisualizerSelection *self = (SpVisualizerSelection *)object;
|
SpSelection *self = (SpSelection *)object;
|
||||||
|
|
||||||
g_clear_pointer (&self->ranges, g_array_unref);
|
g_clear_pointer (&self->ranges, g_array_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (sp_visualizer_selection_parent_class)->finalize (object);
|
G_OBJECT_CLASS (sp_selection_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sp_visualizer_selection_get_property (GObject *object,
|
sp_selection_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
SpVisualizerSelection *self = SP_VISUALIZER_SELECTION (object);
|
SpSelection *self = SP_SELECTION (object);
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_HAS_SELECTION:
|
case PROP_HAS_SELECTION:
|
||||||
g_value_set_boolean (value, sp_visualizer_selection_get_has_selection (self));
|
g_value_set_boolean (value, sp_selection_get_has_selection (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -90,12 +90,12 @@ sp_visualizer_selection_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sp_visualizer_selection_class_init (SpVisualizerSelectionClass *klass)
|
sp_selection_class_init (SpSelectionClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = sp_visualizer_selection_finalize;
|
object_class->finalize = sp_selection_finalize;
|
||||||
object_class->get_property = sp_visualizer_selection_get_property;
|
object_class->get_property = sp_selection_get_property;
|
||||||
|
|
||||||
properties [PROP_HAS_SELECTION] =
|
properties [PROP_HAS_SELECTION] =
|
||||||
g_param_spec_boolean ("has-selection",
|
g_param_spec_boolean ("has-selection",
|
||||||
@ -107,7 +107,7 @@ sp_visualizer_selection_class_init (SpVisualizerSelectionClass *klass)
|
|||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpVisualizerSelection::changed:
|
* SpSelection::changed:
|
||||||
*
|
*
|
||||||
* This signal is emitted when the selection has changed.
|
* This signal is emitted when the selection has changed.
|
||||||
*/
|
*/
|
||||||
@ -119,33 +119,33 @@ sp_visualizer_selection_class_init (SpVisualizerSelectionClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sp_visualizer_selection_init (SpVisualizerSelection *self)
|
sp_selection_init (SpSelection *self)
|
||||||
{
|
{
|
||||||
self->ranges = g_array_new (FALSE, FALSE, sizeof (Range));
|
self->ranges = g_array_new (FALSE, FALSE, sizeof (Range));
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sp_visualizer_selection_get_has_selection (SpVisualizerSelection *self)
|
sp_selection_get_has_selection (SpSelection *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (SP_IS_VISUALIZER_SELECTION (self), FALSE);
|
g_return_val_if_fail (SP_IS_SELECTION (self), FALSE);
|
||||||
|
|
||||||
return self->ranges->len > 0;
|
return self->ranges->len > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sp_visualizer_selection_foreach:
|
* sp_selection_foreach:
|
||||||
* @self: A #SpVisualizerSelection
|
* @self: A #SpSelection
|
||||||
* @foreach_func: (scope call): a callback for each range
|
* @foreach_func: (scope call): a callback for each range
|
||||||
* @user_data: user data for @foreach_func
|
* @user_data: user data for @foreach_func
|
||||||
*
|
*
|
||||||
* Calls @foreach_func for every selected range.
|
* Calls @foreach_func for every selected range.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
sp_visualizer_selection_foreach (SpVisualizerSelection *self,
|
sp_selection_foreach (SpSelection *self,
|
||||||
SpVisualizerSelectionForeachFunc foreach_func,
|
SpSelectionForeachFunc foreach_func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SP_IS_VISUALIZER_SELECTION (self));
|
g_return_if_fail (SP_IS_SELECTION (self));
|
||||||
g_return_if_fail (foreach_func != NULL);
|
g_return_if_fail (foreach_func != NULL);
|
||||||
|
|
||||||
for (guint i = 0; i < self->ranges->len; i++)
|
for (guint i = 0; i < self->ranges->len; i++)
|
||||||
@ -156,13 +156,13 @@ sp_visualizer_selection_foreach (SpVisualizerSelection *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sp_visualizer_selection_select_range (SpVisualizerSelection *self,
|
sp_selection_select_range (SpSelection *self,
|
||||||
gint64 begin_time,
|
gint64 begin_time,
|
||||||
gint64 end_time)
|
gint64 end_time)
|
||||||
{
|
{
|
||||||
Range range = { 0 };
|
Range range = { 0 };
|
||||||
|
|
||||||
g_return_if_fail (SP_IS_VISUALIZER_SELECTION (self));
|
g_return_if_fail (SP_IS_SELECTION (self));
|
||||||
|
|
||||||
int64_swap (&begin_time, &end_time);
|
int64_swap (&begin_time, &end_time);
|
||||||
|
|
||||||
@ -177,11 +177,11 @@ sp_visualizer_selection_select_range (SpVisualizerSelection *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sp_visualizer_selection_unselect_range (SpVisualizerSelection *self,
|
sp_selection_unselect_range (SpSelection *self,
|
||||||
gint64 begin,
|
gint64 begin,
|
||||||
gint64 end)
|
gint64 end)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SP_IS_VISUALIZER_SELECTION (self));
|
g_return_if_fail (SP_IS_SELECTION (self));
|
||||||
|
|
||||||
int64_swap (&begin, &end);
|
int64_swap (&begin, &end);
|
||||||
|
|
||||||
@ -201,9 +201,9 @@ sp_visualizer_selection_unselect_range (SpVisualizerSelection *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sp_visualizer_selection_unselect_all (SpVisualizerSelection *self)
|
sp_selection_unselect_all (SpSelection *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SP_IS_VISUALIZER_SELECTION (self));
|
g_return_if_fail (SP_IS_SELECTION (self));
|
||||||
|
|
||||||
if (self->ranges->len > 0)
|
if (self->ranges->len > 0)
|
||||||
{
|
{
|
||||||
@ -214,8 +214,8 @@ sp_visualizer_selection_unselect_all (SpVisualizerSelection *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sp_visualizer_selection_contains (SpVisualizerSelection *self,
|
sp_selection_contains (SpSelection *self,
|
||||||
gint64 time_at)
|
gint64 time_at)
|
||||||
{
|
{
|
||||||
if (self == NULL || self->ranges->len == 0)
|
if (self == NULL || self->ranges->len == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -231,15 +231,15 @@ sp_visualizer_selection_contains (SpVisualizerSelection *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpVisualizerSelection *
|
SpSelection *
|
||||||
sp_visualizer_selection_copy (const SpVisualizerSelection *self)
|
sp_selection_copy (const SpSelection *self)
|
||||||
{
|
{
|
||||||
SpVisualizerSelection *copy;
|
SpSelection *copy;
|
||||||
|
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
copy = g_object_new (SP_TYPE_VISUALIZER_SELECTION, NULL);
|
copy = g_object_new (SP_TYPE_SELECTION, NULL);
|
||||||
|
|
||||||
for (guint i = 0; i < self->ranges->len; i++)
|
for (guint i = 0; i < self->ranges->len; i++)
|
||||||
{
|
{
|
||||||
52
lib/sp-selection.h
Normal file
52
lib/sp-selection.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* sp-selection.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Christian Hergert <chergert@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SP_SELECTION_H
|
||||||
|
#define SP_SELECTION_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SP_TYPE_SELECTION (sp_selection_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (SpSelection, sp_selection, SP, SELECTION, GObject)
|
||||||
|
|
||||||
|
typedef void (*SpSelectionForeachFunc) (SpSelection *self,
|
||||||
|
gint64 begin_time,
|
||||||
|
gint64 end_time,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
gboolean sp_selection_get_has_selection (SpSelection *self);
|
||||||
|
gboolean sp_selection_contains (SpSelection *self,
|
||||||
|
gint64 time_at);
|
||||||
|
void sp_selection_select_range (SpSelection *self,
|
||||||
|
gint64 begin_time,
|
||||||
|
gint64 end_time);
|
||||||
|
void sp_selection_unselect_range (SpSelection *self,
|
||||||
|
gint64 begin,
|
||||||
|
gint64 end);
|
||||||
|
void sp_selection_unselect_all (SpSelection *self);
|
||||||
|
void sp_selection_foreach (SpSelection *self,
|
||||||
|
SpSelectionForeachFunc foreach_func,
|
||||||
|
gpointer user_data);
|
||||||
|
SpSelection *sp_selection_copy (const SpSelection *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* SP_SELECTION_H */
|
||||||
@ -1,53 +0,0 @@
|
|||||||
/* sp-visualizer-selection.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Christian Hergert <chergert@redhat.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SP_VISUALIZER_SELECTION_H
|
|
||||||
#define SP_VISUALIZER_SELECTION_H
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define SP_TYPE_VISUALIZER_SELECTION (sp_visualizer_selection_get_type())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (SpVisualizerSelection, sp_visualizer_selection, SP, VISUALIZER_SELECTION, GObject)
|
|
||||||
|
|
||||||
typedef void (*SpVisualizerSelectionForeachFunc) (SpVisualizerSelection *self,
|
|
||||||
gint64 begin_time,
|
|
||||||
gint64 end_time,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
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,
|
|
||||||
gint64 begin_time,
|
|
||||||
gint64 end_time);
|
|
||||||
void sp_visualizer_selection_unselect_range (SpVisualizerSelection *self,
|
|
||||||
gint64 begin,
|
|
||||||
gint64 end);
|
|
||||||
void sp_visualizer_selection_unselect_all (SpVisualizerSelection *self);
|
|
||||||
void sp_visualizer_selection_foreach (SpVisualizerSelection *self,
|
|
||||||
SpVisualizerSelectionForeachFunc foreach_func,
|
|
||||||
gpointer user_data);
|
|
||||||
SpVisualizerSelection *
|
|
||||||
sp_visualizer_selection_copy (const SpVisualizerSelection *self);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* SP_VISUALIZER_SELECTION_H */
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#include "sp-visualizer-list.h"
|
#include "sp-visualizer-list.h"
|
||||||
#include "sp-visualizer-row.h"
|
#include "sp-visualizer-row.h"
|
||||||
#include "sp-visualizer-row-private.h"
|
#include "sp-visualizer-row-private.h"
|
||||||
#include "sp-visualizer-selection.h"
|
#include "sp-selection.h"
|
||||||
#include "sp-visualizer-ticks.h"
|
#include "sp-visualizer-ticks.h"
|
||||||
#include "sp-visualizer-view.h"
|
#include "sp-visualizer-view.h"
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
SpCaptureReader *reader;
|
SpCaptureReader *reader;
|
||||||
SpZoomManager *zoom_manager;
|
SpZoomManager *zoom_manager;
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
|
|
||||||
SpVisualizerList *list;
|
SpVisualizerList *list;
|
||||||
GtkScrolledWindow *scroller;
|
GtkScrolledWindow *scroller;
|
||||||
@ -237,7 +237,7 @@ sp_visualizer_view_size_allocate (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_selection_cb (SpVisualizerSelection *selection,
|
draw_selection_cb (SpSelection *selection,
|
||||||
gint64 range_begin,
|
gint64 range_begin,
|
||||||
gint64 range_end,
|
gint64 range_end,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@ -245,7 +245,7 @@ draw_selection_cb (SpVisualizerSelection *selection,
|
|||||||
SelectionDraw *draw = user_data;
|
SelectionDraw *draw = user_data;
|
||||||
GdkRectangle area;
|
GdkRectangle area;
|
||||||
|
|
||||||
g_assert (SP_IS_VISUALIZER_SELECTION (selection));
|
g_assert (SP_IS_SELECTION (selection));
|
||||||
g_assert (draw != NULL);
|
g_assert (draw != NULL);
|
||||||
g_assert (draw->cr != NULL);
|
g_assert (draw->cr != NULL);
|
||||||
g_assert (SP_IS_VISUALIZER_VIEW (draw->self));
|
g_assert (SP_IS_VISUALIZER_VIEW (draw->self));
|
||||||
@ -284,10 +284,10 @@ sp_visualizer_view_draw (GtkWidget *widget,
|
|||||||
|
|
||||||
ret = GTK_WIDGET_CLASS (sp_visualizer_view_parent_class)->draw (widget, cr);
|
ret = GTK_WIDGET_CLASS (sp_visualizer_view_parent_class)->draw (widget, cr);
|
||||||
|
|
||||||
if (sp_visualizer_selection_get_has_selection (priv->selection) || priv->button_pressed)
|
if (sp_selection_get_has_selection (priv->selection) || priv->button_pressed)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_class (draw.style_context, "selection");
|
gtk_style_context_add_class (draw.style_context, "selection");
|
||||||
sp_visualizer_selection_foreach (priv->selection, draw_selection_cb, &draw);
|
sp_selection_foreach (priv->selection, draw_selection_cb, &draw);
|
||||||
if (priv->button_pressed)
|
if (priv->button_pressed)
|
||||||
draw_selection_cb (priv->selection, priv->drag_begin_at, priv->drag_selection_at, &draw);
|
draw_selection_cb (priv->selection, priv->drag_begin_at, priv->drag_selection_at, &draw);
|
||||||
gtk_style_context_remove_class (draw.style_context, "selection");
|
gtk_style_context_remove_class (draw.style_context, "selection");
|
||||||
@ -312,16 +312,16 @@ sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
|
|||||||
|
|
||||||
if (ev->button != GDK_BUTTON_PRIMARY)
|
if (ev->button != GDK_BUTTON_PRIMARY)
|
||||||
{
|
{
|
||||||
if (sp_visualizer_selection_get_has_selection (priv->selection))
|
if (sp_selection_get_has_selection (priv->selection))
|
||||||
{
|
{
|
||||||
sp_visualizer_selection_unselect_all (priv->selection);
|
sp_selection_unselect_all (priv->selection);
|
||||||
return GDK_EVENT_STOP;
|
return GDK_EVENT_STOP;
|
||||||
}
|
}
|
||||||
return GDK_EVENT_PROPAGATE;
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ev->state & GDK_SHIFT_MASK) == 0)
|
if ((ev->state & GDK_SHIFT_MASK) == 0)
|
||||||
sp_visualizer_selection_unselect_all (priv->selection);
|
sp_selection_unselect_all (priv->selection);
|
||||||
|
|
||||||
priv->button_pressed = TRUE;
|
priv->button_pressed = TRUE;
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ sp_visualizer_view_list_button_release_event (SpVisualizerView *self,
|
|||||||
|
|
||||||
if (priv->drag_begin_at != priv->drag_selection_at)
|
if (priv->drag_begin_at != priv->drag_selection_at)
|
||||||
{
|
{
|
||||||
sp_visualizer_selection_select_range (priv->selection,
|
sp_selection_select_range (priv->selection,
|
||||||
priv->drag_begin_at,
|
priv->drag_begin_at,
|
||||||
priv->drag_selection_at);
|
priv->drag_selection_at);
|
||||||
priv->drag_begin_at = -1;
|
priv->drag_begin_at = -1;
|
||||||
@ -404,10 +404,10 @@ sp_visualizer_view_list_realize_after (SpVisualizerView *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
sp_visualizer_view_selection_changed (SpVisualizerView *self,
|
sp_visualizer_view_selection_changed (SpVisualizerView *self,
|
||||||
SpVisualizerSelection *selection)
|
SpSelection *selection)
|
||||||
{
|
{
|
||||||
g_assert (SP_IS_VISUALIZER_VIEW (self));
|
g_assert (SP_IS_VISUALIZER_VIEW (self));
|
||||||
g_assert (SP_IS_VISUALIZER_SELECTION (selection));
|
g_assert (SP_IS_SELECTION (selection));
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ sp_visualizer_view_init (SpVisualizerView *self)
|
|||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
priv->selection = g_object_new (SP_TYPE_VISUALIZER_SELECTION, NULL);
|
priv->selection = g_object_new (SP_TYPE_SELECTION, NULL);
|
||||||
|
|
||||||
g_signal_connect_object (priv->selection,
|
g_signal_connect_object (priv->selection,
|
||||||
"changed",
|
"changed",
|
||||||
@ -634,7 +634,7 @@ sp_visualizer_view_set_reader (SpVisualizerView *self,
|
|||||||
sp_visualizer_ticks_set_epoch (priv->ticks, begin_time);
|
sp_visualizer_ticks_set_epoch (priv->ticks, begin_time);
|
||||||
sp_visualizer_ticks_set_time_range (priv->ticks, begin_time, begin_time);
|
sp_visualizer_ticks_set_time_range (priv->ticks, begin_time, begin_time);
|
||||||
|
|
||||||
sp_visualizer_selection_unselect_all (priv->selection);
|
sp_selection_unselect_all (priv->selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
sp_visualizer_list_set_reader (priv->list, reader);
|
sp_visualizer_list_set_reader (priv->list, reader);
|
||||||
@ -738,12 +738,12 @@ sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
|
|||||||
/**
|
/**
|
||||||
* sp_visualizer_view_get_selection:
|
* sp_visualizer_view_get_selection:
|
||||||
*
|
*
|
||||||
* Gets the #SpVisualizerSelection instance for the visualizer view.
|
* Gets the #SpSelection instance for the visualizer view.
|
||||||
* This can be used to alter the selection or selections of the visualizers.
|
* This can be used to alter the selection or selections of the visualizers.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): An #SpVisualizerSelection.
|
* Returns: (transfer none): An #SpSelection.
|
||||||
*/
|
*/
|
||||||
SpVisualizerSelection *
|
SpSelection *
|
||||||
sp_visualizer_view_get_selection (SpVisualizerView *self)
|
sp_visualizer_view_get_selection (SpVisualizerView *self)
|
||||||
{
|
{
|
||||||
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
|
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "sp-visualizer-row.h"
|
#include "sp-visualizer-row.h"
|
||||||
#include "sp-visualizer-selection.h"
|
#include "sp-selection.h"
|
||||||
#include "sp-zoom-manager.h"
|
#include "sp-zoom-manager.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -58,14 +58,14 @@ struct _SpVisualizerViewClass
|
|||||||
gpointer _reserved16;
|
gpointer _reserved16;
|
||||||
};
|
};
|
||||||
|
|
||||||
GtkWidget *sp_visualizer_view_new (void);
|
GtkWidget *sp_visualizer_view_new (void);
|
||||||
SpCaptureReader *sp_visualizer_view_get_reader (SpVisualizerView *self);
|
SpCaptureReader *sp_visualizer_view_get_reader (SpVisualizerView *self);
|
||||||
void sp_visualizer_view_set_reader (SpVisualizerView *self,
|
void sp_visualizer_view_set_reader (SpVisualizerView *self,
|
||||||
SpCaptureReader *reader);
|
SpCaptureReader *reader);
|
||||||
SpZoomManager *sp_visualizer_view_get_zoom_manager (SpVisualizerView *self);
|
SpZoomManager *sp_visualizer_view_get_zoom_manager (SpVisualizerView *self);
|
||||||
void sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
|
void sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
|
||||||
SpZoomManager *zoom_manager);
|
SpZoomManager *zoom_manager);
|
||||||
SpVisualizerSelection *sp_visualizer_view_get_selection (SpVisualizerView *self);
|
SpSelection *sp_visualizer_view_get_selection (SpVisualizerView *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@ -44,9 +44,9 @@ G_BEGIN_DECLS
|
|||||||
# include "sp-proc-source.h"
|
# include "sp-proc-source.h"
|
||||||
# include "sp-profile.h"
|
# include "sp-profile.h"
|
||||||
# include "sp-profiler.h"
|
# include "sp-profiler.h"
|
||||||
|
# include "sp-selection.h"
|
||||||
# include "sp-source.h"
|
# include "sp-source.h"
|
||||||
# include "sp-symbol-resolver.h"
|
# include "sp-symbol-resolver.h"
|
||||||
# include "sp-visualizer-selection.h"
|
|
||||||
# include "sysprof-version.h"
|
# include "sysprof-version.h"
|
||||||
#undef SYSPROF_INSIDE
|
#undef SYSPROF_INSIDE
|
||||||
|
|
||||||
|
|||||||
@ -238,7 +238,7 @@ static void
|
|||||||
sp_window_build_profile (SpWindow *self)
|
sp_window_build_profile (SpWindow *self)
|
||||||
{
|
{
|
||||||
g_autoptr(SpProfile) profile = NULL;
|
g_autoptr(SpProfile) profile = NULL;
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
|
|
||||||
g_assert (SP_IS_WINDOW (self));
|
g_assert (SP_IS_WINDOW (self));
|
||||||
g_assert (self->reader != NULL);
|
g_assert (self->reader != NULL);
|
||||||
@ -737,10 +737,10 @@ zoom_level_to_string (GBinding *binding,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
sp_window_visualizers_selection_changed (SpWindow *self,
|
sp_window_visualizers_selection_changed (SpWindow *self,
|
||||||
SpVisualizerSelection *selection)
|
SpSelection *selection)
|
||||||
{
|
{
|
||||||
g_assert (SP_IS_WINDOW (self));
|
g_assert (SP_IS_WINDOW (self));
|
||||||
g_assert (SP_IS_VISUALIZER_SELECTION (selection));
|
g_assert (SP_IS_SELECTION (selection));
|
||||||
|
|
||||||
sp_window_build_profile (self);
|
sp_window_build_profile (self);
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ sp_window_init (SpWindow *self)
|
|||||||
{ "save-capture", sp_window_save_capture },
|
{ "save-capture", sp_window_save_capture },
|
||||||
{ "screenshot", sp_window_screenshot },
|
{ "screenshot", sp_window_screenshot },
|
||||||
};
|
};
|
||||||
SpVisualizerSelection *selection;
|
SpSelection *selection;
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user