Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/bz-entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,7 @@ GIcon *
bz_load_mini_icon_sync (const char *unique_id_checksum,
const char *path)
{
guint icon_size = 0;
g_autofree char *main_cache = NULL;
g_autoptr (GString) mini_icon_basename = NULL;
g_autofree char *mini_icon_path = NULL;
Expand All @@ -2356,9 +2357,11 @@ bz_load_mini_icon_sync (const char *unique_id_checksum,
g_autoptr (GFile) mini_icon_file = NULL;
g_autoptr (GIcon) mini_icon = NULL;

icon_size = bz_get_desktop_search_provider_icon_size ();

main_cache = bz_dup_module_dir ();
mini_icon_basename = g_string_new (unique_id_checksum);
g_string_append (mini_icon_basename, "-24x24.png");
g_string_append_printf (mini_icon_basename, "-%ux%u.png", icon_size, icon_size);
mini_icon_path = g_build_filename (main_cache, mini_icon_basename->str, NULL);

if (g_file_test (mini_icon_path, G_FILE_TEST_EXISTS))
Expand All @@ -2369,11 +2372,12 @@ bz_load_mini_icon_sync (const char *unique_id_checksum,
width = cairo_image_surface_get_width (surface_in);
height = cairo_image_surface_get_height (surface_in);

/* 24x24 for the gnome-shell search provider */
surface_out = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 24, 24);
surface_out = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, icon_size, icon_size);
cairo = cairo_create (surface_out);

cairo_scale (cairo, 24.0 / (double) width, 24.0 / (double) height);
cairo_scale (cairo,
(double) icon_size / (double) width,
(double) icon_size / (double) height);
cairo_set_source_surface (cairo, surface_in, 0, 0);
cairo_paint (cairo);
cairo_restore (cairo);
Expand Down
43 changes: 43 additions & 0 deletions src/bz-env.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,46 @@ bz_get_n_download_workers (void)

return n_dl_workers;
}

guint
bz_get_desktop_search_provider_icon_size (void)
{
static guint64 icon_size = 0;

if (g_once_init_enter (&icon_size))
{
const char *envvar = NULL;
guint64 value = 0;

/* default 24x24 for the gnome-shell search provider */
value = 24;

envvar = g_getenv ("BAZAAR_DESKTOP_SEARCH_PROVIDER_ICON_SIZE");
if (envvar != NULL)
{
g_autoptr (GError) local_error = NULL;
g_autoptr (GVariant) variant = NULL;

variant = g_variant_parse (
G_VARIANT_TYPE_UINT64, envvar,
NULL, NULL, &local_error);
if (variant != NULL)
{
guint64 parse_result = 0;

parse_result = g_variant_get_uint64 (variant);
if (parse_result == 0 || parse_result > 256)
g_warning ("BAZAAR_DESKTOP_SEARCH_PROVIDER_ICON_SIZE must be "
"greater than 0 but no greater than 256");
else
value = parse_result;
}
else
g_warning ("BAZAAR_DESKTOP_SEARCH_PROVIDER_ICON_SIZE is invalid: %s", local_error->message);
}

g_once_init_leave (&icon_size, value);
}

return (guint) icon_size;
}
3 changes: 3 additions & 0 deletions src/bz-env.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ bz_get_dex_stack_size (void);
guint64
bz_get_n_download_workers (void);

guint
bz_get_desktop_search_provider_icon_size (void);

G_END_DECLS
Loading