diff --git a/lib/Makefile.am b/lib/Makefile.am index ce7c4e91..24191540 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -66,9 +66,9 @@ headers_DATA = \ sp-proc-source.h \ sp-profile.h \ sp-profiler.h \ + sp-selection.h \ sp-source.h \ sp-symbol-resolver.h \ - sp-visualizer-selection.h \ $(NULL) libsysprof_@API_VERSION@_la_SOURCES = \ @@ -100,9 +100,9 @@ libsysprof_@API_VERSION@_la_SOURCES = \ sp-proc-source.c \ sp-profile.c \ sp-profiler.c \ + sp-selection.c \ sp-source.c \ sp-symbol-resolver.c \ - sp-visualizer-selection.c \ $(NULL) libsysprof_@API_VERSION@_la_CFLAGS = \ diff --git a/lib/sp-callgraph-profile.c b/lib/sp-callgraph-profile.c index e2208d1c..57b09394 100644 --- a/lib/sp-callgraph-profile.c +++ b/lib/sp-callgraph-profile.c @@ -46,7 +46,7 @@ #include "sp-jitmap-symbol-resolver.h" #include "sp-map-lookaside.h" #include "sp-kernel-symbol-resolver.h" -#include "sp-visualizer-selection.h" +#include "sp-selection.h" #include "stackstash.h" @@ -57,7 +57,7 @@ struct _SpCallgraphProfile GObject parent_instance; SpCaptureReader *reader; - SpVisualizerSelection *selection; + SpSelection *selection; StackStash *stash; GStringChunk *symbols; GHashTable *tags; @@ -66,7 +66,7 @@ struct _SpCallgraphProfile typedef struct { SpCaptureReader *reader; - SpVisualizerSelection *selection; + SpSelection *selection; } Generate; static void profile_iface_init (SpProfileInterface *iface); @@ -89,7 +89,7 @@ sp_callgraph_profile_new (void) } 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, "selection", selection, @@ -161,7 +161,7 @@ sp_callgraph_profile_class_init (SpCallgraphProfileClass *klass) g_param_spec_object ("selection", "Selection", "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_object_class_install_properties (object_class, N_PROPS, properties); @@ -220,7 +220,7 @@ sp_callgraph_profile_generate_worker (GTask *task, SpCallgraphProfile *self = source_object; Generate *gen = task_data; SpCaptureReader *reader; - SpVisualizerSelection *selection; + SpSelection *selection; g_autoptr(GArray) resolved = NULL; g_autoptr(GHashTable) maps_by_pid = 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))) goto failure; - if (!sp_visualizer_selection_contains (selection, sample->frame.time)) + if (!sp_selection_contains (selection, sample->frame.time)) continue; 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->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); g_task_set_task_data (task, gen, (GDestroyNotify)generate_free); diff --git a/lib/sp-callgraph-profile.h b/lib/sp-callgraph-profile.h index 1f789b4e..e034748f 100644 --- a/lib/sp-callgraph-profile.h +++ b/lib/sp-callgraph-profile.h @@ -20,7 +20,7 @@ #define SP_CALLGRAPH_PROFILE_H #include "sp-profile.h" -#include "sp-visualizer-selection.h" +#include "sp-selection.h" G_BEGIN_DECLS @@ -29,9 +29,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (SpCallgraphProfile, sp_callgraph_profile, SP, CALLGRAPH_PROFILE, GObject) SpProfile *sp_callgraph_profile_new (void); -SpProfile *sp_callgraph_profile_new_with_selection (SpVisualizerSelection *selection); -GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self, - const gchar *symbol); +SpProfile *sp_callgraph_profile_new_with_selection (SpSelection *selection); +GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self, + const gchar *symbol); G_END_DECLS diff --git a/lib/sp-visualizer-selection.c b/lib/sp-selection.c similarity index 62% rename from lib/sp-visualizer-selection.c rename to lib/sp-selection.c index d0c83d13..56422bf2 100644 --- a/lib/sp-visualizer-selection.c +++ b/lib/sp-selection.c @@ -1,4 +1,4 @@ -/* sp-visualizer-selection.c +/* sp-selection.c * * Copyright (C) 2016 Christian Hergert * @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -#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; GArray *ranges; @@ -32,7 +32,7 @@ typedef struct gint64 end; } Range; -G_DEFINE_TYPE (SpVisualizerSelection, sp_visualizer_selection, G_TYPE_OBJECT) +G_DEFINE_TYPE (SpSelection, sp_selection, G_TYPE_OBJECT) enum { PROP_0, @@ -61,27 +61,27 @@ int64_swap (gint64 *a, } 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_OBJECT_CLASS (sp_visualizer_selection_parent_class)->finalize (object); + G_OBJECT_CLASS (sp_selection_parent_class)->finalize (object); } static void -sp_visualizer_selection_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +sp_selection_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - SpVisualizerSelection *self = SP_VISUALIZER_SELECTION (object); + SpSelection *self = SP_SELECTION (object); switch (prop_id) { 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; default: @@ -90,12 +90,12 @@ sp_visualizer_selection_get_property (GObject *object, } static void -sp_visualizer_selection_class_init (SpVisualizerSelectionClass *klass) +sp_selection_class_init (SpSelectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = sp_visualizer_selection_finalize; - object_class->get_property = sp_visualizer_selection_get_property; + object_class->finalize = sp_selection_finalize; + object_class->get_property = sp_selection_get_property; properties [PROP_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); /** - * SpVisualizerSelection::changed: + * SpSelection::changed: * * This signal is emitted when the selection has changed. */ @@ -119,33 +119,33 @@ sp_visualizer_selection_class_init (SpVisualizerSelectionClass *klass) } static void -sp_visualizer_selection_init (SpVisualizerSelection *self) +sp_selection_init (SpSelection *self) { self->ranges = g_array_new (FALSE, FALSE, sizeof (Range)); } 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; } /** - * sp_visualizer_selection_foreach: - * @self: A #SpVisualizerSelection + * sp_selection_foreach: + * @self: A #SpSelection * @foreach_func: (scope call): a callback for each range * @user_data: user data for @foreach_func * * Calls @foreach_func for every selected range. */ void -sp_visualizer_selection_foreach (SpVisualizerSelection *self, - SpVisualizerSelectionForeachFunc foreach_func, - gpointer user_data) +sp_selection_foreach (SpSelection *self, + SpSelectionForeachFunc foreach_func, + 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); for (guint i = 0; i < self->ranges->len; i++) @@ -156,13 +156,13 @@ sp_visualizer_selection_foreach (SpVisualizerSelection *self, } void -sp_visualizer_selection_select_range (SpVisualizerSelection *self, - gint64 begin_time, - gint64 end_time) +sp_selection_select_range (SpSelection *self, + gint64 begin_time, + gint64 end_time) { 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); @@ -177,11 +177,11 @@ sp_visualizer_selection_select_range (SpVisualizerSelection *self, } void -sp_visualizer_selection_unselect_range (SpVisualizerSelection *self, - gint64 begin, - gint64 end) +sp_selection_unselect_range (SpSelection *self, + gint64 begin, + gint64 end) { - g_return_if_fail (SP_IS_VISUALIZER_SELECTION (self)); + g_return_if_fail (SP_IS_SELECTION (self)); int64_swap (&begin, &end); @@ -201,9 +201,9 @@ sp_visualizer_selection_unselect_range (SpVisualizerSelection *self, } 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) { @@ -214,8 +214,8 @@ sp_visualizer_selection_unselect_all (SpVisualizerSelection *self) } gboolean -sp_visualizer_selection_contains (SpVisualizerSelection *self, - gint64 time_at) +sp_selection_contains (SpSelection *self, + gint64 time_at) { if (self == NULL || self->ranges->len == 0) return TRUE; @@ -231,15 +231,15 @@ sp_visualizer_selection_contains (SpVisualizerSelection *self, return FALSE; } -SpVisualizerSelection * -sp_visualizer_selection_copy (const SpVisualizerSelection *self) +SpSelection * +sp_selection_copy (const SpSelection *self) { - SpVisualizerSelection *copy; + SpSelection *copy; if (self == 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++) { diff --git a/lib/sp-selection.h b/lib/sp-selection.h new file mode 100644 index 00000000..c261e3b0 --- /dev/null +++ b/lib/sp-selection.h @@ -0,0 +1,52 @@ +/* sp-selection.h + * + * Copyright (C) 2016 Christian Hergert + * + * 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 . + */ + +#ifndef SP_SELECTION_H +#define SP_SELECTION_H + +#include + +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 */ diff --git a/lib/sp-visualizer-selection.h b/lib/sp-visualizer-selection.h deleted file mode 100644 index 56be994f..00000000 --- a/lib/sp-visualizer-selection.h +++ /dev/null @@ -1,53 +0,0 @@ -/* sp-visualizer-selection.h - * - * Copyright (C) 2016 Christian Hergert - * - * 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 . - */ - -#ifndef SP_VISUALIZER_SELECTION_H -#define SP_VISUALIZER_SELECTION_H - -#include - -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 */ diff --git a/lib/sp-visualizer-view.c b/lib/sp-visualizer-view.c index 98f70091..4175fe6a 100644 --- a/lib/sp-visualizer-view.c +++ b/lib/sp-visualizer-view.c @@ -24,7 +24,7 @@ #include "sp-visualizer-list.h" #include "sp-visualizer-row.h" #include "sp-visualizer-row-private.h" -#include "sp-visualizer-selection.h" +#include "sp-selection.h" #include "sp-visualizer-ticks.h" #include "sp-visualizer-view.h" @@ -35,7 +35,7 @@ typedef struct { SpCaptureReader *reader; SpZoomManager *zoom_manager; - SpVisualizerSelection *selection; + SpSelection *selection; SpVisualizerList *list; GtkScrolledWindow *scroller; @@ -237,7 +237,7 @@ sp_visualizer_view_size_allocate (GtkWidget *widget, } static void -draw_selection_cb (SpVisualizerSelection *selection, +draw_selection_cb (SpSelection *selection, gint64 range_begin, gint64 range_end, gpointer user_data) @@ -245,7 +245,7 @@ draw_selection_cb (SpVisualizerSelection *selection, SelectionDraw *draw = user_data; GdkRectangle area; - g_assert (SP_IS_VISUALIZER_SELECTION (selection)); + g_assert (SP_IS_SELECTION (selection)); g_assert (draw != NULL); g_assert (draw->cr != NULL); 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); - 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"); - sp_visualizer_selection_foreach (priv->selection, draw_selection_cb, &draw); + sp_selection_foreach (priv->selection, draw_selection_cb, &draw); if (priv->button_pressed) draw_selection_cb (priv->selection, priv->drag_begin_at, priv->drag_selection_at, &draw); 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 (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_PROPAGATE; } if ((ev->state & GDK_SHIFT_MASK) == 0) - sp_visualizer_selection_unselect_all (priv->selection); + sp_selection_unselect_all (priv->selection); 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) { - sp_visualizer_selection_select_range (priv->selection, + sp_selection_select_range (priv->selection, priv->drag_begin_at, priv->drag_selection_at); priv->drag_begin_at = -1; @@ -404,10 +404,10 @@ sp_visualizer_view_list_realize_after (SpVisualizerView *self, static void sp_visualizer_view_selection_changed (SpVisualizerView *self, - SpVisualizerSelection *selection) + SpSelection *selection) { 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)); } @@ -543,7 +543,7 @@ sp_visualizer_view_init (SpVisualizerView *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, "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_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); @@ -738,12 +738,12 @@ sp_visualizer_view_set_zoom_manager (SpVisualizerView *self, /** * 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. * - * Returns: (transfer none): An #SpVisualizerSelection. + * Returns: (transfer none): An #SpSelection. */ -SpVisualizerSelection * +SpSelection * sp_visualizer_view_get_selection (SpVisualizerView *self) { SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self); diff --git a/lib/sp-visualizer-view.h b/lib/sp-visualizer-view.h index 7d856335..a809ed4d 100644 --- a/lib/sp-visualizer-view.h +++ b/lib/sp-visualizer-view.h @@ -22,7 +22,7 @@ #include #include "sp-visualizer-row.h" -#include "sp-visualizer-selection.h" +#include "sp-selection.h" #include "sp-zoom-manager.h" G_BEGIN_DECLS @@ -58,14 +58,14 @@ struct _SpVisualizerViewClass gpointer _reserved16; }; -GtkWidget *sp_visualizer_view_new (void); -SpCaptureReader *sp_visualizer_view_get_reader (SpVisualizerView *self); -void sp_visualizer_view_set_reader (SpVisualizerView *self, - SpCaptureReader *reader); -SpZoomManager *sp_visualizer_view_get_zoom_manager (SpVisualizerView *self); -void sp_visualizer_view_set_zoom_manager (SpVisualizerView *self, - SpZoomManager *zoom_manager); -SpVisualizerSelection *sp_visualizer_view_get_selection (SpVisualizerView *self); +GtkWidget *sp_visualizer_view_new (void); +SpCaptureReader *sp_visualizer_view_get_reader (SpVisualizerView *self); +void sp_visualizer_view_set_reader (SpVisualizerView *self, + SpCaptureReader *reader); +SpZoomManager *sp_visualizer_view_get_zoom_manager (SpVisualizerView *self); +void sp_visualizer_view_set_zoom_manager (SpVisualizerView *self, + SpZoomManager *zoom_manager); +SpSelection *sp_visualizer_view_get_selection (SpVisualizerView *self); G_END_DECLS diff --git a/lib/sysprof.h b/lib/sysprof.h index 86572a96..22aed205 100644 --- a/lib/sysprof.h +++ b/lib/sysprof.h @@ -44,9 +44,9 @@ G_BEGIN_DECLS # include "sp-proc-source.h" # include "sp-profile.h" # include "sp-profiler.h" +# include "sp-selection.h" # include "sp-source.h" # include "sp-symbol-resolver.h" -# include "sp-visualizer-selection.h" # include "sysprof-version.h" #undef SYSPROF_INSIDE diff --git a/src/sp-window.c b/src/sp-window.c index b78db829..597eaaf2 100644 --- a/src/sp-window.c +++ b/src/sp-window.c @@ -238,7 +238,7 @@ static void sp_window_build_profile (SpWindow *self) { g_autoptr(SpProfile) profile = NULL; - SpVisualizerSelection *selection; + SpSelection *selection; g_assert (SP_IS_WINDOW (self)); g_assert (self->reader != NULL); @@ -737,10 +737,10 @@ zoom_level_to_string (GBinding *binding, static void sp_window_visualizers_selection_changed (SpWindow *self, - SpVisualizerSelection *selection) + SpSelection *selection) { g_assert (SP_IS_WINDOW (self)); - g_assert (SP_IS_VISUALIZER_SELECTION (selection)); + g_assert (SP_IS_SELECTION (selection)); sp_window_build_profile (self); } @@ -836,7 +836,7 @@ sp_window_init (SpWindow *self) { "save-capture", sp_window_save_capture }, { "screenshot", sp_window_screenshot }, }; - SpVisualizerSelection *selection; + SpSelection *selection; gtk_widget_init_template (GTK_WIDGET (self));