[gnome-software/1111-version-history-box: 2/2] WIP
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1111-version-history-box: 2/2] WIP
- Date: Thu, 4 Feb 2021 05:54:12 +0000 (UTC)
commit a706e17cc0eaac81c3579a2384f1903e15edfcb6
Author: Phaedrus Leeds <mwleeds endlessos org>
Date: Wed Feb 3 12:45:34 2021 -0800
WIP
po/POTFILES.in | 3 ++
src/gnome-software.gresource.xml | 2 +
src/gs-app-version-history-dialog.c | 93 ++++++++++++++++++++++++++++++++++++
src/gs-app-version-history-dialog.h | 24 ++++++++++
src/gs-app-version-history-dialog.ui | 59 +++++++++++++++++++++++
src/gs-app-version-history-row.c | 86 +++++++++++++++++++++++++++++++++
src/gs-app-version-history-row.h | 27 +++++++++++
src/gs-app-version-history-row.ui | 58 ++++++++++++++++++++++
src/gs-details-page.c | 42 ++++++++++++++--
src/gs-details-page.ui | 51 ++++++++++++++++++++
src/meson.build | 2 +
11 files changed, 443 insertions(+), 4 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ecae3db32..83f714717 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,6 +6,9 @@ src/gnome-software.ui
lib/gs-app.c
src/gs-app-addon-row.c
src/gs-app-addon-row.ui
+src/gs-app-version-history-dialog.ui
+src/gs-app-version-history-row.c
+src/gs-app-version-history-row.ui
src/gs-application.c
src/gs-app-row.c
src/gs-app-row.ui
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index 459ecf821..d0f7ea95c 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -3,6 +3,8 @@
<gresource prefix="/org/gnome/Software">
<file preprocess="xml-stripblanks">gnome-software.ui</file>
<file preprocess="xml-stripblanks">gs-app-addon-row.ui</file>
+ <file preprocess="xml-stripblanks">gs-app-version-history-dialog.ui</file>
+ <file preprocess="xml-stripblanks">gs-app-version-history-row.ui</file>
<file preprocess="xml-stripblanks">gs-app-row.ui</file>
<file preprocess="xml-stripblanks">gs-basic-auth-dialog.ui</file>
<file preprocess="xml-stripblanks">gs-category-page.ui</file>
diff --git a/src/gs-app-version-history-dialog.c b/src/gs-app-version-history-dialog.c
new file mode 100644
index 000000000..6590caffa
--- /dev/null
+++ b/src/gs-app-version-history-dialog.c
@@ -0,0 +1,93 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Matthew Leeds <mwleeds endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include "config.h"
+
+#include "gs-app-version-history-dialog.h"
+
+#include "gnome-software-private.h"
+#include "gs-common.h"
+#include "gs-app-version-history-row.h"
+#include <glib/gi18n.h>
+
+struct _GsAppVersionHistoryDialog
+{
+ GtkDialog parent_instance;
+ GsApp *app;
+ GtkWidget *listbox;
+};
+
+G_DEFINE_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, GTK_TYPE_DIALOG)
+
+static void
+populate_version_history (GsAppVersionHistoryDialog *dialog,
+ GsApp *app)
+{
+ /* remove previous */
+ gs_container_remove_all (GTK_CONTAINER (dialog->listbox));
+
+ /* add each */
+ //TODO iterate over app version history
+ //for (guint i = 0; i < gs_app_list_length (list); i++) {
+ // GtkWidget *row;
+ //TODO get version info
+ // row = gs_app_version_history_row_new (version_number, version_date, version_description);
+
+ //TODO prepend or append?
+ // gtk_list_box_prepend (dialog->listbox, row);
+ // gtk_widget_show (row);
+ //}
+}
+
+static void
+list_header_func (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
+{
+ GtkWidget *header = NULL;
+ if (before != NULL)
+ header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_list_box_row_set_header (row, header);
+}
+
+static void
+gs_app_version_history_dialog_init (GsAppVersionHistoryDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+
+ gtk_list_box_set_header_func (GTK_LIST_BOX (dialog->listbox),
+ list_header_func,
+ dialog,
+ NULL);
+}
+
+static void
+gs_app_version_history_dialog_class_init (GsAppVersionHistoryDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-version-history-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GsAppVersionHistoryDialog, listbox);
+}
+
+GtkWidget *
+gs_app_version_history_dialog_new (GtkWindow *parent, GsApp *app)
+{
+ GsAppVersionHistoryDialog *dialog;
+
+ dialog = g_object_new (GS_TYPE_APP_VERSION_HISTORY_DIALOG,
+ "use-header-bar", TRUE,
+ "transient-for", parent,
+ "modal", TRUE,
+ NULL);
+ populate_version_history (dialog, app);
+
+ return GTK_WIDGET (dialog);
+}
diff --git a/src/gs-app-version-history-dialog.h b/src/gs-app-version-history-dialog.h
new file mode 100644
index 000000000..6abed18e2
--- /dev/null
+++ b/src/gs-app-version-history-dialog.h
@@ -0,0 +1,24 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Matthew Leeds <mwleeds endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "gnome-software-private.h"
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_APP_VERSION_HISTORY_DIALOG (gs_app_version_history_dialog_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, GS,
APP_VERSION_HISTORY_DIALOG, GtkDialog)
+
+GtkWidget *gs_app_version_history_dialog_new (GtkWindow *parent,
+ GsApp *app);
+
+G_END_DECLS
diff --git a/src/gs-app-version-history-dialog.ui b/src/gs-app-version-history-dialog.ui
new file mode 100644
index 000000000..43def7984
--- /dev/null
+++ b/src/gs-app-version-history-dialog.ui
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="GsReposDialog" parent="GtkDialog">
+ <property name="title" translatable="yes">Version History</property>
+ <property name="modal">True</property>
+ <property name="default_width">600</property>
+ <property name="default_height">600</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="use_header_bar">1</property>
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar">
+ <child type="title">
+ <object class="GtkLabel" id="label_header">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Version History</property>
+ <property name="selectable">False</property>
+ <style>
+ <class name="title"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkFrame" id="frame">
+ <property name="visible">True</property>
+ <property name="shadow_type">in</property>
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <property name="vexpand">True</property>
+ <property name="margin_top">9</property>
+ <child>
+ <object class="GtkListBox" id="listbox">
+ <property name="visible">True</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/gs-app-version-history-row.c b/src/gs-app-version-history-row.c
new file mode 100644
index 000000000..35a994ef2
--- /dev/null
+++ b/src/gs-app-version-history-row.c
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Matthew Leeds <mwleeds endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "gs-app-version-history-row.h"
+
+#include "gs-common.h"
+
+struct _GsAppVersionHistoryRow
+{
+ GtkListBoxRow parent_instance;
+
+ GtkWidget *version_number_label;
+ GtkWidget *version_date_label;
+ GtkWidget *version_description_label;
+};
+
+G_DEFINE_TYPE (GsAppVersionHistoryRow, gs_app_version_history_row, GTK_TYPE_LIST_BOX_ROW)
+
+static void
+gs_app_version_history_row_class_init (GsAppVersionHistoryRowClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-app-version-history-row.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GsAppVersionHistoryRow, version_number_label);
+ gtk_widget_class_bind_template_child (widget_class, GsAppVersionHistoryRow, version_date_label);
+ gtk_widget_class_bind_template_child (widget_class, GsAppVersionHistoryRow,
version_description_label);
+}
+
+static void
+gs_app_version_history_row_init (GsAppVersionHistoryRow *row)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (row), FALSE);
+ gtk_widget_init_template (GTK_WIDGET (row));
+}
+
+void
+gs_app_version_history_row_set_info (GsAppVersionHistoryRow *row,
+ const char *version_number,
+ guint64 version_date,
+ const char *version_description)
+{
+ g_autofree char *version_date_string = NULL;
+ g_autoptr(GSettings) desktop_settings = NULL;
+
+ if (version_number == NULL || *version_number == '\0')
+ return;
+
+ if (version_description != NULL && *version_description != '\0') {
+ g_autofree char *version_tmp = NULL;
+ version_tmp = g_strdup_printf (_("New in Version %s"), version_number);
+ gtk_label_set_label (GTK_LABEL (row->version_number_label), version_tmp);
+ gtk_label_set_label (GTK_LABEL (row->version_description_label), version_description);
+ } else {
+ g_autofree char *version_tmp = NULL;
+ version_tmp = g_strdup_printf (_("Version %s"), version_number);
+ gtk_label_set_label (GTK_LABEL (row->version_number_label), version_tmp);
+ gtk_widget_set_visible (row->version_description_label, FALSE);
+ }
+
+ desktop_settings = g_settings_new ("org.gnome.desktop.interface");
+ version_date_string = gs_utils_time_to_string (desktop_settings, (gint64) version_date);
+ if (version_date_string == NULL)
+ gtk_widget_set_visible (row->version_date_label, FALSE);
+ else
+ gtk_label_set_label (GTK_LABEL (row->version_date_label), version_date_string);
+}
+
+GtkWidget *
+gs_app_version_history_row_new (void)
+{
+ GsAppVersionHistoryRow *row;
+
+ row = g_object_new (GS_TYPE_APP_VERSION_HISTORY_ROW, NULL);
+ return GTK_WIDGET (row);
+}
diff --git a/src/gs-app-version-history-row.h b/src/gs-app-version-history-row.h
new file mode 100644
index 000000000..0e91ac6e2
--- /dev/null
+++ b/src/gs-app-version-history-row.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Matthew Leeds <mwleeds endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "gnome-software-private.h"
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_APP_VERSION_HISTORY_ROW (gs_app_version_history_row_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsAppVersionHistoryRow, gs_app_version_history_row, GS, APP_VERSION_HISTORY_ROW,
GtkListBoxRow)
+
+GtkWidget *gs_app_version_history_row_new (void);
+void gs_app_version_history_row_set_info (GsAppVersionHistoryRow *row,
+ const char *version_number,
+ guint64 version_date,
+ const char *version_description);
+
+G_END_DECLS
diff --git a/src/gs-app-version-history-row.ui b/src/gs-app-version-history-row.ui
new file mode 100644
index 000000000..bfc4603e8
--- /dev/null
+++ b/src/gs-app-version-history-row.ui
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GsAppVersionHistoryRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="margin_end">12</property>
+ <property name="orientation">vertical</property>
+ <property name="valign">start</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel" id="version_number_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="version_date_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="version_description_label">
+ <property name="visible">False</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">20</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 379bb1bda..a78d4b8f4 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -20,6 +20,8 @@
#include "gs-details-page.h"
#include "gs-app-addon-row.h"
+#include "gs-app-version-history-row.h"
+#include "gs-app-version-history-dialog.h"
#include "gs-description-box.h"
#include "gs-history-dialog.h"
#include "gs-origin-popover-row.h"
@@ -122,6 +124,8 @@ struct _GsDetailsPage
GtkWidget *label_license_nonfree_details;
GtkWidget *label_licenses_intro;
GtkWidget *list_box_addons;
+ GtkWidget *list_box_version_history;
+ GtkWidget *row_latest_version;
GtkWidget *box_reviews;
GtkWidget *box_details_screenshot_fallback;
GtkWidget *histogram;
@@ -1206,12 +1210,11 @@ gs_details_page_refresh_all (GsDetailsPage *self)
if (tmp != NULL){
gtk_label_set_label (GTK_LABEL (self->label_details_version_value), tmp);
} else {
- /* TRANSLATORS: this is where the version is not known */
- gtk_label_set_label (GTK_LABEL (self->label_details_version_value), C_("version", "Unknown"));
+ gtk_widget_set_visible (self->list_box_version_history, FALSE);
}
- /* refresh size information */
- gs_details_page_refresh_size (self);
+ gs_app_version_history_row_set_info (GS_APP_VERSION_HISTORY_ROW (self->row_latest_version),
+ tmp, gs_app_get_release_date (self->app), NULL);
/* set the released date */
if (gs_app_get_release_date (self->app)) {
@@ -1229,6 +1232,9 @@ gs_details_page_refresh_all (GsDetailsPage *self)
gtk_widget_set_visible (self->label_details_released_value, FALSE);
}
+ /* refresh size information */
+ gs_details_page_refresh_size (self);
+
/* set the updated date */
updated = gs_app_get_install_date (self->app);
if (updated == GS_APP_INSTALL_DATE_UNSET) {
@@ -1466,6 +1472,26 @@ list_sort_func (GtkListBoxRow *a,
gs_app_get_name (a2));
}
+static void
+version_history_list_row_activated_cb (GtkListBox *list_box,
+ GtkListBoxRow *row,
+ GsDetailsPage *self)
+{
+ GtkWidget *dialog;
+
+ /* Only the row with the arrow is clickable */
+ if (GS_IS_APP_VERSION_HISTORY_ROW (row))
+ return;
+
+ dialog = gs_app_version_history_dialog_new (gs_shell_get_window (self->shell),
+ self->app);
+ gs_shell_modal_dialog_present (self->shell, GTK_DIALOG (dialog));
+
+ /* just destroy */
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), dialog);
+}
+
static void gs_details_page_addon_selected_cb (GsAppAddonRow *row, GParamSpec *pspec, GsDetailsPage *self);
static void gs_details_page_addon_remove_cb (GsAppAddonRow *row, gpointer user_data);
@@ -2897,6 +2923,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_permissions_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_failed);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, list_box_addons);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, list_box_version_history);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, row_latest_version);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_reviews);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_screenshot_fallback);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, histogram);
@@ -2955,6 +2983,12 @@ gs_details_page_init (GsDetailsPage *self)
list_sort_func,
self, NULL);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (self->list_box_version_history),
+ list_header_func,
+ self, NULL);
+ g_signal_connect (self->list_box_version_history, "row-activated",
+ G_CALLBACK (version_history_list_row_activated_cb), self);
+
gtk_style_context_add_class (gtk_widget_get_style_context (self->button_details_permissions_value),
"content-rating-permissions");
}
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 456c3e540..b612c6523 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -444,6 +444,57 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkFrame" id="box_version_history_frame">
+ <property name="visible">True</property>
+ <property name="shadow_type">in</property>
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="view"/>
+ </style>
+ <child>
+ <object class="GtkListBox" id="list_box_version_history">
+ <property name="visible">False</property>
+ <property name="selection_mode">none</property>
+ <child>
+ <object class="GsAppVersionHistoryRow" id="row_latest_version">
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="halign">center</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="label" translatable="yes">Version
History</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">go-next-symbolic</property>
+ <property name="margin_start">5</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkLabel" id="label_webapp_warning">
<property name="visible">False</property>
diff --git a/src/meson.build b/src/meson.build
index 82d3fb391..2161a03f7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,6 +17,8 @@ gdbus_src = gnome.gdbus_codegen(
gnome_software_sources = [
'gs-app-addon-row.c',
+ 'gs-app-version-history-dialog.c',
+ 'gs-app-version-history-row.c',
'gs-application.c',
'gs-app-row.c',
'gs-app-tile.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]