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:
parent
d26a4b5555
commit
bc1b53a34c
@ -31,6 +31,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "gtkcssenumvalueprivate.h"
|
#include "gtkcssenumvalueprivate.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkiconfactory.h"
|
#include "gtkiconfactory.h"
|
||||||
#include "gtkiconcache.h"
|
#include "gtkiconcache.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
@ -1275,14 +1276,13 @@ render_icon_name_pixbuf (GtkIconSource *icon_source,
|
|||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkPixbuf *tmp_pixbuf;
|
GdkPixbuf *tmp_pixbuf;
|
||||||
GtkIconSource tmp_source;
|
GtkIconSource tmp_source;
|
||||||
GdkScreen *screen;
|
|
||||||
GtkIconTheme *icon_theme;
|
GtkIconTheme *icon_theme;
|
||||||
gint width, height, pixel_size;
|
gint width, height, pixel_size;
|
||||||
gint *sizes, *s, dist;
|
gint *sizes, *s, dist;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
screen = gtk_style_context_get_screen (context);
|
icon_theme = gtk_css_icon_theme_value_get_icon_theme
|
||||||
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_THEME));
|
||||||
|
|
||||||
if (!gtk_icon_size_lookup (size, &width, &height))
|
if (!gtk_icon_size_lookup (size, &width, &height))
|
||||||
{
|
{
|
||||||
|
@ -41,8 +41,10 @@
|
|||||||
#include "gtknumerableicon.h"
|
#include "gtknumerableicon.h"
|
||||||
#include "gtknumerableiconprivate.h"
|
#include "gtknumerableiconprivate.h"
|
||||||
|
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkicontheme.h"
|
#include "gtkicontheme.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
|
#include "gtkstylepropertyprivate.h"
|
||||||
#include "gtkwidget.h"
|
#include "gtkwidget.h"
|
||||||
#include "gtkwidgetpath.h"
|
#include "gtkwidgetpath.h"
|
||||||
#include "gtkwindow.h"
|
#include "gtkwindow.h"
|
||||||
@ -192,15 +194,14 @@ static cairo_surface_t *
|
|||||||
draw_from_gicon (GtkNumerableIcon *self)
|
draw_from_gicon (GtkNumerableIcon *self)
|
||||||
{
|
{
|
||||||
GtkIconTheme *theme;
|
GtkIconTheme *theme;
|
||||||
GdkScreen *screen;
|
|
||||||
GtkIconInfo *info;
|
GtkIconInfo *info;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
if (self->priv->style != NULL)
|
if (self->priv->style != NULL)
|
||||||
{
|
{
|
||||||
screen = gtk_style_context_get_screen (self->priv->style);
|
theme = gtk_css_icon_theme_value_get_icon_theme
|
||||||
theme = gtk_icon_theme_get_for_screen (screen);
|
(_gtk_style_context_peek_property (self->priv->style, GTK_CSS_PROPERTY_ICON_THEME));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -131,3 +131,10 @@ _gtk_css_icon_theme_value_new (void)
|
|||||||
return _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ICON_THEME);
|
return _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ICON_THEME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkIconTheme *
|
||||||
|
gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (value->class == >K_CSS_VALUE_ICON_THEME, NULL);
|
||||||
|
|
||||||
|
return value->icontheme;
|
||||||
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#ifndef __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
|
#ifndef __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
|
||||||
#define __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
|
#define __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gtkicontheme.h"
|
||||||
|
|
||||||
#include "gtkcssparserprivate.h"
|
#include "gtkcssparserprivate.h"
|
||||||
#include "gtkcssvalueprivate.h"
|
#include "gtkcssvalueprivate.h"
|
||||||
|
|
||||||
@ -27,6 +29,8 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
GtkCssValue * _gtk_css_icon_theme_value_new (void);
|
GtkCssValue * _gtk_css_icon_theme_value_new (void);
|
||||||
|
|
||||||
|
GtkIconTheme * gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__ */
|
#endif /* __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__ */
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkcssrgbavalueprivate.h"
|
#include "gtkcssrgbavalueprivate.h"
|
||||||
#include "gtksettingsprivate.h"
|
#include "gtksettingsprivate.h"
|
||||||
#include "gtkstyleproviderprivate.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 *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
|
||||||
GtkCssImageIconTheme *copy;
|
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 = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
|
||||||
copy->name = g_strdup (icon_theme->name);
|
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->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));
|
copy->color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "gtkcellrenderertext.h"
|
#include "gtkcellrenderertext.h"
|
||||||
#include "gtkcellrendererpixbuf.h"
|
#include "gtkcellrendererpixbuf.h"
|
||||||
#include "gtkcombobox.h"
|
#include "gtkcombobox.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkdnd.h"
|
#include "gtkdnd.h"
|
||||||
#include "gtkicontheme.h"
|
#include "gtkicontheme.h"
|
||||||
#include "deprecated/gtkiconfactory.h"
|
#include "deprecated/gtkiconfactory.h"
|
||||||
@ -1489,10 +1490,8 @@ gtk_file_chooser_button_screen_changed (GtkWidget *widget,
|
|||||||
static GtkIconTheme *
|
static GtkIconTheme *
|
||||||
get_icon_theme (GtkWidget *widget)
|
get_icon_theme (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
if (gtk_widget_has_screen (widget))
|
return gtk_css_icon_theme_value_get_icon_theme
|
||||||
return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
(_gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_THEME));
|
||||||
|
|
||||||
return gtk_icon_theme_get_default ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1963,7 +1962,7 @@ model_add_bookmarks (GtkFileChooserButton *button,
|
|||||||
if (!label)
|
if (!label)
|
||||||
label = _gtk_file_chooser_label_for_file (file);
|
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",
|
surface = gtk_icon_theme_load_surface (icon_theme, "folder-remote",
|
||||||
button->priv->icon_size,
|
button->priv->icon_size,
|
||||||
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
|
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
|
||||||
@ -2070,7 +2069,7 @@ model_update_current_folder (GtkFileChooserButton *button,
|
|||||||
if (!label)
|
if (!label)
|
||||||
label = _gtk_file_chooser_label_for_file (file);
|
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))
|
if (g_file_is_native (file))
|
||||||
surface = gtk_icon_theme_load_surface (icon_theme, "folder",
|
surface = gtk_icon_theme_load_surface (icon_theme, "folder",
|
||||||
|
@ -21,15 +21,16 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include "gtkfilesystem.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
#include "gtkfilechooser.h"
|
#include "gtkfilechooser.h"
|
||||||
#include "gtkfilesystem.h"
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkicontheme.h"
|
|
||||||
#include "gtkprivate.h"
|
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
|
#include "gtkprivate.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
|
|
||||||
/* #define DEBUG_MODE */
|
/* #define DEBUG_MODE */
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
@ -707,14 +708,15 @@ get_surface_from_gicon (GIcon *icon,
|
|||||||
gint icon_size,
|
gint icon_size,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkScreen *screen;
|
GtkStyleContext *context;
|
||||||
GtkIconTheme *icon_theme;
|
GtkIconTheme *icon_theme;
|
||||||
GtkIconInfo *icon_info;
|
GtkIconInfo *icon_info;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
|
context = gtk_widget_get_style_context (widget);
|
||||||
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));
|
||||||
|
|
||||||
icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
|
icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
|
||||||
icon,
|
icon,
|
||||||
@ -726,7 +728,7 @@ get_surface_from_gicon (GIcon *icon,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
|
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
|
||||||
gtk_widget_get_style_context (widget),
|
context,
|
||||||
NULL,
|
NULL,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gtkcssenumvalueprivate.h"
|
#include "gtkcssenumvalueprivate.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkrender.h"
|
#include "gtkrender.h"
|
||||||
#include "gtkstylecontextprivate.h"
|
#include "gtkstylecontextprivate.h"
|
||||||
#include "deprecated/gtkstock.h"
|
#include "deprecated/gtkstock.h"
|
||||||
@ -457,7 +458,8 @@ ensure_surface_for_gicon (GtkIconHelper *self,
|
|||||||
GtkIconLookupFlags flags;
|
GtkIconLookupFlags flags;
|
||||||
cairo_surface_t *surface;
|
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);
|
flags = get_icon_lookup_flags (self, context);
|
||||||
|
|
||||||
ensure_icon_size (self, &width, &height);
|
ensure_icon_size (self, &width, &height);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "gtkmountoperationprivate.h"
|
#include "gtkmountoperationprivate.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkdbusgenerated.h"
|
#include "gtkdbusgenerated.h"
|
||||||
#include "gtkentry.h"
|
#include "gtkentry.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
@ -49,6 +50,7 @@
|
|||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitem.h"
|
||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
|
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
@ -1096,7 +1098,9 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation,
|
|||||||
if (pixbuf == NULL)
|
if (pixbuf == NULL)
|
||||||
{
|
{
|
||||||
GtkIconTheme *theme;
|
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,
|
pixbuf = gtk_icon_theme_load_icon (theme,
|
||||||
"application-x-executable",
|
"application-x-executable",
|
||||||
24,
|
24,
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "gtkcheckmenuitem.h"
|
#include "gtkcheckmenuitem.h"
|
||||||
#include "gtkclipboard.h"
|
#include "gtkclipboard.h"
|
||||||
#include "gtkcomboboxtext.h"
|
#include "gtkcomboboxtext.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkdragsource.h"
|
#include "gtkdragsource.h"
|
||||||
#include "gtkentry.h"
|
#include "gtkentry.h"
|
||||||
#include "gtkeventbox.h"
|
#include "gtkeventbox.h"
|
||||||
@ -54,6 +55,7 @@
|
|||||||
#include "gtkseparatormenuitem.h"
|
#include "gtkseparatormenuitem.h"
|
||||||
#include "gtksizegroup.h"
|
#include "gtksizegroup.h"
|
||||||
#include "gtksizerequest.h"
|
#include "gtksizerequest.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
#include "gtktreemodelsort.h"
|
#include "gtktreemodelsort.h"
|
||||||
#include "gtktreemodelfilter.h"
|
#include "gtktreemodelfilter.h"
|
||||||
#include "gtktreeselection.h"
|
#include "gtktreeselection.h"
|
||||||
@ -1340,10 +1342,9 @@ chooser_set_sort_type (GtkRecentChooserDefault *impl,
|
|||||||
static GtkIconTheme *
|
static GtkIconTheme *
|
||||||
get_icon_theme_for_widget (GtkWidget *widget)
|
get_icon_theme_for_widget (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
if (gtk_widget_has_screen (widget))
|
return gtk_css_icon_theme_value_get_icon_theme
|
||||||
return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
(_gtk_style_context_peek_property (gtk_widget_get_style_context (widget),
|
||||||
|
GTK_CSS_PROPERTY_ICON_THEME));
|
||||||
return gtk_icon_theme_get_default ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "gtkaccelgroupprivate.h"
|
#include "gtkaccelgroupprivate.h"
|
||||||
#include "gtkbindings.h"
|
#include "gtkbindings.h"
|
||||||
#include "gtkcsscornervalueprivate.h"
|
#include "gtkcsscornervalueprivate.h"
|
||||||
|
#include "gtkcssiconthemevalueprivate.h"
|
||||||
#include "gtkcssrgbavalueprivate.h"
|
#include "gtkcssrgbavalueprivate.h"
|
||||||
#include "gtkcssshadowsvalueprivate.h"
|
#include "gtkcssshadowsvalueprivate.h"
|
||||||
#include "gtkkeyhash.h"
|
#include "gtkkeyhash.h"
|
||||||
@ -4412,7 +4413,9 @@ icon_list_from_theme (GtkWindow *window,
|
|||||||
gint *sizes;
|
gint *sizes;
|
||||||
gint i;
|
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);
|
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);
|
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_signal_connect (icon_theme, "changed",
|
||||||
G_CALLBACK (update_themed_icon), window);
|
G_CALLBACK (update_themed_icon), window);
|
||||||
}
|
}
|
||||||
@ -4601,7 +4606,9 @@ gtk_window_unrealize_icon (GtkWindow *window)
|
|||||||
{
|
{
|
||||||
GtkIconTheme *icon_theme;
|
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);
|
g_signal_handlers_disconnect_by_func (icon_theme, update_themed_icon, window);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user