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_feature_tile_set_app (GsFeatureTile *tile, GsApp *app) { const gchar *background; const gchar *stroke_color; const gchar *text_color; const gchar *text_shadow; g_autoptr(GString) data = NULL; g_return_if_fail (GS_IS_FEATURE_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; 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); gtk_label_set_label (GTK_LABEL (tile->title), gs_app_get_name (app)); gtk_label_set_label (GTK_LABEL (tile->subtitle), gs_app_get_summary (app)); /* check the app has the featured data */ text_color = gs_app_get_metadata_item (app, "Featured::text-color"); if (text_color == NULL) { g_autofree gchar *tmp = NULL; tmp = gs_app_to_string (app); g_warning ("%s has no featured data: %s", gs_app_get_id (app), tmp); return; } background = gs_app_get_metadata_item (app, "Featured::background"); stroke_color = gs_app_get_metadata_item (app, "Featured::stroke-color"); text_shadow = gs_app_get_metadata_item (app, "Featured::text-shadow"); data = g_string_sized_new (1024); g_string_append (data, ".featured-tile {\n"); g_string_append_printf (data, " border-color: %s;\n", stroke_color); if (text_shadow != NULL) g_string_append_printf (data, " text-shadow: %s;\n", text_shadow); g_string_append_printf (data, " color: %s;\n", text_color); g_string_append (data, " -GtkWidget-focus-padding: 0;\n"); g_string_append_printf (data, " outline-color: alpha(%s, 0.75);\n", text_color); g_string_append (data, " outline-style: dashed;\n"); g_string_append (data, " outline-offset: 2px;\n"); g_string_append_printf (data, " background: %s;\n", background); g_string_append (data, "}\n"); g_string_append (data, ".featured-tile:hover {\n"); g_string_append (data, " background: linear-gradient(to bottom,\n"); g_string_append (data, " alpha(#fff,0.16),\n"); g_string_append_printf (data, " alpha(#aaa,0.16)), %s;\n", background); g_string_append (data, "}\n"); gtk_css_provider_load_from_data (tile->provider, data->str, -1, NULL); }