mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Merge branch 'tintou/sysprof-visualizer-group-header-no-gdata' into 'master'
libsysprof-ui: Avoid to rely on g_object_set_data to associate header and group See merge request GNOME/sysprof!64
This commit is contained in:
@ -27,16 +27,26 @@
|
||||
#include "sysprof-visualizer.h"
|
||||
#include "sysprof-visualizer-group.h"
|
||||
#include "sysprof-visualizer-group-header.h"
|
||||
#include "sysprof-visualizer-group-private.h"
|
||||
|
||||
struct _SysprofVisualizerGroupHeader
|
||||
{
|
||||
GtkListBoxRow parent_instance;
|
||||
|
||||
SysprofVisualizerGroup *group;
|
||||
GtkBox *box;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (SysprofVisualizerGroupHeader, sysprof_visualizer_group_header, GTK_TYPE_LIST_BOX_ROW)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_GROUP,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_visualizer_group_header_dispose (GObject *object)
|
||||
{
|
||||
@ -51,6 +61,44 @@ sysprof_visualizer_group_header_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (sysprof_visualizer_group_header_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_visualizer_group_header_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofVisualizerGroupHeader *self = SYSPROF_VISUALIZER_GROUP_HEADER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_GROUP:
|
||||
g_value_set_object (value, _sysprof_visualizer_group_header_get_group (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_visualizer_group_header_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofVisualizerGroupHeader *self = SYSPROF_VISUALIZER_GROUP_HEADER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_GROUP:
|
||||
self->group = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_visualizer_group_header_class_init (SysprofVisualizerGroupHeaderClass *klass)
|
||||
{
|
||||
@ -58,6 +106,17 @@ sysprof_visualizer_group_header_class_init (SysprofVisualizerGroupHeaderClass *k
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = sysprof_visualizer_group_header_dispose;
|
||||
object_class->get_property = sysprof_visualizer_group_header_get_property;
|
||||
object_class->set_property = sysprof_visualizer_group_header_set_property;
|
||||
|
||||
properties [PROP_GROUP] =
|
||||
g_param_spec_object ("group",
|
||||
"Group",
|
||||
"The group",
|
||||
SYSPROF_TYPE_VISUALIZER_GROUP,
|
||||
(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_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
@ -79,7 +138,6 @@ _sysprof_visualizer_group_header_add_row (SysprofVisualizerGroupHeader *self,
|
||||
GMenuModel *menu,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *group;
|
||||
GtkWidget *sibling;
|
||||
GtkBox *box;
|
||||
|
||||
@ -125,9 +183,7 @@ _sysprof_visualizer_group_header_add_row (SysprofVisualizerGroupHeader *self,
|
||||
gtk_size_group_add_widget (size_group, GTK_WIDGET (box));
|
||||
}
|
||||
|
||||
group = gtk_widget_get_ancestor (widget, SYSPROF_TYPE_VISUALIZER_GROUP);
|
||||
|
||||
if (position == 0 && sysprof_visualizer_group_get_has_page (SYSPROF_VISUALIZER_GROUP (group)))
|
||||
if (position == 0 && sysprof_visualizer_group_get_has_page (self->group))
|
||||
{
|
||||
GtkImage *image;
|
||||
|
||||
@ -169,7 +225,17 @@ _sysprof_visualizer_group_header_add_row (SysprofVisualizerGroupHeader *self,
|
||||
}
|
||||
|
||||
SysprofVisualizerGroupHeader *
|
||||
_sysprof_visualizer_group_header_new (void)
|
||||
_sysprof_visualizer_group_header_new (SysprofVisualizerGroup *group)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_VISUALIZER_GROUP_HEADER, NULL);
|
||||
return g_object_new (SYSPROF_TYPE_VISUALIZER_GROUP_HEADER,
|
||||
"group", group,
|
||||
NULL);
|
||||
}
|
||||
|
||||
SysprofVisualizerGroup *
|
||||
_sysprof_visualizer_group_header_get_group (SysprofVisualizerGroupHeader *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_GROUP_HEADER(self), NULL);
|
||||
|
||||
return self->group;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ G_BEGIN_DECLS
|
||||
|
||||
void _sysprof_visualizer_group_set_reader (SysprofVisualizerGroup *self,
|
||||
SysprofCaptureReader *reader);
|
||||
SysprofVisualizerGroupHeader *_sysprof_visualizer_group_header_new (void);
|
||||
SysprofVisualizerGroupHeader *_sysprof_visualizer_group_header_new (SysprofVisualizerGroup *group);
|
||||
void _sysprof_visualizer_group_header_add_row (SysprofVisualizerGroupHeader *self,
|
||||
guint position,
|
||||
const gchar *title,
|
||||
@ -37,6 +37,7 @@ void _sysprof_visualizer_group_header_add_row (Syspr
|
||||
GtkWidget *row);
|
||||
void _sysprof_visualizer_group_header_remove_row (SysprofVisualizerGroupHeader *self,
|
||||
guint row);
|
||||
SysprofVisualizerGroup *_sysprof_visualizer_group_header_get_group (SysprofVisualizerGroupHeader *self);
|
||||
void _sysprof_visualizer_group_set_header (SysprofVisualizerGroup *self,
|
||||
SysprofVisualizerGroupHeader *header);
|
||||
|
||||
|
||||
@ -337,8 +337,7 @@ sysprof_visualizers_frame_add_group (SysprofVisualizersFrame *self,
|
||||
|
||||
gtk_list_box_insert (self->visualizers, GTK_WIDGET (group), pos);
|
||||
|
||||
header = _sysprof_visualizer_group_header_new ();
|
||||
g_object_set_data (G_OBJECT (header), "VISUALIZER_GROUP", group);
|
||||
header = _sysprof_visualizer_group_header_new (group);
|
||||
gtk_list_box_insert (self->groups, GTK_WIDGET (header), pos);
|
||||
_sysprof_visualizer_group_set_header (group, header);
|
||||
gtk_widget_show (GTK_WIDGET (header));
|
||||
@ -367,7 +366,7 @@ sysprof_visualizers_frame_group_activated_cb (SysprofVisualizersFrame *self
|
||||
g_assert (SYSPROF_IS_VISUALIZERS_FRAME (self));
|
||||
g_assert (SYSPROF_IS_VISUALIZER_GROUP_HEADER (row));
|
||||
|
||||
group = g_object_get_data (G_OBJECT (row), "VISUALIZER_GROUP");
|
||||
group = _sysprof_visualizer_group_header_get_group (row);
|
||||
g_assert (SYSPROF_IS_VISUALIZER_GROUP (group));
|
||||
|
||||
g_signal_emit_by_name (group, "group-activated");
|
||||
|
||||
Reference in New Issue
Block a user