mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
libsysprof-ui: add color
This commit is contained in:
@ -36,6 +36,7 @@ typedef struct
|
|||||||
gint64 end_time;
|
gint64 end_time;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
SysprofZoomManager *zoom_manager;
|
SysprofZoomManager *zoom_manager;
|
||||||
|
GdkRGBA color;
|
||||||
} SysprofCellRendererDurationPrivate;
|
} SysprofCellRendererDurationPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -43,6 +44,7 @@ enum {
|
|||||||
PROP_BEGIN_TIME,
|
PROP_BEGIN_TIME,
|
||||||
PROP_CAPTURE_BEGIN_TIME,
|
PROP_CAPTURE_BEGIN_TIME,
|
||||||
PROP_CAPTURE_END_TIME,
|
PROP_CAPTURE_END_TIME,
|
||||||
|
PROP_COLOR,
|
||||||
PROP_END_TIME,
|
PROP_END_TIME,
|
||||||
PROP_TEXT,
|
PROP_TEXT,
|
||||||
PROP_ZOOM_MANAGER,
|
PROP_ZOOM_MANAGER,
|
||||||
@ -64,7 +66,6 @@ sysprof_cell_renderer_duration_render (GtkCellRenderer *renderer,
|
|||||||
SysprofCellRendererDuration *self = (SysprofCellRendererDuration *)renderer;
|
SysprofCellRendererDuration *self = (SysprofCellRendererDuration *)renderer;
|
||||||
SysprofCellRendererDurationPrivate *priv = sysprof_cell_renderer_duration_get_instance_private (self);
|
SysprofCellRendererDurationPrivate *priv = sysprof_cell_renderer_duration_get_instance_private (self);
|
||||||
g_autoptr(GString) str = NULL;
|
g_autoptr(GString) str = NULL;
|
||||||
GtkStyleContext *style_context;
|
|
||||||
gdouble x1, x2;
|
gdouble x1, x2;
|
||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
GdkRectangle r;
|
GdkRectangle r;
|
||||||
@ -78,10 +79,7 @@ sysprof_cell_renderer_duration_render (GtkCellRenderer *renderer,
|
|||||||
if (priv->zoom_manager == NULL)
|
if (priv->zoom_manager == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
style_context = gtk_widget_get_style_context (widget);
|
rgba = priv->color;
|
||||||
gtk_style_context_get_color (style_context,
|
|
||||||
gtk_style_context_get_state (style_context),
|
|
||||||
&rgba);
|
|
||||||
|
|
||||||
duration = sysprof_zoom_manager_get_duration_for_width (priv->zoom_manager, bg_area->width);
|
duration = sysprof_zoom_manager_get_duration_for_width (priv->zoom_manager, bg_area->width);
|
||||||
|
|
||||||
@ -292,6 +290,13 @@ sysprof_cell_renderer_duration_set_property (GObject *object,
|
|||||||
priv->capture_duration = priv->capture_end_time - priv->capture_begin_time;
|
priv->capture_duration = priv->capture_end_time - priv->capture_begin_time;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_COLOR:
|
||||||
|
if (g_value_get_boxed (value))
|
||||||
|
priv->color = *(GdkRGBA *)g_value_get_boxed (value);
|
||||||
|
else
|
||||||
|
gdk_rgba_parse (&priv->color, "#000");
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_END_TIME:
|
case PROP_END_TIME:
|
||||||
priv->end_time = g_value_get_int64 (value);
|
priv->end_time = g_value_get_int64 (value);
|
||||||
break;
|
break;
|
||||||
@ -342,6 +347,11 @@ sysprof_cell_renderer_duration_class_init (SysprofCellRendererDurationClass *kla
|
|||||||
G_MININT64, G_MAXINT64, 0,
|
G_MININT64, G_MAXINT64, 0,
|
||||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_COLOR] =
|
||||||
|
g_param_spec_boxed ("color", NULL, NULL,
|
||||||
|
GDK_TYPE_RGBA,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
properties [PROP_END_TIME] =
|
properties [PROP_END_TIME] =
|
||||||
g_param_spec_int64 ("end-time", NULL, NULL,
|
g_param_spec_int64 ("end-time", NULL, NULL,
|
||||||
G_MININT64, G_MAXINT64, 0,
|
G_MININT64, G_MAXINT64, 0,
|
||||||
@ -368,6 +378,9 @@ sysprof_cell_renderer_duration_class_init (SysprofCellRendererDurationClass *kla
|
|||||||
static void
|
static void
|
||||||
sysprof_cell_renderer_duration_init (SysprofCellRendererDuration *self)
|
sysprof_cell_renderer_duration_init (SysprofCellRendererDuration *self)
|
||||||
{
|
{
|
||||||
|
SysprofCellRendererDurationPrivate *priv = sysprof_cell_renderer_duration_get_instance_private (self);
|
||||||
|
|
||||||
|
priv->color.alpha = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkCellRenderer *
|
GtkCellRenderer *
|
||||||
|
|||||||
Reference in New Issue
Block a user