Merge branch 'about-dialog-icon-size' into 'master'

About dialog icon size

See merge request GNOME/gtk!3070
This commit is contained in:
Benjamin Otte 2021-01-11 23:13:21 +00:00
commit d939d04885
4 changed files with 17 additions and 36 deletions

View File

@ -101,6 +101,12 @@
* "title", _("About ExampleCode"),
* NULL);
* ]|
*
* # CSS nodes
*
* GtkAboutDialog has a single CSS node with the name window and style
* class .aboutdialog.
*/
typedef struct
@ -1644,41 +1650,7 @@ gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
if (gtk_image_get_storage_type (GTK_IMAGE (about->logo_image)) == GTK_IMAGE_PAINTABLE)
g_object_notify_by_pspec (G_OBJECT (about), props[PROP_LOGO]);
if (icon_name)
{
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (about)));
int *sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_name);
int i, best_size = 0;
for (i = 0; sizes[i]; i++)
{
if (sizes[i] >= 128 || sizes[i] == -1)
{
best_size = 128;
break;
}
else if (sizes[i] >= 96)
{
best_size = MAX (96, best_size);
}
else if (sizes[i] >= 64)
{
best_size = MAX (64, best_size);
}
else
{
best_size = MAX (48, best_size);
}
}
g_free (sizes);
gtk_image_set_from_icon_name (GTK_IMAGE (about->logo_image), icon_name);
gtk_image_set_pixel_size (GTK_IMAGE (about->logo_image), best_size);
}
else
{
gtk_image_clear (GTK_IMAGE (about->logo_image));
}
gtk_image_set_from_icon_name (GTK_IMAGE (about->logo_image), icon_name);
g_object_notify_by_pspec (G_OBJECT (about), props[PROP_LOGO_ICON_NAME]);

View File

@ -348,7 +348,8 @@ gtk_icon_helper_invalidate_for_change (GtkIconHelper *self,
GtkCssStyleChange *change)
{
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE))
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE |
GTK_CSS_AFFECTS_ICON_SIZE))
{
/* Avoid the queue_resize in gtk_icon_helper_invalidate */
g_clear_object (&self->paintable);

View File

@ -200,6 +200,10 @@ window.assistant {
}
}
window.aboutdialog image.large-icons {
-gtk-icon-size: 128px;
}
%osd,
.osd {
color: $osd_fg_color;

View File

@ -2,6 +2,9 @@
<interface domain="gtk40">
<template class="GtkAboutDialog" parent="GtkWindow">
<property name="resizable">0</property>
<style>
<class name="aboutdialog"/>
</style>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar1">
<child type="title">
@ -32,6 +35,7 @@
<child>
<object class="GtkImage" id="logo_image">
<property name="icon-name">image-missing</property>
<property name="icon-size">large</property>
<style>
<class name="icon-dropshadow"/>
</style>