libsysprof-ui: more GTK 4 porting changes

This commit is contained in:
Christian Hergert
2021-10-01 13:05:05 -07:00
parent 277b303ad3
commit 8afa4940c4
7 changed files with 132 additions and 74 deletions

View File

@ -53,7 +53,11 @@ typedef struct
int nat_below_baseline; int nat_below_baseline;
} EggThreeGridRowInfo; } EggThreeGridRowInfo;
G_DEFINE_TYPE_WITH_PRIVATE (EggThreeGrid, egg_three_grid, GTK_TYPE_WIDGET) static void buildable_iface_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (EggThreeGrid, egg_three_grid, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (EggThreeGrid)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
enum { enum {
PROP_0, PROP_0,
@ -695,3 +699,21 @@ egg_three_grid_column_get_type (void)
return type_id; return type_id;
} }
static void
egg_three_grid_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const char *type)
{
if (GTK_IS_WIDGET (child))
egg_three_grid_add (EGG_THREE_GRID (buildable), GTK_WIDGET (child), 0, EGG_THREE_GRID_COLUMN_LEFT);
else
g_warning ("%s cannot be added to %s", G_OBJECT_TYPE_NAME (child), G_OBJECT_TYPE_NAME (buildable));
}
static void
buildable_iface_init (GtkBuildableIface *iface)
{
iface->add_child = egg_three_grid_add_child;
}

View File

@ -50,6 +50,8 @@ typedef struct
GtkLabel *end; GtkLabel *end;
GtkLabel *duration; GtkLabel *duration;
GtkTextView *message; GtkTextView *message;
GtkWidget *failed;
GtkWidget *marks;
} SysprofMarksPagePrivate; } SysprofMarksPagePrivate;
enum { enum {
@ -310,9 +312,9 @@ sysprof_marks_page_load_cb (GObject *object,
gtk_tree_view_set_model (priv->tree_view, GTK_TREE_MODEL (model)); gtk_tree_view_set_model (priv->tree_view, GTK_TREE_MODEL (model));
if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL) == 0) if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL) == 0)
gtk_stack_set_visible_child_name (priv->stack, "empty-state"); gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->failed));
else else
gtk_stack_set_visible_child_name (priv->stack, "marks"); gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->marks));
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
} }
@ -517,6 +519,8 @@ sysprof_marks_page_class_init (SysprofMarksPageClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, duration); gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, duration);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, time); gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, time);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, message); gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, message);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, marks);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMarksPage, failed);
properties [PROP_KIND] = properties [PROP_KIND] =
g_param_spec_enum ("kind", NULL, NULL, g_param_spec_enum ("kind", NULL, NULL,

View File

@ -3,10 +3,11 @@
<template class="SysprofMarksPage" parent="SysprofPage"> <template class="SysprofMarksPage" parent="SysprofPage">
<child> <child>
<object class="GtkStack" id="stack"> <object class="GtkStack" id="stack">
<property name="homogeneous">false</property> <property name="hhomogeneous">false</property>
<property name="vhomogeneous">false</property>
<property name="visible">true</property> <property name="visible">true</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox" id="marks">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="visible">true</property> <property name="visible">true</property>
<child> <child>
@ -44,11 +45,11 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">0</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">0</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
@ -59,11 +60,11 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">1</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">1</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
@ -73,11 +74,11 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">2</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">2</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
@ -87,11 +88,11 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">3</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">3</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
@ -101,11 +102,11 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">4</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">4</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
@ -116,22 +117,22 @@
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
<layout>
<property name="row">5</property>
<property name="column">0</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">5</property>
<property name="left-attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="group"> <object class="GtkLabel" id="group">
<property name="visible">true</property> <property name="visible">true</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="wrap">true</property> <property name="wrap">true</property>
<layout>
<property name="row">0</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">0</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="mark"> <object class="GtkLabel" id="mark">
@ -139,46 +140,45 @@
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="max-width-chars">5</property> <property name="max-width-chars">5</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<layout>
<property name="row">1</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">1</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="time"> <object class="GtkLabel" id="time">
<property name="visible">true</property> <property name="visible">true</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<layout>
<property name="row">2</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">2</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="end"> <object class="GtkLabel" id="end">
<property name="visible">true</property> <property name="visible">true</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<layout>
<property name="row">3</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">3</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="duration"> <object class="GtkLabel" id="duration">
<property name="visible">true</property> <property name="visible">true</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<layout>
<property name="row">4</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">4</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="hexpand">true</property> <property name="hexpand">true</property>
<property name="shadow-type">in</property>
<property name="visible">true</property> <property name="visible">true</property>
<child> <child>
<object class="GtkTextView" id="message"> <object class="GtkTextView" id="message">
@ -186,11 +186,11 @@
<property name="visible">true</property> <property name="visible">true</property>
</object> </object>
</child> </child>
<layout>
<property name="row">5</property>
<property name="column">1</property>
</layout>
</object> </object>
<packing>
<property name="top-attach">5</property>
<property name="left-attach">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
@ -238,20 +238,44 @@
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="name">marks</property>
</packing>
</child> </child>
<child> <child>
<object class="DzlEmptyState"> <object class="GtkBox" id="failed">
<property name="icon-name">computer-fail-symbolic</property> <property name="halign">center</property>
<property name="title" translatable="yes">No Timings Available</property> <property name="orientation">vertical</property>
<property name="subtitle" translatable="yes">No timing data was found for the current selection</property> <property name="spacing">12</property>
<property name="valign">center</property>
<property name="visible">true</property> <property name="visible">true</property>
<child>
<object class="GtkImage">
<property name="icon-name">computer-fail-symbolic</property>
<property name="pixel-size">128</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel" id="title">
<property name="label" translatable="yes">No Timings Available</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="2.0"/>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="subtitle">
<property name="label" translatable="yes">No timing data was found for the current selection</property>
<property name="use-markup">true</property>
<property name="wrap">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object> </object>
<packing>
<property name="name">empty-state</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View File

@ -318,3 +318,11 @@ sysprof_scrollmap_set_adjustment (SysprofScrollmap *self,
gtk_scrollbar_set_adjustment (GTK_SCROLLBAR (self->scrollbar), adjustment); gtk_scrollbar_set_adjustment (GTK_SCROLLBAR (self->scrollbar), adjustment);
} }
GtkAdjustment *
sysprof_scrollmap_get_adjustment (SysprofScrollmap *self)
{
g_return_val_if_fail (SYSPROF_IS_SCROLLMAP (self), NULL);
return gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (self->scrollbar));
}

View File

@ -28,12 +28,13 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofScrollmap, sysprof_scrollmap, SYSPROF, SCROLLMAP, GtkWidget) G_DECLARE_FINAL_TYPE (SysprofScrollmap, sysprof_scrollmap, SYSPROF, SCROLLMAP, GtkWidget)
void sysprof_scrollmap_set_adjustment (SysprofScrollmap *self, GtkAdjustment *sysprof_scrollmap_get_adjustment (SysprofScrollmap *self);
GtkAdjustment *adjustment); void sysprof_scrollmap_set_adjustment (SysprofScrollmap *self,
void sysprof_scrollmap_set_timings (SysprofScrollmap *self, GtkAdjustment *adjustment);
GArray *timings); void sysprof_scrollmap_set_timings (SysprofScrollmap *self,
void sysprof_scrollmap_set_time_range (SysprofScrollmap *self, GArray *timings);
gint64 begin_time, void sysprof_scrollmap_set_time_range (SysprofScrollmap *self,
gint64 end_time); gint64 begin_time,
gint64 end_time);
G_END_DECLS G_END_DECLS

View File

@ -151,12 +151,11 @@ _sysprof_visualizer_group_header_add_row (SysprofVisualizerGroupHeader *self,
"icon-name", "view-more-symbolic", "icon-name", "view-more-symbolic",
"visible", TRUE, "visible", TRUE,
NULL), NULL),
"margin-right", 6, "margin-end", 6,
"direction", GTK_ARROW_RIGHT, "direction", GTK_ARROW_RIGHT,
"halign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER,
"menu-model", menu, "menu-model", menu,
"tooltip-text", _("Display supplemental graphs"), "tooltip-text", _("Display supplemental graphs"),
"use-popover", FALSE,
"valign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_CENTER,
"visible", TRUE, "visible", TRUE,
NULL); NULL);

View File

@ -706,7 +706,7 @@ sysprof_visualizers_frame_get_hadjustment (SysprofVisualizersFrame *self)
{ {
g_return_val_if_fail (SYSPROF_IS_VISUALIZERS_FRAME (self), NULL); g_return_val_if_fail (SYSPROF_IS_VISUALIZERS_FRAME (self), NULL);
return gtk_range_get_adjustment (GTK_RANGE (self->hscrollbar)); return sysprof_scrollmap_get_adjustment (self->hscrollbar);
} }
void void