Commit 86dbd736 authored by Adrien Plazas's avatar Adrien Plazas

librem5: details-page: Drop the screenshots

It's not worth showing poorly sized desktop screenshots on a phone.
parent 204f6db9
......@@ -21,7 +21,6 @@
#include "gs-app-addon-row.h"
#include "gs-history-dialog.h"
#include "gs-origin-popover-row.h"
#include "gs-screenshot-image.h"
#include "gs-star-widget.h"
#include "gs-review-histogram.h"
#include "gs-review-dialog.h"
......@@ -66,10 +65,6 @@ struct _GsDetailsPage
GtkWidget *box_progress2;
GtkWidget *star;
GtkWidget *label_review_count;
GtkWidget *box_details_screenshot;
GtkWidget *box_details_screenshot_main;
GtkWidget *box_details_screenshot_scrolledwindow;
GtkWidget *box_details_screenshot_thumbnails;
GtkWidget *box_details_license_list;
GtkWidget *button_details_launch;
GtkWidget *button_details_add_shortcut;
......@@ -118,7 +113,6 @@ struct _GsDetailsPage
GtkWidget *label_licenses_intro;
GtkWidget *list_box_addons;
GtkWidget *box_reviews;
GtkWidget *box_details_screenshot_fallback;
GtkWidget *histogram;
GtkWidget *button_review;
GtkWidget *list_box_reviews;
......@@ -469,191 +463,6 @@ gs_details_page_notify_state_changed_cb (GsApp *app,
g_idle_add (gs_details_page_switch_to_idle, g_object_ref (self));
}
static void
gs_details_page_load_main_screenshot (GsDetailsPage *self,
AsScreenshot *screenshot)
{
GsScreenshotImage *ssmain;
g_autoptr(GList) children = NULL;
children = gtk_container_get_children (GTK_CONTAINER (self->box_details_screenshot_main));
ssmain = GS_SCREENSHOT_IMAGE (children->data);
gs_screenshot_image_set_screenshot (ssmain, screenshot);
gs_screenshot_image_load_async (ssmain, NULL);
}
static void
gs_details_page_screenshot_selected_cb (GtkListBox *list,
GtkListBoxRow *row,
GsDetailsPage *self)
{
GsScreenshotImage *ssthumb;
AsScreenshot *ss;
g_autoptr(GList) children = NULL;
if (row == NULL)
return;
ssthumb = GS_SCREENSHOT_IMAGE (gtk_bin_get_child (GTK_BIN (row)));
ss = gs_screenshot_image_get_screenshot (ssthumb);
gs_details_page_load_main_screenshot (self, ss);
}
static void
gs_details_page_refresh_screenshots (GsDetailsPage *self)
{
GPtrArray *screenshots;
AsScreenshot *ss;
GtkWidget *label;
GtkWidget *list;
GtkWidget *ssimg;
GtkWidget *main_screenshot = NULL;
guint i;
gboolean is_offline = !gs_plugin_loader_get_network_available (self->plugin_loader);
guint num_screenshots_loaded = 0;
/* reset the visibility of screenshots */
gtk_widget_show (self->box_details_screenshot);
/* treat screenshots differently */
if (gs_app_get_kind (self->app) == AS_APP_KIND_FONT) {
gs_container_remove_all (GTK_CONTAINER (self->box_details_screenshot_thumbnails));
gs_container_remove_all (GTK_CONTAINER (self->box_details_screenshot_main));
screenshots = gs_app_get_screenshots (self->app);
for (i = 0; i < screenshots->len; i++) {
ss = g_ptr_array_index (screenshots, i);
/* set caption */
label = gtk_label_new (as_screenshot_get_caption (ss, NULL));
g_object_set (label,
"xalign", 0.0,
"max-width-chars", 10,
"wrap", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_main), label);
gtk_widget_set_visible (label, TRUE);
/* set images */
ssimg = gs_screenshot_image_new (self->session);
gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg),
640,
48);
gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), NULL);
gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_main), ssimg);
gtk_widget_set_visible (ssimg, TRUE);
}
gtk_widget_set_visible (self->box_details_screenshot,
screenshots->len > 0);
gtk_widget_set_visible (self->box_details_screenshot_fallback,
screenshots->len == 0 && !is_offline);
return;
}
/* fallback warning */
screenshots = gs_app_get_screenshots (self->app);
switch (gs_app_get_kind (self->app)) {
case AS_APP_KIND_GENERIC:
case AS_APP_KIND_CODEC:
case AS_APP_KIND_ADDON:
case AS_APP_KIND_SOURCE:
case AS_APP_KIND_FIRMWARE:
case AS_APP_KIND_DRIVER:
case AS_APP_KIND_INPUT_METHOD:
case AS_APP_KIND_LOCALIZATION:
case AS_APP_KIND_RUNTIME:
gtk_widget_set_visible (self->box_details_screenshot_fallback, FALSE);
break;
default:
gtk_widget_set_visible (self->box_details_screenshot_fallback,
screenshots->len == 0 && !is_offline);
break;
}
/* reset screenshots */
gs_container_remove_all (GTK_CONTAINER (self->box_details_screenshot_main));
gs_container_remove_all (GTK_CONTAINER (self->box_details_screenshot_thumbnails));
list = gtk_list_box_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (list), "image-list");
gtk_widget_show (list);
gtk_widget_show (self->box_details_screenshot_scrolledwindow);
gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_thumbnails), list);
for (i = 0; i < screenshots->len; i++) {
ss = g_ptr_array_index (screenshots, i);
/* we need to load the main screenshot only once if we're online
* but all times if we're offline (to check which are cached and
* hide those who aren't) */
if (is_offline || main_screenshot == NULL) {
GtkWidget *ssmain = gs_screenshot_image_new (self->session);
gtk_widget_set_can_focus (gtk_bin_get_child (GTK_BIN (ssmain)), FALSE);
gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssmain), ss);
gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssmain),
AS_IMAGE_NORMAL_WIDTH,
AS_IMAGE_NORMAL_HEIGHT);
gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssmain), NULL);
/* when we're offline, the load will be immediate, so we
* can check if it succeeded, and just skip it and its
* thumbnails otherwise */
if (is_offline &&
!gs_screenshot_image_is_showing (GS_SCREENSHOT_IMAGE (ssmain)))
continue;
/* only set the main_screenshot once */
if (main_screenshot == NULL) {
main_screenshot = ssmain;
gtk_box_pack_start (GTK_BOX (self->box_details_screenshot_main),
main_screenshot, FALSE, FALSE, 0);
gtk_widget_show (main_screenshot);
}
}
ssimg = gs_screenshot_image_new (self->session);
gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg),
AS_IMAGE_THUMBNAIL_WIDTH,
AS_IMAGE_THUMBNAIL_HEIGHT);
gtk_style_context_add_class (gtk_widget_get_style_context (ssimg),
"screenshot-image-thumb");
gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), NULL);
gtk_list_box_insert (GTK_LIST_BOX (list), ssimg, -1);
gtk_widget_set_visible (ssimg, TRUE);
++num_screenshots_loaded;
}
if (main_screenshot == NULL) {
gtk_widget_hide (self->box_details_screenshot);
return;
}
/* reload the main screenshot with a larger size if it's the only screenshot
* available */
if (num_screenshots_loaded == 1) {
gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (main_screenshot),
AS_IMAGE_LARGE_WIDTH,
AS_IMAGE_LARGE_HEIGHT);
gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (main_screenshot), NULL);
}
if (num_screenshots_loaded <= 1) {
gtk_widget_hide (self->box_details_screenshot_thumbnails);
return;
}
gtk_widget_show (self->box_details_screenshot_thumbnails);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_BROWSE);
g_signal_connect (list, "row-selected",
G_CALLBACK (gs_details_page_screenshot_selected_cb),
self);
gtk_list_box_select_row (GTK_LIST_BOX (list),
gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), 0));
}
static void
gs_details_page_website_cb (GtkWidget *widget, GsDetailsPage *self)
{
......@@ -1773,7 +1582,6 @@ gs_details_page_load_stage2 (GsDetailsPage *self)
/* update UI */
gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_READY);
gs_details_page_refresh_screenshots (self);
gs_details_page_refresh_addons (self);
gs_details_page_refresh_reviews (self);
gs_details_page_refresh_all (self);
......@@ -2698,10 +2506,6 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_progress2);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, star);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_review_count);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_screenshot);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_screenshot_main);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_screenshot_scrolledwindow);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_screenshot_thumbnails);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_details_license_list);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_launch);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_add_shortcut);
......@@ -2748,7 +2552,6 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
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, 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);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_review);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, list_box_reviews);
......
......@@ -305,7 +305,6 @@
<child>
<object class="GtkBox" id="box_details_screenshot">
<property name="visible">True</property>
<property name="margin_bottom">14</property>
<property name="spacing">9</property>
<child>
......@@ -342,7 +341,6 @@
</child>
<child>
<object class="GtkBox" id="box_details_screenshot_fallback">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="width_request">752</property>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment