mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-03-22 05:01:27 +00:00
libsysprof: add a subtitle property
To make things easier to bind from the window.
This commit is contained in:
@ -127,6 +127,7 @@ enum {
|
|||||||
PROP_SAMPLES,
|
PROP_SAMPLES,
|
||||||
PROP_TIME_SPAN,
|
PROP_TIME_SPAN,
|
||||||
PROP_TITLE,
|
PROP_TITLE,
|
||||||
|
PROP_SUBTITLE,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -421,6 +422,10 @@ sysprof_document_get_property (GObject *object,
|
|||||||
g_value_take_string (value, sysprof_document_dup_title (self));
|
g_value_take_string (value, sysprof_document_dup_title (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SUBTITLE:
|
||||||
|
g_value_take_string (value, sysprof_document_dup_subtitle (self));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -499,6 +504,11 @@ sysprof_document_class_init (SysprofDocumentClass *klass)
|
|||||||
NULL,
|
NULL,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_SUBTITLE] =
|
||||||
|
g_param_spec_string ("subtitle", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2371,6 +2381,22 @@ sysprof_document_dup_title (SysprofDocument *self)
|
|||||||
return g_strdup_printf (_("Recording at %s"), self->header.capture_time);
|
return g_strdup_printf (_("Recording at %s"), self->header.capture_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysprof_document_dup_subtitle (SysprofDocument *self)
|
||||||
|
{
|
||||||
|
g_autoptr(GDateTime) date_time = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
|
||||||
|
|
||||||
|
if (self->title == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ((date_time = g_date_time_new_from_iso8601 (self->header.capture_time, NULL)))
|
||||||
|
return g_date_time_format (date_time, _("Recording at %X %x"));
|
||||||
|
|
||||||
|
return g_strdup_printf (_("Recording at %s"), self->header.capture_time);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_sysprof_document_set_title (SysprofDocument *self,
|
_sysprof_document_set_title (SysprofDocument *self,
|
||||||
const char *title)
|
const char *title)
|
||||||
@ -2378,7 +2404,10 @@ _sysprof_document_set_title (SysprofDocument *self,
|
|||||||
g_return_if_fail (SYSPROF_IS_DOCUMENT (self));
|
g_return_if_fail (SYSPROF_IS_DOCUMENT (self));
|
||||||
|
|
||||||
if (g_set_str (&self->title, title))
|
if (g_set_str (&self->title, title))
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
{
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SUBTITLE]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -43,6 +43,8 @@ G_DECLARE_FINAL_TYPE (SysprofDocument, sysprof_document, SYSPROF, DOCUMENT, GObj
|
|||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
char *sysprof_document_dup_title (SysprofDocument *self);
|
char *sysprof_document_dup_title (SysprofDocument *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
char *sysprof_document_dup_subtitle (SysprofDocument *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
const SysprofTimeSpan *sysprof_document_get_time_span (SysprofDocument *self);
|
const SysprofTimeSpan *sysprof_document_get_time_span (SysprofDocument *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
||||||
|
|||||||
Reference in New Issue
Block a user