Commit b7ee2cbc authored by Timm Bäder's avatar Timm Bäder 🤔 Committed by Matthias Clasen
Browse files

Start using GtkWidget's new style class API

parent b1d64a6b
......@@ -452,8 +452,8 @@ setup_search (GtkAppChooserDialog *self)
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
image = gtk_image_new_from_icon_name ("edit-find-symbolic");
gtk_container_add (GTK_CONTAINER (button), image);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
gtk_style_context_remove_class (gtk_widget_get_style_context (button), "text-button");
gtk_widget_add_style_class (button, "image-button");
gtk_widget_remove_style_class (button, "text-button");
header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
......
......@@ -654,9 +654,8 @@ gtk_button_new_with_mnemonic (const gchar *label)
*/
void
gtk_button_set_relief (GtkButton *button,
GtkReliefStyle relief)
GtkReliefStyle relief)
{
GtkStyleContext *context;
GtkReliefStyle old_relief;
g_return_if_fail (GTK_IS_BUTTON (button));
......@@ -664,11 +663,10 @@ gtk_button_set_relief (GtkButton *button,
old_relief = gtk_button_get_relief (button);
if (old_relief != relief)
{
context = gtk_widget_get_style_context (GTK_WIDGET (button));
if (relief == GTK_RELIEF_NONE)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_FLAT);
gtk_widget_add_style_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
else
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FLAT);
gtk_widget_remove_style_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_RELIEF]);
}
......@@ -685,12 +683,9 @@ gtk_button_set_relief (GtkButton *button,
GtkReliefStyle
gtk_button_get_relief (GtkButton *button)
{
GtkStyleContext *context;
g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_RELIEF_NORMAL);
context = gtk_widget_get_style_context (GTK_WIDGET (button));
if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_FLAT))
if (gtk_widget_has_style_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT))
return GTK_RELIEF_NONE;
else
return GTK_RELIEF_NORMAL;
......@@ -787,12 +782,9 @@ gtk_button_set_label (GtkButton *button,
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GtkWidget *child;
GtkStyleContext *context;
g_return_if_fail (GTK_IS_BUTTON (button));
context = gtk_widget_get_style_context (GTK_WIDGET (button));
child = gtk_bin_get_child (GTK_BIN (button));
if (priv->child_type != LABEL_CHILD || child == NULL)
......@@ -811,8 +803,8 @@ gtk_button_set_label (GtkButton *button,
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
}
gtk_container_add (GTK_CONTAINER (button), child);
gtk_style_context_remove_class (context, "image-button");
gtk_style_context_add_class (context, "text-button");
gtk_widget_remove_style_class (GTK_WIDGET (button), "image-button");
gtk_widget_add_style_class (GTK_WIDGET (button), "text-button");
}
gtk_label_set_label (GTK_LABEL (child), label);
......@@ -944,13 +936,11 @@ gtk_button_set_icon_name (GtkButton *button,
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GtkWidget *child;
GtkStyleContext *context;
g_return_if_fail (GTK_IS_BUTTON (button));
g_return_if_fail (icon_name != NULL);
child = gtk_bin_get_child (GTK_BIN (button));
context = gtk_widget_get_style_context (GTK_WIDGET (button));
if (priv->child_type != ICON_CHILD || child == NULL)
{
......@@ -959,8 +949,8 @@ gtk_button_set_icon_name (GtkButton *button,
child = gtk_image_new_from_icon_name (icon_name);
gtk_container_add (GTK_CONTAINER (button), child);
gtk_style_context_remove_class (context, "text-button");
gtk_style_context_add_class (context, "image-button");
gtk_widget_remove_style_class (GTK_WIDGET (button), "text-button");
gtk_widget_add_style_class (GTK_WIDGET (button), "image-button");
}
else
{
......
......@@ -743,16 +743,15 @@ gtk_calendar_init (GtkCalendar *calendar)
gtk_widget_set_can_focus (widget, TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (calendar)),
GTK_STYLE_CLASS_VIEW);
gtk_widget_add_style_class (GTK_WIDGET (calendar), GTK_STYLE_CLASS_VIEW);
priv->header_box = g_object_new (GTK_TYPE_BOX,
"css-name", "header",
NULL);
priv->year_label = gtk_label_new ("");
gtk_style_context_add_class (gtk_widget_get_style_context (priv->year_label), "year");
gtk_widget_add_style_class (priv->year_label, "year");
priv->month_name_stack = gtk_stack_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (priv->month_name_stack), "month");
gtk_widget_add_style_class (priv->month_name_stack, "month");
priv->arrow_widgets[0] = gtk_button_new_from_icon_name ("pan-start-symbolic");
g_signal_connect_swapped (priv->arrow_widgets[0], "clicked", G_CALLBACK (calendar_set_month_prev), calendar);
priv->arrow_widgets[1] = gtk_button_new_from_icon_name ("pan-end-symbolic");
......
......@@ -393,10 +393,9 @@ gtk_check_button_init (GtkCheckButton *check_button)
{
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button);
gtk_widget_set_receives_default (GTK_WIDGET (check_button), FALSE);
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (check_button)), "toggle");
gtk_widget_remove_style_class (GTK_WIDGET (check_button), "toggle");
priv->draw_indicator = TRUE;
draw_indicator_changed (check_button);
......
......@@ -299,7 +299,6 @@ gtk_color_button_init (GtkColorButton *button)
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
PangoLayout *layout;
PangoRectangle rect;
GtkStyleContext *context;
GdkContentFormats *targets;
GdkContentProvider *content;
GtkDragSource *source;
......@@ -340,8 +339,7 @@ gtk_color_button_init (GtkColorButton *button)
g_signal_connect (source, "drag-begin", G_CALLBACK (gtk_color_button_drag_begin), button);
gtk_widget_add_controller (priv->button, GTK_EVENT_CONTROLLER (source));
context = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
gtk_style_context_add_class (context, "color");
gtk_widget_add_style_class (priv->button, "color");
}
static void
......
......@@ -378,19 +378,19 @@ add_palette (GtkColorChooserWidget *cc,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (pos == left)
gtk_style_context_add_class (gtk_widget_get_style_context (p), GTK_STYLE_CLASS_LEFT);
else if (pos == right)
gtk_style_context_add_class (gtk_widget_get_style_context (p), GTK_STYLE_CLASS_RIGHT);
if (pos == left)
gtk_widget_add_style_class (p, GTK_STYLE_CLASS_LEFT);
else if (pos == right)
gtk_widget_add_style_class (p, GTK_STYLE_CLASS_RIGHT);
gtk_grid_attach (GTK_GRID (grid), p, pos, line, 1, 1);
gtk_grid_attach (GTK_GRID (grid), p, pos, line, 1, 1);
}
else
{
if (pos == 0)
gtk_style_context_add_class (gtk_widget_get_style_context (p), GTK_STYLE_CLASS_TOP);
gtk_widget_add_style_class (p, GTK_STYLE_CLASS_TOP);
else if (pos == colors_per_line - 1)
gtk_style_context_add_class (gtk_widget_get_style_context (p), GTK_STYLE_CLASS_BOTTOM);
gtk_widget_add_style_class (p, GTK_STYLE_CLASS_BOTTOM);
gtk_grid_attach (GTK_GRID (grid), p, line, pos, 1, 1);
}
......
......@@ -386,11 +386,9 @@ gtk_color_editor_init (GtkColorEditor *editor)
gtk_widget_init_template (GTK_WIDGET (editor));
if (gtk_widget_get_direction (editor->priv->h_slider) == GTK_TEXT_DIR_RTL)
gtk_style_context_add_class (gtk_widget_get_style_context (editor->priv->h_slider),
"marks-before");
gtk_widget_add_style_class (editor->priv->h_slider, "marks-before");
else
gtk_style_context_add_class (gtk_widget_get_style_context (editor->priv->h_slider),
"marks-after");
gtk_widget_add_style_class (editor->priv->h_slider, "marks-after");
/* Create the scaled popup adjustments manually here because connecting user data is not
* supported by template GtkBuilder xml (it would be possible to set this up in the xml
......@@ -419,7 +417,7 @@ gtk_color_editor_init (GtkColorEditor *editor)
g_signal_connect (controller, "key-pressed", G_CALLBACK (popup_key_pressed), editor);
gtk_widget_add_controller (editor->priv->a_entry, controller);
gtk_style_context_remove_class (gtk_widget_get_style_context (editor->priv->swatch), "activatable");
gtk_widget_remove_style_class (editor->priv->swatch, "activatable");
editor->priv->picker = gtk_color_picker_new ();
if (editor->priv->picker == NULL)
......
......@@ -148,7 +148,6 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
static void
gtk_color_scale_init (GtkColorScale *scale)
{
GtkStyleContext *context;
GtkGesture *gesture;
gesture = gtk_gesture_long_press_new ();
......@@ -158,8 +157,7 @@ gtk_color_scale_init (GtkColorScale *scale)
GTK_PHASE_TARGET);
gtk_widget_add_controller (GTK_WIDGET (scale), GTK_EVENT_CONTROLLER (gesture));
context = gtk_widget_get_style_context (GTK_WIDGET (scale));
gtk_style_context_add_class (context, "color");
gtk_widget_add_style_class (GTK_WIDGET (scale), "color");
}
static void
......
......@@ -558,7 +558,7 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
G_CALLBACK (key_controller_key_pressed), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), controller);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (swatch)), "activatable");
gtk_widget_add_style_class (GTK_WIDGET (swatch), "activatable");
priv->overlay_widget = g_object_new (GTK_TYPE_IMAGE,
"css-name", "overlay",
......@@ -591,9 +591,6 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
const GdkRGBA *color)
{
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (swatch));
if (!priv->has_color)
{
......@@ -614,13 +611,14 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
if (INTENSITY (priv->color.red, priv->color.green, priv->color.blue) > 0.5)
{
gtk_style_context_add_class (context, "light");
gtk_style_context_remove_class (context, "dark");
gtk_widget_add_style_class (GTK_WIDGET (swatch), "light");
gtk_widget_remove_style_class (GTK_WIDGET (swatch), "dark");
}
else
{
gtk_style_context_add_class (context, "dark");
gtk_style_context_remove_class (context, "light");
gtk_widget_add_style_class (GTK_WIDGET (swatch), "dark");
gtk_widget_remove_style_class (GTK_WIDGET (swatch), "light");
}
gtk_widget_queue_draw (GTK_WIDGET (swatch));
......
......@@ -825,7 +825,6 @@ static void
gtk_combo_box_init (GtkComboBox *combo_box)
{
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
GtkStyleContext *context;
GtkEventController *controller;
priv->active = -1;
......@@ -848,9 +847,8 @@ gtk_combo_box_init (GtkComboBox *combo_box)
g_type_ensure (GTK_TYPE_TREE_POPOVER);
gtk_widget_init_template (GTK_WIDGET (combo_box));
context = gtk_widget_get_style_context (priv->button);
gtk_style_context_remove_class (context, "toggle");
gtk_style_context_add_class (context, "combo");
gtk_widget_remove_style_class (priv->button, "toggle");
gtk_widget_add_style_class (priv->button, "combo");
gtk_tree_popover_set_row_separator_func (GTK_TREE_POPOVER (priv->popup_widget),
(GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
......@@ -1029,13 +1027,11 @@ gtk_combo_box_create_child (GtkComboBox *combo_box)
if (priv->has_entry)
{
GtkWidget *entry;
GtkStyleContext *context;
entry = gtk_entry_new ();
gtk_container_add (GTK_CONTAINER (combo_box), entry);
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_style_context_add_class (context, "combo");
gtk_widget_add_style_class (GTK_WIDGET (entry), "combo");
g_signal_connect (combo_box, "changed",
G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
......
......@@ -398,12 +398,11 @@ update_suggested_action (GtkDialog *dialog)
for (l = children; l != NULL; l = l->next)
{
GtkWidget *child = l->data;
GtkStyleContext *context = gtk_widget_get_style_context (child);
if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_DEFAULT))
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SUGGESTED_ACTION);
if (gtk_widget_has_style_class (child, GTK_STYLE_CLASS_DEFAULT))
gtk_widget_add_style_class (child, GTK_STYLE_CLASS_SUGGESTED_ACTION);
else
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SUGGESTED_ACTION);
gtk_widget_remove_style_class (child, GTK_STYLE_CLASS_SUGGESTED_ACTION);
}
g_list_free (children);
}
......
......@@ -290,7 +290,7 @@ show_variations (GtkEmojiChooser *chooser,
parent_popover = gtk_widget_get_ancestor (child, GTK_TYPE_POPOVER);
popover = gtk_popover_new (child);
view = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (view), "view");
gtk_widget_add_style_class (view, "view");
box = gtk_flow_box_new ();
gtk_flow_box_set_homogeneous (GTK_FLOW_BOX (box), TRUE);
gtk_flow_box_set_min_children_per_line (GTK_FLOW_BOX (box), 6);
......
......@@ -1341,7 +1341,6 @@ update_icon_style (GtkWidget *widget,
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
EntryIconInfo *icon_info = priv->icons[icon_pos];
const gchar *sides[2] = { GTK_STYLE_CLASS_LEFT, GTK_STYLE_CLASS_RIGHT };
GtkStyleContext *context;
if (icon_info == NULL)
return;
......@@ -1349,9 +1348,8 @@ update_icon_style (GtkWidget *widget,
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
icon_pos = 1 - icon_pos;
context = gtk_widget_get_style_context (icon_info->widget);
gtk_style_context_add_class (context, sides[icon_pos]);
gtk_style_context_remove_class (context, sides[1 - icon_pos]);
gtk_widget_add_style_class (icon_info->widget, sides[icon_pos]);
gtk_widget_remove_style_class (icon_info->widget, sides[1 - icon_pos]);
}
static void
......@@ -2200,15 +2198,13 @@ gtk_entry_get_activates_default (GtkEntry *entry)
* gtk_entry_set_has_frame:
* @entry: a #GtkEntry
* @setting: new value
*
*
* Sets whether the entry has a beveled frame around it.
**/
void
gtk_entry_set_has_frame (GtkEntry *entry,
gboolean setting)
{
GtkStyleContext *context;
g_return_if_fail (GTK_IS_ENTRY (entry));
setting = (setting != FALSE);
......@@ -2216,11 +2212,10 @@ gtk_entry_set_has_frame (GtkEntry *entry,
if (setting == gtk_entry_get_has_frame (entry))
return;
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
if (setting)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FLAT);
gtk_widget_remove_style_class (GTK_WIDGET (entry), GTK_STYLE_CLASS_FLAT);
else
gtk_style_context_add_class (context, GTK_STYLE_CLASS_FLAT);
gtk_widget_add_style_class (GTK_WIDGET (entry), GTK_STYLE_CLASS_FLAT);
g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_HAS_FRAME]);
}
......@@ -2236,13 +2231,9 @@ gtk_entry_set_has_frame (GtkEntry *entry,
gboolean
gtk_entry_get_has_frame (GtkEntry *entry)
{
GtkStyleContext *context;
g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
return !gtk_style_context_has_class (context, GTK_STYLE_CLASS_FLAT);
return !gtk_widget_has_style_class (GTK_WIDGET (entry), GTK_STYLE_CLASS_FRAME);
}
/**
......
......@@ -585,7 +585,7 @@ gtk_entry_completion_constructed (GObject *object)
gtk_popover_set_position (GTK_POPOVER (priv->popup_window), GTK_POS_BOTTOM);
gtk_popover_set_autohide (GTK_POPOVER (priv->popup_window), FALSE);
gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_window), FALSE);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->popup_window), "entry-completion");
gtk_widget_add_style_class (priv->popup_window, "entry-completion");
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed",
......
......@@ -370,8 +370,7 @@ gtk_expander_init (GtkExpander *expander)
gtk_container_add (GTK_CONTAINER (priv->box), priv->title_widget);
priv->arrow_widget = gtk_builtin_icon_new ("expander");
gtk_style_context_add_class (gtk_widget_get_style_context (priv->arrow_widget),
GTK_STYLE_CLASS_HORIZONTAL);
gtk_widget_add_style_class (priv->arrow_widget, GTK_STYLE_CLASS_HORIZONTAL);
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
formats = gdk_content_formats_new (NULL, 0);
......
......@@ -555,7 +555,6 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
static void
gtk_font_button_init (GtkFontButton *font_button)
{
GtkStyleContext *context;
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
GtkWidget *box;
......@@ -592,8 +591,7 @@ gtk_font_button_init (GtkFontButton *font_button)
gtk_font_button_take_font_desc (font_button, NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
gtk_style_context_add_class (context, "font");
gtk_widget_add_style_class (priv->button, "font");
}
static void
......
......@@ -534,11 +534,9 @@ gtk_frame_set_shadow_type (GtkFrame *frame,
priv->shadow_type = type;
if (type == GTK_SHADOW_NONE)
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (frame)),
GTK_STYLE_CLASS_FLAT);
gtk_widget_add_style_class (GTK_WIDGET (frame), "flat");
else
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (frame)),
GTK_STYLE_CLASS_FLAT);
gtk_widget_remove_style_class (GTK_WIDGET (frame), "flat");
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_SHADOW_TYPE]);
}
......
......@@ -163,7 +163,6 @@ init_sizing_box (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GtkWidget *w;
GtkStyleContext *context;
/* We use this box to always request size for the two labels (title
* and subtitle) as if they were always visible, but then allocate
......@@ -174,8 +173,7 @@ init_sizing_box (GtkHeaderBar *bar)
priv->label_sizing_box = g_object_ref_sink (w);
w = gtk_label_new (NULL);
context = gtk_widget_get_style_context (w);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLE);
gtk_widget_add_style_class (w, GTK_STYLE_CLASS_TITLE);
gtk_container_add (GTK_CONTAINER (priv->label_sizing_box), w);
gtk_label_set_wrap (GTK_LABEL (w), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
......@@ -183,8 +181,7 @@ init_sizing_box (GtkHeaderBar *bar)
gtk_label_set_width_chars (GTK_LABEL (w), MIN_TITLE_CHARS);
w = gtk_label_new (NULL);
context = gtk_widget_get_style_context (w);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SUBTITLE);
gtk_widget_add_style_class (w, GTK_STYLE_CLASS_SUBTITLE);
gtk_container_add (GTK_CONTAINER (priv->label_sizing_box), w);
gtk_label_set_wrap (GTK_LABEL (w), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
......@@ -202,14 +199,12 @@ create_title_box (const char *title,
GtkWidget *label_box;
GtkWidget *title_label;
GtkWidget *subtitle_label;
GtkStyleContext *context;
label_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_valign (label_box, GTK_ALIGN_CENTER);
title_label = gtk_label_new (title);
context = gtk_widget_get_style_context (title_label);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLE);
gtk_widget_add_style_class (title_label, GTK_STYLE_CLASS_TITLE);
gtk_label_set_wrap (GTK_LABEL (title_label), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (title_label), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (title_label), PANGO_ELLIPSIZE_END);
......@@ -217,8 +212,7 @@ create_title_box (const char *title,
gtk_label_set_width_chars (GTK_LABEL (title_label), MIN_TITLE_CHARS);
subtitle_label = gtk_label_new (subtitle);
context = gtk_widget_get_style_context (subtitle_label);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SUBTITLE);
gtk_widget_add_style_class (subtitle_label, GTK_STYLE_CLASS_SUBTITLE);
gtk_label_set_wrap (GTK_LABEL (subtitle_label), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (subtitle_label), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (subtitle_label), PANGO_ELLIPSIZE_END);
......@@ -371,7 +365,7 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
t = g_strsplit (tokens[i], ",", -1);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_style_context_add_class (gtk_widget_get_style_context (separator), "titlebutton");
gtk_widget_add_style_class (separator, "titlebutton");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
......@@ -387,8 +381,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button = gtk_image_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
priv->titlebar_icon = button;
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "icon");
gtk_widget_add_style_class (button, "titlebutton");
gtk_widget_add_style_class (button, "icon");
gtk_widget_set_size_request (button, 20, 20);
if (!_gtk_header_bar_update_window_icon (bar, window))
......@@ -405,8 +399,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button = gtk_menu_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "menu");
gtk_widget_add_style_class (button, "titlebutton");
gtk_widget_add_style_class (button, "menu");
image = gtk_image_new ();
gtk_menu_button_add_child (GTK_MENU_BUTTON (button), image);
gtk_widget_set_can_focus (button, FALSE);
......@@ -426,8 +420,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
{
button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "minimize");
gtk_widget_add_style_class (button, "titlebutton");
gtk_widget_add_style_class (button, "minimize");
image = gtk_image_new_from_icon_name ("window-minimize-symbolic");
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
......@@ -449,8 +443,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
icon_name = maximized ? "window-restore-symbolic" : "window-maximize-symbolic";
button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "maximize");
gtk_widget_add_style_class (button, "titlebutton");
gtk_widget_add_style_class (button, "maximize");
image = gtk_image_new_from_icon_name (icon_name);
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
......@@ -468,8 +462,8 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
image = gtk_image_new_from_icon_name ("window-close-symbolic");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "close");
gtk_widget_add_style_class (button, "titlebutton");
gtk_widget_add_style_class (button, "close");
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_set_can_focus (button, FALSE);
......@@ -503,9 +497,9 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
gtk_box_reorder_child_after (GTK_BOX (box), separator, NULL);
if (i == 0)
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LEFT);
gtk_widget_add_style_class (box, GTK_STYLE_CLASS_LEFT);
else
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RIGHT);
gtk_widget_add_style_class (box, GTK_STYLE_CLASS_RIGHT);
if (i == 0)
{
......@@ -540,7 +534,6 @@ update_default_decoration (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GtkLayoutManager *layout = gtk_widget_get_layout_manager (GTK_WIDGET (bar));
GtkStyleContext *context;
gboolean have_children = FALSE;
/* Check whether we have any child widgets that we didn't add ourselves */
......@@ -576,12 +569,10 @@ update_default_decoration (GtkHeaderBar *bar)
}
}
context = gtk_widget_get_style_context (GTK_WIDGET (bar));
if (have_children || priv->custom_title != NULL)
gtk_style_context_remove_class (context, "default-decoration");
gtk_widget_remove_style_class (GTK_WIDGET (bar), "default-decoration");
else
gtk_style_context_add_class (context, "default-decoration");
gtk_widget_add_style_class (GTK_WIDGET (bar), "default-decoration");
}
void
......@@ -1242,11 +1233,11 @@ gtk_header_bar_init (GtkHeaderBar *bar)
layout = gtk_widget_get_layout_manager (GTK_WIDGET (bar));
priv->start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->start_box), "start");
gtk_widget_add_style_class (priv->start_box, "start");
gtk_widget_set_parent (priv->start_box, GTK_WIDGET (bar));
gtk_center_layout_set_start_widget (GTK_CENTER_LAYOUT (layout), priv->start_box);
priv->end_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->end_box), "end");
gtk_widget_add_style_class (priv->end_box, "end");
gtk_widget_set_parent (priv->end_box, GTK_WIDGET (bar));
gtk_center_layout_set_end_widget (GTK_CENTER_LAYOUT (layout), priv->end_box);
......
......@@ -956,8 +956,7 @@ gtk_icon_view_init (GtkIconView *icon_view)
icon_view->priv->row_contexts =
g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (icon_view)),
GTK_STYLE_CLASS_VIEW);
gtk_widget_add_style_class (GTK_WIDGET (icon_view), GTK_STYLE_CLASS_VIEW);
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_icon_view_button_press),
......
......@@ -531,7 +531,7 @@ gtk_info_bar_init (GtkInfoBar *info_bar)