void gs_popular_tile_set_app (GsPopularTile *tile, GsApp *app) { g_return_if_fail (GS_IS_POPULAR_TILE (tile)); g_return_if_fail (GS_IS_APP (app) || app == NULL); if (tile->app) g_signal_handlers_disconnect_by_func (tile->app, app_state_changed, tile); g_set_object (&tile->app, app); if (!app) return; if (gs_app_get_rating (tile->app) >= 0) { gtk_widget_set_visible (tile->stars, TRUE); gs_star_widget_set_rating (GS_STAR_WIDGET (tile->stars), gs_app_get_rating (tile->app)); } else { gtk_widget_set_visible (tile->stars, FALSE); } gtk_stack_set_visible_child_name (GTK_STACK (tile->stack), "content"); g_signal_connect (tile->app, "notify::state", G_CALLBACK (app_state_changed), tile); app_state_changed (tile->app, NULL, tile); /* perhaps set custom css */ gs_utils_widget_set_custom_css (app, GTK_WIDGET (tile), "GnomeSoftware::PopularTile-css"); gs_image_set_from_pixbuf (GTK_IMAGE (tile->image), gs_app_get_pixbuf (tile->app)); gtk_label_set_label (GTK_LABEL (tile->label), gs_app_get_name (app)); }
void gs_app_tile_set_app (GsAppTile *tile, GsApp *app) { GsAppTilePrivate *priv; const gchar *summary; g_return_if_fail (GS_IS_APP_TILE (tile)); g_return_if_fail (GS_IS_APP (app) || app == NULL); priv = gs_app_tile_get_instance_private (tile); gtk_image_clear (GTK_IMAGE (priv->image)); gtk_image_set_pixel_size (GTK_IMAGE (priv->image), 64); if (priv->app) g_signal_handlers_disconnect_by_func (priv->app, app_state_changed, tile); g_clear_object (&priv->app); if (!app) return; priv->app = g_object_ref (app); if (gs_app_get_rating_kind (priv->app) == GS_APP_RATING_KIND_USER) { gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars), GS_APP_RATING_KIND_USER, gs_app_get_rating (priv->app)); } else { gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars), GS_APP_RATING_KIND_KUDOS, gs_app_get_kudos_percentage (priv->app)); } gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "content"); g_signal_connect (priv->app, "notify::state", G_CALLBACK (app_state_changed), tile); app_state_changed (priv->app, NULL, tile); gs_image_set_from_pixbuf (GTK_IMAGE (priv->image), gs_app_get_pixbuf (app)); gtk_label_set_label (GTK_LABEL (priv->name), gs_app_get_name (app)); summary = gs_app_get_summary (app); gtk_label_set_label (GTK_LABEL (priv->summary), summary); gtk_widget_set_visible (priv->summary, summary && summary[0]); }
void gs_app_row_refresh (GsAppRow *app_row) { GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row); GtkStyleContext *context; GString *str = NULL; const gchar *tmp; gboolean missing_search_result; guint64 installed_size; if (priv->app == NULL) return; /* is this a missing search result from the extras page? */ missing_search_result = (gs_app_get_state (priv->app) == AS_APP_STATE_UNAVAILABLE && gs_app_get_url (priv->app, AS_URL_KIND_MISSING) != NULL); /* do a fill bar for the current progress */ switch (gs_app_get_state (priv->app)) { case AS_APP_STATE_INSTALLING: gs_progress_button_set_progress (GS_PROGRESS_BUTTON (priv->button), gs_app_get_progress (priv->app)); gs_progress_button_set_show_progress (GS_PROGRESS_BUTTON (priv->button), TRUE); break; default: gs_progress_button_set_show_progress (GS_PROGRESS_BUTTON (priv->button), FALSE); break; } /* join the description lines */ str = gs_app_row_get_description (app_row); if (str != NULL) { as_utils_string_replace (str, "\n", " "); gtk_label_set_label (GTK_LABEL (priv->description_label), str->str); g_string_free (str, TRUE); } else { gtk_label_set_text (GTK_LABEL (priv->description_label), NULL); } /* add warning */ if (gs_app_has_quirk (priv->app, AS_APP_QUIRK_REMOVABLE_HARDWARE)) { gtk_label_set_text (GTK_LABEL (priv->label_warning), /* TRANSLATORS: during the update the device * will restart into a special update-only mode */ _("Device cannot be used during update.")); gtk_widget_show (priv->label_warning); } /* where did this app come from */ if (priv->show_source) { tmp = gs_app_get_origin_hostname (priv->app); if (tmp != NULL) { g_autofree gchar *origin_tmp = NULL; /* TRANSLATORS: this refers to where the app came from */ origin_tmp = g_strdup_printf ("%s: %s", _("Source"), tmp); gtk_label_set_label (GTK_LABEL (priv->label_origin), origin_tmp); } gtk_widget_set_visible (priv->label_origin, tmp != NULL); } else { gtk_widget_set_visible (priv->label_origin, FALSE); } /* installed tag */ if (!priv->show_buttons) { switch (gs_app_get_state (priv->app)) { case AS_APP_STATE_UPDATABLE: case AS_APP_STATE_UPDATABLE_LIVE: case AS_APP_STATE_INSTALLED: gtk_widget_set_visible (priv->label_installed, TRUE); break; default: gtk_widget_set_visible (priv->label_installed, FALSE); break; } } else { gtk_widget_set_visible (priv->label_installed, FALSE); } /* name */ if (g_strcmp0 (gs_app_get_branch (priv->app), "master") == 0) { g_autofree gchar *name = NULL; /* TRANSLATORS: not translated to match what flatpak does */ name = g_strdup_printf ("%s (Nightly)", gs_app_get_name (priv->app)); gtk_label_set_label (GTK_LABEL (priv->name_label), name); } else { gtk_label_set_label (GTK_LABEL (priv->name_label), gs_app_get_name (priv->app)); } if (priv->show_update && (gs_app_get_state (priv->app) == AS_APP_STATE_UPDATABLE || gs_app_get_state (priv->app) == AS_APP_STATE_UPDATABLE_LIVE)) { g_autofree gchar *verstr = NULL; verstr = gs_app_row_format_version_update (priv->app); gtk_label_set_label (GTK_LABEL (priv->version_label), verstr); gtk_widget_set_visible (priv->version_label, verstr != NULL); gtk_widget_hide (priv->star); } else { gtk_widget_hide (priv->version_label); if (missing_search_result || gs_app_get_rating (priv->app) <= 0) { gtk_widget_hide (priv->star); } else { gtk_widget_show (priv->star); gtk_widget_set_sensitive (priv->star, FALSE); gs_star_widget_set_rating (GS_STAR_WIDGET (priv->star), gs_app_get_rating (priv->app)); } gtk_label_set_label (GTK_LABEL (priv->version_label), gs_app_get_version_ui (priv->app)); } /* folders */ if (priv->show_folders && gs_utils_is_current_desktop ("GNOME") && g_settings_get_boolean (priv->settings, "show-folder-management")) { g_autoptr(GsFolders) folders = NULL; const gchar *folder; folders = gs_folders_get (); folder = gs_folders_get_app_folder (folders, gs_app_get_id (priv->app), gs_app_get_categories (priv->app)); if (folder != NULL) folder = gs_folders_get_folder_name (folders, folder); gtk_label_set_label (GTK_LABEL (priv->folder_label), folder); gtk_widget_set_visible (priv->folder_label, folder != NULL); } else { gtk_widget_hide (priv->folder_label); } /* pixbuf */ if (gs_app_get_pixbuf (priv->app) != NULL) gs_image_set_from_pixbuf (GTK_IMAGE (priv->image), gs_app_get_pixbuf (priv->app)); context = gtk_widget_get_style_context (priv->image); if (missing_search_result) gtk_style_context_add_class (context, "dimmer-label"); else gtk_style_context_remove_class (context, "dimmer-label"); /* pending label */ switch (gs_app_get_state (priv->app)) { case AS_APP_STATE_QUEUED_FOR_INSTALL: gtk_widget_set_visible (priv->label, TRUE); gtk_label_set_label (GTK_LABEL (priv->label), _("Pending")); break; default: gtk_widget_set_visible (priv->label, FALSE); break; } /* spinner */ switch (gs_app_get_state (priv->app)) { case AS_APP_STATE_REMOVING: gtk_spinner_start (GTK_SPINNER (priv->spinner)); gtk_widget_set_visible (priv->spinner, TRUE); break; default: gtk_widget_set_visible (priv->spinner, FALSE); break; } /* button */ gs_app_row_refresh_button (app_row, missing_search_result); /* hide buttons in the update list, unless the app is live updatable */ switch (gs_app_get_state (priv->app)) { case AS_APP_STATE_UPDATABLE_LIVE: case AS_APP_STATE_INSTALLING: gtk_widget_set_visible (priv->button_box, TRUE); break; default: gtk_widget_set_visible (priv->button_box, !priv->show_update); break; } /* checkbox */ if (priv->selectable) { if (gs_app_get_kind (priv->app) == AS_APP_KIND_DESKTOP || gs_app_get_kind (priv->app) == AS_APP_KIND_RUNTIME || gs_app_get_kind (priv->app) == AS_APP_KIND_WEB_APP) gtk_widget_set_visible (priv->checkbox, TRUE); } else { gtk_widget_set_visible (priv->checkbox, FALSE); } installed_size = gs_app_get_size_installed (priv->app); if (priv->show_installed_size && installed_size != GS_APP_SIZE_UNKNOWABLE && installed_size != 0) { g_autofree gchar *size = NULL; size = g_format_size (installed_size); gtk_label_set_label (GTK_LABEL (priv->label_app_size), size); gtk_widget_show (priv->label_app_size); } else { gtk_widget_hide (priv->label_app_size); } }