mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
sysprof: categorize sidebar sections
This commit is contained in:
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
char *category;
|
||||||
char *title;
|
char *title;
|
||||||
SysprofSession *session;
|
SysprofSession *session;
|
||||||
} SysprofSectionPrivate;
|
} SysprofSectionPrivate;
|
||||||
@ -34,6 +35,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SysprofSection, sysprof_section, GTK_TYPE_W
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_SESSION,
|
PROP_SESSION,
|
||||||
|
PROP_CATEGORY,
|
||||||
PROP_TITLE,
|
PROP_TITLE,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
@ -52,6 +54,7 @@ sysprof_section_dispose (GObject *object)
|
|||||||
|
|
||||||
g_clear_object (&priv->session);
|
g_clear_object (&priv->session);
|
||||||
g_clear_pointer (&priv->title, g_free);
|
g_clear_pointer (&priv->title, g_free);
|
||||||
|
g_clear_pointer (&priv->category, g_free);
|
||||||
|
|
||||||
G_OBJECT_CLASS (sysprof_section_parent_class)->dispose (object);
|
G_OBJECT_CLASS (sysprof_section_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -70,6 +73,10 @@ sysprof_section_get_property (GObject *object,
|
|||||||
g_value_set_object (value, sysprof_section_get_session (self));
|
g_value_set_object (value, sysprof_section_get_session (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_CATEGORY:
|
||||||
|
g_value_set_string (value, sysprof_section_get_category (self));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_TITLE:
|
case PROP_TITLE:
|
||||||
g_value_set_string (value, sysprof_section_get_title (self));
|
g_value_set_string (value, sysprof_section_get_title (self));
|
||||||
break;
|
break;
|
||||||
@ -93,6 +100,10 @@ sysprof_section_set_property (GObject *object,
|
|||||||
sysprof_section_set_session (self, g_value_get_object (value));
|
sysprof_section_set_session (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_CATEGORY:
|
||||||
|
sysprof_section_set_category (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_TITLE:
|
case PROP_TITLE:
|
||||||
sysprof_section_set_title (self, g_value_get_string (value));
|
sysprof_section_set_title (self, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
@ -122,6 +133,11 @@ sysprof_section_class_init (SysprofSectionClass *klass)
|
|||||||
NULL,
|
NULL,
|
||||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties[PROP_CATEGORY] =
|
||||||
|
g_param_spec_string ("category", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||||
@ -176,3 +192,25 @@ sysprof_section_set_title (SysprofSection *self,
|
|||||||
if (g_set_str (&priv->title, title))
|
if (g_set_str (&priv->title, title))
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_section_get_category (SysprofSection *self)
|
||||||
|
{
|
||||||
|
SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_SECTION (self), NULL);
|
||||||
|
|
||||||
|
return priv->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sysprof_section_set_category (SysprofSection *self,
|
||||||
|
const char *category)
|
||||||
|
{
|
||||||
|
SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_if_fail (SYSPROF_IS_SECTION (self));
|
||||||
|
|
||||||
|
if (g_set_str (&priv->category, category))
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CATEGORY]);
|
||||||
|
}
|
||||||
|
|||||||
@ -35,11 +35,14 @@ struct _SysprofSectionClass
|
|||||||
GtkWidgetClass parent_class;
|
GtkWidgetClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
SysprofSession *sysprof_section_get_session (SysprofSection *self);
|
SysprofSession *sysprof_section_get_session (SysprofSection *self);
|
||||||
void sysprof_section_set_session (SysprofSection *self,
|
void sysprof_section_set_session (SysprofSection *self,
|
||||||
SysprofSession *session);
|
SysprofSession *session);
|
||||||
const char *sysprof_section_get_title (SysprofSection *self);
|
const char *sysprof_section_get_category (SysprofSection *self);
|
||||||
void sysprof_section_set_title (SysprofSection *self,
|
void sysprof_section_set_category (SysprofSection *self,
|
||||||
const char *title);
|
const char *category);
|
||||||
|
const char *sysprof_section_get_title (SysprofSection *self);
|
||||||
|
void sysprof_section_set_title (SysprofSection *self,
|
||||||
|
const char *title);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -112,6 +112,24 @@ list_box_row_activated_cb (SysprofSidebar *self,
|
|||||||
gtk_stack_set_visible_child (stack, GTK_WIDGET (section));
|
gtk_stack_set_visible_child (stack, GTK_WIDGET (section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_sidebar_header_func (GtkListBoxRow *row,
|
||||||
|
GtkListBoxRow *before_row,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
SysprofSection *section;
|
||||||
|
SysprofSection *before_section;
|
||||||
|
|
||||||
|
if (before_row == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((section = g_object_get_data (G_OBJECT (row), "SECTION")) &&
|
||||||
|
(before_section = g_object_get_data (G_OBJECT (before_row), "SECTION")) &&
|
||||||
|
g_strcmp0 (sysprof_section_get_category (section),
|
||||||
|
sysprof_section_get_category (before_section)) != 0)
|
||||||
|
gtk_list_box_row_set_header (row, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_sidebar_dispose (GObject *object)
|
sysprof_sidebar_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
@ -203,4 +221,8 @@ sysprof_sidebar_init (SysprofSidebar *self)
|
|||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
gtk_list_box_set_header_func (self->list_box,
|
||||||
|
sysprof_sidebar_header_func,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,6 +99,7 @@
|
|||||||
<property name="vexpand">true</property>
|
<property name="vexpand">true</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofSamplesSection">
|
<object class="SysprofSamplesSection">
|
||||||
|
<property name="category">callgraph</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
@ -106,6 +107,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofLogsSection">
|
<object class="SysprofLogsSection">
|
||||||
|
<property name="category">processes</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
@ -113,6 +115,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofMarksSection">
|
<object class="SysprofMarksSection">
|
||||||
|
<property name="category">processes</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
@ -120,6 +123,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofProcessesSection">
|
<object class="SysprofProcessesSection">
|
||||||
|
<property name="category">processes</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
@ -127,6 +131,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofFilesSection">
|
<object class="SysprofFilesSection">
|
||||||
|
<property name="category">auxiliary</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
@ -134,6 +139,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="SysprofMetadataSection">
|
<object class="SysprofMetadataSection">
|
||||||
|
<property name="category">auxiliary</property>
|
||||||
<binding name="session">
|
<binding name="session">
|
||||||
<lookup name="session">SysprofWindow</lookup>
|
<lookup name="session">SysprofWindow</lookup>
|
||||||
</binding>
|
</binding>
|
||||||
|
|||||||
Reference in New Issue
Block a user