GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 4a6658b0 authored by Paolo Borelli's avatar Paolo Borelli

Set infobar css classes permanently

The message-type css classes must be in the widget context all the time,
not only when drawing, otherwise they are not propagated to the
children, for instance a label in the InfoBar must inherit the
color. Add a corresponding reftest.

https://bugzilla.gnome.org/show_bug.cgi?id=670555
parent 86ffa06f
......@@ -290,13 +290,6 @@ gtk_info_bar_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv;
const char* type_class[] = {
GTK_STYLE_CLASS_INFO,
GTK_STYLE_CLASS_WARNING,
GTK_STYLE_CLASS_QUESTION,
GTK_STYLE_CLASS_ERROR,
NULL
};
if (priv->message_type != GTK_MESSAGE_OTHER)
{
......@@ -304,20 +297,12 @@ gtk_info_bar_draw (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
if (type_class[priv->message_type])
gtk_style_context_add_class (context,
type_class[priv->message_type]);
gtk_render_background (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
gtk_render_frame (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
gtk_style_context_restore (context);
}
if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw)
......@@ -1091,7 +1076,6 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
GtkMessageType message_type)
{
GtkInfoBarPrivate *priv;
AtkObject *atk_obj;
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
......@@ -1099,6 +1083,21 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
if (priv->message_type != message_type)
{
GtkStyleContext *context;
AtkObject *atk_obj;
const char *type_class[] = {
GTK_STYLE_CLASS_INFO,
GTK_STYLE_CLASS_WARNING,
GTK_STYLE_CLASS_QUESTION,
GTK_STYLE_CLASS_ERROR,
NULL
};
context = gtk_widget_get_style_context (GTK_WIDGET (info_bar));
if (type_class[priv->message_type])
gtk_style_context_remove_class (context, type_class[priv->message_type]);
priv->message_type = message_type;
gtk_widget_queue_draw (GTK_WIDGET (info_bar));
......@@ -1144,6 +1143,9 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
}
}
if (type_class[priv->message_type])
gtk_style_context_add_class (context, type_class[priv->message_type]);
g_object_notify (G_OBJECT (info_bar), "message-type");
}
}
......
......@@ -144,6 +144,9 @@ EXTRA_DIST += \
grid-spacing3.css \
grid-spacing3.ref.ui \
grid-spacing3.ui \
info-bar-message-types.css \
info-bar-message-types.ref.ui \
info-bar-message-types.ui \
inherit-and-initial.css \
inherit-and-initial.ref.ui \
inherit-and-initial.ui \
......
@import "reset-to-defaults.css";
.info {
/* FIXME: for now label does not support background */
/* background-color: @info_bg_color;*/
color: @info_fg_color;
}
.warning {
/* background-color: @warning_bg_color;*/
color: @warning_fg_color;
}
.question {
/* background-color: @question_bg_color;*/
color: @question_fg_color;
}
.error {
/* background-color: @error_bg_color;*/
color: @error_fg_color;
}
#reference-info {
padding: 8px;
color: @info_fg_color;
background-color: @info_bg_color;
background-image: none;
}
#reference-warning {
padding: 8px;
color: @warning_fg_color;
background-color: @warning_bg_color;
background-image: none;
}
#reference-question {
padding: 8px;
color: @question_fg_color;
background-color: @question_bg_color;
background-image: none;
}
#reference-error {
padding: 8px;
color: @error_fg_color;
background-color: @error_bg_color;
background-image: none;
}
#reference-other {
padding: 8px;
}
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="type">popup</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Info</property>
<property name="name">reference-info</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Warning</property>
<property name="name">reference-warning</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Question</property>
<property name="name">reference-question</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Error</property>
<property name="name">reference-error</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Other</property>
<property name="name">reference-other</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="type">popup</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkInfoBar" id="infobar1">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="message_type">info</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area1">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Info</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area1">
<property name="can_focus">False</property>
<property name="border_width">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="infobar2">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="message_type">warning</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area2">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Warning</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area2">
<property name="can_focus">False</property>
<property name="border_width">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="infobar3">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="message_type">question</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area3">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Question</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area3">
<property name="can_focus">False</property>
<property name="border_width">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="infobar4">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="message_type">error</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area4">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Error</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area4">
<property name="can_focus">False</property>
<property name="border_width">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="infobar5">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="message_type">other</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area5">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Other</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area5">
<property name="can_focus">False</property>
<property name="border_width">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment