From 7e403af62495c2e6295f2158f08cc7ec4a5b7721 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 25 Jun 2019 10:01:52 -0700 Subject: [PATCH] build: remove dead code --- src/libsysprof-ui/sysprof-callgraph-view.c | 1225 ----------------- src/libsysprof-ui/sysprof-callgraph-view.h | 46 - src/libsysprof-ui/sysprof-callgraph-view.ui | 235 ---- src/libsysprof-ui/sysprof-details-view.c | 308 ----- src/libsysprof-ui/sysprof-details-view.h | 45 - src/libsysprof-ui/sysprof-details-view.ui | 372 ----- src/libsysprof-ui/sysprof-empty-state-view.c | 219 --- src/libsysprof-ui/sysprof-empty-state-view.h | 41 - src/libsysprof-ui/sysprof-empty-state-view.ui | 64 - src/libsysprof-ui/sysprof-logs-view.c | 112 -- src/libsysprof-ui/sysprof-logs-view.h | 43 - src/libsysprof-ui/sysprof-logs-view.ui | 75 - 12 files changed, 2785 deletions(-) delete mode 100644 src/libsysprof-ui/sysprof-callgraph-view.c delete mode 100644 src/libsysprof-ui/sysprof-callgraph-view.h delete mode 100644 src/libsysprof-ui/sysprof-callgraph-view.ui delete mode 100644 src/libsysprof-ui/sysprof-details-view.c delete mode 100644 src/libsysprof-ui/sysprof-details-view.h delete mode 100644 src/libsysprof-ui/sysprof-details-view.ui delete mode 100644 src/libsysprof-ui/sysprof-empty-state-view.c delete mode 100644 src/libsysprof-ui/sysprof-empty-state-view.h delete mode 100644 src/libsysprof-ui/sysprof-empty-state-view.ui delete mode 100644 src/libsysprof-ui/sysprof-logs-view.c delete mode 100644 src/libsysprof-ui/sysprof-logs-view.h delete mode 100644 src/libsysprof-ui/sysprof-logs-view.ui diff --git a/src/libsysprof-ui/sysprof-callgraph-view.c b/src/libsysprof-ui/sysprof-callgraph-view.c deleted file mode 100644 index 07ea0d09..00000000 --- a/src/libsysprof-ui/sysprof-callgraph-view.c +++ /dev/null @@ -1,1225 +0,0 @@ -/* sysprof-callgraph-view.c - * - * Copyright 2016-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 - */ - -/* Sysprof -- Sampling, systemwide CPU profiler - * Copyright 2004, Red Hat, Inc. - * Copyright 2004, 2005, 2006, Soeren Sandmann - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include - -#include "../stackstash.h" - -#include "sysprof-callgraph-view.h" -#include "sysprof-cell-renderer-percent.h" - -typedef struct -{ - SysprofCallgraphProfile *profile; - - GtkTreeView *callers_view; - GtkTreeView *functions_view; - GtkTreeView *descendants_view; - GtkTreeViewColumn *descendants_name_column; - GtkStack *stack; - - GQueue *history; - - guint profile_size; - guint loading; -} SysprofCallgraphViewPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (SysprofCallgraphView, sysprof_callgraph_view, GTK_TYPE_BIN) - -enum { - PROP_0, - PROP_PROFILE, - N_PROPS -}; - -enum { - GO_PREVIOUS, - N_SIGNALS -}; - -enum { - COLUMN_NAME, - COLUMN_SELF, - COLUMN_TOTAL, - COLUMN_POINTER, - COLUMN_HITS, -}; - - -static void sysprof_callgraph_view_update_descendants (SysprofCallgraphView *self, - StackNode *node); - -static GParamSpec *properties [N_PROPS]; -static guint signals [N_SIGNALS]; - -static guint -sysprof_callgraph_view_get_profile_size (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - StackStash *stash; - StackNode *node; - guint size = 0; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - if (priv->profile_size != 0) - return priv->profile_size; - - if (priv->profile == NULL) - return 0; - - if (NULL == (stash = sysprof_callgraph_profile_get_stash (priv->profile))) - return 0; - - for (node = stack_stash_get_root (stash); node != NULL; node = node->siblings) - size += node->total; - - priv->profile_size = size; - - return size; -} - -static void -build_functions_store (StackNode *node, - gpointer user_data) -{ - struct { - GtkListStore *store; - gdouble profile_size; - } *state = user_data; - GtkTreeIter iter; - const StackNode *n; - guint size = 0; - guint total = 0; - - g_assert (state != NULL); - g_assert (GTK_IS_LIST_STORE (state->store)); - - for (n = node; n != NULL; n = n->next) - { - size += n->size; - if (n->toplevel) - total += n->total; - } - - gtk_list_store_append (state->store, &iter); - gtk_list_store_set (state->store, &iter, - COLUMN_NAME, U64_TO_POINTER(node->data), - COLUMN_SELF, 100.0 * size / state->profile_size, - COLUMN_TOTAL, 100.0 * total / state->profile_size, - COLUMN_POINTER, node, - -1); - -} - -static void -sysprof_callgraph_view_load (SysprofCallgraphView *self, - SysprofCallgraphProfile *profile) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkListStore *functions; - StackStash *stash; - StackNode *n; - GtkTreeIter iter; - struct { - GtkListStore *store; - gdouble profile_size; - } state = { 0 }; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (profile)); - - /* - * TODO: This is probably the type of thing we want to do off the main - * thread. We should be able to build the tree models off thread - * and then simply apply them on the main thread. - * - * In the mean time, we should set the state of the widget to - * insensitive and give some indication of loading progress. - */ - - if (!g_set_object (&priv->profile, profile)) - return; - - if (sysprof_callgraph_profile_is_empty (profile)) - return; - - stash = sysprof_callgraph_profile_get_stash (profile); - - for (n = stack_stash_get_root (stash); n; n = n->siblings) - state.profile_size += n->total; - - functions = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_POINTER); - - state.store = functions; - stack_stash_foreach_by_address (stash, build_functions_store, &state); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (functions), - COLUMN_TOTAL, - GTK_SORT_DESCENDING); - - gtk_tree_view_set_model (priv->functions_view, GTK_TREE_MODEL (functions)); - gtk_tree_view_set_model (priv->callers_view, NULL); - gtk_tree_view_set_model (priv->descendants_view, NULL); - - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (functions), &iter)) - { - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (priv->functions_view); - gtk_tree_selection_select_iter (selection, &iter); - } - - gtk_stack_set_visible_child_name (priv->stack, "callgraph"); - - g_clear_object (&functions); -} - -void -_sysprof_callgraph_view_set_failed (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - gtk_stack_set_visible_child_name (priv->stack, "empty-state"); -} - -static void -sysprof_callgraph_view_unload (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (priv->profile)); - - g_queue_clear (priv->history); - g_clear_object (&priv->profile); - priv->profile_size = 0; - - gtk_tree_view_set_model (priv->callers_view, NULL); - gtk_tree_view_set_model (priv->functions_view, NULL); - gtk_tree_view_set_model (priv->descendants_view, NULL); - - gtk_stack_set_visible_child_name (priv->stack, "empty-state"); -} - -/** - * sysprof_callgraph_view_get_profile: - * - * Returns: (transfer none): An #SysprofCallgraphProfile. - */ -SysprofCallgraphProfile * -sysprof_callgraph_view_get_profile (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), NULL); - - return priv->profile; -} - -void -sysprof_callgraph_view_set_profile (SysprofCallgraphView *self, - SysprofCallgraphProfile *profile) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_return_if_fail (!profile || SYSPROF_IS_CALLGRAPH_PROFILE (profile)); - - if (profile != priv->profile) - { - if (priv->profile) - sysprof_callgraph_view_unload (self); - - if (profile) - sysprof_callgraph_view_load (self, profile); - - g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PROFILE]); - } -} - -static void -sysprof_callgraph_view_expand_descendants (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeModel *model; - GList *all_paths = NULL; - GtkTreePath *first_path; - GtkTreeIter iter; - gdouble top_value = 0; - gint max_rows = 40; /* FIXME */ - gint n_rows; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - model = gtk_tree_view_get_model (priv->descendants_view); - first_path = gtk_tree_path_new_first (); - all_paths = g_list_prepend (all_paths, first_path); - n_rows = 1; - - gtk_tree_model_get_iter (model, &iter, first_path); - gtk_tree_model_get (model, &iter, - COLUMN_TOTAL, &top_value, - -1); - - while ((all_paths != NULL) && (n_rows < max_rows)) - { - GtkTreeIter best_iter; - GtkTreePath *best_path = NULL; - GList *list; - gdouble best_value = 0.0; - gint n_children; - gint i; - - for (list = all_paths; list != NULL; list = list->next) - { - GtkTreePath *path = list->data; - - g_assert (path != NULL); - - if (gtk_tree_model_get_iter (model, &iter, path)) - { - gdouble value; - - gtk_tree_model_get (model, &iter, - COLUMN_TOTAL, &value, - -1); - - if (value >= best_value) - { - best_value = value; - best_path = path; - best_iter = iter; - } - } - } - - n_children = gtk_tree_model_iter_n_children (model, &best_iter); - - if ((n_children > 0) && - ((best_value / top_value) > 0.04) && - ((n_children + gtk_tree_path_get_depth (best_path)) / (gdouble)max_rows) < (best_value / top_value)) - { - gtk_tree_view_expand_row (priv->descendants_view, best_path, FALSE); - n_rows += n_children; - - if (gtk_tree_path_get_depth (best_path) < 4) - { - GtkTreePath *path; - - path = gtk_tree_path_copy (best_path); - gtk_tree_path_down (path); - - for (i = 0; i < n_children; i++) - { - all_paths = g_list_prepend (all_paths, path); - - path = gtk_tree_path_copy (path); - gtk_tree_path_next (path); - } - - gtk_tree_path_free (path); - } - } - - all_paths = g_list_remove (all_paths, best_path); - - /* Always expand at least once */ - if ((all_paths == NULL) && (n_rows == 1)) - gtk_tree_view_expand_row (priv->descendants_view, best_path, FALSE); - - gtk_tree_path_free (best_path); - } - - g_list_free_full (all_paths, (GDestroyNotify)gtk_tree_path_free); -} - -typedef struct -{ - StackNode *node; - const gchar *name; - guint self; - guint total; -} Caller; - -static Caller * -caller_new (StackNode *node) -{ - Caller *c; - - c = g_slice_new (Caller); - c->name = U64_TO_POINTER (node->data); - c->self = 0; - c->total = 0; - c->node = node; - - return c; -} - -static void -caller_free (gpointer data) -{ - Caller *c = data; - g_slice_free (Caller, c); -} - -static void -sysprof_callgraph_view_function_selection_changed (SysprofCallgraphView *self, - GtkTreeSelection *selection) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeModel *model = NULL; - GtkTreeIter iter; - GtkListStore *callers_store; - g_autoptr(GHashTable) callers = NULL; - g_autoptr(GHashTable) processed = NULL; - StackNode *callees = NULL; - StackNode *node; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (GTK_IS_TREE_SELECTION (selection)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_view_set_model (priv->callers_view, NULL); - gtk_tree_view_set_model (priv->descendants_view, NULL); - return; - } - - gtk_tree_model_get (model, &iter, - COLUMN_POINTER, &callees, - -1); - - sysprof_callgraph_view_update_descendants (self, callees); - - callers_store = gtk_list_store_new (4, - G_TYPE_STRING, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE, - G_TYPE_POINTER); - - callers = g_hash_table_new_full (NULL, NULL, NULL, caller_free); - processed = g_hash_table_new (NULL, NULL); - - for (node = callees; node != NULL; node = node->next) - { - Caller *c; - - if (!node->parent) - continue; - - c = g_hash_table_lookup (callers, U64_TO_POINTER (node->parent->data)); - - if (c == NULL) - { - c = caller_new (node->parent); - g_hash_table_insert (callers, (gpointer)c->name, c); - } - } - - for (node = callees; node != NULL; node = node->next) - { - StackNode *top_caller = node->parent; - StackNode *top_callee = node; - StackNode *n; - Caller *c; - - if (!node->parent) - continue; - - /* - * We could have a situation where the function was called in a - * reentrant fashion, so we want to take the top-most match in the - * stack. - */ - for (n = node; n && n->parent; n = n->parent) - { - if (n->data == node->data && n->parent->data == node->parent->data) - { - top_caller = n->parent; - top_callee = n; - } - } - - c = g_hash_table_lookup (callers, U64_TO_POINTER (node->parent->data)); - - g_assert (c != NULL); - - if (!g_hash_table_lookup (processed, top_caller)) - { - c->total += top_callee->total; - g_hash_table_insert (processed, top_caller, top_caller); - } - - c->self += node->size; - } - - { - GHashTableIter hiter; - gpointer key, value; - guint size = 0; - - size = MAX (1, sysprof_callgraph_view_get_profile_size (self)); - - g_hash_table_iter_init (&hiter, callers); - - while (g_hash_table_iter_next (&hiter, &key, &value)) - { - Caller *c = value; - - gtk_list_store_append (callers_store, &iter); - gtk_list_store_set (callers_store, &iter, - COLUMN_NAME, c->name, - COLUMN_SELF, c->self * 100.0 / size, - COLUMN_TOTAL, c->total * 100.0 / size, - COLUMN_POINTER, c->node, - -1); - } - } - - gtk_tree_view_set_model (priv->callers_view, GTK_TREE_MODEL (callers_store)); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (callers_store), - COLUMN_TOTAL, - GTK_SORT_DESCENDING); - - g_clear_object (&callers_store); -} - -static void -sysprof_callgraph_view_set_node (SysprofCallgraphView *self, - StackNode *node) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeModel *model; - GtkTreeIter iter; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (node != NULL); - - if (priv->profile == NULL) - return; - - model = gtk_tree_view_get_model (priv->functions_view); - - if (gtk_tree_model_get_iter_first (model, &iter)) - { - do - { - StackNode *item = NULL; - - gtk_tree_model_get (model, &iter, - COLUMN_POINTER, &item, - -1); - - if (item != NULL && item->data == node->data) - { - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (priv->functions_view); - gtk_tree_selection_select_iter (selection, &iter); - - break; - } - } - while (gtk_tree_model_iter_next (model, &iter)); - } -} - -static void -sysprof_callgraph_view_descendant_activated (SysprofCallgraphView *self, - GtkTreePath *path, - GtkTreeViewColumn *column, - GtkTreeView *tree_view) -{ - GtkTreeModel *model; - StackNode *node = NULL; - GtkTreeIter iter; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (GTK_IS_TREE_VIEW (tree_view)); - g_assert (path != NULL); - g_assert (GTK_IS_TREE_VIEW_COLUMN (column)); - - model = gtk_tree_view_get_model (tree_view); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - return; - - gtk_tree_model_get (model, &iter, - COLUMN_POINTER, &node, - -1); - - if (node != NULL) - sysprof_callgraph_view_set_node (self, node); -} - -static void -sysprof_callgraph_view_caller_activated (SysprofCallgraphView *self, - GtkTreePath *path, - GtkTreeViewColumn *column, - GtkTreeView *tree_view) -{ - GtkTreeModel *model; - StackNode *node = NULL; - GtkTreeIter iter; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - g_assert (GTK_IS_TREE_VIEW (tree_view)); - g_assert (path != NULL); - g_assert (GTK_IS_TREE_VIEW_COLUMN (column)); - - model = gtk_tree_view_get_model (tree_view); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - return; - - gtk_tree_model_get (model, &iter, - COLUMN_POINTER, &node, - -1); - - if (node != NULL) - sysprof_callgraph_view_set_node (self, node); -} - -static void -sysprof_callgraph_view_tag_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - SysprofCallgraphView *self = data; - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - StackNode *node = NULL; - const gchar *str = NULL; - - if (priv->profile == NULL) - return; - - gtk_tree_model_get (model, iter, COLUMN_POINTER, &node, -1); - - if (node && node->data) - { - GQuark tag; - - tag = sysprof_callgraph_profile_get_tag (priv->profile, GSIZE_TO_POINTER (node->data)); - if (tag != 0) - str = g_quark_to_string (tag); - } - - g_object_set (cell, "text", str, NULL); -} - -static void -sysprof_callgraph_view_real_go_previous (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - StackNode *node; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - node = g_queue_pop_head (priv->history); - - if (NULL != (node = g_queue_peek_head (priv->history))) - sysprof_callgraph_view_set_node (self, node); -} - -static void -descendants_view_move_cursor_cb (GtkTreeView *descendants_view, - GtkMovementStep step, - int direction, - gpointer user_data) -{ - if (step == GTK_MOVEMENT_VISUAL_POSITIONS) - { - GtkTreePath *path; - - gtk_tree_view_get_cursor (descendants_view, &path, NULL); - - if (direction == 1) - { - gtk_tree_view_expand_row (descendants_view, path, FALSE); - g_signal_stop_emission_by_name (descendants_view, "move-cursor"); - } - else if (direction == -1) - { - gtk_tree_view_collapse_row (descendants_view, path); - g_signal_stop_emission_by_name (descendants_view, "move-cursor"); - } - - gtk_tree_path_free (path); - } -} - -static void -copy_tree_view_selection_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - g_autofree gchar *name = NULL; - gchar sstr[16]; - gchar tstr[16]; - GString *str = data; - gdouble self; - gdouble total; - gint depth; - - g_assert (GTK_IS_TREE_MODEL (model)); - g_assert (path != NULL); - g_assert (iter != NULL); - g_assert (str != NULL); - - depth = gtk_tree_path_get_depth (path); - gtk_tree_model_get (model, iter, - COLUMN_NAME, &name, - COLUMN_SELF, &self, - COLUMN_TOTAL, &total, - -1); - - g_snprintf (sstr, sizeof sstr, "%.2lf%%", self); - g_snprintf (tstr, sizeof tstr, "%.2lf%%", total); - - g_string_append_printf (str, "[%8s] [%8s] ", sstr, tstr); - - for (gint i = 1; i < depth; i++) - g_string_append (str, " "); - g_string_append (str, name); - g_string_append_c (str, '\n'); -} - -static void -copy_tree_view_selection (GtkTreeView *tree_view) -{ - g_autoptr(GString) str = NULL; - GtkClipboard *clipboard; - - g_assert (GTK_IS_TREE_VIEW (tree_view)); - - str = g_string_new (" SELF TOTAL FUNCTION\n"); - gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree_view), - copy_tree_view_selection_cb, - str); - - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (tree_view), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text (clipboard, str->str, str->len); -} - -static void -sysprof_callgraph_view_copy_cb (GtkWidget *widget, - SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkWidget *toplevel; - GtkWidget *focus; - - g_assert (GTK_IS_WIDGET (widget)); - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - if (!(toplevel = gtk_widget_get_toplevel (widget)) || - !GTK_IS_WINDOW (toplevel) || - !(focus = gtk_window_get_focus (GTK_WINDOW (toplevel)))) - return; - - if (focus == GTK_WIDGET (priv->descendants_view)) - copy_tree_view_selection (priv->descendants_view); - else if (focus == GTK_WIDGET (priv->callers_view)) - copy_tree_view_selection (priv->callers_view); - else if (focus == GTK_WIDGET (priv->functions_view)) - copy_tree_view_selection (priv->functions_view); -} - -static void -sysprof_callgraph_view_finalize (GObject *object) -{ - SysprofCallgraphView *self = (SysprofCallgraphView *)object; - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_clear_pointer (&priv->history, g_queue_free); - g_clear_object (&priv->profile); - - G_OBJECT_CLASS (sysprof_callgraph_view_parent_class)->finalize (object); -} - -static void -sysprof_callgraph_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - SysprofCallgraphView *self = SYSPROF_CALLGRAPH_VIEW (object); - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - switch (prop_id) - { - case PROP_PROFILE: - g_value_set_object (value, priv->profile); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -sysprof_callgraph_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - SysprofCallgraphView *self = SYSPROF_CALLGRAPH_VIEW (object); - - switch (prop_id) - { - case PROP_PROFILE: - sysprof_callgraph_view_set_profile (self, g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkBindingSet *bindings; - - object_class->finalize = sysprof_callgraph_view_finalize; - object_class->get_property = sysprof_callgraph_view_get_property; - object_class->set_property = sysprof_callgraph_view_set_property; - - klass->go_previous = sysprof_callgraph_view_real_go_previous; - - properties [PROP_PROFILE] = - g_param_spec_object ("profile", - "Profile", - "The callgraph profile to view", - SYSPROF_TYPE_CALLGRAPH_PROFILE, - (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_properties (object_class, N_PROPS, properties); - - signals [GO_PREVIOUS] = - g_signal_new ("go-previous", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (SysprofCallgraphViewClass, go_previous), - NULL, NULL, NULL, G_TYPE_NONE, 0); - - gtk_widget_class_set_template_from_resource (widget_class, - "/org/gnome/sysprof/ui/sysprof-callgraph-view.ui"); - - gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, callers_view); - gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, functions_view); - gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_view); - gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_name_column); - gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, stack); - - bindings = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (bindings, GDK_KEY_Left, GDK_MOD1_MASK, "go-previous", 0); - - g_type_ensure (SYSPROF_TYPE_CELL_RENDERER_PERCENT); -} - -static void -sysprof_callgraph_view_init (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - DzlShortcutController *controller; - GtkTreeSelection *selection; - GtkCellRenderer *cell; - - priv->history = g_queue_new (); - - gtk_widget_init_template (GTK_WIDGET (self)); - - gtk_stack_set_visible_child_name (priv->stack, "empty-state"); - - selection = gtk_tree_view_get_selection (priv->functions_view); - - g_signal_connect_object (selection, - "changed", - G_CALLBACK (sysprof_callgraph_view_function_selection_changed), - self, - G_CONNECT_SWAPPED); - - g_signal_connect_object (priv->descendants_view, - "row-activated", - G_CALLBACK (sysprof_callgraph_view_descendant_activated), - self, - G_CONNECT_SWAPPED); - - g_signal_connect_object (priv->callers_view, - "row-activated", - G_CALLBACK (sysprof_callgraph_view_caller_activated), - self, - G_CONNECT_SWAPPED); - - g_signal_connect (priv->descendants_view, - "move-cursor", - G_CALLBACK (descendants_view_move_cursor_cb), - NULL); - - cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, - "ellipsize", PANGO_ELLIPSIZE_MIDDLE, - "xalign", 0.0f, - NULL); - gtk_tree_view_column_pack_start (priv->descendants_name_column, cell, TRUE); - gtk_tree_view_column_add_attribute (priv->descendants_name_column, cell, "text", 0); - - cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, - "foreground", "#666666", - "scale", PANGO_SCALE_SMALL, - "xalign", 1.0f, - NULL); - gtk_tree_view_column_pack_start (priv->descendants_name_column, cell, FALSE); - gtk_tree_view_column_set_cell_data_func (priv->descendants_name_column, cell, - sysprof_callgraph_view_tag_data_func, - self, NULL); - - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (priv->descendants_view), - GTK_SELECTION_MULTIPLE); - - controller = dzl_shortcut_controller_find (GTK_WIDGET (self)); - - dzl_shortcut_controller_add_command_callback (controller, - "org.gnome.sysprof3.capture.copy", - "c", - DZL_SHORTCUT_PHASE_BUBBLE, - (GtkCallback) sysprof_callgraph_view_copy_cb, - self, - NULL); -} - -typedef struct _Descendant Descendant; - -struct _Descendant -{ - const gchar *name; - guint self; - guint cumulative; - Descendant *parent; - Descendant *siblings; - Descendant *children; -}; - -static void -build_tree_cb (StackLink *trace, - gint size, - gpointer user_data) -{ - Descendant **tree = user_data; - Descendant *parent = NULL; - StackLink *link; - - g_assert (trace != NULL); - g_assert (tree != NULL); - - /* Get last item */ - link = trace; - while (link->next) - link = link->next; - - for (; link != NULL; link = link->prev) - { - const gchar *address = U64_TO_POINTER (link->data); - Descendant *prev = NULL; - Descendant *match = NULL; - - for (match = *tree; match != NULL; match = match->siblings) - { - if (match->name == address) - { - if (prev != NULL) - { - /* Move to front */ - prev->siblings = match->siblings; - match->siblings = *tree; - *tree = match; - } - break; - } - } - - if (match == NULL) - { - /* Have we seen this object further up the tree? */ - for (match = parent; match != NULL; match = match->parent) - { - if (match->name == address) - break; - } - } - - if (match == NULL) - { - match = g_slice_new (Descendant); - match->name = address; - match->cumulative = 0; - match->self = 0; - match->children = NULL; - match->parent = parent; - match->siblings = *tree; - *tree = match; - } - - tree = &match->children; - parent = match; - } - - parent->self += size; - - for (; parent != NULL; parent = parent->parent) - parent->cumulative += size; -} - -static Descendant * -build_tree (StackNode *node) -{ - Descendant *tree = NULL; - - for (; node != NULL; node = node->next) - { - if (node->toplevel) - stack_node_foreach_trace (node, build_tree_cb, &tree); - } - - return tree; -} - -static void -append_to_tree_and_free (SysprofCallgraphView *self, - StackStash *stash, - GtkTreeStore *store, - Descendant *item, - GtkTreeIter *parent) -{ - StackNode *node = NULL; - GtkTreeIter iter; - guint profile_size; - - g_assert (GTK_IS_TREE_STORE (store)); - g_assert (item != NULL); - - profile_size = MAX (1, sysprof_callgraph_view_get_profile_size (self)); - - gtk_tree_store_append (store, &iter, parent); - - node = stack_stash_find_node (stash, (gpointer)item->name); - - gtk_tree_store_set (store, &iter, - COLUMN_NAME, item->name, - COLUMN_SELF, item->self * 100.0 / (gdouble)profile_size, - COLUMN_TOTAL, item->cumulative * 100.0 / (gdouble)profile_size, - COLUMN_POINTER, node, - COLUMN_HITS, (guint)item->cumulative, - -1); - - if (item->siblings != NULL) - append_to_tree_and_free (self, stash, store, item->siblings, parent); - - if (item->children != NULL) - append_to_tree_and_free (self, stash, store, item->children, &iter); - - g_slice_free (Descendant, item); -} - -static void -sysprof_callgraph_view_update_descendants (SysprofCallgraphView *self, - StackNode *node) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeStore *store; - - g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - if (g_queue_peek_head (priv->history) != node) - g_queue_push_head (priv->history, node); - - store = gtk_tree_store_new (5, - G_TYPE_STRING, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE, - G_TYPE_POINTER, - G_TYPE_UINT); - - if (priv->profile != NULL) - { - StackStash *stash; - - stash = sysprof_callgraph_profile_get_stash (priv->profile); - if (stash != NULL) - { - Descendant *tree; - - tree = build_tree (node); - if (tree != NULL) - append_to_tree_and_free (self, stash, store, tree, NULL); - } - } - - gtk_tree_view_set_model (priv->descendants_view, GTK_TREE_MODEL (store)); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COLUMN_TOTAL, GTK_SORT_DESCENDING); - sysprof_callgraph_view_expand_descendants (self); - - g_clear_object (&store); -} - -/** - * sysprof_callgraph_view_screenshot: - * @self: A #SysprofCallgraphView. - * - * This function will generate a text representation of the descendants tree. - * This is useful if you want to include various profiling information in a - * commit message or email. - * - * The text generated will match the current row expansion in the tree view. - * - * Returns: (nullable) (transfer full): A newly allocated string that should be freed - * with g_free(). - */ -gchar * -sysprof_callgraph_view_screenshot (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeView *tree_view; - GtkTreeModel *model; - GtkTreePath *tree_path; - GString *str; - GtkTreeIter iter; - - g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), NULL); - - tree_view = priv->descendants_view; - - if (NULL == (model = gtk_tree_view_get_model (tree_view))) - return NULL; - - /* - * To avoid having to precalculate the deepest visible row, we - * put the timing information at the beginning of the line. - */ - - str = g_string_new (" SELF CUMULATIVE FUNCTION\n"); - tree_path = gtk_tree_path_new_first (); - - for (;;) - { - if (gtk_tree_model_get_iter (model, &iter, tree_path)) - { - guint depth = gtk_tree_path_get_depth (tree_path); - StackNode *node; - gdouble in_self; - gdouble total; - guint i; - - gtk_tree_model_get (model, &iter, - COLUMN_SELF, &in_self, - COLUMN_TOTAL, &total, - COLUMN_POINTER, &node, - -1); - - g_string_append_printf (str, "[% 7.2lf%%] [% 7.2lf%%] ", in_self, total); - - for (i = 0; i < depth; i++) - g_string_append (str, " "); - g_string_append (str, GSIZE_TO_POINTER (node->data)); - g_string_append_c (str, '\n'); - - if (gtk_tree_view_row_expanded (tree_view, tree_path)) - gtk_tree_path_down (tree_path); - else - gtk_tree_path_next (tree_path); - - continue; - } - - if (!gtk_tree_path_up (tree_path) || !gtk_tree_path_get_depth (tree_path)) - break; - - gtk_tree_path_next (tree_path); - } - - gtk_tree_path_free (tree_path); - - return g_string_free (str, FALSE); -} - -guint -sysprof_callgraph_view_get_n_functions (SysprofCallgraphView *self) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - GtkTreeModel *model; - guint ret = 0; - - g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), 0); - - if (NULL != (model = gtk_tree_view_get_model (priv->functions_view))) - ret = gtk_tree_model_iter_n_children (model, NULL); - - return ret; -} - -void -_sysprof_callgraph_view_set_loading (SysprofCallgraphView *self, - gboolean loading) -{ - SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self); - - g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self)); - - if (loading) - priv->loading++; - else - priv->loading--; - - if (priv->loading) - gtk_stack_set_visible_child_name (priv->stack, "loading"); - else - gtk_stack_set_visible_child_name (priv->stack, "callgraph"); -} diff --git a/src/libsysprof-ui/sysprof-callgraph-view.h b/src/libsysprof-ui/sysprof-callgraph-view.h deleted file mode 100644 index 7b0c2ec1..00000000 --- a/src/libsysprof-ui/sysprof-callgraph-view.h +++ /dev/null @@ -1,46 +0,0 @@ -/* sysprof-callgraph-view.h - * - * Copyright 2016-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 - -G_BEGIN_DECLS - -#define SYSPROF_TYPE_CALLGRAPH_VIEW (sysprof_callgraph_view_get_type()) - -G_DECLARE_DERIVABLE_TYPE (SysprofCallgraphView, sysprof_callgraph_view, SYSPROF, CALLGRAPH_VIEW, GtkBin) - -struct _SysprofCallgraphViewClass -{ - GtkBinClass parent_class; - - void (*go_previous) (SysprofCallgraphView *self); -}; - -GtkWidget *sysprof_callgraph_view_new (void); -SysprofCallgraphProfile *sysprof_callgraph_view_get_profile (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_profile (SysprofCallgraphView *self, - SysprofCallgraphProfile *profile); -gchar *sysprof_callgraph_view_screenshot (SysprofCallgraphView *self); -guint sysprof_callgraph_view_get_n_functions (SysprofCallgraphView *self); - -G_END_DECLS diff --git a/src/libsysprof-ui/sysprof-callgraph-view.ui b/src/libsysprof-ui/sysprof-callgraph-view.ui deleted file mode 100644 index e1939e07..00000000 --- a/src/libsysprof-ui/sysprof-callgraph-view.ui +++ /dev/null @@ -1,235 +0,0 @@ - - - diff --git a/src/libsysprof-ui/sysprof-details-view.c b/src/libsysprof-ui/sysprof-details-view.c deleted file mode 100644 index 1f8ca447..00000000 --- a/src/libsysprof-ui/sysprof-details-view.c +++ /dev/null @@ -1,308 +0,0 @@ -/* sysprof-details-view.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 - */ - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#define G_LOG_DOMAIN "sysprof-details-view" - -#include "config.h" - -#include -#include -#include - -#include "sysprof-details-view.h" -#include "sysprof-ui-private.h" - -#define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L) - -struct _SysprofDetailsView -{ - GtkBin parent_instance; - - /* Template Objects */ - DzlThreeGrid *three_grid; - GtkListStore *marks_store; - GtkTreeView *marks_view; - GtkLabel *counters; - GtkLabel *duration; - GtkLabel *filename; - GtkLabel *forks; - GtkLabel *marks; - GtkLabel *processes; - GtkLabel *samples; - GtkLabel *start_time; - GtkLabel *cpu_label; - - guint next_row; -}; - -G_DEFINE_TYPE (SysprofDetailsView, sysprof_details_view, GTK_TYPE_BIN) - -#if GLIB_CHECK_VERSION(2, 56, 0) -# define _g_date_time_new_from_iso8601 g_date_time_new_from_iso8601 -#else -static GDateTime * -_g_date_time_new_from_iso8601 (const gchar *str, - GTimeZone *default_tz) -{ - GTimeVal tv; - - if (g_time_val_from_iso8601 (str, &tv)) - { - g_autoptr(GDateTime) dt = g_date_time_new_from_timeval_utc (&tv); - - if (default_tz) - return g_date_time_to_timezone (dt, default_tz); - else - return g_steal_pointer (&dt); - } - - return NULL; -} -#endif - -static void -sysprof_details_view_finalize (GObject *object) -{ - G_OBJECT_CLASS (sysprof_details_view_parent_class)->finalize (object); -} - -static void -sysprof_details_view_class_init (SysprofDetailsViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->finalize = sysprof_details_view_finalize; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-details-view.ui"); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, counters); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, cpu_label); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, duration); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, filename); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, forks); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks_store); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks_view); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, processes); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, samples); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, start_time); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, three_grid); - - g_type_ensure (DZL_TYPE_THREE_GRID); -} - -static void -sysprof_details_view_init (SysprofDetailsView *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); - - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->marks_view), - GTK_SELECTION_MULTIPLE); - - self->next_row = 8; -} - -GtkWidget * -sysprof_details_view_new (void) -{ - return g_object_new (SYSPROF_TYPE_DETAILS_VIEW, NULL); -} - -static void -update_cpu_info_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - g_autoptr(SysprofDetailsView) self = user_data; - g_autofree gchar *str = NULL; - - g_assert (SYSPROF_IS_DETAILS_VIEW (self)); - g_assert (G_IS_TASK (result)); - - if ((str = g_task_propagate_pointer (G_TASK (result), NULL))) - gtk_label_set_label (self->cpu_label, str); -} - -static gboolean -cpu_info_cb (const SysprofCaptureFrame *frame, - gpointer user_data) -{ - const SysprofCaptureFileChunk *fc = (gpointer)frame; - const gchar *endptr; - const gchar *line; - gchar **str = user_data; - - endptr = (gchar *)fc->data + fc->len; - line = memmem ((gchar *)fc->data, fc->len, "model name", 10); - endptr = memchr (line, '\n', endptr - line); - - if (endptr) - { - gchar *tmp = *str = g_strndup (line, endptr - line); - for (; *tmp && *tmp != ':'; tmp++) - *tmp = ' '; - if (*tmp == ':') - *tmp = ' '; - g_strstrip (*str); - return FALSE; - } - - return TRUE; -} - -static void -sysprof_details_view_update_cpu_info_worker (GTask *task, - gpointer source_object, - gpointer task_data, - GCancellable *cancellable) -{ - SysprofCaptureCursor *cursor = task_data; - gchar *str = NULL; - - g_assert (G_IS_TASK (task)); - g_assert (cursor != NULL); - - sysprof_capture_cursor_foreach (cursor, cpu_info_cb, &str); - g_task_return_pointer (task, g_steal_pointer (&str), g_free); -} - -static void -sysprof_details_view_update_cpu_info (SysprofDetailsView *self, - SysprofCaptureReader *reader) -{ - g_autoptr(SysprofCaptureCursor) cursor = NULL; - g_autoptr(GTask) task = NULL; - - g_assert (SYSPROF_IS_DETAILS_VIEW (self)); - g_assert (reader != NULL); - - cursor = sysprof_capture_cursor_new (reader); - sysprof_capture_cursor_add_condition (cursor, - sysprof_capture_condition_new_where_file ("/proc/cpuinfo")); - - task = g_task_new (NULL, NULL, update_cpu_info_cb, g_object_ref (self)); - g_task_set_task_data (task, - g_steal_pointer (&cursor), - (GDestroyNotify) sysprof_capture_cursor_unref); - g_task_run_in_thread (task, sysprof_details_view_update_cpu_info_worker); -} - -void -sysprof_details_view_set_reader (SysprofDetailsView *self, - SysprofCaptureReader *reader) -{ - g_autoptr(GDateTime) dt = NULL; - g_autoptr(GDateTime) local = NULL; - g_autofree gchar *duration_str = NULL; - const gchar *filename; - const gchar *capture_at; - SysprofCaptureStat st_buf; - gint64 duration; - - g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); - g_return_if_fail (reader != NULL); - - sysprof_details_view_update_cpu_info (self, reader); - - if (!(filename = sysprof_capture_reader_get_filename (reader))) - filename = _("Memory Capture"); - gtk_label_set_label (self->filename, filename); - - if ((capture_at = sysprof_capture_reader_get_time (reader)) && - (dt = _g_date_time_new_from_iso8601 (capture_at, NULL)) && - (local = g_date_time_to_local (dt))) - { - g_autofree gchar *str = g_date_time_format (local, "%x %X"); - gtk_label_set_label (self->start_time, str); - } - - duration = sysprof_capture_reader_get_end_time (reader) - - sysprof_capture_reader_get_start_time (reader); - duration_str = g_strdup_printf (_("%0.4lf seconds"), duration / (gdouble)NSEC_PER_SEC); - gtk_label_set_label (self->duration, duration_str); - - if (sysprof_capture_reader_get_stat (reader, &st_buf)) - { -#define SET_FRAME_COUNT(field, TYPE) \ - G_STMT_START { \ - g_autofree gchar *str = NULL; \ - str = g_strdup_printf ("%"G_GSIZE_FORMAT, st_buf.frame_count[TYPE]); \ - gtk_label_set_label (self->field, str); \ - } G_STMT_END - - SET_FRAME_COUNT (samples, SYSPROF_CAPTURE_FRAME_SAMPLE); - SET_FRAME_COUNT (marks, SYSPROF_CAPTURE_FRAME_MARK); - SET_FRAME_COUNT (processes, SYSPROF_CAPTURE_FRAME_PROCESS); - SET_FRAME_COUNT (forks, SYSPROF_CAPTURE_FRAME_FORK); - SET_FRAME_COUNT (counters, SYSPROF_CAPTURE_FRAME_CTRSET); - -#undef SET_FRAME_COUNT - } -} - -void -sysprof_details_view_add_item (SysprofDetailsView *self, - GtkWidget *left, - GtkWidget *center) -{ - g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); - g_return_if_fail (!left || GTK_IS_WIDGET (left)); - g_return_if_fail (!center || GTK_IS_WIDGET (center)); - - if (left) - gtk_container_add_with_properties (GTK_CONTAINER (self->three_grid), left, - "row", self->next_row, - "column", DZL_THREE_GRID_COLUMN_LEFT, - NULL); - - if (center) - gtk_container_add_with_properties (GTK_CONTAINER (self->three_grid), center, - "row", self->next_row, - "column", DZL_THREE_GRID_COLUMN_CENTER, - NULL); - - self->next_row++; -} - -void -sysprof_details_view_add_mark (SysprofDetailsView *self, - const gchar *mark, - gint64 min, - gint64 max, - gint64 avg, - gint64 hits) -{ - GtkTreeIter iter; - - g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); - - gtk_list_store_append (self->marks_store, &iter); - gtk_list_store_set (self->marks_store, &iter, - 0, mark, - 1, min ? _sysprof_format_duration (min) : "—", - 2, max ? _sysprof_format_duration (max) : "—", - 3, avg ? _sysprof_format_duration (avg) : "—", - 4, hits, - -1); -} diff --git a/src/libsysprof-ui/sysprof-details-view.h b/src/libsysprof-ui/sysprof-details-view.h deleted file mode 100644 index c512298b..00000000 --- a/src/libsysprof-ui/sysprof-details-view.h +++ /dev/null @@ -1,45 +0,0 @@ -/* sysprof-details-view.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 - -G_BEGIN_DECLS - -#define SYSPROF_TYPE_DETAILS_VIEW (sysprof_details_view_get_type()) - -G_DECLARE_FINAL_TYPE (SysprofDetailsView, sysprof_details_view, SYSPROF, DETAILS_VIEW, GtkBin) - -GtkWidget *sysprof_details_view_new (void); -void sysprof_details_view_set_reader (SysprofDetailsView *self, - SysprofCaptureReader *reader); -void sysprof_details_view_add_mark (SysprofDetailsView *self, - const gchar *mark, - gint64 min, - gint64 max, - gint64 avg, - gint64 hits); -void sysprof_details_view_add_item (SysprofDetailsView *self, - GtkWidget *left, - GtkWidget *center); - -G_END_DECLS diff --git a/src/libsysprof-ui/sysprof-details-view.ui b/src/libsysprof-ui/sysprof-details-view.ui deleted file mode 100644 index f25845f7..00000000 --- a/src/libsysprof-ui/sysprof-details-view.ui +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/libsysprof-ui/sysprof-empty-state-view.c b/src/libsysprof-ui/sysprof-empty-state-view.c deleted file mode 100644 index 9b878d2a..00000000 --- a/src/libsysprof-ui/sysprof-empty-state-view.c +++ /dev/null @@ -1,219 +0,0 @@ -/* sysprof-empty-state-view.c - * - * Copyright 2016-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-empty-state-view" - -#include "config.h" - -#include - -#include "sysprof-empty-state-view.h" - -typedef struct -{ - GtkImage *image; - GtkLabel *title; - GtkLabel *subtitle; -} SysprofEmptyStateViewPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (SysprofEmptyStateView, sysprof_empty_state_view, GTK_TYPE_BIN) - -enum { - PROP_0, - PROP_TITLE, - PROP_SUBTITLE, - PROP_ICON_NAME, - N_PROPS -}; - -static GParamSpec *properties [N_PROPS]; - -GtkWidget * -sysprof_empty_state_view_new (void) -{ - return g_object_new (SYSPROF_TYPE_EMPTY_STATE_VIEW, NULL); -} - -static gboolean -sysprof_empty_state_view_action (GtkWidget *widget, - const gchar *prefix, - const gchar *action_name, - GVariant *parameter) -{ - GtkWidget *toplevel; - GApplication *app; - GActionGroup *group = NULL; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - g_return_val_if_fail (prefix, FALSE); - g_return_val_if_fail (action_name, FALSE); - - app = g_application_get_default (); - toplevel = gtk_widget_get_toplevel (widget); - - while ((group == NULL) && (widget != NULL)) - { - group = gtk_widget_get_action_group (widget, prefix); - widget = gtk_widget_get_parent (widget); - } - - if (!group && g_str_equal (prefix, "win") && G_IS_ACTION_GROUP (toplevel)) - group = G_ACTION_GROUP (toplevel); - - if (!group && g_str_equal (prefix, "app") && G_IS_ACTION_GROUP (app)) - group = G_ACTION_GROUP (app); - - if (group && g_action_group_has_action (group, action_name)) - { - g_action_group_activate_action (group, action_name, parameter); - return TRUE; - } - - if (parameter && g_variant_is_floating (parameter)) - { - parameter = g_variant_ref_sink (parameter); - g_variant_unref (parameter); - } - - g_warning ("Failed to locate action %s.%s", prefix, action_name); - - return FALSE; -} - -static gboolean -sysprof_empty_state_view_activate_link (SysprofEmptyStateView *self, - const gchar *uri, - GtkLabel *label) -{ - g_assert (SYSPROF_IS_EMPTY_STATE_VIEW (self)); - g_assert (uri != NULL); - g_assert (GTK_IS_LABEL (label)); - - if (g_str_has_prefix (uri, "action://")) - { - g_autofree gchar *full_name = NULL; - g_autofree gchar *action_name = NULL; - g_autofree gchar *group_name = NULL; - g_autoptr(GVariant) param = NULL; - g_autoptr(GError) error = NULL; - - uri += strlen ("action://"); - - if (g_action_parse_detailed_name (uri, &full_name, ¶m, &error)) - { - const gchar *dot = strchr (full_name, '.'); - - if (param != NULL && g_variant_is_floating (param)) - param = g_variant_ref_sink (param); - - if (dot == NULL) - return FALSE; - - group_name = g_strndup (full_name, dot - full_name); - action_name = g_strdup (++dot); - - sysprof_empty_state_view_action (GTK_WIDGET (self), - group_name, - action_name, - param); - - return TRUE; - } - else - g_warning ("%s", error->message); - } - - return FALSE; -} - -static void -sysprof_empty_state_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - SysprofEmptyStateView *self = SYSPROF_EMPTY_STATE_VIEW (object); - SysprofEmptyStateViewPrivate *priv = sysprof_empty_state_view_get_instance_private (self); - - switch (prop_id) - { - case PROP_ICON_NAME: - g_object_set (priv->image, - "icon-name", g_value_get_string (value), - NULL); - break; - - case PROP_TITLE: - gtk_label_set_label (priv->title, g_value_get_string (value)); - break; - - case PROP_SUBTITLE: - gtk_label_set_label (priv->subtitle, g_value_get_string (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -sysprof_empty_state_view_class_init (SysprofEmptyStateViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->set_property = sysprof_empty_state_view_set_property; - - properties [PROP_ICON_NAME] = - g_param_spec_string ("icon-name", NULL, NULL, - NULL, - (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); - - properties [PROP_TITLE] = - g_param_spec_string ("title", NULL, NULL, - NULL, - (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); - - properties [PROP_SUBTITLE] = - g_param_spec_string ("subtitle", NULL, NULL, - NULL, - (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_properties (object_class, N_PROPS, properties); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-empty-state-view.ui"); - gtk_widget_class_bind_template_child_private (widget_class, SysprofEmptyStateView, subtitle); - gtk_widget_class_bind_template_child_private (widget_class, SysprofEmptyStateView, title); - gtk_widget_class_bind_template_child_private (widget_class, SysprofEmptyStateView, image); -} - -static void -sysprof_empty_state_view_init (SysprofEmptyStateView *self) -{ - SysprofEmptyStateViewPrivate *priv = sysprof_empty_state_view_get_instance_private (self); - - gtk_widget_init_template (GTK_WIDGET (self)); - - g_signal_connect_object (priv->subtitle, - "activate-link", - G_CALLBACK (sysprof_empty_state_view_activate_link), - self, - G_CONNECT_SWAPPED); -} diff --git a/src/libsysprof-ui/sysprof-empty-state-view.h b/src/libsysprof-ui/sysprof-empty-state-view.h deleted file mode 100644 index 4c15aecf..00000000 --- a/src/libsysprof-ui/sysprof-empty-state-view.h +++ /dev/null @@ -1,41 +0,0 @@ -/* sysprof-empty-state-view.h - * - * Copyright 2016-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 - -G_BEGIN_DECLS - -#define SYSPROF_TYPE_EMPTY_STATE_VIEW (sysprof_empty_state_view_get_type()) - -G_DECLARE_DERIVABLE_TYPE (SysprofEmptyStateView, sysprof_empty_state_view, SYSPROF, EMPTY_STATE_VIEW, GtkBin) - -struct _SysprofEmptyStateViewClass -{ - GtkBinClass parent; - - gpointer padding[4]; -}; - -GtkWidget *sysprof_empty_state_view_new (void); - -G_END_DECLS diff --git a/src/libsysprof-ui/sysprof-empty-state-view.ui b/src/libsysprof-ui/sysprof-empty-state-view.ui deleted file mode 100644 index 1e26551c..00000000 --- a/src/libsysprof-ui/sysprof-empty-state-view.ui +++ /dev/null @@ -1,64 +0,0 @@ - - - - diff --git a/src/libsysprof-ui/sysprof-logs-view.c b/src/libsysprof-ui/sysprof-logs-view.c deleted file mode 100644 index a6fed734..00000000 --- a/src/libsysprof-ui/sysprof-logs-view.c +++ /dev/null @@ -1,112 +0,0 @@ -/* sysprof-logs-view.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-logs-view" - -#include "config.h" - -#include "sysprof-log-model.h" -#include "sysprof-logs-view.h" - -struct _SysprofLogsView -{ - GtkBin parent_instance; - - GtkTreeView *tree_view; -}; - -G_DEFINE_TYPE (SysprofLogsView, sysprof_logs_view, GTK_TYPE_BIN) - -static void -sysprof_logs_view_class_init (SysprofLogsViewClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-logs-view.ui"); - gtk_widget_class_bind_template_child (widget_class, SysprofLogsView, tree_view); -} - -static void -sysprof_logs_view_init (SysprofLogsView *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); -} - -static void -sysprof_logs_view_load_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - g_autoptr(SysprofLogModel) model = NULL; - g_autoptr(GTask) task = user_data; - g_autoptr(GError) error = NULL; - - g_assert (G_IS_ASYNC_RESULT (result)); - g_assert (G_IS_TASK (task)); - - if (!(model = sysprof_log_model_new_finish (result, &error))) - { - g_task_return_error (task, g_steal_pointer (&error)); - } - else - { - SysprofLogsView *self; - - self = g_task_get_source_object (task); - gtk_tree_view_set_model (GTK_TREE_VIEW (self->tree_view), GTK_TREE_MODEL (model)); - g_task_return_boolean (task, TRUE); - } -} - -void -sysprof_logs_view_load_async (SysprofLogsView *self, - SysprofCaptureReader *reader, - SysprofSelection *selection, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - g_autoptr(GTask) task = NULL; - - g_return_if_fail (SYSPROF_IS_LOGS_VIEW (self)); - g_return_if_fail (reader != NULL); - g_return_if_fail (!selection || SYSPROF_IS_SELECTION (selection)); - g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); - - task = g_task_new (self, cancellable, callback, user_data); - g_task_set_source_tag (task, sysprof_logs_view_load_async); - - sysprof_log_model_new_async (reader, - selection, - cancellable, - sysprof_logs_view_load_cb, - g_steal_pointer (&task)); -} - -gboolean -sysprof_logs_view_load_finish (SysprofLogsView *self, - GAsyncResult *result, - GError **error) -{ - g_return_val_if_fail (SYSPROF_IS_LOGS_VIEW (self), FALSE); - g_return_val_if_fail (G_IS_TASK (result), FALSE); - - return g_task_propagate_boolean (G_TASK (result), error); -} diff --git a/src/libsysprof-ui/sysprof-logs-view.h b/src/libsysprof-ui/sysprof-logs-view.h deleted file mode 100644 index 5ff21356..00000000 --- a/src/libsysprof-ui/sysprof-logs-view.h +++ /dev/null @@ -1,43 +0,0 @@ -/* sysprof-logs-view.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 "sysprof-log-model.h" - -G_BEGIN_DECLS - -#define SYSPROF_TYPE_LOGS_VIEW (sysprof_logs_view_get_type()) - -G_DECLARE_FINAL_TYPE (SysprofLogsView, sysprof_logs_view, SYSPROF, LOGS_VIEW, GtkBin) - -void sysprof_logs_view_load_async (SysprofLogsView *self, - SysprofCaptureReader *reader, - SysprofSelection *selection, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean sysprof_logs_view_load_finish (SysprofLogsView *self, - GAsyncResult *result, - GError **error); - -G_END_DECLS diff --git a/src/libsysprof-ui/sysprof-logs-view.ui b/src/libsysprof-ui/sysprof-logs-view.ui deleted file mode 100644 index 5a5a386f..00000000 --- a/src/libsysprof-ui/sysprof-logs-view.ui +++ /dev/null @@ -1,75 +0,0 @@ - - - -