[gnome-software/1754-improve-the-sources-dropdown: 1/10] gs-app: Add an argument to gs_app_dup_origin_ui()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1754-improve-the-sources-dropdown: 1/10] gs-app: Add an argument to gs_app_dup_origin_ui()
- Date: Wed, 3 Aug 2022 14:59:33 +0000 (UTC)
commit 2e6b4de25238aa7ae38202a9addc11a557ac49d9
Author: Milan Crha <mcrha redhat com>
Date: Wed Aug 3 15:48:00 2022 +0200
gs-app: Add an argument to gs_app_dup_origin_ui()
Rather than having two functions, one to return the origin with
the packaging format and one without it, add an argument to influence
the returned value. Let the default (for the property) be to return
with the packaging format.
This will be used in the following commit.
lib/gs-app.c | 25 +++++++++++++++----------
lib/gs-app.h | 3 ++-
plugins/epiphany/gs-self-test.c | 2 +-
src/gs-common.c | 2 +-
src/gs-details-page.c | 10 +++++-----
src/gs-origin-popover-row.c | 2 +-
src/gs-repos-dialog.c | 2 +-
7 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 8d323b234..8cbb0a7eb 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -5340,7 +5340,7 @@ gs_app_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
g_value_take_boxed (value, gs_app_get_relations (app));
break;
case PROP_ORIGIN_UI:
- g_value_take_string (value, gs_app_dup_origin_ui (app));
+ g_value_take_string (value, gs_app_dup_origin_ui (app, TRUE));
break;
case PROP_HAS_TRANSLATIONS:
g_value_set_boolean (value, gs_app_get_has_translations (app));
@@ -6125,8 +6125,9 @@ gs_app_new_from_unique_id (const gchar *unique_id)
/**
* gs_app_dup_origin_ui:
* @app: a #GsApp
+ * @with_packaging_format: %TRUE, to include also packaging format
*
- * Gets the package origin that's suitable for UI use. i.e. The value of
+ * Gets the package origin that's suitable for UI use, i.e. the value of
* #GsApp:origin-ui.
*
* Returns: (not nullable) (transfer full): The package origin for UI use
@@ -6134,12 +6135,12 @@ gs_app_new_from_unique_id (const gchar *unique_id)
* Since: 43
**/
gchar *
-gs_app_dup_origin_ui (GsApp *app)
+gs_app_dup_origin_ui (GsApp *app,
+ gboolean with_packaging_format)
{
GsAppPrivate *priv;
g_autoptr(GMutexLocker) locker = NULL;
g_autoptr(GsOsRelease) os_release = NULL;
- g_autofree gchar *packaging_format = NULL;
const gchar *origin_str = NULL;
g_return_val_if_fail (GS_IS_APP (app), NULL);
@@ -6171,13 +6172,17 @@ gs_app_dup_origin_ui (GsApp *app)
}
}
- packaging_format = gs_app_get_packaging_format (app);
+ if (with_packaging_format) {
+ g_autofree gchar *packaging_format = NULL;
- if (packaging_format) {
- /* TRANSLATORS: the first %s is replaced with an origin name;
- the second %s is replaced with the packaging format.
- Example string: "Local file (RPM)" */
- return g_strdup_printf (_("%s (%s)"), origin_str, packaging_format);
+ packaging_format = gs_app_get_packaging_format (app);
+
+ if (packaging_format) {
+ /* TRANSLATORS: the first %s is replaced with an origin name;
+ the second %s is replaced with the packaging format.
+ Example string: "Local file (RPM)" */
+ return g_strdup_printf (_("%s (%s)"), origin_str, packaging_format);
+ }
}
return g_strdup (origin_str);
diff --git a/lib/gs-app.h b/lib/gs-app.h
index a053299f2..1d9fdf4bf 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -484,7 +484,8 @@ void gs_app_remove_quirk (GsApp *app,
GsAppQuirk quirk);
gboolean gs_app_is_installed (GsApp *app);
gboolean gs_app_is_updatable (GsApp *app);
-gchar *gs_app_dup_origin_ui (GsApp *app);
+gchar *gs_app_dup_origin_ui (GsApp *app,
+ gboolean with_packaging_format);
void gs_app_set_origin_ui (GsApp *app,
const gchar *origin_ui);
gchar *gs_app_get_packaging_format (GsApp *app);
diff --git a/plugins/epiphany/gs-self-test.c b/plugins/epiphany/gs-self-test.c
index 650384846..1b910217e 100644
--- a/plugins/epiphany/gs-self-test.c
+++ b/plugins/epiphany/gs-self-test.c
@@ -181,7 +181,7 @@ gs_plugins_epiphany_installed_func (GsPluginLoader *plugin_loader)
g_assert_cmpstr (gs_app_get_name (app), ==, "Pinafore");
g_assert_cmpstr (gs_app_get_summary (app), ==, "pinafore.social");
g_assert_cmpstr (gs_app_get_origin (app), ==, "gnome-web");
- origin_ui = gs_app_dup_origin_ui (app);
+ origin_ui = gs_app_dup_origin_ui (app, TRUE);
g_assert_cmpstr (origin_ui, ==, "GNOME Web");
icon = gs_app_get_icon_for_size (app, 4096, 1, NULL);
g_assert_nonnull (icon);
diff --git a/src/gs-common.c b/src/gs-common.c
index 45693c456..f9fbffd95 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -229,7 +229,7 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), title->str);
body = g_string_new ("");
- origin_ui = gs_app_dup_origin_ui (app);
+ origin_ui = gs_app_dup_origin_ui (app, TRUE);
if (hint & GS_APP_LICENSE_NONFREE) {
g_string_append_printf (body,
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index af5de904f..e4308f606 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -266,7 +266,7 @@ gs_details_page_update_origin_button (GsDetailsPage *self,
return;
}
- origin_ui = gs_app_dup_origin_ui (self->app);
+ origin_ui = gs_app_dup_origin_ui (self->app, TRUE);
if (origin_ui != NULL)
gtk_menu_button_set_label (GTK_MENU_BUTTON (self->origin_button), origin_ui);
else
@@ -548,8 +548,8 @@ app_origin_equal (GsApp *a,
if (a == b)
return TRUE;
- a_origin_ui = gs_app_dup_origin_ui (a);
- b_origin_ui = gs_app_dup_origin_ui (b);
+ a_origin_ui = gs_app_dup_origin_ui (a, TRUE);
+ b_origin_ui = gs_app_dup_origin_ui (b, TRUE);
a_local_file = gs_app_get_local_file (a);
b_local_file = gs_app_get_local_file (b);
@@ -1853,8 +1853,8 @@ origin_popover_list_sort_func (GtkListBoxRow *a,
{
GsApp *a1 = gs_origin_popover_row_get_app (GS_ORIGIN_POPOVER_ROW (a));
GsApp *a2 = gs_origin_popover_row_get_app (GS_ORIGIN_POPOVER_ROW (b));
- g_autofree gchar *a1_origin = gs_app_dup_origin_ui (a1);
- g_autofree gchar *a2_origin = gs_app_dup_origin_ui (a2);
+ g_autofree gchar *a1_origin = gs_app_dup_origin_ui (a1, TRUE);
+ g_autofree gchar *a2_origin = gs_app_dup_origin_ui (a2, TRUE);
return gs_utils_sort_strcmp (a1_origin, a2_origin);
}
diff --git a/src/gs-origin-popover-row.c b/src/gs-origin-popover-row.c
index eae58cf86..b23f7fb7e 100644
--- a/src/gs-origin-popover-row.c
+++ b/src/gs-origin-popover-row.c
@@ -43,7 +43,7 @@ refresh_ui (GsOriginPopoverRow *row)
g_assert (GS_IS_ORIGIN_POPOVER_ROW (row));
g_assert (GS_IS_APP (priv->app));
- origin_ui = gs_app_dup_origin_ui (priv->app);
+ origin_ui = gs_app_dup_origin_ui (priv->app, TRUE);
if (origin_ui != NULL) {
gtk_label_set_text (GTK_LABEL (priv->name_label), origin_ui);
}
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index bb9546392..81a1471fb 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -376,7 +376,7 @@ add_repo (GsReposDialog *dialog,
return;
}
- origin_ui = gs_app_dup_origin_ui (repo);
+ origin_ui = gs_app_dup_origin_ui (repo, TRUE);
if (!origin_ui)
origin_ui = gs_app_get_packaging_format (repo);
if (!origin_ui) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]