mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
timevisualizer: port to GTK 4
This commit is contained in:
@ -114,35 +114,39 @@ copy_array (GArray *ar)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
sysprof_time_visualizer_draw (GtkWidget *widget,
|
sysprof_time_visualizer_snapshot (GtkWidget *widget,
|
||||||
cairo_t *cr)
|
GtkSnapshot *snapshot)
|
||||||
{
|
{
|
||||||
SysprofTimeVisualizer *self = (SysprofTimeVisualizer *)widget;
|
SysprofTimeVisualizer *self = (SysprofTimeVisualizer *)widget;
|
||||||
SysprofTimeVisualizerPrivate *priv = sysprof_time_visualizer_get_instance_private (self);
|
SysprofTimeVisualizerPrivate *priv = sysprof_time_visualizer_get_instance_private (self);
|
||||||
GtkStyleContext *style_context;
|
GtkStyleContext *style_context;
|
||||||
GtkStateFlags flags;
|
cairo_t *cr;
|
||||||
GtkAllocation alloc;
|
GtkAllocation alloc;
|
||||||
GdkRectangle clip;
|
|
||||||
GdkRGBA foreground;
|
GdkRGBA foreground;
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_TIME_VISUALIZER (widget));
|
g_assert (SYSPROF_IS_TIME_VISUALIZER (widget));
|
||||||
g_assert (cr != NULL);
|
g_assert (snapshot != NULL);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &alloc);
|
gtk_widget_get_allocation (widget, &alloc);
|
||||||
|
|
||||||
ret = GTK_WIDGET_CLASS (sysprof_time_visualizer_parent_class)->draw (widget, cr);
|
GTK_WIDGET_CLASS (sysprof_time_visualizer_parent_class)->snapshot (widget, snapshot);
|
||||||
|
|
||||||
if (priv->cache == NULL)
|
if (priv->cache == NULL)
|
||||||
return ret;
|
return;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (!gdk_cairo_get_clip_rectangle (cr, &clip))
|
if (!gdk_cairo_get_clip_rectangle (cr, &clip))
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
alloc.x = 0;
|
||||||
|
alloc.y = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
style_context = gtk_widget_get_style_context (widget);
|
style_context = gtk_widget_get_style_context (widget);
|
||||||
flags = gtk_widget_get_state_flags (widget);
|
gtk_style_context_get_color (style_context, &foreground);
|
||||||
gtk_style_context_get_color (style_context, flags, &foreground);
|
|
||||||
|
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, alloc.width, alloc.height));
|
||||||
|
|
||||||
gdk_cairo_set_source_rgba (cr, &foreground);
|
gdk_cairo_set_source_rgba (cr, &foreground);
|
||||||
|
|
||||||
@ -187,7 +191,7 @@ sysprof_time_visualizer_draw (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -243,10 +247,10 @@ sysprof_time_visualizer_queue_reload (SysprofTimeVisualizer *self)
|
|||||||
|
|
||||||
if (priv->queued_load == 0)
|
if (priv->queued_load == 0)
|
||||||
priv->queued_load =
|
priv->queued_load =
|
||||||
gdk_threads_add_idle_full (G_PRIORITY_LOW,
|
g_idle_add_full (G_PRIORITY_LOW,
|
||||||
sysprof_time_visualizer_do_reload,
|
sysprof_time_visualizer_do_reload,
|
||||||
self,
|
self,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -283,11 +287,7 @@ sysprof_time_visualizer_finalize (GObject *object)
|
|||||||
g_clear_pointer (&priv->cache, point_cache_unref);
|
g_clear_pointer (&priv->cache, point_cache_unref);
|
||||||
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
|
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
|
||||||
|
|
||||||
if (priv->queued_load != 0)
|
g_clear_handle_id (&priv->queued_load, g_source_remove);
|
||||||
{
|
|
||||||
g_source_remove (priv->queued_load);
|
|
||||||
priv->queued_load = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (sysprof_time_visualizer_parent_class)->finalize (object);
|
G_OBJECT_CLASS (sysprof_time_visualizer_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ sysprof_time_visualizer_class_init (SysprofTimeVisualizerClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = sysprof_time_visualizer_finalize;
|
object_class->finalize = sysprof_time_visualizer_finalize;
|
||||||
|
|
||||||
widget_class->draw = sysprof_time_visualizer_draw;
|
widget_class->snapshot = sysprof_time_visualizer_snapshot;
|
||||||
|
|
||||||
visualizer_class->set_reader = sysprof_time_visualizer_set_reader;
|
visualizer_class->set_reader = sysprof_time_visualizer_set_reader;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user