[gnome-software/585-gs-details-page-show-also-release-date: 22/22] gs-details-page: Show also release date
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/585-gs-details-page-show-also-release-date: 22/22] gs-details-page: Show also release date
- Date: Fri, 4 Dec 2020 12:47:13 +0000 (UTC)
commit e70081e957ffe8f254835e5e1a61e342594cf82c
Author: Milan Crha <mcrha redhat com>
Date: Fri Dec 4 13:44:34 2020 +0100
gs-details-page: Show also release date
Show also release date on the details page when it is available
for the chosen application.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/585
lib/gs-app.c | 64 ++++++++++++++++++++++++++++++++++++++
lib/gs-app.h | 3 ++
plugins/core/gs-appstream.c | 6 ++++
plugins/snap/gs-plugin-snap.c | 7 +++++
src/gs-details-page.c | 20 ++++++++++++
src/gs-details-page.ui | 71 ++++++++++++++++++++++++++++++++-----------
6 files changed, 153 insertions(+), 18 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index e6946347..95a59229 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -106,6 +106,7 @@ typedef struct
GsAppList *related;
GsAppList *history;
guint64 install_date;
+ guint64 release_date;
guint64 kudos;
gboolean to_be_installed;
GsAppQuirk quirk;
@@ -134,6 +135,7 @@ enum {
PROP_PROGRESS,
PROP_CAN_CANCEL_INSTALLATION,
PROP_INSTALL_DATE,
+ PROP_RELEASE_DATE,
PROP_QUIRK,
PROP_PENDING_ACTION,
PROP_KEY_COLORS,
@@ -609,6 +611,11 @@ gs_app_to_string_append (GsApp *app, GString *str)
G_GUINT64_FORMAT "",
priv->install_date);
}
+ if (priv->release_date != 0) {
+ gs_app_kv_printf (str, "release-date", "%"
+ G_GUINT64_FORMAT "",
+ priv->release_date);
+ }
if (priv->size_installed != 0)
gs_app_kv_size (str, "size-installed", priv->size_installed);
if (priv->size_download != 0)
@@ -3517,6 +3524,45 @@ gs_app_set_install_date (GsApp *app, guint64 install_date)
priv->install_date = install_date;
}
+/**
+ * gs_app_get_release_date:
+ * @app: a #GsApp
+ *
+ * Gets the date that an application was released.
+ *
+ * Returns: A UNIX epoch, or 0 for unset
+ *
+ * Since: 3.40
+ **/
+guint64
+gs_app_get_release_date (GsApp *app)
+{
+ GsAppPrivate *priv = gs_app_get_instance_private (app);
+ g_return_val_if_fail (GS_IS_APP (app), 0);
+ return priv->release_date;
+}
+
+/**
+ * gs_app_set_release_date:
+ * @app: a #GsApp
+ * @release_date: an epoch, or 0
+ *
+ * Sets the date that an application was released.
+ *
+ * Since: 3.40
+ **/
+void
+gs_app_set_release_date (GsApp *app, guint64 release_date)
+{
+ GsAppPrivate *priv = gs_app_get_instance_private (app);
+ g_return_if_fail (GS_IS_APP (app));
+ if (release_date == priv->release_date)
+ return;
+ priv->release_date = release_date;
+
+ gs_app_queue_notify (app, obj_props[PROP_RELEASE_DATE]);
+}
+
/**
* gs_app_is_installed:
* @app: a #GsApp
@@ -4199,6 +4245,9 @@ gs_app_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
case PROP_INSTALL_DATE:
g_value_set_uint64 (value, priv->install_date);
break;
+ case PROP_RELEASE_DATE:
+ g_value_set_uint64 (value, priv->release_date);
+ break;
case PROP_QUIRK:
g_value_set_uint64 (value, priv->quirk);
break;
@@ -4260,6 +4309,9 @@ gs_app_set_property (GObject *object, guint prop_id, const GValue *value, GParam
case PROP_INSTALL_DATE:
gs_app_set_install_date (app, g_value_get_uint64 (value));
break;
+ case PROP_RELEASE_DATE:
+ gs_app_set_release_date (app, g_value_get_uint64 (value));
+ break;
case PROP_QUIRK:
priv->quirk = g_value_get_uint64 (value);
break;
@@ -4439,6 +4491,18 @@ gs_app_class_init (GsAppClass *klass)
0, G_MAXUINT64, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ /**
+ * GsApp:release-date:
+ *
+ * Set to the release date of the application on the server. Can be 0,
+ * which means the release date is unknown.
+ *
+ * Since: 3.40
+ */
+ obj_props[PROP_RELEASE_DATE] = g_param_spec_uint64 ("release-date", NULL, NULL,
+ 0, G_MAXUINT64, 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+
/**
* GsApp:quirk:
*/
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 7b1608d3..d099b772 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -354,6 +354,9 @@ void gs_app_add_history (GsApp *app,
guint64 gs_app_get_install_date (GsApp *app);
void gs_app_set_install_date (GsApp *app,
guint64 install_date);
+guint64 gs_app_get_release_date (GsApp *app);
+void gs_app_set_release_date (GsApp *app,
+ guint64 release_date);
GPtrArray *gs_app_get_categories (GsApp *app);
void gs_app_set_categories (GsApp *app,
GPtrArray *categories);
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 3f8fdfac..0e33cc81 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -684,6 +684,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
GError **error)
{
const gchar *tmp;
+ guint64 timestamp;
g_autoptr(GPtrArray) bundles = NULL;
g_autoptr(GPtrArray) launchables = NULL;
g_autoptr(XbNode) req = NULL;
@@ -890,6 +891,11 @@ gs_appstream_refine_app (GsPlugin *plugin,
gs_app_set_kind (app, as_app_kind_from_string (tmp));
}
+ /* set the release date */
+ timestamp = xb_node_query_attr_as_uint (component, "releases/release", "timestamp", NULL);
+ if (timestamp != G_MAXUINT64)
+ gs_app_set_release_date (app, timestamp);
+
/* copy all the metadata */
if (!gs_appstream_copy_metadata (app, component, error))
return FALSE;
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 05d02943..1ea360b9 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -911,6 +911,7 @@ refine_app_with_client (GsPlugin *plugin,
SnapdSnap *snap;
const gchar *developer_name;
g_autofree gchar *description = NULL;
+ guint64 release_date = 0;
/* not us */
if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
@@ -989,6 +990,7 @@ refine_app_with_client (GsPlugin *plugin,
for (i = 0; i < channels->len; i++) {
SnapdChannel *c = channels->pdata[i];
g_autofree gchar *expanded_name = NULL;
+ GDateTime *dt;
expanded_name = expand_channel_name (snapd_channel_get_name (c));
if (g_strcmp0 (expanded_name, channel) != 0)
@@ -996,10 +998,15 @@ refine_app_with_client (GsPlugin *plugin,
version = snapd_channel_get_version (c);
confinement = snapd_channel_get_confinement (c);
+
+ dt = snapd_channel_get_released_at (c);
+ if (dt)
+ release_date = (guint64) g_date_time_to_unix (dt);
}
}
gs_app_set_version (app, version);
+ gs_app_set_release_date (app, release_date);
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS &&
priv->system_confinement == SNAPD_SYSTEM_CONFINEMENT_STRICT &&
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 505045c5..e2891eb9 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -112,6 +112,8 @@ struct _GsDetailsPage
GtkWidget *label_details_updated_value;
GtkWidget *label_details_version_title;
GtkWidget *label_details_version_value;
+ GtkWidget *label_details_released_title;
+ GtkWidget *label_details_released_value;
GtkWidget *label_details_permissions_title;
GtkWidget *button_details_permissions_value;
GtkWidget *label_failed;
@@ -1250,6 +1252,22 @@ gs_details_page_refresh_all (GsDetailsPage *self)
/* refresh size information */
gs_details_page_refresh_size (self);
+ /* set the released date */
+ if (gs_app_get_release_date (self->app)) {
+ g_autoptr(GDateTime) dt = NULL;
+ g_autofree gchar *released_str = NULL;
+
+ dt = g_date_time_new_from_unix_utc ((gint64) gs_app_get_release_date (self->app));
+ released_str = g_date_time_format (dt, "%x");
+
+ gtk_label_set_label (GTK_LABEL (self->label_details_released_value), released_str);
+ gtk_widget_set_visible (self->label_details_released_title, TRUE);
+ gtk_widget_set_visible (self->label_details_released_value, TRUE);
+ } else {
+ gtk_widget_set_visible (self->label_details_released_title, FALSE);
+ gtk_widget_set_visible (self->label_details_released_value, FALSE);
+ }
+
/* set the updated date */
updated = gs_app_get_install_date (self->app);
if (updated == GS_APP_INSTALL_DATE_UNSET) {
@@ -2873,6 +2891,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_updated_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_version_title);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_version_value);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_released_title);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_released_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_permissions_title);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_permissions_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_failed);
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index b5561a2b..51c10a2d 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -679,6 +679,41 @@
<property name="top_attach">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label_details_released_title">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Released</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="vexpand">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_details_released_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="label">0.12.3</property>
+ <property name="selectable">True</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <accessibility>
+ <relation type="labelled-by" target="label_details_released_title"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
<child>
<object class="GtkLabel" id="label_details_rating_title">
@@ -693,7 +728,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -714,7 +749,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
@@ -731,7 +766,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -752,7 +787,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">11</property>
</packing>
</child>
@@ -769,7 +804,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -787,7 +822,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -803,7 +838,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -823,7 +858,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
@@ -840,7 +875,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -854,7 +889,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
@@ -871,7 +906,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -885,7 +920,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
@@ -902,7 +937,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -917,7 +952,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -933,7 +968,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -963,7 +998,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -979,7 +1014,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -1025,7 +1060,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]