[gnome-builder: 125/139] sysprof: port to libide-gui
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 125/139] sysprof: port to libide-gui
- Date: Thu, 10 Jan 2019 04:27:49 +0000 (UTC)
commit 57dd778cb00c94ee8443a54ebfdf6bc1218845e0
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:39:36 2019 -0800
sysprof: port to libide-gui
...sysprof-perspective.c => gbp-sysprof-surface.c} | 127 ++++-------
...sysprof-perspective.h => gbp-sysprof-surface.h} | 20 +-
...sprof-perspective.ui => gbp-sysprof-surface.ui} | 2 +-
...bench-addin.c => gbp-sysprof-workspace-addin.c} | 243 +++++++++++----------
...bench-addin.h => gbp-sysprof-workspace-addin.h} | 8 +-
src/plugins/sysprof/gtk/menus.ui | 20 +-
src/plugins/sysprof/meson.build | 35 ++-
.../{gbp-sysprof-plugin.c => sysprof-plugin.c} | 18 +-
src/plugins/sysprof/sysprof.gresource.xml | 6 +-
src/plugins/sysprof/sysprof.plugin | 12 +-
10 files changed, 248 insertions(+), 243 deletions(-)
---
diff --git a/src/plugins/sysprof/gbp-sysprof-perspective.c b/src/plugins/sysprof/gbp-sysprof-surface.c
similarity index 64%
rename from src/plugins/sysprof/gbp-sysprof-perspective.c
rename to src/plugins/sysprof/gbp-sysprof-surface.c
index 56f1ff208..4f7da1d28 100644
--- a/src/plugins/sysprof/gbp-sysprof-perspective.c
+++ b/src/plugins/sysprof/gbp-sysprof-surface.c
@@ -1,4 +1,4 @@
-/* gbp-sysprof-perspective.c
+/* gbp-sysprof-surface.c
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -18,17 +18,17 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-sysprof-perspective"
+#define G_LOG_DOMAIN "gbp-sysprof-surface"
#include <glib/gi18n.h>
#include <sysprof.h>
#include <sysprof-ui.h>
-#include "gbp-sysprof-perspective.h"
+#include "gbp-sysprof-surface.h"
-struct _GbpSysprofPerspective
+struct _GbpSysprofSurface
{
- GtkBin parent_instance;
+ IdeSurface parent_instance;
SpCaptureReader *reader;
@@ -42,58 +42,56 @@ struct _GbpSysprofPerspective
SpZoomManager *zoom_manager;
};
-static void perspective_iface_init (IdePerspectiveInterface *iface);
-static void gbp_sysprof_perspective_reload (GbpSysprofPerspective *self);
+static void gbp_sysprof_surface_reload (GbpSysprofSurface *self);
-G_DEFINE_TYPE_EXTENDED (GbpSysprofPerspective, gbp_sysprof_perspective, GTK_TYPE_BIN, 0,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, perspective_iface_init))
+G_DEFINE_TYPE (GbpSysprofSurface, gbp_sysprof_surface, IDE_TYPE_SURFACE)
static void
-hide_info_bar (GbpSysprofPerspective *self,
+hide_info_bar (GbpSysprofSurface *self,
GtkButton *button)
{
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
gtk_revealer_set_reveal_child (self->info_bar_revealer, FALSE);
}
static void
-gbp_sysprof_perspective_selection_changed (GbpSysprofPerspective *self,
+gbp_sysprof_surface_selection_changed (GbpSysprofSurface *self,
SpSelection *selection)
{
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
g_assert (SP_IS_SELECTION (selection));
- gbp_sysprof_perspective_reload (self);
+ gbp_sysprof_surface_reload (self);
}
static void
-gbp_sysprof_perspective_finalize (GObject *object)
+gbp_sysprof_surface_finalize (GObject *object)
{
- GbpSysprofPerspective *self = (GbpSysprofPerspective *)object;
+ GbpSysprofSurface *self = (GbpSysprofSurface *)object;
g_clear_pointer (&self->reader, sp_capture_reader_unref);
- G_OBJECT_CLASS (gbp_sysprof_perspective_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gbp_sysprof_surface_parent_class)->finalize (object);
}
static void
-gbp_sysprof_perspective_class_init (GbpSysprofPerspectiveClass *klass)
+gbp_sysprof_surface_class_init (GbpSysprofSurfaceClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gbp_sysprof_perspective_finalize;
+ object_class->finalize = gbp_sysprof_surface_finalize;
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/sysprof-plugin/gbp-sysprof-perspective.ui");
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, callgraph_view);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_label);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_close);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_revealer);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, stack);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, recording_view);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, visualizers);
- gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, zoom_manager);
+ gtk_widget_class_set_template_from_resource (widget_class, "/plugins/sysprof/gbp-sysprof-surface.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, callgraph_view);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, info_bar_label);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, info_bar_close);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, info_bar_revealer);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, stack);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, recording_view);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, visualizers);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofSurface, zoom_manager);
g_type_ensure (SP_TYPE_CALLGRAPH_VIEW);
g_type_ensure (SP_TYPE_CPU_VISUALIZER_ROW);
@@ -104,12 +102,16 @@ gbp_sysprof_perspective_class_init (GbpSysprofPerspectiveClass *klass)
}
static void
-gbp_sysprof_perspective_init (GbpSysprofPerspective *self)
+gbp_sysprof_surface_init (GbpSysprofSurface *self)
{
SpSelection *selection;
gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_widget_set_name (GTK_WIDGET (self), "profiler");
+ ide_surface_set_icon_name (IDE_SURFACE (self), "utilities-system-monitor-symbolic");
+ ide_surface_set_title (IDE_SURFACE (self), _("Profiler"));
+
g_signal_connect_object (self->info_bar_close,
"clicked",
G_CALLBACK (hide_info_bar),
@@ -120,55 +122,22 @@ gbp_sysprof_perspective_init (GbpSysprofPerspective *self)
g_signal_connect_object (selection,
"changed",
- G_CALLBACK (gbp_sysprof_perspective_selection_changed),
+ G_CALLBACK (gbp_sysprof_surface_selection_changed),
self,
G_CONNECT_SWAPPED);
}
-static gchar *
-gbp_sysprof_perspective_get_icon_name (IdePerspective *perspective)
-{
- return g_strdup ("utilities-system-monitor-symbolic");
-}
-
-static gchar *
-gbp_sysprof_perspective_get_title (IdePerspective *perspective)
-{
- return g_strdup (_("Profiler"));
-}
-
-static gchar *
-gbp_sysprof_perspective_get_id (IdePerspective *perspective)
-{
- return g_strdup ("profiler");
-}
-
-static gchar *
-gbp_sysprof_perspective_get_accelerator (IdePerspective *perspective)
-{
- return g_strdup ("<Alt>3");
-}
-
-static void
-perspective_iface_init (IdePerspectiveInterface *iface)
-{
- iface->get_icon_name = gbp_sysprof_perspective_get_icon_name;
- iface->get_title = gbp_sysprof_perspective_get_title;
- iface->get_id = gbp_sysprof_perspective_get_id;
- iface->get_accelerator = gbp_sysprof_perspective_get_accelerator;
-}
-
static void
generate_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SpCallgraphProfile *profile = (SpCallgraphProfile *)object;
- g_autoptr(GbpSysprofPerspective) self = user_data;
+ g_autoptr(GbpSysprofSurface) self = user_data;
g_autoptr(GError) error = NULL;
g_assert (SP_IS_CALLGRAPH_PROFILE (profile));
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
if (!sp_profile_generate_finish (SP_PROFILE (profile), result, &error))
{
@@ -180,12 +149,12 @@ generate_cb (GObject *object,
}
static void
-gbp_sysprof_perspective_reload (GbpSysprofPerspective *self)
+gbp_sysprof_surface_reload (GbpSysprofSurface *self)
{
SpSelection *selection;
g_autoptr(SpProfile) profile = NULL;
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
if (self->reader == NULL)
return;
@@ -206,18 +175,18 @@ gbp_sysprof_perspective_reload (GbpSysprofPerspective *self)
}
SpCaptureReader *
-gbp_sysprof_perspective_get_reader (GbpSysprofPerspective *self)
+gbp_sysprof_surface_get_reader (GbpSysprofSurface *self)
{
- g_return_val_if_fail (GBP_IS_SYSPROF_PERSPECTIVE (self), NULL);
+ g_return_val_if_fail (GBP_IS_SYSPROF_SURFACE (self), NULL);
return sp_visualizer_view_get_reader (self->visualizers);
}
void
-gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
+gbp_sysprof_surface_set_reader (GbpSysprofSurface *self,
SpCaptureReader *reader)
{
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
if (reader != self->reader)
{
@@ -237,19 +206,19 @@ gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
if (reader != NULL)
{
self->reader = sp_capture_reader_ref (reader);
- gbp_sysprof_perspective_reload (self);
+ gbp_sysprof_surface_reload (self);
}
}
}
static void
-gbp_sysprof_perspective_profiler_failed (GbpSysprofPerspective *self,
+gbp_sysprof_surface_profiler_failed (GbpSysprofSurface *self,
const GError *error,
SpProfiler *profiler)
{
IDE_ENTRY;
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self));
g_assert (error != NULL);
g_assert (SP_IS_PROFILER (profiler));
@@ -262,10 +231,10 @@ gbp_sysprof_perspective_profiler_failed (GbpSysprofPerspective *self,
}
void
-gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
+gbp_sysprof_surface_set_profiler (GbpSysprofSurface *self,
SpProfiler *profiler)
{
- g_return_if_fail (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_return_if_fail (GBP_IS_SYSPROF_SURFACE (self));
g_return_if_fail (!profiler || SP_IS_PROFILER (profiler));
sp_recording_state_view_set_profiler (self->recording_view, profiler);
@@ -276,7 +245,7 @@ gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
g_signal_connect_object (profiler,
"failed",
- G_CALLBACK (gbp_sysprof_perspective_profiler_failed),
+ G_CALLBACK (gbp_sysprof_surface_profiler_failed),
self,
G_CONNECT_SWAPPED);
}
@@ -287,9 +256,9 @@ gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
}
SpZoomManager *
-gbp_sysprof_perspective_get_zoom_manager (GbpSysprofPerspective *self)
+gbp_sysprof_surface_get_zoom_manager (GbpSysprofSurface *self)
{
- g_return_val_if_fail (GBP_IS_SYSPROF_PERSPECTIVE (self), NULL);
+ g_return_val_if_fail (GBP_IS_SYSPROF_SURFACE (self), NULL);
return self->zoom_manager;
}
diff --git a/src/plugins/sysprof/gbp-sysprof-perspective.h b/src/plugins/sysprof/gbp-sysprof-surface.h
similarity index 52%
rename from src/plugins/sysprof/gbp-sysprof-perspective.h
rename to src/plugins/sysprof/gbp-sysprof-surface.h
index 3354c31ff..4ed48180a 100644
--- a/src/plugins/sysprof/gbp-sysprof-perspective.h
+++ b/src/plugins/sysprof/gbp-sysprof-surface.h
@@ -1,4 +1,4 @@
-/* gbp-sysprof-perspective.h
+/* gbp-sysprof-surface.h
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -20,20 +20,20 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
#include <sysprof-ui.h>
G_BEGIN_DECLS
-#define GBP_TYPE_SYSPROF_PERSPECTIVE (gbp_sysprof_perspective_get_type())
+#define GBP_TYPE_SYSPROF_SURFACE (gbp_sysprof_surface_get_type())
-G_DECLARE_FINAL_TYPE (GbpSysprofPerspective, gbp_sysprof_perspective, GBP, SYSPROF_PERSPECTIVE, GtkBin)
+G_DECLARE_FINAL_TYPE (GbpSysprofSurface, gbp_sysprof_surface, GBP, SYSPROF_SURFACE, IdeSurface)
-SpZoomManager *gbp_sysprof_perspective_get_zoom_manager (GbpSysprofPerspective *self);
-void gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
- SpProfiler *profiler);
-SpCaptureReader *gbp_sysprof_perspective_get_reader (GbpSysprofPerspective *self);
-void gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
- SpCaptureReader *reader);
+SpZoomManager *gbp_sysprof_surface_get_zoom_manager (GbpSysprofSurface *self);
+void gbp_sysprof_surface_set_profiler (GbpSysprofSurface *self,
+ SpProfiler *profiler);
+SpCaptureReader *gbp_sysprof_surface_get_reader (GbpSysprofSurface *self);
+void gbp_sysprof_surface_set_reader (GbpSysprofSurface *self,
+ SpCaptureReader *reader);
G_END_DECLS
diff --git a/src/plugins/sysprof/gbp-sysprof-perspective.ui b/src/plugins/sysprof/gbp-sysprof-surface.ui
similarity index 98%
rename from src/plugins/sysprof/gbp-sysprof-perspective.ui
rename to src/plugins/sysprof/gbp-sysprof-surface.ui
index 272081189..bc2fcbe5c 100644
--- a/src/plugins/sysprof/gbp-sysprof-perspective.ui
+++ b/src/plugins/sysprof/gbp-sysprof-surface.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="GbpSysprofPerspective" parent="GtkBin">
+ <template class="GbpSysprofSurface" parent="IdeSurface">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
diff --git a/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
b/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
similarity index 67%
rename from src/plugins/sysprof/gbp-sysprof-workbench-addin.c
rename to src/plugins/sysprof/gbp-sysprof-workspace-addin.c
index 614e6fb25..2266cb377 100644
--- a/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
+++ b/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
@@ -1,4 +1,4 @@
-/* gbp-sysprof-workbench-addin.c
+/* gbp-sysprof-workspace-addin.c
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -21,44 +21,49 @@
#include <glib/gi18n.h>
#include <sysprof.h>
-#include "gbp-sysprof-perspective.h"
-#include "gbp-sysprof-workbench-addin.h"
+#include "gbp-sysprof-surface.h"
+#include "gbp-sysprof-workspace-addin.h"
-struct _GbpSysprofWorkbenchAddin
+struct _GbpSysprofWorkspaceAddin
{
GObject parent_instance;
GSimpleActionGroup *actions;
SpProfiler *profiler;
- GbpSysprofPerspective *perspective;
- IdeWorkbench *workbench;
+ GbpSysprofSurface *surface;
+ IdeWorkspace *workspace;
GtkBox *zoom_controls;
};
-static void workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface);
+static void workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface);
-G_DEFINE_TYPE_EXTENDED (GbpSysprofWorkbenchAddin, gbp_sysprof_workbench_addin, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKBENCH_ADDIN, workbench_addin_iface_init))
+G_DEFINE_TYPE_WITH_CODE (GbpSysprofWorkspaceAddin, gbp_sysprof_workspace_addin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
static void
-gbp_sysprof_workbench_addin_update_controls (GbpSysprofWorkbenchAddin *self)
+gbp_sysprof_workspace_addin_update_controls (GbpSysprofWorkspaceAddin *self)
{
- IdePerspective *perspective;
+ IdeSurface *surface;
gboolean visible;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
- perspective = ide_workbench_get_visible_perspective (self->workbench);
- visible = GBP_IS_SYSPROF_PERSPECTIVE (perspective) &&
- !!gbp_sysprof_perspective_get_reader (GBP_SYSPROF_PERSPECTIVE (perspective));
+ if (self->workspace == NULL)
+ return;
+
+ surface = ide_workspace_get_visible_surface (self->workspace);
+ visible = GBP_IS_SYSPROF_SURFACE (surface) &&
+ !!gbp_sysprof_surface_get_reader (GBP_SYSPROF_SURFACE (surface));
- gtk_widget_set_visible (GTK_WIDGET (self->zoom_controls), visible);
+ if (self->zoom_controls)
+ gtk_widget_set_visible (GTK_WIDGET (self->zoom_controls), visible);
}
static void
-profiler_stopped (GbpSysprofWorkbenchAddin *self,
+profiler_stopped (GbpSysprofWorkspaceAddin *self,
SpProfiler *profiler)
{
g_autoptr(SpCaptureReader) reader = NULL;
@@ -67,13 +72,14 @@ profiler_stopped (GbpSysprofWorkbenchAddin *self,
IDE_ENTRY;
- g_return_if_fail (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
- g_return_if_fail (SP_IS_PROFILER (profiler));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
+ g_assert (SP_IS_PROFILER (profiler));
if (self->profiler != profiler)
IDE_EXIT;
- if (self->workbench == NULL)
+ if (self->workspace == NULL)
IDE_EXIT;
writer = sp_profiler_get_writer (profiler);
@@ -86,23 +92,24 @@ profiler_stopped (GbpSysprofWorkbenchAddin *self,
IDE_EXIT;
}
- gbp_sysprof_perspective_set_reader (self->perspective, reader);
+ gbp_sysprof_surface_set_reader (self->surface, reader);
- ide_workbench_set_visible_perspective_name (self->workbench, "profiler");
+ ide_workspace_set_visible_surface_name (self->workspace, "profiler");
- gbp_sysprof_workbench_addin_update_controls (self);
+ gbp_sysprof_workspace_addin_update_controls (self);
IDE_EXIT;
}
static void
-profiler_child_spawned (GbpSysprofWorkbenchAddin *self,
+profiler_child_spawned (GbpSysprofWorkspaceAddin *self,
const gchar *identifier,
IdeRunner *runner)
{
GPid pid = 0;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
g_assert (identifier != NULL);
g_assert (IDE_IS_RUNNER (runner));
@@ -133,9 +140,10 @@ get_runtime_sysroot (IdeContext *context,
IdeConfiguration *config;
IdeRuntime *runtime;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_CONTEXT (context));
- config_manager = ide_context_get_configuration_manager (context);
+ config_manager = ide_configuration_manager_from_context (context);
config = ide_configuration_manager_get_current (config_manager);
runtime = ide_configuration_get_runtime (config);
@@ -156,14 +164,15 @@ profiler_run_handler (IdeRunManager *run_manager,
IdeRunner *runner,
gpointer user_data)
{
- GbpSysprofWorkbenchAddin *self = user_data;
+ GbpSysprofWorkspaceAddin *self = user_data;
g_autoptr(SpSource) proc_source = NULL;
g_autoptr(SpSource) perf_source = NULL;
g_autoptr(SpSource) hostinfo_source = NULL;
g_autoptr(SpSource) memory_source = NULL;
IdeContext *context;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_RUNNER (runner));
g_assert (IDE_IS_RUN_MANAGER (run_manager));
@@ -210,7 +219,7 @@ profiler_run_handler (IdeRunManager *run_manager,
g_signal_connect_object (self->profiler,
"stopped",
- G_CALLBACK (gbp_sysprof_workbench_addin_update_controls),
+ G_CALLBACK (gbp_sysprof_workspace_addin_update_controls),
self,
G_CONNECT_SWAPPED);
@@ -259,21 +268,21 @@ profiler_run_handler (IdeRunManager *run_manager,
self,
G_CONNECT_SWAPPED);
- gbp_sysprof_perspective_set_profiler (self->perspective, self->profiler);
+ gbp_sysprof_surface_set_profiler (self->surface, self->profiler);
- ide_workbench_set_visible_perspective (self->workbench, IDE_PERSPECTIVE (self->perspective));
+ ide_workspace_set_visible_surface (self->workspace, IDE_SURFACE (self->surface));
}
static void
-gbp_sysprof_workbench_addin_open_cb (GObject *object,
+gbp_sysprof_workspace_addin_open_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)object;
+ GbpSysprofWorkspaceAddin *self = (GbpSysprofWorkspaceAddin *)object;
g_autoptr(SpCaptureReader) reader = NULL;
g_autoptr(GError) error = NULL;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_TASK (result));
reader = ide_task_propagate_pointer (IDE_TASK (result), &error);
@@ -286,14 +295,14 @@ gbp_sysprof_workbench_addin_open_cb (GObject *object,
return;
}
- gbp_sysprof_perspective_set_profiler (self->perspective, NULL);
- gbp_sysprof_perspective_set_reader (self->perspective, reader);
+ gbp_sysprof_surface_set_profiler (self->surface, NULL);
+ gbp_sysprof_surface_set_reader (self->surface, reader);
- gbp_sysprof_workbench_addin_update_controls (self);
+ gbp_sysprof_workspace_addin_update_controls (self);
}
static void
-gbp_sysprof_workbench_addin_open_worker (IdeTask *task,
+gbp_sysprof_workspace_addin_open_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@@ -304,7 +313,7 @@ gbp_sysprof_workbench_addin_open_worker (IdeTask *task,
GFile *file = task_data;
g_assert (IDE_IS_TASK (task));
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (source_object));
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (source_object));
g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -317,12 +326,12 @@ gbp_sysprof_workbench_addin_open_worker (IdeTask *task,
}
static void
-gbp_sysprof_workbench_addin_open (GbpSysprofWorkbenchAddin *self,
+gbp_sysprof_workspace_addin_open (GbpSysprofWorkspaceAddin *self,
GFile *file)
{
g_autoptr(IdeTask) task = NULL;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
g_assert (G_IS_FILE (file));
if (!g_file_is_native (file))
@@ -331,9 +340,9 @@ gbp_sysprof_workbench_addin_open (GbpSysprofWorkbenchAddin *self,
return;
}
- task = ide_task_new (self, NULL, gbp_sysprof_workbench_addin_open_cb, NULL);
+ task = ide_task_new (self, NULL, gbp_sysprof_workspace_addin_open_cb, NULL);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
- ide_task_run_in_thread (task, gbp_sysprof_workbench_addin_open_worker);
+ ide_task_run_in_thread (task, gbp_sysprof_workspace_addin_open_worker);
}
static void
@@ -341,26 +350,25 @@ open_profile_action (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
- GbpSysprofWorkbenchAddin *self = user_data;
+ GbpSysprofWorkspaceAddin *self = user_data;
+ g_autoptr(GFile) workdir = NULL;
GtkFileChooserNative *native;
GtkFileFilter *filter;
IdeContext *context;
- IdeVcs *vcs;
- GFile *workdir;
gint ret;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
- g_assert (IDE_IS_WORKBENCH (self->workbench));
- g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self->perspective));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_WORKSPACE (self->workspace));
+ g_assert (GBP_IS_SYSPROF_SURFACE (self->surface));
- ide_workbench_set_visible_perspective (self->workbench, IDE_PERSPECTIVE (self->perspective));
+ ide_workspace_set_visible_surface (self->workspace, IDE_SURFACE (self->surface));
- context = ide_workbench_get_context (self->workbench);
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
+ context = ide_workspace_get_context (self->workspace);
+ workdir = ide_context_ref_workdir (context);
native = gtk_file_chooser_native_new (_("Open Sysprof Capture…"),
- GTK_WINDOW (self->workbench),
+ GTK_WINDOW (self->workspace),
GTK_FILE_CHOOSER_ACTION_OPEN,
_("Open"),
_("Cancel"));
@@ -389,7 +397,7 @@ open_profile_action (GSimpleAction *action,
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
if (G_IS_FILE (file))
- gbp_sysprof_workbench_addin_open (self, file);
+ gbp_sysprof_workspace_addin_open (self, file);
}
gtk_native_dialog_hide (GTK_NATIVE_DIALOG (native));
@@ -397,30 +405,34 @@ open_profile_action (GSimpleAction *action,
}
static void
-gbp_sysprof_workbench_addin_finalize (GObject *object)
+gbp_sysprof_workspace_addin_finalize (GObject *object)
{
- GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)object;
+ GbpSysprofWorkspaceAddin *self = (GbpSysprofWorkspaceAddin *)object;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
g_clear_object (&self->actions);
- G_OBJECT_CLASS (gbp_sysprof_workbench_addin_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gbp_sysprof_workspace_addin_parent_class)->finalize (object);
}
static void
-gbp_sysprof_workbench_addin_class_init (GbpSysprofWorkbenchAddinClass *klass)
+gbp_sysprof_workspace_addin_class_init (GbpSysprofWorkspaceAddinClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gbp_sysprof_workbench_addin_finalize;
+ object_class->finalize = gbp_sysprof_workspace_addin_finalize;
}
static void
-gbp_sysprof_workbench_addin_init (GbpSysprofWorkbenchAddin *self)
+gbp_sysprof_workspace_addin_init (GbpSysprofWorkspaceAddin *self)
{
static const GActionEntry entries[] = {
{ "open-profile", open_profile_action },
};
+ g_assert (IDE_IS_MAIN_THREAD ());
+
self->actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (self->actions),
@@ -430,10 +442,11 @@ gbp_sysprof_workbench_addin_init (GbpSysprofWorkbenchAddin *self)
}
static void
-run_manager_stopped (GbpSysprofWorkbenchAddin *self,
+run_manager_stopped (GbpSysprofWorkspaceAddin *self,
IdeRunManager *run_manager)
{
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_RUN_MANAGER (run_manager));
if (self->profiler != NULL && sp_profiler_get_is_running (self->profiler))
@@ -452,27 +465,28 @@ zoom_level_to_string (GBinding *binding,
}
static void
-gbp_sysprof_workbench_addin_load (IdeWorkbenchAddin *addin,
- IdeWorkbench *workbench)
+gbp_sysprof_workspace_addin_load (IdeWorkspaceAddin *addin,
+ IdeWorkspace *workspace)
{
- GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)addin;
- IdeWorkbenchHeaderBar *header;
+ GbpSysprofWorkspaceAddin *self = (GbpSysprofWorkspaceAddin *)addin;
SpZoomManager *zoom_manager;
IdeRunManager *run_manager;
+ IdeHeaderBar *header;
IdeContext *context;
GtkLabel *label;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
- g_assert (IDE_IS_WORKBENCH (workbench));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace));
- self->workbench = workbench;
+ self->workspace = workspace;
- context = ide_workbench_get_context (workbench);
+ context = ide_workspace_get_context (workspace);
/*
* Register our custom run handler to activate the profiler.
*/
- run_manager = ide_context_get_run_manager (context);
+ run_manager = ide_run_manager_from_context (context);
ide_run_manager_add_handler (run_manager,
"profiler",
_("Run with Profiler"),
@@ -487,30 +501,34 @@ gbp_sysprof_workbench_addin_load (IdeWorkbenchAddin *addin,
self,
G_CONNECT_SWAPPED);
- /*
- * Add the perspcetive to the workbench.
- */
- self->perspective = g_object_new (GBP_TYPE_SYSPROF_PERSPECTIVE,
- "visible", TRUE,
- NULL);
- ide_workbench_add_perspective (workbench, IDE_PERSPECTIVE (self->perspective));
+ /* Add the surface to the workspace. */
+ self->surface = g_object_new (GBP_TYPE_SYSPROF_SURFACE,
+ "visible", TRUE,
+ NULL);
+ g_signal_connect (self->surface,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &self->surface);
+ ide_workspace_add_surface (workspace, IDE_SURFACE (self->surface));
- zoom_manager = gbp_sysprof_perspective_get_zoom_manager (self->perspective);
+ zoom_manager = gbp_sysprof_surface_get_zoom_manager (self->surface);
/*
- * Add our actions to the workbench so they can be activated via the
- * headerbar or the perspective.
+ * Add our actions to the workspace so they can be activated via the
+ * headerbar or the surface.
*/
- gtk_widget_insert_action_group (GTK_WIDGET (workbench), "profiler", G_ACTION_GROUP (self->actions));
- gtk_widget_insert_action_group (GTK_WIDGET (workbench), "profiler-zoom", G_ACTION_GROUP (zoom_manager));
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "profiler", G_ACTION_GROUP (self->actions));
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "profiler-zoom", G_ACTION_GROUP (zoom_manager));
- /*
- * Add our buttons to the header.
- */
- header = ide_workbench_get_headerbar (workbench);
+ /* Add our buttons to the header. */
+ header = ide_workspace_get_header_bar (workspace);
self->zoom_controls = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_HORIZONTAL,
NULL);
+ g_signal_connect (self->zoom_controls,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &self->zoom_controls);
dzl_gtk_widget_add_style_class (GTK_WIDGET (self->zoom_controls), "linked");
gtk_container_add (GTK_CONTAINER (self->zoom_controls),
g_object_new (GTK_TYPE_BUTTON,
@@ -545,50 +563,55 @@ gbp_sysprof_workbench_addin_load (IdeWorkbenchAddin *addin,
NULL),
"visible", TRUE,
NULL));
- ide_workbench_header_bar_insert_left (header, GTK_WIDGET (self->zoom_controls), GTK_PACK_START, 100);
+ ide_header_bar_add_primary (header, GTK_WIDGET (self->zoom_controls));
}
static void
-gbp_sysprof_workbench_addin_unload (IdeWorkbenchAddin *addin,
- IdeWorkbench *workbench)
+gbp_sysprof_workspace_addin_unload (IdeWorkspaceAddin *addin,
+ IdeWorkspace *workspace)
{
- GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)addin;
+ GbpSysprofWorkspaceAddin *self = (GbpSysprofWorkspaceAddin *)addin;
IdeRunManager *run_manager;
IdeContext *context;
- g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
- g_assert (IDE_IS_WORKBENCH (workbench));
+ g_assert (GBP_IS_SYSPROF_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_WORKSPACE (workspace));
+
+ context = ide_workspace_get_context (workspace);
- context = ide_workbench_get_context (workbench);
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "profiler", NULL);
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "profiler-zoom", NULL);
- run_manager = ide_context_get_run_manager (context);
+ run_manager = ide_run_manager_from_context (context);
ide_run_manager_remove_handler (run_manager, "profiler");
- ide_workbench_remove_perspective (workbench, IDE_PERSPECTIVE (self->perspective));
+ if (self->surface)
+ gtk_widget_destroy (GTK_WIDGET (self->surface));
- gtk_widget_destroy (GTK_WIDGET (self->zoom_controls));
+ if (self->zoom_controls)
+ gtk_widget_destroy (GTK_WIDGET (self->zoom_controls));
self->zoom_controls = NULL;
- self->perspective = NULL;
- self->workbench = NULL;
+ self->surface = NULL;
+ self->workspace = NULL;
}
static void
-gbp_sysprof_workbench_addin_perspective_set (IdeWorkbenchAddin *addin,
- IdePerspective *perspective)
+gbp_sysprof_workspace_addin_surface_set (IdeWorkspaceAddin *addin,
+ IdeSurface *surface)
{
- GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)addin;
+ GbpSysprofWorkspaceAddin *self = (GbpSysprofWorkspaceAddin *)addin;
- g_assert (IDE_IS_WORKBENCH_ADDIN (addin));
- g_assert (IDE_IS_PERSPECTIVE (perspective));
+ g_assert (IDE_IS_WORKSPACE_ADDIN (addin));
+ g_assert (!surface || IDE_IS_SURFACE (surface));
- gbp_sysprof_workbench_addin_update_controls (self);
+ gbp_sysprof_workspace_addin_update_controls (self);
}
static void
-workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface)
+workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface)
{
- iface->load = gbp_sysprof_workbench_addin_load;
- iface->unload = gbp_sysprof_workbench_addin_unload;
- iface->perspective_set = gbp_sysprof_workbench_addin_perspective_set;
+ iface->load = gbp_sysprof_workspace_addin_load;
+ iface->unload = gbp_sysprof_workspace_addin_unload;
+ iface->surface_set = gbp_sysprof_workspace_addin_surface_set;
}
diff --git a/src/plugins/sysprof/gbp-sysprof-workbench-addin.h
b/src/plugins/sysprof/gbp-sysprof-workspace-addin.h
similarity index 77%
rename from src/plugins/sysprof/gbp-sysprof-workbench-addin.h
rename to src/plugins/sysprof/gbp-sysprof-workspace-addin.h
index 89ed65816..e43254ea1 100644
--- a/src/plugins/sysprof/gbp-sysprof-workbench-addin.h
+++ b/src/plugins/sysprof/gbp-sysprof-workspace-addin.h
@@ -1,4 +1,4 @@
-/* gbp-sysprof-workbench-addin.h
+/* gbp-sysprof-workspace-addin.h
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -20,12 +20,12 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
-#define GBP_TYPE_SYSPROF_WORKBENCH_ADDIN (gbp_sysprof_workbench_addin_get_type())
+#define GBP_TYPE_SYSPROF_WORKSPACE_ADDIN (gbp_sysprof_workspace_addin_get_type())
-G_DECLARE_FINAL_TYPE (GbpSysprofWorkbenchAddin, gbp_sysprof_workbench_addin, GBP, SYSPROF_WORKBENCH_ADDIN,
GObject)
+G_DECLARE_FINAL_TYPE (GbpSysprofWorkspaceAddin, gbp_sysprof_workspace_addin, GBP, SYSPROF_WORKSPACE_ADDIN,
GObject)
G_END_DECLS
diff --git a/src/plugins/sysprof/gtk/menus.ui b/src/plugins/sysprof/gtk/menus.ui
index 5b2c5ad47..03ddad217 100644
--- a/src/plugins/sysprof/gtk/menus.ui
+++ b/src/plugins/sysprof/gtk/menus.ui
@@ -10,13 +10,13 @@
</item>
</section>
</menu>
- <menu id="perspectives-menu">
- <section id="perspectives-menu-section">
+ <menu id="ide-primary-workspace-surfaces-menu">
+ <section id="ide-primary-workspace-surfaces-menu-section">
<item>
<attribute name="accel"><alt>3</attribute>
- <attribute name="action">win.perspective</attribute>
- <attribute name="after">perspective-menu-editor</attribute>
- <attribute name="id">perspective-menu-profiler</attribute>
+ <attribute name="action">win.surface</attribute>
+ <attribute name="after">surface-menu-config</attribute>
+ <attribute name="id">surface-menu-profiler</attribute>
<attribute name="label" translatable="yes">Profiler</attribute>
<attribute name="role">normal</attribute>
<attribute name="target">profiler</attribute>
@@ -37,4 +37,14 @@
</item>
</section>
</menu>
+ <menu id="project-tree-run-with-submenu">
+ <section id="project-tree-menu-run-with-section">
+ <item>
+ <attribute name="id">project-tree-menu-profiler</attribute>
+ <attribute name="label" translatable="yes">Run with Profiler</attribute>
+ <attribute name="action">buildui.run-with-handler</attribute>
+ <attribute name="target" type="s">'profiler'</attribute>
+ </item>
+ </section>
+ </menu>
</interface>
diff --git a/src/plugins/sysprof/meson.build b/src/plugins/sysprof/meson.build
index 31849c907..4930297d9 100644
--- a/src/plugins/sysprof/meson.build
+++ b/src/plugins/sysprof/meson.build
@@ -1,25 +1,24 @@
-if get_option('with_sysprof')
+if get_option('plugin_sysprof')
-sysprof_resources = gnome.compile_resources(
- 'gbp-sysprof-resources',
- 'sysprof.gresource.xml',
- c_name: 'gbp_sysprof',
-)
-
-sysprof_sources = [
- 'gbp-sysprof-plugin.c',
- 'gbp-sysprof-perspective.c',
- 'gbp-sysprof-perspective.h',
- 'gbp-sysprof-workbench-addin.c',
- 'gbp-sysprof-workbench-addin.h',
-]
-
-gnome_builder_plugins_deps += [
+plugins_deps += [
dependency('sysprof-2', version: '>= 3.31.1'),
dependency('sysprof-ui-2', version: '>= 3.31.1'),
]
-gnome_builder_plugins_sources += files(sysprof_sources)
-gnome_builder_plugins_sources += sysprof_resources[0]
+plugins_sources += files([
+ 'sysprof-plugin.c',
+ 'gbp-sysprof-surface.c',
+ 'gbp-sysprof-surface.h',
+ 'gbp-sysprof-workspace-addin.c',
+ 'gbp-sysprof-workspace-addin.h',
+])
+
+plugin_sysprof_resources = gnome.compile_resources(
+ 'sysprof-resources',
+ 'sysprof.gresource.xml',
+ c_name: 'gbp_sysprof',
+)
+
+plugins_sources += plugin_sysprof_resources[0]
endif
diff --git a/src/plugins/sysprof/gbp-sysprof-plugin.c b/src/plugins/sysprof/sysprof-plugin.c
similarity index 76%
rename from src/plugins/sysprof/gbp-sysprof-plugin.c
rename to src/plugins/sysprof/sysprof-plugin.c
index d313c92ee..5654cc39a 100644
--- a/src/plugins/sysprof/gbp-sysprof-plugin.c
+++ b/src/plugins/sysprof/sysprof-plugin.c
@@ -1,4 +1,4 @@
-/* gbp-sysprof-plugin.c
+/* sysprof-plugin.c
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -18,18 +18,22 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
+#define G_LOG_DOMAIN "sysprof-plugin"
+
+#include "config.h"
+
#include <libpeas/peas.h>
-#include <ide.h>
+#include <libide-gui.h>
#include <sysprof.h>
-#include "gbp-sysprof-workbench-addin.h"
+#include "gbp-sysprof-workspace-addin.h"
-void
-gbp_sysprof_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_sysprof_register_types (PeasObjectModule *module)
{
sp_clock_init ();
peas_object_module_register_extension_type (module,
- IDE_TYPE_WORKBENCH_ADDIN,
- GBP_TYPE_SYSPROF_WORKBENCH_ADDIN);
+ IDE_TYPE_WORKSPACE_ADDIN,
+ GBP_TYPE_SYSPROF_WORKSPACE_ADDIN);
}
diff --git a/src/plugins/sysprof/sysprof.gresource.xml b/src/plugins/sysprof/sysprof.gresource.xml
index 3d6cdc782..1d23d1167 100644
--- a/src/plugins/sysprof/sysprof.gresource.xml
+++ b/src/plugins/sysprof/sysprof.gresource.xml
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/builder/plugins">
+ <gresource prefix="/plugins/sysprof">
<file>sysprof.plugin</file>
- </gresource>
- <gresource prefix="/org/gnome/builder/plugins/sysprof-plugin">
<file>gtk/menus.ui</file>
<file>themes/shared.css</file>
- <file>gbp-sysprof-perspective.ui</file>
+ <file>gbp-sysprof-surface.ui</file>
</gresource>
</gresources>
diff --git a/src/plugins/sysprof/sysprof.plugin b/src/plugins/sysprof/sysprof.plugin
index 1fbd71991..602e998a0 100644
--- a/src/plugins/sysprof/sysprof.plugin
+++ b/src/plugins/sysprof/sysprof.plugin
@@ -1,8 +1,10 @@
[Plugin]
-Module=sysprof-plugin
-Name=Sysprof
-Description=Integration with the Sysprof system profiler
Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2016 Christian Hergert
Builtin=true
-Embedded=gbp_sysprof_register_types
+Copyright=Copyright © 2016-2018 Christian Hergert
+Description=Integration with the Sysprof system profiler
+Embedded=_gbp_sysprof_register_types
+Hidden=true
+Module=sysprof
+Name=Sysprof
+X-Workspace-Kind=primary;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]