[gnome-builder/wip/gtk4-port: 1063/1774] plugins/sysprof: create page with active profiler
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1063/1774] plugins/sysprof: create page with active profiler
- Date: Mon, 11 Jul 2022 22:31:33 +0000 (UTC)
commit 8a67996c5b356790fc97e8a7563077d1070f97e3
Author: Christian Hergert <chergert redhat com>
Date: Tue May 17 17:12:23 2022 -0700
plugins/sysprof: create page with active profiler
src/plugins/sysprof/gbp-sysprof-page.c | 92 +++++++++++------------
src/plugins/sysprof/gbp-sysprof-page.h | 7 +-
src/plugins/sysprof/gbp-sysprof-workspace-addin.c | 6 +-
3 files changed, 56 insertions(+), 49 deletions(-)
---
diff --git a/src/plugins/sysprof/gbp-sysprof-page.c b/src/plugins/sysprof/gbp-sysprof-page.c
index 9d5fb2ec0..e7196c3a5 100644
--- a/src/plugins/sysprof/gbp-sysprof-page.c
+++ b/src/plugins/sysprof/gbp-sysprof-page.c
@@ -22,6 +22,8 @@
#include "config.h"
+#include <glib/gi18n.h>
+
#include <sysprof-ui.h>
#include "gbp-sysprof-page.h"
@@ -53,22 +55,6 @@ gbp_sysprof_page_get_file (GbpSysprofPage *self)
return self->file;
}
-static void
-gbp_sysprof_page_set_file (GbpSysprofPage *self,
- GFile *file)
-{
- g_assert (GBP_IS_SYSPROF_PAGE (self));
- g_assert (!file || G_IS_FILE (file));
- g_assert (self->file == NULL);
-
- if (file == NULL)
- return;
-
- g_set_object (&self->file, file);
- sysprof_display_open (self->display, file);
- ide_page_set_can_split (IDE_PAGE (self), TRUE);
-}
-
static IdePage *
gbp_sysprof_page_create_split (IdePage *page)
{
@@ -80,6 +66,21 @@ gbp_sysprof_page_create_split (IdePage *page)
return IDE_PAGE (gbp_sysprof_page_new_for_file (self->file));
}
+static void
+gbp_sysprof_page_set_display (GbpSysprofPage *self,
+ SysprofDisplay *display)
+{
+ g_assert (GBP_IS_SYSPROF_PAGE (self));
+ g_assert (SYSPROF_IS_DISPLAY (display));
+
+ self->display = display;
+
+ g_object_bind_property (display, "title", self, "title", G_BINDING_SYNC_CREATE);
+ gtk_widget_set_hexpand (GTK_WIDGET (display), TRUE);
+ gtk_widget_set_vexpand (GTK_WIDGET (display), TRUE);
+ ide_page_add_content_widget (IDE_PAGE (self), GTK_WIDGET (display));
+}
+
static void
gbp_sysprof_page_dispose (GObject *object)
{
@@ -109,25 +110,6 @@ gbp_sysprof_page_get_property (GObject *object,
}
}
-static void
-gbp_sysprof_page_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GbpSysprofPage *self = GBP_SYSPROF_PAGE (object);
-
- switch (prop_id)
- {
- case PROP_FILE:
- gbp_sysprof_page_set_file (self, g_value_get_object (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
static void
gbp_sysprof_page_class_init (GbpSysprofPageClass *klass)
{
@@ -136,14 +118,13 @@ gbp_sysprof_page_class_init (GbpSysprofPageClass *klass)
object_class->dispose = gbp_sysprof_page_dispose;
object_class->get_property = gbp_sysprof_page_get_property;
- object_class->set_property = gbp_sysprof_page_set_property;
page_class->create_split = gbp_sysprof_page_create_split;
properties [PROP_FILE] =
g_param_spec_object ("file", NULL, NULL,
G_TYPE_FILE,
- (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -151,23 +132,42 @@ gbp_sysprof_page_class_init (GbpSysprofPageClass *klass)
static void
gbp_sysprof_page_init (GbpSysprofPage *self)
{
- self->display = SYSPROF_DISPLAY (sysprof_display_new ());
- g_object_bind_property (self->display, "title", self, "title", 0);
- gtk_widget_set_hexpand (GTK_WIDGET (self->display), TRUE);
- gtk_widget_set_vexpand (GTK_WIDGET (self->display), TRUE);
- ide_page_add_content_widget (IDE_PAGE (self), GTK_WIDGET (self->display));
ide_page_set_menu_id (IDE_PAGE (self), "gbp-sysprof-page-menu");
-
panel_widget_set_icon_name (PANEL_WIDGET (self), "builder-profiler-symbolic");
}
GbpSysprofPage *
gbp_sysprof_page_new_for_file (GFile *file)
{
+ GbpSysprofPage *self;
+ SysprofDisplay *display;
+
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (g_file_is_native (file), NULL);
- return g_object_new (GBP_TYPE_SYSPROF_PAGE,
- "file", file,
- NULL);
+ self = g_object_new (GBP_TYPE_SYSPROF_PAGE, NULL);
+ g_set_object (&self->file, file);
+ ide_page_set_can_split (IDE_PAGE (self), TRUE);
+
+ display = SYSPROF_DISPLAY (sysprof_display_new ());
+ sysprof_display_open (display, file);
+
+ gbp_sysprof_page_set_display (self, display);
+
+ return self;
+}
+
+GbpSysprofPage *
+gbp_sysprof_page_new_for_profiler (SysprofProfiler *profiler)
+{
+ GbpSysprofPage *self;
+ SysprofDisplay *display;
+
+ g_return_val_if_fail (SYSPROF_IS_PROFILER (profiler), NULL);
+
+ self = g_object_new (GBP_TYPE_SYSPROF_PAGE, NULL);
+ display = SYSPROF_DISPLAY (sysprof_display_new_for_profiler (profiler));
+ gbp_sysprof_page_set_display (self, display);
+
+ return self;
}
diff --git a/src/plugins/sysprof/gbp-sysprof-page.h b/src/plugins/sysprof/gbp-sysprof-page.h
index a662d32cf..f1f941d7b 100644
--- a/src/plugins/sysprof/gbp-sysprof-page.h
+++ b/src/plugins/sysprof/gbp-sysprof-page.h
@@ -20,6 +20,8 @@
#pragma once
+#include <sysprof.h>
+
#include <libide-gui.h>
G_BEGIN_DECLS
@@ -28,7 +30,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpSysprofPage, gbp_sysprof_page, GBP, SYSPROF_PAGE, IdePage)
-GbpSysprofPage *gbp_sysprof_page_new_for_file (GFile *file);
-GFile *gbp_sysprof_page_get_file (GbpSysprofPage *self);
+GbpSysprofPage *gbp_sysprof_page_new_for_file (GFile *file);
+GbpSysprofPage *gbp_sysprof_page_new_for_profiler (SysprofProfiler *profiler);
+GFile *gbp_sysprof_page_get_file (GbpSysprofPage *self);
G_END_DECLS
diff --git a/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
b/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
index fd69067d9..66e89f8df 100644
--- a/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
+++ b/src/plugins/sysprof/gbp-sysprof-workspace-addin.c
@@ -102,9 +102,11 @@ profiler_run_handler (IdeRunManager *run_manager,
g_autoptr(SysprofProfiler) profiler = NULL;
g_autoptr(SysprofSource) app_source = NULL;
g_autoptr(SysprofSpawnable) spawnable = NULL;
+ g_autoptr(IdePanelPosition) position = NULL;
g_autoptr(GPtrArray) sources = NULL;
g_auto(GStrv) argv = NULL;
const gchar * const *env;
+ GbpSysprofPage *page;
IdeEnvironment *ienv;
g_assert (IDE_IS_MAIN_THREAD ());
@@ -210,7 +212,9 @@ profiler_run_handler (IdeRunManager *run_manager,
sysprof_spawnable_foreach_fd (spawnable, foreach_fd, runner);
- //gbp_sysprof_surface_add_profiler (self->surface, profiler);
+ page = gbp_sysprof_page_new_for_profiler (profiler);
+ position = ide_panel_position_new ();
+ ide_workspace_add_page (self->workspace, IDE_PAGE (page), position);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]