[sysprof] libsysprof-ui: use custom cell renderer for progress + .2 precision
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: use custom cell renderer for progress + .2 precision
- Date: Wed, 29 May 2019 22:42:07 +0000 (UTC)
commit eecb3192ec6d2444295abe2ee7dca4d87acc5e30
Author: Christian Hergert <chergert redhat com>
Date: Wed May 22 10:05:12 2019 -0700
libsysprof-ui: use custom cell renderer for progress + .2 precision
src/libsysprof-ui/sysprof-cell-renderer-percent.c | 13 +++++++-----
src/libsysprof-ui/sysprof-cell-renderer-percent.h | 4 ++--
src/libsysprof-ui/ui/sysprof-callgraph-view.ui | 24 +++++++++++------------
3 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-cell-renderer-percent.c
b/src/libsysprof-ui/sysprof-cell-renderer-percent.c
index 672a431..c03e262 100644
--- a/src/libsysprof-ui/sysprof-cell-renderer-percent.c
+++ b/src/libsysprof-ui/sysprof-cell-renderer-percent.c
@@ -35,7 +35,7 @@ enum {
N_PROPS
};
-G_DEFINE_TYPE_WITH_PRIVATE (SysprofCellRendererPercent, sysprof_cell_renderer_percent,
GTK_TYPE_CELL_RENDERER_TEXT)
+G_DEFINE_TYPE_WITH_PRIVATE (SysprofCellRendererPercent, sysprof_cell_renderer_percent,
GTK_TYPE_CELL_RENDERER_PROGRESS)
static GParamSpec *properties [N_PROPS];
@@ -100,7 +100,7 @@ sysprof_cell_renderer_percent_class_init (SysprofCellRendererPercentClass *klass
static void
sysprof_cell_renderer_percent_init (SysprofCellRendererPercent *self)
{
- g_object_set (self, "xalign", 1.0f, NULL);
+ g_object_set (self, "text-xalign", 1.0f, NULL);
}
gdouble
@@ -125,14 +125,17 @@ sysprof_cell_renderer_percent_set_percent (SysprofCellRendererPercent *self,
if (percent != priv->percent)
{
- gchar text[128];
+ gchar text[8];
priv->percent = percent;
- g_snprintf (text, sizeof text, "%.2lf<span size='smaller'><span size='smaller'> </span>%%</span>",
percent);
+ g_snprintf (text, sizeof text, "%.2lf%%", percent);
text [sizeof text - 1] = '\0';
- g_object_set (self, "markup", text, NULL);
+ g_object_set (self,
+ "value", (guint)percent,
+ "text", text,
+ NULL);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PERCENT]);
}
diff --git a/src/libsysprof-ui/sysprof-cell-renderer-percent.h
b/src/libsysprof-ui/sysprof-cell-renderer-percent.h
index 38bd095..9c43720 100644
--- a/src/libsysprof-ui/sysprof-cell-renderer-percent.h
+++ b/src/libsysprof-ui/sysprof-cell-renderer-percent.h
@@ -43,12 +43,12 @@ typedef struct _SysprofCellRendererPercentClass SysprofCellRendererPercentClass;
struct _SysprofCellRendererPercent
{
- GtkCellRendererText parent;
+ GtkCellRendererProgress parent;
};
struct _SysprofCellRendererPercentClass
{
- GtkCellRendererTextClass parent_class;
+ GtkCellRendererProgressClass parent_class;
gpointer padding[4];
};
diff --git a/src/libsysprof-ui/ui/sysprof-callgraph-view.ui b/src/libsysprof-ui/ui/sysprof-callgraph-view.ui
index 8b2858b..2631a49 100644
--- a/src/libsysprof-ui/ui/sysprof-callgraph-view.ui
+++ b/src/libsysprof-ui/ui/sysprof-callgraph-view.ui
@@ -42,11 +42,11 @@
<property name="sort-column-id">1</property>
<property name="title" translatable="yes">Self</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">1</attribute>
+ <attribute name="percent">1</attribute>
</attributes>
</child>
</object>
@@ -58,11 +58,11 @@
<property name="sort-column-id">2</property>
<property name="title" translatable="yes">Total</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">2</attribute>
+ <attribute name="percent">2</attribute>
</attributes>
</child>
</object>
@@ -103,11 +103,11 @@
<property name="sort-column-id">1</property>
<property name="title" translatable="yes">Self</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">1</attribute>
+ <attribute name="percent">1</attribute>
</attributes>
</child>
</object>
@@ -119,11 +119,11 @@
<property name="sort-column-id">2</property>
<property name="title" translatable="yes">Total</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">2</attribute>
+ <attribute name="percent">2</attribute>
</attributes>
</child>
</object>
@@ -158,11 +158,11 @@
<property name="sort-column-id">1</property>
<property name="title" translatable="yes">Self</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">1</attribute>
+ <attribute name="percent">1</attribute>
</attributes>
</child>
</object>
@@ -174,11 +174,11 @@
<property name="sort-column-id">2</property>
<property name="title" translatable="yes">Total</property>
<child>
- <object class="GtkCellRendererProgress">
+ <object class="SysprofCellRendererPercent">
<property name="width">65</property>
</object>
<attributes>
- <attribute name="value">2</attribute>
+ <attribute name="percent">2</attribute>
</attributes>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]