mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: use custom cell renderer for progress + .2 precision
This commit is contained in:
@ -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]);
|
||||
}
|
||||
|
||||
@ -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];
|
||||
};
|
||||
|
||||
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user