From 65f1a8d5a0469070d4579c4b9eea1e2faabccb24 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 18 May 2019 16:44:02 -0700 Subject: [PATCH] libsysprof-ui: start on data collection icons --- src/libsysprof-ui/libsysprof-ui.gresource.xml | 1 + src/libsysprof-ui/meson.build | 1 + src/libsysprof-ui/sysprof-aid-icon.c | 187 +++++++ src/libsysprof-ui/sysprof-aid-icon.h | 38 ++ .../sysprof-profiler-assistant.c | 22 + src/libsysprof-ui/ui/sysprof-aid-icon.ui | 61 +++ .../ui/sysprof-profiler-assistant.ui | 494 ++++++++++-------- src/sysprof/ui/sysprof-window.ui | 27 - 8 files changed, 590 insertions(+), 241 deletions(-) create mode 100644 src/libsysprof-ui/sysprof-aid-icon.c create mode 100644 src/libsysprof-ui/sysprof-aid-icon.h create mode 100644 src/libsysprof-ui/ui/sysprof-aid-icon.ui diff --git a/src/libsysprof-ui/libsysprof-ui.gresource.xml b/src/libsysprof-ui/libsysprof-ui.gresource.xml index 1f438231..e59b934d 100644 --- a/src/libsysprof-ui/libsysprof-ui.gresource.xml +++ b/src/libsysprof-ui/libsysprof-ui.gresource.xml @@ -10,6 +10,7 @@ ../../data/icons/scalable/apps/org.gnome.Sysprof.svg ../../data/icons/symbolic/apps/org.gnome.Sysprof-symbolic.svg + ui/sysprof-aid-icon.ui ui/sysprof-callgraph-view.ui ui/sysprof-capture-view.ui ui/sysprof-display.ui diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build index eff755b6..53c5c64d 100644 --- a/src/libsysprof-ui/meson.build +++ b/src/libsysprof-ui/meson.build @@ -27,6 +27,7 @@ libsysprof_ui_public_sources = [ libsysprof_ui_private_sources = [ 'pointcache.c', 'rectangles.c', + 'sysprof-aid-icon.c', 'sysprof-details-view.c', 'sysprof-cairo.c', 'sysprof-cell-renderer-duration.c', diff --git a/src/libsysprof-ui/sysprof-aid-icon.c b/src/libsysprof-ui/sysprof-aid-icon.c new file mode 100644 index 00000000..6ee91a7e --- /dev/null +++ b/src/libsysprof-ui/sysprof-aid-icon.c @@ -0,0 +1,187 @@ +/* sysprof-aid-icon.c + * + * Copyright 2019 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "sysprof-aid-icon" + +#include "config.h" + +#include "sysprof-aid-icon.h" + +struct _SysprofAidIcon +{ + GtkFlowBoxChild parent_instance; + + SysprofAid *aid; + + /* Template Objects */ + GtkLabel *label; + GtkImage *image; + GtkImage *check; +}; + +G_DEFINE_TYPE (SysprofAidIcon, sysprof_aid_icon, GTK_TYPE_FLOW_BOX_CHILD) + +enum { + PROP_0, + PROP_AID, + N_PROPS +}; + +static GParamSpec *properties [N_PROPS]; + +/** + * sysprof_aid_icon_new: + * + * Create a new #SysprofAidIcon. + * + * Returns: (transfer full): a newly created #SysprofAidIcon + */ +GtkWidget * +sysprof_aid_icon_new (SysprofAid *aid) +{ + g_return_val_if_fail (SYSPROF_IS_AID (aid), NULL); + + return g_object_new (SYSPROF_TYPE_AID_ICON, + "aid", aid, + NULL); +} + +/** + * sysprof_aid_icon_get_aid: + * + * Get the aid that is represented by the icon. + * + * Returns: (transfer none): a #SysprofAid + * + * Since: 3.34 + */ +SysprofAid * +sysprof_aid_icon_get_aid (SysprofAidIcon *self) +{ + g_return_val_if_fail (SYSPROF_IS_AID_ICON (self), NULL); + + return self->aid; +} + +static void +sysprof_aid_icon_set_aid (SysprofAidIcon *self, + SysprofAid *aid) +{ + g_return_if_fail (SYSPROF_IS_AID_ICON (self)); + g_return_if_fail (SYSPROF_IS_AID (aid)); + + if (g_set_object (&self->aid, aid)) + { + GIcon *icon = sysprof_aid_get_icon (aid); + const gchar *title = sysprof_aid_get_display_name (aid); + + g_object_set (self->image, "gicon", icon, NULL); + gtk_label_set_label (self->label, title); + } +} + +static void +sysprof_aid_icon_finalize (GObject *object) +{ + SysprofAidIcon *self = (SysprofAidIcon *)object; + + g_clear_object (&self->aid); + + G_OBJECT_CLASS (sysprof_aid_icon_parent_class)->finalize (object); +} + +static void +sysprof_aid_icon_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + SysprofAidIcon *self = SYSPROF_AID_ICON (object); + + switch (prop_id) + { + case PROP_AID: + g_value_set_object (value, sysprof_aid_icon_get_aid (self)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +sysprof_aid_icon_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + SysprofAidIcon *self = SYSPROF_AID_ICON (object); + + switch (prop_id) + { + case PROP_AID: + sysprof_aid_icon_set_aid (self, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +sysprof_aid_icon_class_init (SysprofAidIconClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = sysprof_aid_icon_finalize; + object_class->get_property = sysprof_aid_icon_get_property; + object_class->set_property = sysprof_aid_icon_set_property; + + properties [PROP_AID] = + g_param_spec_object ("aid", + "Aid", + "The aid for the icon", + SYSPROF_TYPE_AID, + (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_css_name (widget_class, "sysprofaidicon"); + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-aid-icon.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofAidIcon, check); + gtk_widget_class_bind_template_child (widget_class, SysprofAidIcon, image); + gtk_widget_class_bind_template_child (widget_class, SysprofAidIcon, label); +} + +static void +sysprof_aid_icon_init (SysprofAidIcon *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +void +sysprof_aid_icon_toggle (SysprofAidIcon *self) +{ + g_return_if_fail (SYSPROF_IS_AID_ICON (self)); + + gtk_widget_set_visible (GTK_WIDGET (self->check), + !gtk_widget_get_visible (GTK_WIDGET (self->check))); +} diff --git a/src/libsysprof-ui/sysprof-aid-icon.h b/src/libsysprof-ui/sysprof-aid-icon.h new file mode 100644 index 00000000..b49726b1 --- /dev/null +++ b/src/libsysprof-ui/sysprof-aid-icon.h @@ -0,0 +1,38 @@ +/* sysprof-aid-icon.h + * + * Copyright 2019 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include +#include + +#include "sysprof-aid.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_AID_ICON (sysprof_aid_icon_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofAidIcon, sysprof_aid_icon, SYSPROF, AID_ICON, GtkFlowBoxChild) + +GtkWidget *sysprof_aid_icon_new (SysprofAid *aid); +SysprofAid *sysprof_aid_icon_get_aid (SysprofAidIcon *self); +void sysprof_aid_icon_toggle (SysprofAidIcon *self); + +G_END_DECLS diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c index 34ee3506..37feddae 100644 --- a/src/libsysprof-ui/sysprof-profiler-assistant.c +++ b/src/libsysprof-ui/sysprof-profiler-assistant.c @@ -24,6 +24,7 @@ #include +#include "sysprof-aid-icon.h" #include "sysprof-environ-editor.h" #include "sysprof-profiler-assistant.h" #include "sysprof-process-model-row.h" @@ -37,6 +38,7 @@ struct _SysprofProfilerAssistant GtkRevealer *process_revealer; GtkListBox *process_list_box; SysprofEnvironEditor *environ_editor; + GtkFlowBox *aid_flow_box; }; G_DEFINE_TYPE (SysprofProfilerAssistant, sysprof_profiler_assistant, GTK_TYPE_BIN) @@ -56,6 +58,18 @@ sysprof_profiler_assistant_new (void) return g_object_new (SYSPROF_TYPE_PROFILER_ASSISTANT, NULL); } +static void +sysprof_profiler_assistant_aid_activated_cb (SysprofProfilerAssistant *self, + SysprofAidIcon *icon, + GtkFlowBox *flow_box) +{ + g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self)); + g_assert (SYSPROF_IS_AID_ICON (icon)); + g_assert (GTK_IS_FLOW_BOX (flow_box)); + + sysprof_aid_icon_toggle (icon); +} + static GtkWidget * create_process_row_cb (gpointer item_, gpointer user_data) @@ -128,11 +142,13 @@ sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-profiler-assistant.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, aid_flow_box); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, command_line); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, environ_editor); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_list_box); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_revealer); + g_type_ensure (SYSPROF_TYPE_AID_ICON); g_type_ensure (SYSPROF_TYPE_ENVIRON_EDITOR); } @@ -161,5 +177,11 @@ sysprof_profiler_assistant_init (SysprofProfilerAssistant *self) self, G_CONNECT_SWAPPED); + g_signal_connect_object (self->aid_flow_box, + "child-activated", + G_CALLBACK (sysprof_profiler_assistant_aid_activated_cb), + self, + G_CONNECT_SWAPPED); + sysprof_environ_editor_set_environ (self->environ_editor, environ); } diff --git a/src/libsysprof-ui/ui/sysprof-aid-icon.ui b/src/libsysprof-ui/ui/sysprof-aid-icon.ui new file mode 100644 index 00000000..cf9f86be --- /dev/null +++ b/src/libsysprof-ui/ui/sysprof-aid-icon.ui @@ -0,0 +1,61 @@ + + + + + + diff --git a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui index 10cca39d..36282400 100644 --- a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui +++ b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui @@ -8,96 +8,155 @@ never true - + 36 - 12 - 6 + 12 + vertical true - - All Processes - 1.0 - true - - - - left - 0 - - - - - true - start - center - true - - - center - 0 - - - - - vertical + + 12 + 6 true - - Enable to generate callgraph information for all applications and the operating system kernel. This may not be possible on some system system configurations. - 6 - 10 - true + + Data Collection + 1.0 + start true - 0.0 - - - + + left + 0 + - - + + true + 24 + 12 + 4 + 4 + fill + single + 24 true - - 12 - vertical + true + + + + + true + + + + + true + + + + + true + + + + + center + 0 + + + + + All Processes + 1.0 + true + + + + left + 1 + + + + + true + start + center + true + + + center + 1 + + + + + vertical + true + + + Include all applications and operating system kernel in callgraph. This may not be possible on some system system configurations. + 6 + 10 + true + true + 0.0 + + + + + + + + + true - - Search Processes… - true - - - - - in - never - 175 - 175 + + 12 + vertical true + - - none + + Search Processes… true - - - 12 - 12 - Loading Processes… - center + + + + + in + never + 175 + 175 + true + + + none true - + + + 12 + 12 + Loading Processes… + center + true + + + @@ -107,179 +166,185 @@ - - - - center - 1 - - - - - Launch Application - 1.0 - start - true - - - - left - 2 - - - - - vertical - 500 - start - true - - - false - start - center - true - + + center + 2 + - - Enable to launch a program of your choosing before profiling. - 6 - 6 - 10 - true + + Launch Application + 1.0 + start true - 0.0 - - - + + left + 3 + - - + + vertical + 500 + start true - + + false + start + center + true + + + + + Enable to launch a program of your choosing before profiling. 6 - 6 - 12 - vertical + 6 + 10 + true + true + 0.0 + + + + + + + + + true - - Command Line - 0.0 - true - - - - - - - - - - true - - - - - Environment - 12 - 0.0 - true - - - - - - - - - - in + + 6 + 6 + 12 + vertical true - + + Command Line + 0.0 + true + + + + + + + + + true - - - - - Inherit Environment - 12 - 10 - true - true - 0.0 - - - - - - - - - - true - start - true - - - - - Enable to ensure your application shares the display, message-bus, and other desktop environment settings. - 12 - 10 - true - true - 0.0 - - - - + + + Environment + 12 + 0.0 + true + + + + + + + + + + in + true + + + true + + + + + + + Inherit Environment + 12 + 10 + true + true + 0.0 + + + + + + + + + + true + start + true + + + + + Enable to ensure your application shares the display, message-bus, and other desktop environment settings. + 12 + 10 + true + true + 0.0 + + + + + + + + center + 3 + + + + + _Record + true + end + 125 + true + 12 + 24 + + + + center + 4 + - center - 2 - - - - - _Record - true - end - 125 - true - - - - center - 4 + start + 2 @@ -290,6 +355,7 @@ vertical + diff --git a/src/sysprof/ui/sysprof-window.ui b/src/sysprof/ui/sysprof-window.ui index 0467721b..63110d2a 100644 --- a/src/sysprof/ui/sysprof-window.ui +++ b/src/sysprof/ui/sysprof-window.ui @@ -53,33 +53,6 @@ - - - true - - - - _Record - true - true - 100 - - - - - - true - - - - - 12