mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
sysprof: allow creation of process dialog from table
This commit is contained in:
@ -57,29 +57,63 @@ format_number (gpointer unused,
|
|||||||
return g_strdup_printf ("%'u", number);
|
return g_strdup_printf ("%'u", number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_dialog (GtkNative *transient_for,
|
||||||
|
SysprofDocumentProcess *process)
|
||||||
|
{
|
||||||
|
SysprofProcessDialog *dialog;
|
||||||
|
g_autofree char *title = NULL;
|
||||||
|
|
||||||
|
g_assert (!transient_for || GTK_IS_NATIVE (transient_for));
|
||||||
|
g_assert (SYSPROF_IS_DOCUMENT_PROCESS (process));
|
||||||
|
|
||||||
|
title = sysprof_document_process_dup_title (process);
|
||||||
|
|
||||||
|
dialog = g_object_new (SYSPROF_TYPE_PROCESS_DIALOG,
|
||||||
|
"process", process,
|
||||||
|
"transient-for", transient_for,
|
||||||
|
"title", title,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_window_present (GTK_WINDOW (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activate_layer_item_cb (GtkListItem *list_item,
|
activate_layer_item_cb (GtkListItem *list_item,
|
||||||
SysprofChartLayer *layer,
|
SysprofChartLayer *layer,
|
||||||
SysprofDocumentProcess *process,
|
SysprofDocumentProcess *process,
|
||||||
SysprofChart *chart)
|
SysprofChart *chart)
|
||||||
{
|
{
|
||||||
SysprofProcessDialog *dialog;
|
|
||||||
g_autofree char *title = NULL;
|
GtkNative *transient_for;
|
||||||
|
|
||||||
g_assert (GTK_IS_LIST_ITEM (list_item));
|
g_assert (GTK_IS_LIST_ITEM (list_item));
|
||||||
g_assert (SYSPROF_IS_CHART_LAYER (layer));
|
g_assert (SYSPROF_IS_CHART_LAYER (layer));
|
||||||
g_assert (SYSPROF_IS_DOCUMENT_PROCESS (process));
|
g_assert (SYSPROF_IS_DOCUMENT_PROCESS (process));
|
||||||
g_assert (SYSPROF_IS_CHART (chart));
|
g_assert (SYSPROF_IS_CHART (chart));
|
||||||
|
|
||||||
title = sysprof_document_process_dup_title (process);
|
transient_for = gtk_widget_get_native (GTK_WIDGET (chart));
|
||||||
|
|
||||||
dialog = g_object_new (SYSPROF_TYPE_PROCESS_DIALOG,
|
show_dialog (transient_for, process);
|
||||||
"process", process,
|
}
|
||||||
"transient-for", gtk_widget_get_root (GTK_WIDGET (chart)),
|
|
||||||
"title", title,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
static void
|
||||||
|
process_table_activate_cb (SysprofProcessesSection *self,
|
||||||
|
guint position,
|
||||||
|
GtkColumnView *column_view)
|
||||||
|
{
|
||||||
|
g_autoptr(SysprofDocumentProcess) process = NULL;
|
||||||
|
GtkSelectionModel *model;
|
||||||
|
GtkNative *transient_for;
|
||||||
|
|
||||||
|
g_assert (SYSPROF_IS_PROCESSES_SECTION (self));
|
||||||
|
g_assert (GTK_IS_COLUMN_VIEW (column_view));
|
||||||
|
|
||||||
|
model = gtk_column_view_get_model (column_view);
|
||||||
|
process = g_list_model_get_item (G_LIST_MODEL (model), position);
|
||||||
|
transient_for = gtk_widget_get_native (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
show_dialog (transient_for, process);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -105,6 +139,7 @@ sysprof_processes_section_class_init (SysprofProcessesSectionClass *klass)
|
|||||||
gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, list_view);
|
gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, list_view);
|
||||||
gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, time_column);
|
gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, time_column);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, activate_layer_item_cb);
|
gtk_widget_class_bind_template_callback (widget_class, activate_layer_item_cb);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, process_table_activate_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
||||||
|
|
||||||
g_type_ensure (SYSPROF_TYPE_CHART);
|
g_type_ensure (SYSPROF_TYPE_CHART);
|
||||||
|
|||||||
@ -179,6 +179,7 @@
|
|||||||
<style>
|
<style>
|
||||||
<class name="data-table"/>
|
<class name="data-table"/>
|
||||||
</style>
|
</style>
|
||||||
|
<signal name="activate" handler="process_table_activate_cb" swapped="true"/>
|
||||||
<property name="model">
|
<property name="model">
|
||||||
<object class="GtkNoSelection">
|
<object class="GtkNoSelection">
|
||||||
<property name="model">
|
<property name="model">
|
||||||
@ -311,6 +312,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkColumnViewColumn" id="cmdline_column">
|
<object class="GtkColumnViewColumn" id="cmdline_column">
|
||||||
<property name="title" translatable="yes">Command Line</property>
|
<property name="title" translatable="yes">Command Line</property>
|
||||||
|
<property name="expand">true</property>
|
||||||
<property name="sorter">
|
<property name="sorter">
|
||||||
<object class="GtkStringSorter">
|
<object class="GtkStringSorter">
|
||||||
<property name="expression">
|
<property name="expression">
|
||||||
|
|||||||
Reference in New Issue
Block a user