mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-24 12:41:16 +00:00
stylecontext: Port to use display instead of screen
This commit is contained in:
parent
a2e625692e
commit
9151e0b9f5
@ -130,9 +130,9 @@ do_css_blendmodes (GtkWidget *do_widget)
|
||||
/* Setup the CSS provider for window */
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
setup_listbox (builder, provider);
|
||||
}
|
||||
|
@ -1661,9 +1661,9 @@ activate (GApplication *app)
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/org/gtk/WidgetFactory/widget-factory.css");
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
g_object_unref (provider);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/WidgetFactory/widget-factory.ui");
|
||||
|
@ -2643,7 +2643,6 @@ GtkSettingsValue
|
||||
gtk_settings_get_default
|
||||
gtk_settings_get_for_display
|
||||
gtk_settings_get_for_screen
|
||||
gtk_settings_get_for_display
|
||||
gtk_rc_property_parse_color
|
||||
gtk_rc_property_parse_enum
|
||||
gtk_rc_property_parse_flags
|
||||
@ -5093,12 +5092,12 @@ GTK_STYLE_CLASS_WIDE
|
||||
GtkStyleContext
|
||||
gtk_style_context_new
|
||||
gtk_style_context_add_provider
|
||||
gtk_style_context_add_provider_for_screen
|
||||
gtk_style_context_add_provider_for_display
|
||||
gtk_style_context_get
|
||||
gtk_style_context_get_parent
|
||||
gtk_style_context_get_path
|
||||
gtk_style_context_get_property
|
||||
gtk_style_context_get_screen
|
||||
gtk_style_context_get_display
|
||||
gtk_style_context_get_frame_clock
|
||||
gtk_style_context_get_state
|
||||
gtk_style_context_get_valist
|
||||
@ -5111,7 +5110,7 @@ gtk_style_context_get_padding
|
||||
gtk_style_context_get_margin
|
||||
gtk_style_context_lookup_color
|
||||
gtk_style_context_remove_provider
|
||||
gtk_style_context_remove_provider_for_screen
|
||||
gtk_style_context_remove_provider_for_display
|
||||
gtk_style_context_reset_widgets
|
||||
gtk_style_context_restore
|
||||
gtk_style_context_save
|
||||
@ -5121,7 +5120,7 @@ gtk_style_context_add_class
|
||||
gtk_style_context_remove_class
|
||||
gtk_style_context_has_class
|
||||
gtk_style_context_list_classes
|
||||
gtk_style_context_set_screen
|
||||
gtk_style_context_set_display
|
||||
gtk_style_context_set_frame_clock
|
||||
gtk_style_context_set_state
|
||||
gtk_style_context_set_scale
|
||||
|
@ -692,7 +692,7 @@ You can also change the font of a widget by putting
|
||||
}
|
||||
</programlisting>
|
||||
in a CSS file, loading it with gtk_css_provider_load_from_file(), and
|
||||
adding the provider with gtk_style_context_add_provider_for_screen().
|
||||
adding the provider with gtk_style_context_add_provider_for_display().
|
||||
To associate this style information with your widget, set a style class
|
||||
on its #GtkStyleContext using gtk_style_context_add_class().
|
||||
The advantage of this approach is that users can then override the font
|
||||
|
@ -226,9 +226,9 @@ plugin_action (GAction *action,
|
||||
|
||||
css_provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (css_provider, css_to_load, -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -912,9 +912,9 @@ preview_file (const char *filename,
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_path (provider, cssfile);
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
|
@ -81,7 +81,7 @@ gtk_css_value_icon_theme_compute (GtkCssValue *icon_theme,
|
||||
if (icon_theme->icontheme)
|
||||
icontheme = icon_theme->icontheme;
|
||||
else
|
||||
icontheme = gtk_icon_theme_get_for_screen (_gtk_settings_get_screen (_gtk_style_provider_private_get_settings (provider)));
|
||||
icontheme = gtk_icon_theme_get_for_screen (gdk_display_get_default_screen (_gtk_settings_get_display (_gtk_style_provider_private_get_settings (provider))));
|
||||
|
||||
return gtk_css_icon_theme_value_new (icontheme);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
settings = _gtk_style_provider_private_get_settings (provider);
|
||||
if (settings)
|
||||
{
|
||||
GdkScreen *screen = _gtk_settings_get_screen (settings);
|
||||
GdkScreen *screen = gdk_display_get_default_screen (_gtk_settings_get_display (settings));
|
||||
double resolution = gdk_screen_get_resolution (screen);
|
||||
|
||||
if (resolution > 0.0)
|
||||
|
@ -58,7 +58,7 @@
|
||||
* An application can make GTK+ parse a specific CSS style sheet by calling
|
||||
* gtk_css_provider_load_from_file() or gtk_css_provider_load_from_resource()
|
||||
* and adding the provider with gtk_style_context_add_provider() or
|
||||
* gtk_style_context_add_provider_for_screen().
|
||||
* gtk_style_context_add_provider_for_display().
|
||||
|
||||
* In addition, certain files will be read when GTK+ is initialized. First, the
|
||||
* file `$XDG_CONFIG_HOME/gtk-4.0/gtk.css` is loaded if it exists. Then, GTK+
|
||||
|
@ -738,7 +738,7 @@ theme_changed_idle (gpointer user_data)
|
||||
g_signal_emit (icon_theme, signal_changed, 0);
|
||||
|
||||
if (priv->screen && priv->is_screen_singleton)
|
||||
gtk_style_context_reset_widgets (priv->screen);
|
||||
gtk_style_context_reset_widgets (gdk_screen_get_display (priv->screen));
|
||||
|
||||
priv->theme_changed_idle = 0;
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ gtk_settings_notify (GObject *object,
|
||||
case PROP_FONT_NAME:
|
||||
settings_update_font_values (settings);
|
||||
settings_invalidate_style (settings);
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (priv->display));
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
break;
|
||||
case PROP_KEY_THEME_NAME:
|
||||
settings_update_key_theme (settings);
|
||||
@ -1410,21 +1410,21 @@ gtk_settings_notify (GObject *object,
|
||||
* widgets with gtk_widget_style_set(), and also causes more
|
||||
* recomputation than necessary.
|
||||
*/
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (priv->display));
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
break;
|
||||
case PROP_XFT_ANTIALIAS:
|
||||
case PROP_XFT_HINTING:
|
||||
case PROP_XFT_HINTSTYLE:
|
||||
case PROP_XFT_RGBA:
|
||||
settings_update_font_options (settings);
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (priv->display));
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
break;
|
||||
case PROP_FONTCONFIG_TIMESTAMP:
|
||||
if (settings_update_fontconfig (settings))
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (priv->display));
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
break;
|
||||
case PROP_ENABLE_ANIMATIONS:
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (priv->display));
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
break;
|
||||
case PROP_CURSOR_THEME_NAME:
|
||||
case PROP_CURSOR_THEME_SIZE:
|
||||
@ -2321,21 +2321,19 @@ settings_update_provider (GdkDisplay *display,
|
||||
{
|
||||
if (display != NULL && *old != new)
|
||||
{
|
||||
GdkScreen *screen = gdk_display_get_default_screen (display);
|
||||
|
||||
if (*old)
|
||||
{
|
||||
gtk_style_context_remove_provider_for_screen (screen,
|
||||
GTK_STYLE_PROVIDER (*old));
|
||||
gtk_style_context_remove_provider_for_display (display,
|
||||
GTK_STYLE_PROVIDER (*old));
|
||||
g_object_unref (*old);
|
||||
*old = NULL;
|
||||
}
|
||||
|
||||
if (new)
|
||||
{
|
||||
gtk_style_context_add_provider_for_screen (screen,
|
||||
GTK_STYLE_PROVIDER (new),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_THEME);
|
||||
gtk_style_context_add_provider_for_display (display,
|
||||
GTK_STYLE_PROVIDER (new),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_THEME);
|
||||
*old = g_object_ref (new);
|
||||
}
|
||||
}
|
||||
@ -2436,10 +2434,10 @@ gtk_settings_get_font_options (GtkSettings *settings)
|
||||
return settings->priv->font_options;
|
||||
}
|
||||
|
||||
GdkScreen *
|
||||
_gtk_settings_get_screen (GtkSettings *settings)
|
||||
GdkDisplay *
|
||||
_gtk_settings_get_display (GtkSettings *settings)
|
||||
{
|
||||
return gdk_display_get_default_screen (settings->priv->display);
|
||||
return settings->priv->display;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -38,7 +38,7 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParse
|
||||
GValue *dest_value);
|
||||
const cairo_font_options_t *
|
||||
gtk_settings_get_font_options (GtkSettings *settings);
|
||||
GdkScreen *_gtk_settings_get_screen (GtkSettings *settings);
|
||||
GdkDisplay *_gtk_settings_get_display (GtkSettings *settings);
|
||||
GtkStyleCascade *_gtk_settings_get_style_cascade (GtkSettings *settings,
|
||||
gint scale);
|
||||
|
||||
|
@ -62,18 +62,18 @@
|
||||
* In order to construct the final style information, #GtkStyleContext
|
||||
* queries information from all attached #GtkStyleProviders. Style providers
|
||||
* can be either attached explicitly to the context through
|
||||
* gtk_style_context_add_provider(), or to the screen through
|
||||
* gtk_style_context_add_provider_for_screen(). The resulting style is a
|
||||
* gtk_style_context_add_provider(), or to the display through
|
||||
* gtk_style_context_add_provider_for_display(). The resulting style is a
|
||||
* combination of all providers’ information in priority order.
|
||||
*
|
||||
* For GTK+ widgets, any #GtkStyleContext returned by
|
||||
* gtk_widget_get_style_context() will already have a #GtkWidgetPath, a
|
||||
* #GdkScreen and RTL/LTR information set. The style context will also be
|
||||
* #GdkDisplay and RTL/LTR information set. The style context will also be
|
||||
* updated automatically if any of these settings change on the widget.
|
||||
*
|
||||
* If you are using the theming layer standalone, you will need to set a
|
||||
* widget path and a screen yourself to the created style context through
|
||||
* gtk_style_context_set_path() and gtk_style_context_set_screen(), as well
|
||||
* widget path and a display yourself to the created style context through
|
||||
* gtk_style_context_set_path() and gtk_style_context_set_display(), as well
|
||||
* as updating the context yourself using gtk_style_context_invalidate()
|
||||
* whenever any of the conditions change, such as a change in the
|
||||
* #GtkSettings:gtk-theme-name setting or a hierarchy change in the rendered
|
||||
@ -118,7 +118,7 @@ struct PropertyValue
|
||||
|
||||
struct _GtkStyleContextPrivate
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GdkDisplay *display;
|
||||
|
||||
guint cascade_changed_id;
|
||||
GtkStyleCascade *cascade;
|
||||
@ -134,7 +134,7 @@ typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SCREEN,
|
||||
PROP_DISPLAY,
|
||||
PROP_FRAME_CLOCK,
|
||||
PROP_PARENT,
|
||||
LAST_PROP
|
||||
@ -206,10 +206,10 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
properties[PROP_SCREEN] =
|
||||
g_param_spec_object ("screen",
|
||||
P_("Screen"),
|
||||
P_("The associated GdkScreen"),
|
||||
properties[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
P_("Display"),
|
||||
P_("The associated GdkDisplay"),
|
||||
GDK_TYPE_SCREEN,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
@ -295,13 +295,13 @@ gtk_style_context_init (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
priv->screen = gdk_screen_get_default ();
|
||||
priv->display = gdk_display_get_default ();
|
||||
|
||||
if (priv->screen == NULL)
|
||||
if (priv->display == NULL)
|
||||
g_error ("Can't create a GtkStyleContext without a display connection");
|
||||
|
||||
gtk_style_context_set_cascade (context,
|
||||
_gtk_settings_get_style_cascade (gtk_settings_get_for_screen (priv->screen), 1));
|
||||
_gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display), 1));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -344,8 +344,8 @@ gtk_style_context_impl_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SCREEN:
|
||||
gtk_style_context_set_screen (context, g_value_get_object (value));
|
||||
case PROP_DISPLAY:
|
||||
gtk_style_context_set_display (context, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_FRAME_CLOCK:
|
||||
gtk_style_context_set_frame_clock (context, g_value_get_object (value));
|
||||
@ -370,8 +370,8 @@ gtk_style_context_impl_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SCREEN:
|
||||
g_value_set_object (value, priv->screen);
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, priv->display);
|
||||
break;
|
||||
case PROP_FRAME_CLOCK:
|
||||
g_value_set_object (value, priv->frame_clock);
|
||||
@ -421,7 +421,7 @@ static gboolean
|
||||
gtk_style_context_has_custom_cascade (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
GtkSettings *settings = gtk_settings_get_for_screen (priv->screen);
|
||||
GtkSettings *settings = gtk_settings_get_for_display (priv->display);
|
||||
|
||||
return priv->cascade != _gtk_settings_get_style_cascade (settings, _gtk_style_cascade_get_scale (priv->cascade));
|
||||
}
|
||||
@ -500,11 +500,11 @@ gtk_style_context_new_for_node (GtkCssNode *node)
|
||||
* Note that a style provider added by this function only affects
|
||||
* the style of the widget to which @context belongs. If you want
|
||||
* to affect the style of all widgets, use
|
||||
* gtk_style_context_add_provider_for_screen().
|
||||
* gtk_style_context_add_provider_for_display().
|
||||
*
|
||||
* Note: If both priorities are the same, a #GtkStyleProvider
|
||||
* added through this function takes precedence over another added
|
||||
* through gtk_style_context_add_provider_for_screen().
|
||||
* through gtk_style_context_add_provider_for_display().
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
@ -525,7 +525,7 @@ gtk_style_context_add_provider (GtkStyleContext *context,
|
||||
new_cascade = _gtk_style_cascade_new ();
|
||||
_gtk_style_cascade_set_scale (new_cascade, _gtk_style_cascade_get_scale (priv->cascade));
|
||||
_gtk_style_cascade_set_parent (new_cascade,
|
||||
_gtk_settings_get_style_cascade (gtk_settings_get_for_screen (priv->screen), 1));
|
||||
_gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display), 1));
|
||||
_gtk_style_cascade_add_provider (new_cascade, provider, priority);
|
||||
gtk_style_context_set_cascade (context, new_cascade);
|
||||
g_object_unref (new_cascade);
|
||||
@ -562,7 +562,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context,
|
||||
|
||||
/**
|
||||
* gtk_style_context_reset_widgets:
|
||||
* @screen: a #GdkScreen
|
||||
* @display: a #GdkScreen
|
||||
*
|
||||
* This function recomputes the styles for all widgets under a particular
|
||||
* #GdkScreen. This is useful when some global parameter has changed that
|
||||
@ -574,7 +574,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context,
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gtk_style_context_reset_widgets (GdkScreen *screen)
|
||||
gtk_style_context_reset_widgets (GdkDisplay *display)
|
||||
{
|
||||
GList *list, *toplevels;
|
||||
|
||||
@ -583,7 +583,7 @@ gtk_style_context_reset_widgets (GdkScreen *screen)
|
||||
|
||||
for (list = toplevels; list; list = list->next)
|
||||
{
|
||||
if (gtk_widget_get_screen (list->data) == screen)
|
||||
if (gtk_widget_get_display (list->data) == display)
|
||||
gtk_widget_reset_style (list->data);
|
||||
|
||||
g_object_unref (list->data);
|
||||
@ -593,8 +593,8 @@ gtk_style_context_reset_widgets (GdkScreen *screen)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_add_provider_for_screen:
|
||||
* @screen: a #GdkScreen
|
||||
* gtk_style_context_add_provider_for_display:
|
||||
* @display: a #GdkDisplay
|
||||
* @provider: a #GtkStyleProvider
|
||||
* @priority: the priority of the style provider. The lower
|
||||
* it is, the earlier it will be used in the style
|
||||
@ -602,8 +602,8 @@ gtk_style_context_reset_widgets (GdkScreen *screen)
|
||||
* between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and
|
||||
* %GTK_STYLE_PROVIDER_PRIORITY_USER
|
||||
*
|
||||
* Adds a global style provider to @screen, which will be used
|
||||
* in style construction for all #GtkStyleContexts under @screen.
|
||||
* Adds a global style provider to @display, which will be used
|
||||
* in style construction for all #GtkStyleContexts under @display.
|
||||
*
|
||||
* GTK+ uses this to make styling information from #GtkSettings
|
||||
* available.
|
||||
@ -612,43 +612,43 @@ gtk_style_context_reset_widgets (GdkScreen *screen)
|
||||
* added through gtk_style_context_add_provider() takes precedence
|
||||
* over another added through this function.
|
||||
*
|
||||
* Since: 3.0
|
||||
* Since: 3.94
|
||||
**/
|
||||
void
|
||||
gtk_style_context_add_provider_for_screen (GdkScreen *screen,
|
||||
GtkStyleProvider *provider,
|
||||
guint priority)
|
||||
gtk_style_context_add_provider_for_display (GdkDisplay *display,
|
||||
GtkStyleProvider *provider,
|
||||
guint priority)
|
||||
{
|
||||
GtkStyleCascade *cascade;
|
||||
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
|
||||
g_return_if_fail (!GTK_IS_SETTINGS (provider) || _gtk_settings_get_screen (GTK_SETTINGS (provider)) == screen);
|
||||
g_return_if_fail (!GTK_IS_SETTINGS (provider) || _gtk_settings_get_display (GTK_SETTINGS (provider)) == display);
|
||||
|
||||
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (screen), 1);
|
||||
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
|
||||
_gtk_style_cascade_add_provider (cascade, provider, priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_remove_provider_for_screen:
|
||||
* @screen: a #GdkScreen
|
||||
* gtk_style_context_remove_provider_for_display:
|
||||
* @display: a #GdkScreen
|
||||
* @provider: a #GtkStyleProvider
|
||||
*
|
||||
* Removes @provider from the global style providers list in @screen.
|
||||
* Removes @provider from the global style providers list in @display.
|
||||
*
|
||||
* Since: 3.0
|
||||
* Since: 3.94
|
||||
**/
|
||||
void
|
||||
gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
|
||||
GtkStyleProvider *provider)
|
||||
gtk_style_context_remove_provider_for_display (GdkDisplay *display,
|
||||
GtkStyleProvider *provider)
|
||||
{
|
||||
GtkStyleCascade *cascade;
|
||||
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
|
||||
g_return_if_fail (!GTK_IS_SETTINGS (provider));
|
||||
|
||||
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (screen), 1);
|
||||
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
|
||||
_gtk_style_cascade_remove_provider (cascade, provider);
|
||||
}
|
||||
|
||||
@ -936,7 +936,7 @@ gtk_style_context_set_scale (GtkStyleContext *context,
|
||||
{
|
||||
GtkStyleCascade *new_cascade;
|
||||
|
||||
new_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (priv->screen),
|
||||
new_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display),
|
||||
scale);
|
||||
gtk_style_context_set_cascade (context, new_cascade);
|
||||
}
|
||||
@ -1324,67 +1324,69 @@ _gtk_style_context_peek_property (GtkStyleContext *context,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_set_screen:
|
||||
* gtk_style_context_set_display:
|
||||
* @context: a #GtkStyleContext
|
||||
* @screen: a #GdkScreen
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Attaches @context to the given screen.
|
||||
* Attaches @context to the given display.
|
||||
*
|
||||
* The screen is used to add style information from “global” style
|
||||
* providers, such as the screens #GtkSettings instance.
|
||||
* The display is used to add style information from “global” style
|
||||
* providers, such as the display's #GtkSettings instance.
|
||||
*
|
||||
* If you are using a #GtkStyleContext returned from
|
||||
* gtk_widget_get_style_context(), you do not need to
|
||||
* call this yourself.
|
||||
*
|
||||
* Since: 3.0
|
||||
* Since: 3.94
|
||||
**/
|
||||
void
|
||||
gtk_style_context_set_screen (GtkStyleContext *context,
|
||||
GdkScreen *screen)
|
||||
gtk_style_context_set_display (GtkStyleContext *context,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
GtkStyleCascade *screen_cascade;
|
||||
GtkStyleCascade *display_cascade;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
if (priv->screen == screen)
|
||||
if (priv->display == display)
|
||||
return;
|
||||
|
||||
if (gtk_style_context_has_custom_cascade (context))
|
||||
{
|
||||
screen_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (screen), 1);
|
||||
_gtk_style_cascade_set_parent (priv->cascade, screen_cascade);
|
||||
display_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
|
||||
_gtk_style_cascade_set_parent (priv->cascade, display_cascade);
|
||||
}
|
||||
else
|
||||
{
|
||||
screen_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (screen),
|
||||
display_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display),
|
||||
_gtk_style_cascade_get_scale (priv->cascade));
|
||||
gtk_style_context_set_cascade (context, screen_cascade);
|
||||
gtk_style_context_set_cascade (context, display_cascade);
|
||||
}
|
||||
|
||||
priv->screen = screen;
|
||||
priv->display = display;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_SCREEN]);
|
||||
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_DISPLAY]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_get_screen:
|
||||
* gtk_style_context_get_display:
|
||||
* @context: a #GtkStyleContext
|
||||
*
|
||||
* Returns the #GdkScreen to which @context is attached.
|
||||
* Returns the #GdkDisplay to which @context is attached.
|
||||
*
|
||||
* Returns: (transfer none): a #GdkScreen.
|
||||
* Returns: (transfer none): a #GdkDisplay.
|
||||
*
|
||||
* Since: 3.94
|
||||
**/
|
||||
GdkScreen *
|
||||
gtk_style_context_get_screen (GtkStyleContext *context)
|
||||
GdkDisplay *
|
||||
gtk_style_context_get_display (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||
|
||||
return priv->screen;
|
||||
return priv->display;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1895,11 +1897,11 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
|
||||
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
||||
g_return_if_fail (index >= 0);
|
||||
|
||||
g_object_get (gtk_settings_get_for_screen (priv->screen),
|
||||
g_object_get (gtk_settings_get_for_display (priv->display),
|
||||
"gtk-split-cursor", &split_cursor,
|
||||
NULL);
|
||||
|
||||
keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gdk_screen_get_display (priv->screen)));
|
||||
keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (priv->display));
|
||||
|
||||
pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
|
||||
|
||||
@ -1980,11 +1982,11 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
||||
g_return_if_fail (index >= 0);
|
||||
|
||||
g_object_get (gtk_settings_get_for_screen (priv->screen),
|
||||
g_object_get (gtk_settings_get_for_display (priv->display),
|
||||
"gtk-split-cursor", &split_cursor,
|
||||
NULL);
|
||||
|
||||
keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gdk_screen_get_display (priv->screen)));
|
||||
keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (priv->display));
|
||||
|
||||
pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
|
||||
|
||||
|
@ -974,13 +974,13 @@ GType gtk_style_context_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkStyleContext * gtk_style_context_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_add_provider_for_screen (GdkScreen *screen,
|
||||
GtkStyleProvider *provider,
|
||||
guint priority);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
|
||||
GtkStyleProvider *provider);
|
||||
GDK_AVAILABLE_IN_3_94
|
||||
void gtk_style_context_add_provider_for_display (GdkDisplay *display,
|
||||
GtkStyleProvider *provider,
|
||||
guint priority);
|
||||
GDK_AVAILABLE_IN_3_94
|
||||
void gtk_style_context_remove_provider_for_display (GdkDisplay *display,
|
||||
GtkStyleProvider *provider);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_add_provider (GtkStyleContext *context,
|
||||
@ -1047,10 +1047,10 @@ gboolean gtk_style_context_has_class (GtkStyleContext *context,
|
||||
const gchar *class_name);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_set_screen (GtkStyleContext *context,
|
||||
GdkScreen *screen);
|
||||
void gtk_style_context_set_display (GtkStyleContext *context,
|
||||
GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
|
||||
GdkDisplay *gtk_style_context_get_display (GtkStyleContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_3_8
|
||||
void gtk_style_context_set_frame_clock (GtkStyleContext *context,
|
||||
@ -1085,7 +1085,7 @@ void gtk_style_context_get_margin (GtkStyleContext *context,
|
||||
GtkBorder *margin);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_reset_widgets (GdkScreen *screen);
|
||||
void gtk_style_context_reset_widgets (GdkDisplay *display);
|
||||
|
||||
GDK_AVAILABLE_IN_3_4
|
||||
void gtk_render_insertion_cursor
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @See_also: #GtkStyleContext, #GtkCssProvider
|
||||
*
|
||||
* GtkStyleProvider is an interface used to provide style information to a #GtkStyleContext.
|
||||
* See gtk_style_context_add_provider() and gtk_style_context_add_provider_for_screen().
|
||||
* See gtk_style_context_add_provider() and gtk_style_context_add_provider_for_display().
|
||||
*/
|
||||
|
||||
static void gtk_style_provider_iface_init (gpointer g_iface);
|
||||
|
@ -8469,7 +8469,7 @@ do_display_change (GtkWidget *widget,
|
||||
_gtk_tooltip_hide (widget);
|
||||
|
||||
if (new_display && priv->context)
|
||||
gtk_style_context_set_screen (priv->context, gdk_display_get_default_screen (new_display));
|
||||
gtk_style_context_set_display (priv->context, new_display);
|
||||
|
||||
g_signal_emit (widget, widget_signals[DISPLAY_CHANGED], 0, old_display);
|
||||
}
|
||||
@ -14002,7 +14002,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
||||
|
||||
if (G_UNLIKELY (priv->context == NULL))
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GdkDisplay *display;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
priv->context = gtk_style_context_new_for_node (priv->cssnode);
|
||||
@ -14011,9 +14011,9 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
||||
gtk_style_context_set_state (priv->context, priv->state_flags);
|
||||
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
|
||||
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
if (screen)
|
||||
gtk_style_context_set_screen (priv->context, screen);
|
||||
display = gtk_widget_get_display (widget);
|
||||
if (display)
|
||||
gtk_style_context_set_display (priv->context, display);
|
||||
|
||||
frame_clock = gtk_widget_get_frame_clock (widget);
|
||||
if (frame_clock)
|
||||
|
@ -170,7 +170,7 @@ invalidate_win32_themes (GdkXEvent *xevent,
|
||||
theme_was_open |= gtk_win32_theme_close (theme);
|
||||
}
|
||||
if (theme_was_open)
|
||||
gtk_style_context_reset_widgets (gdk_display_get_default_screen (gdk_window_get_display (event->any.window)));
|
||||
gtk_style_context_reset_widgets (gdk_window_get_display (event->any.window));
|
||||
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
@ -122,12 +122,12 @@ disable_toggled (GtkToggleButton *button,
|
||||
GtkInspectorCssEditor *ce)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider));
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider));
|
||||
else
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@ -286,9 +286,9 @@ static void
|
||||
create_provider (GtkInspectorCssEditor *ce)
|
||||
{
|
||||
ce->priv->provider = gtk_css_provider_new ();
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
g_signal_connect (ce->priv->provider, "parsing-error",
|
||||
G_CALLBACK (show_parsing_error), ce);
|
||||
@ -297,8 +297,8 @@ create_provider (GtkInspectorCssEditor *ce)
|
||||
static void
|
||||
destroy_provider (GtkInspectorCssEditor *ce)
|
||||
{
|
||||
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider));
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (ce->priv->provider));
|
||||
g_clear_object (&ce->priv->provider);
|
||||
}
|
||||
|
||||
|
@ -364,9 +364,9 @@ main (int argc, char *argv[])
|
||||
".black-bg { background-color: black; }"
|
||||
".red-bg { background-color: red; }"
|
||||
".blue-bg { background-color: blue; }", -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
|
||||
if (g_getenv ("RTL"))
|
||||
|
@ -83,9 +83,9 @@ main (int argc,
|
||||
".small-font { font-size: 5px; }"
|
||||
".medium-font { font-size: 10px; }"
|
||||
".large-font { font-size: 15px; }", -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
@ -156,9 +156,9 @@ main (gint argc, gchar **argv)
|
||||
NULL);
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
|
@ -8311,7 +8311,6 @@ main (int argc, char *argv[])
|
||||
{
|
||||
GtkCssProvider *provider, *memory_provider;
|
||||
GdkDisplay *display;
|
||||
GdkScreen *screen;
|
||||
GtkBindingSet *binding_set;
|
||||
int i;
|
||||
gboolean done_benchmarks = FALSE;
|
||||
@ -8341,10 +8340,9 @@ main (int argc, char *argv[])
|
||||
g_warning ("Couldn't find file \"testgtk.css\".");
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (display, GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
|
||||
gtk_accelerator_set_default_mod_mask (GDK_SHIFT_MASK |
|
||||
@ -8414,8 +8412,8 @@ main (int argc, char *argv[])
|
||||
" font-size: 18px;\n"
|
||||
"}",
|
||||
-1);
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (memory_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
|
||||
gtk_style_context_add_provider_for_display (display, GTK_STYLE_PROVIDER (memory_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
|
||||
|
||||
create_main_window ();
|
||||
|
||||
|
@ -136,9 +136,9 @@ main (int argc, char *argv[])
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
|
||||
change_header (NULL, window);
|
||||
|
@ -216,16 +216,14 @@ static void
|
||||
set_styles (void)
|
||||
{
|
||||
GtkCssProvider *provider;
|
||||
GdkScreen *screen;
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
|
||||
gtk_css_provider_load_from_data (provider, CSS, -1);
|
||||
|
||||
screen = gdk_display_get_default_screen (gdk_display_get_default ());
|
||||
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -35,9 +35,9 @@ add_custom_css (void)
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, data, -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -262,9 +262,9 @@ main (int argc, char *argv[])
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
|
||||
list = gtk_list_box_new ();
|
||||
|
@ -152,7 +152,7 @@ main (int argc, char *argv[])
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 300);
|
||||
|
||||
|
@ -615,9 +615,9 @@ main (int argc, char *argv[])
|
||||
|
||||
css_provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (css_provider, css, -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
win1 = test_nonzerox ();
|
||||
gtk_widget_show (win1);
|
||||
|
@ -55,9 +55,9 @@ main (int argc, char *argv[])
|
||||
".left { border-left-style: none; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }"
|
||||
".right { border-right-style: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }",
|
||||
-1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (win), 600, 600);
|
||||
|
@ -273,9 +273,9 @@ main()
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
widget = g_object_new (GTK_TYPE_FOCUS_WIDGET, NULL);
|
||||
|
@ -116,9 +116,9 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_path (provider, css_file);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
|
||||
builder = gtk_builder_new_from_file (ui_file);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
@ -150,8 +150,8 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
g_free (diff);
|
||||
|
||||
out:
|
||||
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider));
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider));
|
||||
g_object_unref (provider);
|
||||
|
||||
g_free (output);
|
||||
|
@ -346,13 +346,13 @@ test_style_priorities_equal (PrioritiesFixture *f,
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
/* When style providers are added to the screen as well as the style context
|
||||
/* When style providers are added to the display as well as the style context
|
||||
the one specific to the style context should take priority */
|
||||
gdk_rgba_parse (&ref_color, "red");
|
||||
gtk_style_context_get_color (f->context, &color);
|
||||
@ -361,14 +361,14 @@ test_style_priorities_equal (PrioritiesFixture *f,
|
||||
}
|
||||
|
||||
static void
|
||||
test_style_priorities_screen_only (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
test_style_priorities_display_only (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
gdk_rgba_parse (&ref_color, "blue");
|
||||
gtk_style_context_get_color (f->context, &color);
|
||||
@ -392,14 +392,14 @@ test_style_priorities_context_only (PrioritiesFixture *f,
|
||||
}
|
||||
|
||||
static void
|
||||
test_style_priorities_screen_higher (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
test_style_priorities_display_higher (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
@ -415,9 +415,9 @@ test_style_priorities_context_higher (PrioritiesFixture *f,
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
|
||||
@ -428,17 +428,17 @@ test_style_priorities_context_higher (PrioritiesFixture *f,
|
||||
}
|
||||
|
||||
static void
|
||||
test_style_priorities_two_screen (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
test_style_priorities_two_display (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
|
||||
gdk_rgba_parse (&ref_color, "red");
|
||||
gtk_style_context_get_color (f->context, &color);
|
||||
@ -464,17 +464,17 @@ test_style_priorities_two_context (PrioritiesFixture *f,
|
||||
}
|
||||
|
||||
static void
|
||||
test_style_priorities_three_screen_higher (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
test_style_priorities_three_display_higher (PrioritiesFixture *f,
|
||||
gconstpointer unused)
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->green_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->green_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER + 1);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
@ -490,9 +490,9 @@ test_style_priorities_three_context_higher (PrioritiesFixture *f,
|
||||
{
|
||||
GdkRGBA color, ref_color;
|
||||
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (f->blue_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->red_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_add_provider (f->context, GTK_STYLE_PROVIDER (f->green_provider),
|
||||
@ -522,13 +522,13 @@ main (int argc, char *argv[])
|
||||
(func), test_style_priorities_teardown)
|
||||
|
||||
ADD_PRIORITIES_TEST ("equal", test_style_priorities_equal);
|
||||
ADD_PRIORITIES_TEST ("screen-only", test_style_priorities_screen_only);
|
||||
ADD_PRIORITIES_TEST ("display-only", test_style_priorities_display_only);
|
||||
ADD_PRIORITIES_TEST ("context-only", test_style_priorities_context_only);
|
||||
ADD_PRIORITIES_TEST ("screen-higher", test_style_priorities_screen_higher);
|
||||
ADD_PRIORITIES_TEST ("display-higher", test_style_priorities_display_higher);
|
||||
ADD_PRIORITIES_TEST ("context-higher", test_style_priorities_context_higher);
|
||||
ADD_PRIORITIES_TEST ("two-screen", test_style_priorities_two_screen);
|
||||
ADD_PRIORITIES_TEST ("two-display", test_style_priorities_two_display);
|
||||
ADD_PRIORITIES_TEST ("two-context", test_style_priorities_two_context);
|
||||
ADD_PRIORITIES_TEST ("three-screen-higher", test_style_priorities_three_screen_higher);
|
||||
ADD_PRIORITIES_TEST ("three-display-higher", test_style_priorities_three_display_higher);
|
||||
ADD_PRIORITIES_TEST ("three-context-higher", test_style_priorities_three_context_higher);
|
||||
|
||||
#undef ADD_PRIORITIES_TEST
|
||||
|
@ -224,9 +224,9 @@ add_extra_css (const char *testname,
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
gtk_css_provider_load_from_path (GTK_CSS_PROVIDER (provider),
|
||||
css_file);
|
||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
provider,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FORCE);
|
||||
|
||||
g_free (css_file);
|
||||
|
||||
@ -239,8 +239,8 @@ remove_extra_css (GtkStyleProvider *provider)
|
||||
if (provider == NULL)
|
||||
return;
|
||||
|
||||
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
||||
provider);
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
||||
provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user