css: Query icon theme from style, not from settings

No need to look at the settings when the CSS has a property for the icon
theme.
This commit is contained in:
Benjamin Otte 2015-12-02 03:18:26 +01:00
parent d26a4b5555
commit bc1b53a34c
11 changed files with 58 additions and 38 deletions

View File

@ -31,6 +31,7 @@
#include <string.h>
#include "gtkcssenumvalueprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkiconfactory.h"
#include "gtkiconcache.h"
#include "gtkdebug.h"
@ -1275,14 +1276,13 @@ render_icon_name_pixbuf (GtkIconSource *icon_source,
GdkPixbuf *pixbuf;
GdkPixbuf *tmp_pixbuf;
GtkIconSource tmp_source;
GdkScreen *screen;
GtkIconTheme *icon_theme;
gint width, height, pixel_size;
gint *sizes, *s, dist;
GError *error = NULL;
screen = gtk_style_context_get_screen (context);
icon_theme = gtk_icon_theme_get_for_screen (screen);
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_THEME));
if (!gtk_icon_size_lookup (size, &width, &height))
{

View File

@ -41,8 +41,10 @@
#include "gtknumerableicon.h"
#include "gtknumerableiconprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtkstylepropertyprivate.h"
#include "gtkwidget.h"
#include "gtkwidgetpath.h"
#include "gtkwindow.h"
@ -192,15 +194,14 @@ static cairo_surface_t *
draw_from_gicon (GtkNumerableIcon *self)
{
GtkIconTheme *theme;
GdkScreen *screen;
GtkIconInfo *info;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
if (self->priv->style != NULL)
{
screen = gtk_style_context_get_screen (self->priv->style);
theme = gtk_icon_theme_get_for_screen (screen);
theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (self->priv->style, GTK_CSS_PROPERTY_ICON_THEME));
}
else
{

View File

@ -131,3 +131,10 @@ _gtk_css_icon_theme_value_new (void)
return _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_ICON_THEME);
}
GtkIconTheme *
gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_ICON_THEME, NULL);
return value->icontheme;
}

View File

@ -20,6 +20,8 @@
#ifndef __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
#define __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
#include "gtkicontheme.h"
#include "gtkcssparserprivate.h"
#include "gtkcssvalueprivate.h"
@ -27,6 +29,8 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_icon_theme_value_new (void);
GtkIconTheme * gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value);
G_END_DECLS
#endif /* __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__ */

View File

@ -23,6 +23,7 @@
#include <math.h>
#include "gtkcssiconthemevalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstyleproviderprivate.h"
@ -133,18 +134,10 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkCssImageIconTheme *copy;
GtkSettings *settings;
GdkScreen *screen;
settings = _gtk_style_provider_private_get_settings (provider);
if (settings == NULL)
screen = gdk_screen_get_default ();
else
screen = _gtk_settings_get_screen (settings);
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
copy->name = g_strdup (icon_theme->name);
copy->icon_theme = gtk_icon_theme_get_for_screen (screen);
copy->icon_theme = gtk_css_icon_theme_value_get_icon_theme (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_THEME));
copy->scale = _gtk_style_provider_private_get_scale (provider);
copy->color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));

View File

@ -34,6 +34,7 @@
#include "gtkcellrenderertext.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkcombobox.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkdnd.h"
#include "gtkicontheme.h"
#include "deprecated/gtkiconfactory.h"
@ -1489,10 +1490,8 @@ gtk_file_chooser_button_screen_changed (GtkWidget *widget,
static GtkIconTheme *
get_icon_theme (GtkWidget *widget)
{
if (gtk_widget_has_screen (widget))
return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
return gtk_icon_theme_get_default ();
return gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_THEME));
}
@ -1963,7 +1962,7 @@ model_add_bookmarks (GtkFileChooserButton *button,
if (!label)
label = _gtk_file_chooser_label_for_file (file);
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
icon_theme = get_icon_theme (GTK_WIDGET (button));
surface = gtk_icon_theme_load_surface (icon_theme, "folder-remote",
button->priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
@ -2070,7 +2069,7 @@ model_update_current_folder (GtkFileChooserButton *button,
if (!label)
label = _gtk_file_chooser_label_for_file (file);
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
icon_theme = get_icon_theme (GTK_WIDGET (button));
if (g_file_is_native (file))
surface = gtk_icon_theme_load_surface (icon_theme, "folder",

View File

@ -21,15 +21,16 @@
#include "config.h"
#include <string.h>
#include "gtkfilesystem.h"
#include <string.h>
#include <glib/gi18n-lib.h>
#include "gtkfilechooser.h"
#include "gtkfilesystem.h"
#include "gtkicontheme.h"
#include "gtkprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
/* #define DEBUG_MODE */
#ifdef DEBUG_MODE
@ -707,14 +708,15 @@ get_surface_from_gicon (GIcon *icon,
gint icon_size,
GError **error)
{
GdkScreen *screen;
GtkStyleContext *context;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
icon_theme = gtk_icon_theme_get_for_screen (screen);
context = gtk_widget_get_style_context (widget);
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_THEME));
icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
icon,
@ -726,7 +728,7 @@ get_surface_from_gicon (GIcon *icon,
return NULL;
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
gtk_widget_get_style_context (widget),
context,
NULL,
error);

View File

@ -24,6 +24,7 @@
#include <math.h>
#include "gtkcssenumvalueprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkrender.h"
#include "gtkstylecontextprivate.h"
#include "deprecated/gtkstock.h"
@ -457,7 +458,8 @@ ensure_surface_for_gicon (GtkIconHelper *self,
GtkIconLookupFlags flags;
cairo_surface_t *surface;
icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_THEME));
flags = get_icon_lookup_flags (self, context);
ensure_icon_size (self, &width, &height);

View File

@ -29,6 +29,7 @@
#include "gtkmountoperationprivate.h"
#include "gtkbox.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkdbusgenerated.h"
#include "gtkentry.h"
#include "gtkbox.h"
@ -49,6 +50,7 @@
#include "gtkmenuitem.h"
#include "gtkmain.h"
#include "gtksettings.h"
#include "gtkstylecontextprivate.h"
#include <glib/gprintf.h>
@ -1096,7 +1098,9 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation,
if (pixbuf == NULL)
{
GtkIconTheme *theme;
theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (mount_operation->priv->dialog)));
theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (mount_operation->priv->dialog)),
GTK_CSS_PROPERTY_ICON_THEME));
pixbuf = gtk_icon_theme_load_icon (theme,
"application-x-executable",
24,

View File

@ -38,6 +38,7 @@
#include "gtkcheckmenuitem.h"
#include "gtkclipboard.h"
#include "gtkcomboboxtext.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkdragsource.h"
#include "gtkentry.h"
#include "gtkeventbox.h"
@ -54,6 +55,7 @@
#include "gtkseparatormenuitem.h"
#include "gtksizegroup.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtktreemodelsort.h"
#include "gtktreemodelfilter.h"
#include "gtktreeselection.h"
@ -1340,10 +1342,9 @@ chooser_set_sort_type (GtkRecentChooserDefault *impl,
static GtkIconTheme *
get_icon_theme_for_widget (GtkWidget *widget)
{
if (gtk_widget_has_screen (widget))
return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
return gtk_icon_theme_get_default ();
return gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (widget),
GTK_CSS_PROPERTY_ICON_THEME));
}
static gint

View File

@ -36,6 +36,7 @@
#include "gtkaccelgroupprivate.h"
#include "gtkbindings.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkkeyhash.h"
@ -4412,7 +4413,9 @@ icon_list_from_theme (GtkWindow *window,
gint *sizes;
gint i;
icon_theme = gtk_icon_theme_get_for_screen (_gtk_window_get_screen (window));
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (window)),
GTK_CSS_PROPERTY_ICON_THEME));
sizes = gtk_icon_theme_get_icon_sizes (icon_theme, name);
@ -4514,7 +4517,9 @@ gtk_window_realize_icon (GtkWindow *window)
g_list_free_full (icon_list, g_object_unref);
icon_theme = gtk_icon_theme_get_for_screen (_gtk_window_get_screen (window));
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (window)),
GTK_CSS_PROPERTY_ICON_THEME));
g_signal_connect (icon_theme, "changed",
G_CALLBACK (update_themed_icon), window);
}
@ -4601,7 +4606,9 @@ gtk_window_unrealize_icon (GtkWindow *window)
{
GtkIconTheme *icon_theme;
icon_theme = gtk_icon_theme_get_for_screen (_gtk_window_get_screen (window));
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (window)),
GTK_CSS_PROPERTY_ICON_THEME));
g_signal_handlers_disconnect_by_func (icon_theme, update_themed_icon, window);
}