mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 06:30:54 +00:00
sysprof: allow sorting embedded files by path
This commit is contained in:
@ -24,9 +24,12 @@
|
|||||||
|
|
||||||
struct _SysprofFilesDialog
|
struct _SysprofFilesDialog
|
||||||
{
|
{
|
||||||
AdwWindow parent_instance;
|
AdwWindow parent_instance;
|
||||||
|
|
||||||
SysprofDocument *document;
|
SysprofDocument *document;
|
||||||
|
|
||||||
|
GtkColumnView *column_view;
|
||||||
|
GtkColumnViewColumn *path_column;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -42,7 +45,7 @@ static GParamSpec *properties [N_PROPS];
|
|||||||
static void
|
static void
|
||||||
sysprof_files_dialog_activate_cb (SysprofFilesDialog *self,
|
sysprof_files_dialog_activate_cb (SysprofFilesDialog *self,
|
||||||
guint position,
|
guint position,
|
||||||
GtkListView *list_view)
|
GtkColumnView *view)
|
||||||
{
|
{
|
||||||
g_autoptr(SysprofDocumentFile) file = NULL;
|
g_autoptr(SysprofDocumentFile) file = NULL;
|
||||||
g_autoptr(GtkTextBuffer) buffer = NULL;
|
g_autoptr(GtkTextBuffer) buffer = NULL;
|
||||||
@ -58,8 +61,9 @@ sysprof_files_dialog_activate_cb (SysprofFilesDialog *self,
|
|||||||
gsize len;
|
gsize len;
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_FILES_DIALOG (self));
|
g_assert (SYSPROF_IS_FILES_DIALOG (self));
|
||||||
|
g_assert (GTK_IS_COLUMN_VIEW (view));
|
||||||
|
|
||||||
model = gtk_list_view_get_model (list_view);
|
model = gtk_column_view_get_model (view);
|
||||||
file = g_list_model_get_item (G_LIST_MODEL (model), position);
|
file = g_list_model_get_item (G_LIST_MODEL (model), position);
|
||||||
bytes = sysprof_document_file_dup_bytes (file);
|
bytes = sysprof_document_file_dup_bytes (file);
|
||||||
str = (const char *)g_bytes_get_data (bytes, &len);
|
str = (const char *)g_bytes_get_data (bytes, &len);
|
||||||
@ -169,12 +173,16 @@ sysprof_files_dialog_class_init (SysprofFilesDialogClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-files-dialog.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-files-dialog.ui");
|
||||||
gtk_widget_class_bind_template_callback (widget_class, sysprof_files_dialog_activate_cb);
|
gtk_widget_class_bind_template_callback (widget_class, sysprof_files_dialog_activate_cb);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, SysprofFilesDialog, column_view);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, SysprofFilesDialog, path_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_files_dialog_init (SysprofFilesDialog *self)
|
sysprof_files_dialog_init (SysprofFilesDialog *self)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
gtk_column_view_sort_by_column (self->column_view, self->path_column, GTK_SORT_ASCENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
|||||||
@ -18,21 +18,40 @@
|
|||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListView">
|
<object class="GtkColumnView" id="column_view">
|
||||||
<signal name="activate" handler="sysprof_files_dialog_activate_cb" swapped="true"/>
|
<signal name="activate" handler="sysprof_files_dialog_activate_cb" swapped="true"/>
|
||||||
<property name="show-separators">true</property>
|
<property name="show-column-separators">true</property>
|
||||||
|
<property name="show-row-separators">true</property>
|
||||||
<property name="model">
|
<property name="model">
|
||||||
<object class="GtkNoSelection">
|
<object class="GtkNoSelection">
|
||||||
<binding name="model">
|
<property name="model">
|
||||||
<lookup name="files" type="SysprofDocument">
|
<object class="GtkSortListModel">
|
||||||
<lookup name="document">SysprofFilesDialog</lookup>
|
<binding name="sorter">
|
||||||
</lookup>
|
<lookup name="sorter">column_view</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
|
<binding name="model">
|
||||||
|
<lookup name="files" type="SysprofDocument">
|
||||||
|
<lookup name="document">SysprofFilesDialog</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<property name="factory">
|
<child>
|
||||||
<object class="GtkBuilderListItemFactory">
|
<object class="GtkColumnViewColumn" id="path_column">
|
||||||
<property name="bytes"><![CDATA[
|
<property name="title" translatable="yes">Path</property>
|
||||||
|
<property name="expand">true</property>
|
||||||
|
<property name="sorter">
|
||||||
|
<object class="GtkStringSorter">
|
||||||
|
<property name="expression">
|
||||||
|
<lookup name="path" type="SysprofDocumentFile"/>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<template class="GtkListItem">
|
<template class="GtkListItem">
|
||||||
@ -53,9 +72,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
]]>
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user