[gtk/wip/baedert/for-master] Start using GtkWidget's new style class API
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] Start using GtkWidget's new style class API
- Date: Wed, 29 Jan 2020 15:23:42 +0000 (UTC)
commit 89bb18ad3c5d7f9f294be8da0ef16d1bae9a3e6e
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 29 12:11:39 2020 +0100
Start using GtkWidget's new style class API
gtk/gtkbutton.c | 26 +++++-----------
gtk/gtkcolorbutton.c | 4 +--
gtk/gtkcolorscale.c | 4 +--
gtk/gtkcolorswatch.c | 14 ++++-----
gtk/gtkcombobox.c | 10 ++----
gtk/gtkdialog.c | 7 ++---
gtk/gtkemojichooser.c | 2 +-
gtk/gtkentry.c | 21 ++++---------
gtk/gtkexpander.c | 3 +-
gtk/gtkfontbutton.c | 4 +--
gtk/gtkframe.c | 6 ++--
gtk/gtkheaderbar.c | 51 +++++++++++++-----------------
gtk/gtkinfobar.c | 13 +++-----
gtk/gtklinkbutton.c | 4 +--
gtk/gtklistbox.c | 13 +++-----
gtk/gtklockbutton.c | 4 +--
gtk/gtkmenubutton.c | 4 +--
gtk/gtkmessagedialog.c | 2 +-
gtk/gtkmodelbutton.c | 77 +++++++++++++++++++---------------------------
gtk/gtknotebook.c | 35 ++++++++-------------
gtk/gtkorientable.c | 10 +++---
gtk/gtkpaned.c | 9 ++----
gtk/gtkpasswordentry.c | 4 +--
gtk/gtkpopovermenu.c | 5 +--
gtk/gtkprogressbar.c | 34 +++++++++-----------
gtk/gtkrange.c | 39 ++++++++---------------
gtk/gtkscale.c | 39 +++++++++--------------
gtk/gtkscalebutton.c | 4 +--
gtk/gtkscrolledwindow.c | 42 +++++++++----------------
gtk/gtksearchbar.c | 2 +-
gtk/gtksearchentry.c | 2 +-
gtk/gtkseparatortoolitem.c | 12 ++------
gtk/gtkshortcutlabel.c | 4 +--
gtk/gtkshortcutssection.c | 5 ++-
gtk/gtkshortcutswindow.c | 10 +++---
gtk/gtksidebarrow.c | 4 +--
gtk/gtkspinbutton.c | 4 +--
gtk/gtkstacksidebar.c | 10 ++----
gtk/gtkstackswitcher.c | 20 +++++-------
gtk/gtktext.c | 15 ++++-----
gtk/gtktogglebutton.c | 4 +--
gtk/gtktoolbutton.c | 17 +++++-----
gtk/gtkviewport.c | 13 +++-----
gtk/gtkwidget.c | 12 ++------
gtk/gtkwindow.c | 55 +++++++++++++--------------------
45 files changed, 251 insertions(+), 428 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 6fcc605b08..756e40ea02 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -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
{
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 19759ff8e4..13908fc957 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -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
diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c
index efead89d8d..2e54959a8d 100644
--- a/gtk/gtkcolorscale.c
+++ b/gtk/gtkcolorscale.c
@@ -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
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index af7dcbd6b5..44edf1e005 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -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));
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index bbb7dba9b1..45fcc6594d 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -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);
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 2aea42bd3e..598c54b24a 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -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);
}
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index 9865ce8aeb..5a0cdd5251 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -277,7 +277,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);
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 921a96951b..d3fe86bc73 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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);
}
/**
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index f1a38acc48..8542cacb85 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -370,8 +370,7 @@ gtk_expander_init (GtkExpander *expander)
gtk_container_add (GTK_CONTAINER (priv->box), priv->title_widget);
priv->arrow_widget = gtk_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);
diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c
index 79ac0c31ed..f9ef7ad7b3 100644
--- a/gtk/gtkfontbutton.c
+++ b/gtk/gtkfontbutton.c
@@ -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
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 40d5bc2939..ab7ccb429c 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -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]);
}
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 0c8100872d..b00dc0b6cd 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -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);
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c
index a7b902cf17..d7c04299dd 100644
--- a/gtk/gtkinfobar.c
+++ b/gtk/gtkinfobar.c
@@ -516,7 +516,7 @@ gtk_info_bar_init (GtkInfoBar *info_bar)
priv->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
gtk_widget_hide (priv->close_button);
gtk_widget_set_valign (priv->close_button, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->close_button), "close");
+ gtk_widget_add_style_class (priv->close_button, "close");
gtk_container_add (GTK_CONTAINER (main_box), priv->close_button);
g_signal_connect (priv->close_button, "clicked",
G_CALLBACK (close_button_clicked_cb), info_bar);
@@ -787,9 +787,9 @@ update_default_response (GtkInfoBar *info_bar,
priv->default_response_sensitive = sensitive;
if (response_id && sensitive)
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (info_bar)), "action");
+ gtk_widget_add_style_class (GTK_WIDGET (info_bar), "action");
else
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (info_bar)), "action");
+ gtk_widget_remove_style_class (GTK_WIDGET (info_bar), "action");
}
/**
@@ -1137,7 +1137,6 @@ 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,
@@ -1147,10 +1146,8 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
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]);
+ gtk_widget_remove_style_class (GTK_WIDGET (info_bar), type_class[priv->message_type]);
priv->message_type = message_type;
@@ -1194,7 +1191,7 @@ 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]);
+ gtk_widget_add_style_class (GTK_WIDGET (info_bar), type_class[priv->message_type]);
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_MESSAGE_TYPE]);
}
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 2621591a5e..be28f64613 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -320,7 +320,6 @@ gtk_link_content_init (GtkLinkContent *content)
static void
gtk_link_button_init (GtkLinkButton *link_button)
{
- GtkStyleContext *context;
GtkGesture *gesture;
GdkContentProvider *content;
GtkDragSource *source;
@@ -347,8 +346,7 @@ gtk_link_button_init (GtkLinkButton *link_button)
link_button);
gtk_widget_add_controller (GTK_WIDGET (link_button), GTK_EVENT_CONTROLLER (gesture));
- context = gtk_widget_get_style_context (GTK_WIDGET (link_button));
- gtk_style_context_add_class (context, "link");
+ gtk_widget_add_style_class (GTK_WIDGET (link_button), "link");
gtk_widget_set_cursor_from_name (GTK_WIDGET (link_button), "pointer");
}
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 681c33f3aa..580dcf44a7 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -3157,7 +3157,6 @@ static void
gtk_list_box_update_row_style (GtkListBox *box,
GtkListBoxRow *row)
{
- GtkStyleContext *context;
gboolean can_select;
if (box && BOX_PRIV (box)->selection_mode != GTK_SELECTION_NONE)
@@ -3165,12 +3164,11 @@ gtk_list_box_update_row_style (GtkListBox *box,
else
can_select = FALSE;
- context = gtk_widget_get_style_context (GTK_WIDGET (row));
if (ROW_PRIV (row)->activatable ||
(ROW_PRIV (row)->selectable && can_select))
- gtk_style_context_add_class (context, "activatable");
+ gtk_widget_add_style_class (GTK_WIDGET (row), "activatable");
else
- gtk_style_context_remove_class (context, "activatable");
+ gtk_widget_remove_style_class (GTK_WIDGET (row), "activatable");
}
static void
@@ -3496,8 +3494,7 @@ gtk_list_box_row_init (GtkListBoxRow *row)
ROW_PRIV (row)->activatable = TRUE;
ROW_PRIV (row)->selectable = TRUE;
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (row)),
- "activatable");
+ gtk_widget_add_style_class (GTK_WIDGET (row), "activatable");
}
static void
@@ -3669,9 +3666,9 @@ gtk_list_box_set_show_separators (GtkListBox *box,
priv->show_separators = show_separators;
if (show_separators)
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (box)), "separators");
+ gtk_widget_add_style_class (GTK_WIDGET (box), "separators");
else
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (box)), "separators");
+ gtk_widget_remove_style_class (GTK_WIDGET (box), "separators");
g_object_notify_by_pspec (G_OBJECT (box), properties[PROP_SHOW_SEPARATORS]);
}
diff --git a/gtk/gtklockbutton.c b/gtk/gtklockbutton.c
index f22670110a..5312b07434 100644
--- a/gtk/gtklockbutton.c
+++ b/gtk/gtklockbutton.c
@@ -241,7 +241,6 @@ gtk_lock_button_init (GtkLockButton *button)
{
GtkLockButtonPrivate *priv = gtk_lock_button_get_instance_private (button);
const char *names[3];
- GtkStyleContext *context;
gtk_widget_init_template (GTK_WIDGET (button));
@@ -257,8 +256,7 @@ gtk_lock_button_init (GtkLockButton *button)
update_state (button);
- context = gtk_widget_get_style_context (GTK_WIDGET (button));
- gtk_style_context_add_class (context, I_("lock"));
+ gtk_widget_add_style_class (GTK_WIDGET (button), I_("lock"));
}
static void
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 3e0a31a391..15a6de1644 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -471,7 +471,6 @@ static void
gtk_menu_button_init (GtkMenuButton *menu_button)
{
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
- GtkStyleContext *context;
priv->arrow_type = GTK_ARROW_DOWN;
@@ -482,8 +481,7 @@ gtk_menu_button_init (GtkMenuButton *menu_button)
gtk_widget_set_sensitive (priv->button, FALSE);
- context = gtk_widget_get_style_context (GTK_WIDGET (menu_button));
- gtk_style_context_add_class (context, "popup");
+ gtk_widget_add_style_class (GTK_WIDGET (menu_button), "popup");
}
/**
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index b7e3161092..769b3af410 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -366,7 +366,7 @@ gtk_message_dialog_constructed (GObject *object)
gtk_widget_set_margin_bottom (label, 6);
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (label, TRUE);
- gtk_style_context_add_class (gtk_widget_get_style_context (label), "title");
+ gtk_widget_add_style_class (label, "title");
gtk_container_add (GTK_CONTAINER (box), label);
g_signal_connect_object (dialog, "notify::title", G_CALLBACK (update_title), label, 0);
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 07bf8c25c2..eb7c6a346d 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -287,28 +287,20 @@ gtk_model_button_actionable_iface_init (GtkActionableInterface *iface)
static void
update_node_ordering (GtkModelButton *button)
{
- GtkStyleContext *start_indicator_context = NULL;
- GtkStyleContext *end_indicator_context = NULL;
GtkWidget *child;
- if (button->start_indicator)
- start_indicator_context = gtk_widget_get_style_context (button->start_indicator);
-
- if (button->end_indicator)
- end_indicator_context = gtk_widget_get_style_context (button->end_indicator);
-
if (gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR)
{
- if (start_indicator_context)
+ if (button->start_indicator)
{
- gtk_style_context_add_class (start_indicator_context, GTK_STYLE_CLASS_LEFT);
- gtk_style_context_remove_class (start_indicator_context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_style_class (button->start_indicator, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (button->start_indicator, GTK_STYLE_CLASS_RIGHT);
}
- if (end_indicator_context)
+ if (button->end_indicator)
{
- gtk_style_context_add_class (end_indicator_context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_remove_class (end_indicator_context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (button->end_indicator, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (button->end_indicator, GTK_STYLE_CLASS_LEFT);
}
child = gtk_widget_get_first_child (GTK_WIDGET (button));
@@ -321,16 +313,17 @@ update_node_ordering (GtkModelButton *button)
}
else
{
- if (start_indicator_context)
+ if (button->start_indicator)
{
- gtk_style_context_add_class (start_indicator_context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_remove_class (start_indicator_context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (button->start_indicator, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (button->start_indicator, GTK_STYLE_CLASS_LEFT);
}
- if (end_indicator_context)
+ if (button->end_indicator)
{
- gtk_style_context_add_class (end_indicator_context, GTK_STYLE_CLASS_LEFT);
- gtk_style_context_remove_class (end_indicator_context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_style_class (button->end_indicator, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (button->end_indicator, GTK_STYLE_CLASS_RIGHT);
+
}
child = gtk_widget_get_first_child (GTK_WIDGET (button));
@@ -347,22 +340,19 @@ static void
update_end_indicator (GtkModelButton *self)
{
const gboolean is_ltr = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR;
- GtkStyleContext *context;
if (!self->end_indicator)
return;
- context = gtk_widget_get_style_context (self->end_indicator);
-
if (is_ltr)
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_style_class (self->end_indicator, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (self->end_indicator, GTK_STYLE_CLASS_LEFT);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (self->end_indicator, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (self->end_indicator, GTK_STYLE_CLASS_RIGHT);
}
}
@@ -387,25 +377,23 @@ static void
update_start_indicator (GtkModelButton *self)
{
const gboolean is_ltr = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR;
- GtkStyleContext *context;
if (!self->start_indicator)
return;
gtk_widget_set_state_flags (self->start_indicator, get_start_indicator_state (self), TRUE);
- context = gtk_widget_get_style_context (self->start_indicator);
-
if (is_ltr)
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (self->start_indicator, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (self->start_indicator, GTK_STYLE_CLASS_RIGHT);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_style_class (self->start_indicator, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (self->start_indicator, GTK_STYLE_CLASS_LEFT);
}
+
}
static void
@@ -538,12 +526,12 @@ gtk_model_button_set_role (GtkModelButton *self,
if (role == GTK_BUTTON_ROLE_TITLE)
{
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "title");
+ gtk_widget_add_style_class (GTK_WIDGET (self), "title");
gtk_widget_set_halign (self->label, GTK_ALIGN_CENTER);
}
else
{
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "title");
+ gtk_widget_remove_style_class (GTK_WIDGET (self), "title");
gtk_widget_set_halign (self->label, GTK_ALIGN_START);
}
@@ -652,7 +640,6 @@ gtk_model_button_set_iconic (GtkModelButton *self,
gboolean iconic)
{
GtkCssNode *widget_node;
- GtkStyleContext *context;
iconic = !!iconic;
if (self->iconic == iconic)
@@ -661,22 +648,22 @@ gtk_model_button_set_iconic (GtkModelButton *self,
self->iconic = iconic;
widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
if (iconic)
{
gtk_widget_hide (self->start_box);
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
- gtk_style_context_add_class (context, "model");
- gtk_style_context_add_class (context, "image-button");
- gtk_style_context_remove_class (context, "flat");
+ gtk_widget_add_style_class (self->start_box, "model");
+ gtk_widget_add_style_class (self->start_box, "image-button");
+ gtk_widget_remove_style_class (self->start_box, "flat");
}
else
{
gtk_widget_show (self->start_box);
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("modelbutton"));
- gtk_style_context_remove_class (context, "model");
- gtk_style_context_remove_class (context, "image-button");
- gtk_style_context_add_class (context, "flat");
+ gtk_widget_remove_style_class (self->start_box, "model");
+ gtk_widget_remove_style_class (self->start_box, "image-button");
+ gtk_widget_add_style_class (self->start_box, "flat");
+
}
self->centered = iconic;
@@ -1374,7 +1361,7 @@ gtk_model_button_init (GtkModelButton *self)
gtk_widget_insert_after (self->start_box, GTK_WIDGET (self), NULL);
update_node_ordering (self);
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "flat");
+ gtk_widget_add_style_class (GTK_WIDGET (self), "flat");
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "enter", G_CALLBACK (enter_cb), self);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 70c50793a3..f3f8e596c4 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1328,8 +1328,7 @@ gtk_notebook_init (GtkNotebook *notebook)
priv->header_widget = g_object_new (GTK_TYPE_BOX,
"css-name", "header",
NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->header_widget),
- GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (priv->header_widget, GTK_STYLE_CLASS_TOP);
gtk_widget_hide (priv->header_widget);
gtk_widget_set_parent (priv->header_widget, GTK_WIDGET (notebook));
@@ -1365,8 +1364,7 @@ gtk_notebook_init (GtkNotebook *notebook)
g_signal_connect (controller, "motion", G_CALLBACK (gtk_notebook_motion), notebook);
gtk_widget_add_controller (GTK_WIDGET (notebook), controller);
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (notebook)),
- GTK_STYLE_CLASS_FRAME);
+ gtk_widget_add_style_class (GTK_WIDGET (notebook), GTK_STYLE_CLASS_FRAME);
layout = gtk_widget_get_layout_manager (GTK_WIDGET (notebook));
gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), GTK_ORIENTATION_VERTICAL);
@@ -2634,7 +2632,7 @@ static void
tab_drag_begin (GtkNotebook *notebook,
GtkNotebookPage *page)
{
- gtk_style_context_add_class (gtk_widget_get_style_context (page->tab_widget), GTK_STYLE_CLASS_DND);
+ gtk_widget_add_style_class (page->tab_widget, GTK_STYLE_CLASS_DND);
}
/* This function undoes the reparenting that happens both when drag_surface
@@ -2652,7 +2650,7 @@ tab_drag_end (GtkNotebook *notebook,
g_object_unref (page->tab_label);
}
- gtk_style_context_remove_class (gtk_widget_get_style_context (page->tab_widget), GTK_STYLE_CLASS_DND);
+ gtk_widget_remove_style_class (page->tab_widget, GTK_STYLE_CLASS_DND);
}
static void
@@ -3034,7 +3032,6 @@ update_arrow_nodes (GtkNotebook *notebook)
if (priv->arrow_widget[i] == NULL)
{
GtkWidget *next_widget;
- GtkStyleContext *context;
switch (i)
{
@@ -3079,16 +3076,14 @@ update_arrow_nodes (GtkNotebook *notebook)
"css-name", "arrow",
NULL);
- context = gtk_widget_get_style_context (priv->arrow_widget[i]);
-
if (i == ARROW_LEFT_BEFORE || i == ARROW_LEFT_AFTER)
{
- gtk_style_context_add_class (context, "down");
+ gtk_widget_add_style_class (priv->arrow_widget[i], "down");
gtk_widget_insert_after (priv->arrow_widget[i], priv->tabs_widget, next_widget);
}
else
{
- gtk_style_context_add_class (context, "up");
+ gtk_widget_add_style_class (priv->arrow_widget[i], "up");
gtk_widget_insert_before (priv->arrow_widget[i], priv->tabs_widget, next_widget);
}
}
@@ -6127,13 +6122,12 @@ gtk_notebook_set_show_border (GtkNotebook *notebook,
if (priv->show_border != show_border)
{
- GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (notebook));
priv->show_border = show_border;
if (show_border)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
+ gtk_widget_add_style_class (GTK_WIDGET (notebook), GTK_STYLE_CLASS_FRAME);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
+ gtk_widget_remove_style_class (GTK_WIDGET (notebook), GTK_STYLE_CLASS_FRAME);
g_object_notify_by_pspec (G_OBJECT (notebook), properties[PROP_SHOW_BORDER]);
}
@@ -6258,11 +6252,9 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
for (i = 0; i < G_N_ELEMENTS (tab_pos_names); i++)
{
if (tab_pos == i)
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->header_widget),
- tab_pos_names[i]);
+ gtk_widget_add_style_class (priv->header_widget, tab_pos_names[i]);
else
- gtk_style_context_remove_class (gtk_widget_get_style_context (priv->header_widget),
- tab_pos_names[i]);
+ gtk_widget_remove_style_class (priv->header_widget, tab_pos_names[i]);
}
layout = gtk_widget_get_layout_manager (GTK_WIDGET (notebook));
@@ -7021,11 +7013,10 @@ gtk_notebook_set_tab_reorderable (GtkNotebook *notebook,
{
page->reorderable = reorderable;
if (reorderable)
- gtk_style_context_add_class (gtk_widget_get_style_context (page->tab_widget),
- "reorderable-page");
+ gtk_widget_add_style_class (page->tab_widget, "reorderable-page");
else
- gtk_style_context_remove_class (gtk_widget_get_style_context (page->tab_widget),
- "reorderable-page");
+ gtk_widget_remove_style_class (page->tab_widget, "reorderable-page");
+
g_object_notify (G_OBJECT (page), "reorderable");
}
}
diff --git a/gtk/gtkorientable.c b/gtk/gtkorientable.c
index 70b8e60ff7..8cdefc70c4 100644
--- a/gtk/gtkorientable.c
+++ b/gtk/gtkorientable.c
@@ -110,23 +110,21 @@ gtk_orientable_get_orientation (GtkOrientable *orientable)
void
_gtk_orientable_set_style_classes (GtkOrientable *orientable)
{
- GtkStyleContext *context;
GtkOrientation orientation;
g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
g_return_if_fail (GTK_IS_WIDGET (orientable));
- context = gtk_widget_get_style_context (GTK_WIDGET (orientable));
orientation = gtk_orientable_get_orientation (orientable);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+ gtk_widget_add_style_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_widget_remove_style_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
}
else
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_widget_add_style_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
+ gtk_widget_remove_style_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
}
}
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index f1689302ca..06eff84f67 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -2421,11 +2421,9 @@ gtk_paned_set_wide_handle (GtkPaned *paned,
if (old_wide != wide)
{
if (wide)
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->handle_widget),
- GTK_STYLE_CLASS_WIDE);
+ gtk_widget_add_style_class (priv->handle_widget, GTK_STYLE_CLASS_WIDE);
else
- gtk_style_context_remove_class (gtk_widget_get_style_context (priv->handle_widget),
- GTK_STYLE_CLASS_WIDE);
+ gtk_widget_remove_style_class (priv->handle_widget, GTK_STYLE_CLASS_WIDE);
g_object_notify_by_pspec (G_OBJECT (paned), paned_props[PROP_WIDE_HANDLE]);
}
@@ -2446,6 +2444,5 @@ gtk_paned_get_wide_handle (GtkPaned *paned)
g_return_val_if_fail (GTK_IS_PANED (paned), FALSE);
- return gtk_style_context_has_class (gtk_widget_get_style_context (priv->handle_widget),
- GTK_STYLE_CLASS_WIDE);
+ return gtk_widget_has_style_class (priv->handle_widget, GTK_STYLE_CLASS_WIDE);
}
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index a2eeda7900..a3de52e488 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -149,11 +149,11 @@ gtk_password_entry_init (GtkPasswordEntry *entry)
priv->icon = gtk_image_new_from_icon_name ("caps-lock-symbolic");
gtk_widget_set_tooltip_text (priv->icon, _("Caps Lock is on"));
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->icon), "caps-lock-indicator");
+ gtk_widget_add_style_class (priv->icon, "caps-lock-indicator");
gtk_widget_set_cursor (priv->icon, gtk_widget_get_cursor (priv->entry));
gtk_widget_set_parent (priv->icon, GTK_WIDGET (entry));
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (entry)), I_("password"));
+ gtk_widget_add_style_class (GTK_WIDGET (entry), I_("password"));
gtk_password_entry_set_extra_menu (entry, NULL);
}
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index 0765c9dd3d..3bacdc53f9 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -201,7 +201,6 @@ static void
gtk_popover_menu_init (GtkPopoverMenu *popover)
{
GtkWidget *stack;
- GtkStyleContext *style_context;
GtkEventController *controller;
stack = gtk_stack_new ();
@@ -212,8 +211,7 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
g_signal_connect (stack, "notify::visible-child-name",
G_CALLBACK (visible_submenu_changed), popover);
- style_context = gtk_widget_get_style_context (GTK_WIDGET (popover));
- gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_MENU);
+ gtk_widget_add_style_class (GTK_WIDGET (popover), "menu");
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "focus-out", G_CALLBACK (focus_out), popover);
@@ -222,7 +220,6 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "leave", G_CALLBACK (leave_cb), popover);
gtk_widget_add_controller (GTK_WIDGET (popover), controller);
-
}
static void
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index c950dcfff2..a19c390870 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -266,7 +266,6 @@ static void
update_fraction_classes (GtkProgressBar *pbar)
{
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
- GtkStyleContext *context;
gboolean empty = FALSE;
gboolean full = FALSE;
@@ -281,25 +280,22 @@ update_fraction_classes (GtkProgressBar *pbar)
full = TRUE;
}
- context = gtk_widget_get_style_context (priv->trough_widget);
-
if (empty)
- gtk_style_context_add_class (context, "empty");
+ gtk_widget_add_style_class (priv->trough_widget, "empty");
else
- gtk_style_context_remove_class (context, "empty");
+ gtk_widget_remove_style_class (priv->trough_widget, "empty");
if (full)
- gtk_style_context_add_class (context, "full");
+ gtk_widget_add_style_class (priv->trough_widget, "full");
else
- gtk_style_context_remove_class (context, "full");
+ gtk_widget_remove_style_class (priv->trough_widget, "full");
}
static void
update_node_classes (GtkProgressBar *pbar)
{
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
- GtkStyleContext *context;
- gboolean left = FALSE;
+ gboolean left = FALSE;
gboolean right = FALSE;
gboolean top = FALSE;
gboolean bottom = FALSE;
@@ -344,27 +340,25 @@ update_node_classes (GtkProgressBar *pbar)
}
}
- context = gtk_widget_get_style_context (priv->progress_widget);
-
if (left)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (priv->progress_widget, GTK_STYLE_CLASS_LEFT);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (priv->progress_widget, GTK_STYLE_CLASS_LEFT);
if (right)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_style_class (priv->progress_widget, GTK_STYLE_CLASS_RIGHT);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (priv->progress_widget, GTK_STYLE_CLASS_RIGHT);
if (top)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (priv->progress_widget, GTK_STYLE_CLASS_TOP);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_style_class (priv->progress_widget, GTK_STYLE_CLASS_TOP);
if (bottom)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_style_class (priv->progress_widget, GTK_STYLE_CLASS_BOTTOM);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_style_class (priv->progress_widget, GTK_STYLE_CLASS_BOTTOM);
update_fraction_classes (pbar);
}
@@ -667,7 +661,7 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
GtkWidget *widget = GTK_WIDGET (pbar);
gboolean inverted;
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->progress_widget), GTK_STYLE_CLASS_PULSE);
+ gtk_widget_add_style_class (priv->progress_widget, GTK_STYLE_CLASS_PULSE);
inverted = priv->inverted;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index b2c2ae5d1d..fc08073895 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -712,22 +712,19 @@ static void
update_highlight_position (GtkRange *range)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- GtkStyleContext *context;
if (!priv->highlight_widget)
return;
- context = gtk_widget_get_style_context (priv->highlight_widget);
-
if (should_invert (range))
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_TOP);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_BOTTOM);
}
}
@@ -735,22 +732,19 @@ static void
update_fill_position (GtkRange *range)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- GtkStyleContext *context;
if (!priv->fill_widget)
return;
- context = gtk_widget_get_style_context (priv->fill_widget);
-
if (should_invert (range))
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_TOP);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_style_class (GTK_WIDGET (range), GTK_STYLE_CLASS_BOTTOM);
}
}
@@ -1662,9 +1656,6 @@ range_grab_add (GtkRange *range,
GtkWidget *location)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (GTK_WIDGET (range));
/* Don't perform any GDK/GTK+ grab here. Since a button
* is down, there's an ongoing implicit grab on
@@ -1673,7 +1664,7 @@ range_grab_add (GtkRange *range,
*/
priv->grab_location = location;
- gtk_style_context_add_class (context, "dragging");
+ gtk_widget_add_style_class (GTK_WIDGET (range), "dragging");
}
static void
@@ -1681,14 +1672,11 @@ update_zoom_state (GtkRange *range,
gboolean enabled)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (GTK_WIDGET (range));
if (enabled)
- gtk_style_context_add_class (context, "fine-tune");
+ gtk_widget_add_style_class (GTK_WIDGET (range), "fine-tune");
else
- gtk_style_context_remove_class (context, "fine-tune");
+ gtk_widget_remove_style_class (GTK_WIDGET (range), "fine-tune");
priv->zoom = enabled;
}
@@ -1697,18 +1685,15 @@ static void
range_grab_remove (GtkRange *range)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- GtkStyleContext *context;
if (!priv->grab_location)
return;
- context = gtk_widget_get_style_context (GTK_WIDGET (range));
-
priv->grab_location = NULL;
update_zoom_state (range, FALSE);
- gtk_style_context_remove_class (context, "dragging");
+ gtk_widget_remove_style_class (GTK_WIDGET (range), "dragging");
}
static GtkScrollType
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 918ecb3bbb..e49675934a 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -1042,24 +1042,21 @@ static void
update_value_position (GtkScale *scale)
{
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
- GtkStyleContext *context;
if (!priv->value_widget)
return;
- context = gtk_widget_get_style_context (priv->value_widget);
-
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (priv->value_widget, GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_style_class (priv->value_widget, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (priv->value_widget, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_style_class (priv->value_widget, GTK_STYLE_CLASS_LEFT);
switch (priv->value_pos)
{
- case GTK_POS_TOP: gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP); break;
- case GTK_POS_RIGHT: gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT); break;
- case GTK_POS_BOTTOM: gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM); break;
- case GTK_POS_LEFT: gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT); break;
+ case GTK_POS_TOP: gtk_widget_add_style_class (priv->value_widget, GTK_STYLE_CLASS_TOP); break;
+ case GTK_POS_RIGHT: gtk_widget_add_style_class (priv->value_widget, GTK_STYLE_CLASS_RIGHT); break;
+ case GTK_POS_BOTTOM: gtk_widget_add_style_class (priv->value_widget, GTK_STYLE_CLASS_BOTTOM); break;
+ case GTK_POS_LEFT: gtk_widget_add_style_class (priv->value_widget, GTK_STYLE_CLASS_LEFT); break;
default: g_assert_not_reached ();
}
@@ -1646,20 +1643,17 @@ void
gtk_scale_clear_marks (GtkScale *scale)
{
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
- GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCALE (scale));
g_slist_free_full (priv->marks, gtk_scale_mark_free);
priv->marks = NULL;
-
g_clear_pointer (&priv->top_marks_widget, gtk_widget_unparent);
g_clear_pointer (&priv->bottom_marks_widget, gtk_widget_unparent);
- context = gtk_widget_get_style_context (GTK_WIDGET (scale));
- gtk_style_context_remove_class (context, "marks-before");
- gtk_style_context_remove_class (context, "marks-after");
+ gtk_widget_remove_style_class (GTK_WIDGET (scale), "marks-before");
+ gtk_widget_remove_style_class (GTK_WIDGET (scale), "marks-after");
_gtk_range_set_stop_values (GTK_RANGE (scale), NULL, 0);
@@ -1700,7 +1694,6 @@ gtk_scale_add_mark (GtkScale *scale,
GSList *m;
gdouble *values;
gint n, i;
- GtkStyleContext *context;
GtkWidget *marks_widget;
g_return_if_fail (GTK_IS_SCALE (scale));
@@ -1735,8 +1728,7 @@ gtk_scale_add_mark (GtkScale *scale,
(priv->value_widget &&
(priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)) ?
priv->value_widget : NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->top_marks_widget),
- GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (priv->top_marks_widget, GTK_STYLE_CLASS_TOP);
}
marks_widget = priv->top_marks_widget;
}
@@ -1755,8 +1747,7 @@ gtk_scale_add_mark (GtkScale *scale,
(priv->value_widget &&
(priv->value_pos == GTK_POS_BOTTOM || priv->value_pos ==
GTK_POS_RIGHT)) ?
priv->value_widget: NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->bottom_marks_widget),
- GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_style_class (priv->bottom_marks_widget, GTK_STYLE_CLASS_BOTTOM);
}
marks_widget = priv->bottom_marks_widget;
}
@@ -1810,11 +1801,11 @@ gtk_scale_add_mark (GtkScale *scale,
g_free (values);
- context = gtk_widget_get_style_context (GTK_WIDGET (scale));
if (priv->top_marks_widget)
- gtk_style_context_add_class (context, "marks-before");
+ gtk_widget_add_style_class (GTK_WIDGET (scale), "marks-before");
+
if (priv->bottom_marks_widget)
- gtk_style_context_add_class (context, "marks-after");
+ gtk_widget_add_style_class (GTK_WIDGET (scale), "marks-after");
gtk_widget_queue_resize (widget);
}
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index fa683db75f..8f22f01311 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -369,7 +369,6 @@ static void
gtk_scale_button_init (GtkScaleButton *button)
{
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
- GtkStyleContext *context;
GtkEventController *controller;
priv->click_id = 0;
@@ -384,8 +383,7 @@ gtk_scale_button_init (GtkScaleButton *button)
g_object_ref_sink (priv->adjustment);
gtk_range_set_adjustment (GTK_RANGE (priv->scale), priv->adjustment);
- context = gtk_widget_get_style_context (GTK_WIDGET (button));
- gtk_style_context_add_class (context, "scale");
+ gtk_widget_add_style_class (GTK_WIDGET (button), "scale");
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
g_signal_connect (controller, "scroll",
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 83b4c1e285..c992034499 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -462,28 +462,25 @@ static void
update_scrollbar_positions (GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
- GtkStyleContext *context;
gboolean is_rtl;
if (priv->hscrollbar != NULL)
{
- context = gtk_widget_get_style_context (priv->hscrollbar);
if (priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_TOP_RIGHT)
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (priv->hscrollbar, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_style_class (priv->hscrollbar, GTK_STYLE_CLASS_TOP);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (priv->hscrollbar, GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_style_class (priv->hscrollbar, GTK_STYLE_CLASS_BOTTOM);
}
}
if (priv->vscrollbar != NULL)
{
- context = gtk_widget_get_style_context (priv->vscrollbar);
is_rtl = _gtk_widget_get_direction (GTK_WIDGET (scrolled_window)) == GTK_TEXT_DIR_RTL;
if ((is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_RIGHT ||
@@ -492,13 +489,13 @@ update_scrollbar_positions (GtkScrolledWindow *scrolled_window)
(priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (priv->vscrollbar, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_style_class (priv->vscrollbar, GTK_STYLE_CLASS_LEFT);
}
else
{
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_style_class (priv->vscrollbar, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_style_class (priv->vscrollbar, GTK_STYLE_CLASS_RIGHT);
}
}
}
@@ -1036,8 +1033,6 @@ static void
indicator_set_over (Indicator *indicator,
gboolean over)
{
- GtkStyleContext *context;
-
if (indicator->over_timeout_id)
{
g_source_remove (indicator->over_timeout_id);
@@ -1047,13 +1042,12 @@ indicator_set_over (Indicator *indicator,
if (indicator->over == over)
return;
- context = gtk_widget_get_style_context (indicator->scrollbar);
indicator->over = over;
if (indicator->over)
- gtk_style_context_add_class (context, "hovering");
+ gtk_widget_add_style_class (indicator->scrollbar, "hovering");
else
- gtk_style_context_remove_class (context, "hovering");
+ gtk_widget_remove_style_class (indicator->scrollbar, "hovering");
gtk_widget_queue_resize (indicator->scrollbar);
}
@@ -2439,10 +2433,9 @@ gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window)
**/
void
gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window,
- GtkShadowType type)
+ GtkShadowType type)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
- GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (type >= GTK_SHADOW_NONE && type <= GTK_SHADOW_ETCHED_OUT);
@@ -2451,11 +2444,10 @@ gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window,
{
priv->shadow_type = type;
- context = gtk_widget_get_style_context (GTK_WIDGET (scrolled_window));
if (type != GTK_SHADOW_NONE)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
+ gtk_widget_add_style_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
+ gtk_widget_remove_style_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME);
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_SHADOW_TYPE]);
}
@@ -3763,18 +3755,16 @@ setup_indicator (GtkScrolledWindow *scrolled_window,
Indicator *indicator,
GtkWidget *scrollbar)
{
- GtkStyleContext *context;
GtkAdjustment *adjustment;
if (scrollbar == NULL)
return;
- context = gtk_widget_get_style_context (scrollbar);
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
indicator->scrollbar = scrollbar;
- gtk_style_context_add_class (context, "overlay-indicator");
+ gtk_widget_add_style_class (scrollbar, "overlay-indicator");
g_signal_connect (adjustment, "value-changed",
G_CALLBACK (indicator_value_changed), indicator);
@@ -3787,7 +3777,6 @@ remove_indicator (GtkScrolledWindow *scrolled_window,
Indicator *indicator)
{
GtkWidget *scrollbar;
- GtkStyleContext *context;
GtkAdjustment *adjustment;
if (indicator->scrollbar == NULL)
@@ -3796,8 +3785,7 @@ remove_indicator (GtkScrolledWindow *scrolled_window,
scrollbar = indicator->scrollbar;
indicator->scrollbar = NULL;
- context = gtk_widget_get_style_context (scrollbar);
- gtk_style_context_remove_class (context, "overlay-indicator");
+ gtk_widget_remove_style_class (scrollbar, "overlay-indicator");
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
g_signal_handlers_disconnect_by_data (adjustment, indicator);
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index 484e97342c..1338b3e625 100644
--- a/gtk/gtksearchbar.c
+++ b/gtk/gtksearchbar.c
@@ -351,7 +351,7 @@ gtk_search_bar_init (GtkSearchBar *bar)
gtk_widget_set_hexpand (priv->box_center, TRUE);
priv->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->close_button), "close");
+ gtk_widget_add_style_class (priv->close_button, "close");
gtk_center_box_set_end_widget (GTK_CENTER_BOX (priv->box_center), priv->close_button);
gtk_widget_hide (priv->close_button);
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index f701ac21be..6baf857b80 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -540,7 +540,7 @@ gtk_search_entry_init (GtkSearchEntry *entry)
g_signal_connect (press, "released", G_CALLBACK (gtk_search_entry_icon_release), entry);
gtk_widget_add_controller (priv->icon, GTK_EVENT_CONTROLLER (press));
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (entry)), I_("search"));
+ gtk_widget_add_style_class (GTK_WIDGET (entry), I_("search"));
}
/**
diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c
index 2bd71cfd90..10bb29ecc7 100644
--- a/gtk/gtkseparatortoolitem.c
+++ b/gtk/gtkseparatortoolitem.c
@@ -188,13 +188,9 @@ gtk_separator_tool_item_new (void)
gboolean
gtk_separator_tool_item_get_draw (GtkSeparatorToolItem *item)
{
- GtkStyleContext *context;
-
g_return_val_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item), FALSE);
- context = gtk_widget_get_style_context (GTK_WIDGET (item));
-
- return !gtk_style_context_has_class (context, "invisible");
+ return !gtk_widget_has_style_class (GTK_WIDGET (item), "invisible");
}
/**
@@ -218,11 +214,9 @@ gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *item,
return;
if (draw)
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
- "invisible");
+ gtk_widget_remove_style_class (GTK_WIDGET (item), "invisible");
else
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
- "invisible");
+ gtk_widget_add_style_class (GTK_WIDGET (item), "invisible");
g_object_notify (G_OBJECT (item), "draw");
}
diff --git a/gtk/gtkshortcutlabel.c b/gtk/gtkshortcutlabel.c
index 4afa3f901f..9dc6355333 100644
--- a/gtk/gtkshortcutlabel.c
+++ b/gtk/gtkshortcutlabel.c
@@ -258,7 +258,7 @@ dim_label (const gchar *text)
GtkWidget *label;
label = gtk_label_new (text);
- gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
+ gtk_widget_add_style_class (label, "dim-label");
return label;
}
@@ -284,7 +284,7 @@ display_shortcut (GtkWidget *self,
if (i < n_mods)
gtk_widget_set_size_request (disp, 50, -1);
- gtk_style_context_add_class (gtk_widget_get_style_context (disp), "keycap");
+ gtk_widget_add_style_class (disp, "keycap");
gtk_label_set_use_markup (GTK_LABEL (disp), TRUE);
gtk_widget_set_parent (disp, self);
diff --git a/gtk/gtkshortcutssection.c b/gtk/gtkshortcutssection.c
index 0bb55fee01..9195f09ea0 100644
--- a/gtk/gtkshortcutssection.c
+++ b/gtk/gtkshortcutssection.c
@@ -729,8 +729,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
{
GtkWidget *w;
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->switcher)),
- "circular");
+ gtk_widget_add_style_class (GTK_WIDGET (self->switcher), "circular");
for (w = gtk_widget_get_first_child (GTK_WIDGET (self->switcher));
w != NULL;
@@ -738,7 +737,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
{
GtkWidget *label;
- gtk_style_context_add_class (gtk_widget_get_style_context (w), "circular");
+ gtk_widget_add_style_class (w, "circular");
label = gtk_bin_get_child (GTK_BIN (w));
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index bea8e84122..84e7298964 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -917,18 +917,18 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
/* Translators: This is the window title for the shortcuts window in normal mode */
label = gtk_label_new (_("Shortcuts"));
- gtk_style_context_add_class (gtk_widget_get_style_context (label), GTK_STYLE_CLASS_TITLE);
+ gtk_widget_add_style_class (label, GTK_STYLE_CLASS_TITLE);
gtk_stack_add_named (priv->title_stack, label, "title");
/* Translators: This is the window title for the shortcuts window in search mode */
label = gtk_label_new (_("Search Results"));
- gtk_style_context_add_class (gtk_widget_get_style_context (label), GTK_STYLE_CLASS_TITLE);
+ gtk_widget_add_style_class (label, GTK_STYLE_CLASS_TITLE);
gtk_stack_add_named (priv->title_stack, label, "search");
priv->menu_button = g_object_new (GTK_TYPE_MENU_BUTTON,
"focus-on-click", FALSE,
NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (priv->menu_button)), "flat");
+ gtk_widget_add_style_class (GTK_WIDGET (priv->menu_button), "flat");
gtk_stack_add_named (priv->title_stack, GTK_WIDGET (priv->menu_button), "sections");
priv->popover = g_object_new (GTK_TYPE_POPOVER,
@@ -971,7 +971,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
"halign", GTK_ALIGN_CENTER,
"orientation", GTK_ORIENTATION_VERTICAL,
NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (box)), "shortcuts-search-results");
+ gtk_widget_add_style_class (GTK_WIDGET (box), "shortcuts-search-results");
gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (box));
gtk_stack_add_named (priv->stack, scroller, "internal-search");
@@ -997,7 +997,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
"halign", GTK_ALIGN_CENTER,
"valign", GTK_ALIGN_CENTER,
NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (empty), GTK_STYLE_CLASS_DIM_LABEL);
+ gtk_widget_add_style_class (empty, GTK_STYLE_CLASS_DIM_LABEL);
gtk_grid_attach (GTK_GRID (empty),
g_object_new (GTK_TYPE_IMAGE,
"icon-name", "edit-find-symbolic",
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index 9b7fedd1ae..35ce3d0534 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -212,7 +212,6 @@ gtk_sidebar_row_set_property (GObject *object,
GParamSpec *pspec)
{
GtkSidebarRow *self = GTK_SIDEBAR_ROW (object);
- GtkStyleContext *context;
switch (prop_id)
{
@@ -353,8 +352,7 @@ gtk_sidebar_row_set_property (GObject *object,
(GtkCallback) gtk_widget_destroy,
NULL);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "sidebar-placeholder-row");
+ gtk_widget_add_style_class (GTK_WIDGET (self), "sidebar-placeholder-row");
}
break;
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 93484a617f..c2e916b87b 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -965,7 +965,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
gtk_widget_set_parent (priv->entry, GTK_WIDGET (spin_button));
priv->down_button = gtk_button_new_from_icon_name ("value-decrease-symbolic");
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->down_button), "down");
+ gtk_widget_add_style_class (priv->down_button, "down");
gtk_widget_set_can_focus (priv->down_button, FALSE);
gtk_widget_set_parent (priv->down_button, GTK_WIDGET (spin_button));
@@ -980,7 +980,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
gtk_widget_add_controller (GTK_WIDGET (priv->down_button), GTK_EVENT_CONTROLLER (gesture));
priv->up_button = gtk_button_new_from_icon_name ("value-increase-symbolic");
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->up_button), "up");
+ gtk_widget_add_style_class (priv->up_button, "up");
gtk_widget_set_can_focus (priv->up_button, FALSE);
gtk_widget_set_parent (priv->up_button, GTK_WIDGET (spin_button));
diff --git a/gtk/gtkstacksidebar.c b/gtk/gtkstacksidebar.c
index 31b5025de4..82ef454312 100644
--- a/gtk/gtkstacksidebar.c
+++ b/gtk/gtkstacksidebar.c
@@ -154,7 +154,6 @@ gtk_stack_sidebar_row_selected (GtkListBox *box,
static void
gtk_stack_sidebar_init (GtkStackSidebar *self)
{
- GtkStyleContext *style;
GtkWidget *sw;
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -173,8 +172,7 @@ gtk_stack_sidebar_init (GtkStackSidebar *self)
g_signal_connect (self->list, "row-selected",
G_CALLBACK (gtk_stack_sidebar_row_selected), self);
- style = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (style, "sidebar");
+ gtk_widget_add_style_class (GTK_WIDGET (self), "sidebar");
self->rows = g_hash_table_new (NULL, NULL);
}
@@ -188,7 +186,6 @@ update_row (GtkStackSidebar *self,
gchar *title;
gboolean needs_attention;
gboolean visible;
- GtkStyleContext *context;
g_object_get (page,
"title", &title,
@@ -201,11 +198,10 @@ update_row (GtkStackSidebar *self,
gtk_widget_set_visible (row, visible && title != NULL);
- context = gtk_widget_get_style_context (row);
if (needs_attention)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+ gtk_widget_add_style_class (row, GTK_STYLE_CLASS_NEEDS_ATTENTION);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+ gtk_widget_remove_style_class (row, GTK_STYLE_CLASS_NEEDS_ATTENTION);
g_free (title);
}
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index c9d30fecf1..572c108958 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -111,14 +111,12 @@ static void
gtk_stack_switcher_init (GtkStackSwitcher *switcher)
{
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
- GtkStyleContext *context;
GdkContentFormats *formats;
GtkDropTarget *dest;
priv->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
- context = gtk_widget_get_style_context (GTK_WIDGET (switcher));
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
+ gtk_widget_add_style_class (GTK_WIDGET (switcher), "linked");
formats = gdk_content_formats_new (NULL, 0);
dest = gtk_drop_target_new (formats, 0);
@@ -157,7 +155,6 @@ rebuild_child (GtkWidget *self,
const gchar *icon_name,
const gchar *title)
{
- GtkStyleContext *context;
GtkWidget *button_child;
button_child = gtk_bin_get_child (GTK_BIN (self));
@@ -165,7 +162,6 @@ rebuild_child (GtkWidget *self,
gtk_widget_destroy (button_child);
button_child = NULL;
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
if (icon_name != NULL)
{
@@ -173,8 +169,8 @@ rebuild_child (GtkWidget *self,
if (title != NULL)
gtk_widget_set_tooltip_text (GTK_WIDGET (self), title);
- gtk_style_context_remove_class (context, "text-button");
- gtk_style_context_add_class (context, "image-button");
+ gtk_widget_remove_style_class (self, "text-button");
+ gtk_widget_add_style_class (self, "image-button");
}
else if (title != NULL)
{
@@ -182,8 +178,8 @@ rebuild_child (GtkWidget *self,
gtk_widget_set_tooltip_text (GTK_WIDGET (self), NULL);
- gtk_style_context_remove_class (context, "image-button");
- gtk_style_context_add_class (context, "text-button");
+ gtk_widget_remove_style_class (self, "image-button");
+ gtk_widget_add_style_class (self, "text-button");
}
if (button_child)
@@ -202,7 +198,6 @@ update_button (GtkStackSwitcher *self,
gchar *icon_name;
gboolean needs_attention;
gboolean visible;
- GtkStyleContext *context;
g_object_get (page,
"title", &title,
@@ -215,11 +210,10 @@ update_button (GtkStackSwitcher *self,
gtk_widget_set_visible (button, visible && (title != NULL || icon_name != NULL));
- context = gtk_widget_get_style_context (button);
if (needs_attention)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+ gtk_widget_add_style_class (button, GTK_STYLE_CLASS_NEEDS_ATTENTION);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+ gtk_widget_remove_style_class (button, GTK_STYLE_CLASS_NEEDS_ATTENTION);
g_free (title);
g_free (icon_name);
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 872abd76f2..5eee78c72b 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1898,8 +1898,7 @@ gtk_text_ensure_magnifier (GtkText *self)
gtk_widget_set_size_request (priv->magnifier, 100, 60);
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
priv->magnifier_popover = gtk_popover_new (GTK_WIDGET (self));
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->magnifier_popover),
- "magnifier");
+ gtk_widget_add_style_class (priv->magnifier_popover, "magnifier");
gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
gtk_container_add (GTK_CONTAINER (priv->magnifier_popover),
priv->magnifier);
@@ -5326,7 +5325,6 @@ gtk_text_set_editable (GtkText *self,
gboolean is_editable)
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
- GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
if (is_editable != priv->editable)
{
@@ -5341,11 +5339,11 @@ gtk_text_set_editable (GtkText *self,
priv->preedit_length = 0;
priv->preedit_cursor = 0;
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_READ_ONLY);
+ gtk_widget_remove_style_class (GTK_WIDGET (self), GTK_STYLE_CLASS_READ_ONLY);
}
else
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_READ_ONLY);
+ gtk_widget_add_style_class (GTK_WIDGET (self), GTK_STYLE_CLASS_READ_ONLY);
}
priv->editable = is_editable;
@@ -6008,7 +6006,7 @@ append_bubble_item (GtkText *self,
image = gtk_image_new_from_icon_name (icon_name);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (item), image);
- gtk_style_context_add_class (gtk_widget_get_style_context (item), "image-button");
+ gtk_widget_add_style_class (item, "image-button");
gtk_actionable_set_action_name (GTK_ACTIONABLE (item), action_name);
gtk_widget_show (GTK_WIDGET (item));
gtk_container_add (GTK_CONTAINER (toolbar), item);
@@ -6043,8 +6041,7 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
priv->selection_bubble = gtk_popover_new (GTK_WIDGET (self));
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble),
- GTK_STYLE_CLASS_TOUCH_SELECTION);
+ gtk_widget_add_style_class (priv->selection_bubble, GTK_STYLE_CLASS_TOUCH_SELECTION);
gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble), GTK_POS_BOTTOM);
gtk_popover_set_autohide (GTK_POPOVER (priv->selection_bubble), FALSE);
g_signal_connect (priv->selection_bubble, "notify::visible",
@@ -6054,7 +6051,7 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
g_object_set (box, "margin", 10, NULL);
gtk_widget_show (box);
toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), "linked");
+ gtk_widget_add_style_class (toolbar, "linked");
gtk_container_add (GTK_CONTAINER (priv->selection_bubble), box);
gtk_container_add (GTK_CONTAINER (box), toolbar);
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index ad70b984ab..1f2f6cc09a 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -189,12 +189,10 @@ static void
gtk_toggle_button_init (GtkToggleButton *toggle_button)
{
GtkToggleButtonPrivate *priv = gtk_toggle_button_get_instance_private (toggle_button);
- GtkStyleContext *context;
priv->active = FALSE;
- context = gtk_widget_get_style_context (GTK_WIDGET (toggle_button));
- gtk_style_context_add_class (context, "toggle");
+ gtk_widget_add_style_class (GTK_WIDGET (toggle_button), "toggle");
}
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index 8cc681cf8f..d99a064f9c 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -492,8 +492,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
case GTK_TOOLBAR_ICONS:
if (icon)
gtk_container_add (GTK_CONTAINER (button->priv->button), icon);
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "image-button");
- gtk_style_context_remove_class (gtk_widget_get_style_context (button->priv->button), "text-button");
+ gtk_widget_add_style_class (button->priv->button, "image-button");
+ gtk_widget_remove_style_class (button->priv->button, "text-button");
break;
case GTK_TOOLBAR_BOTH:
@@ -507,8 +507,9 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (button->priv->button), box);
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "image-button");
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "text-button");
+ gtk_widget_add_style_class (button->priv->button, "image-button");
+ gtk_widget_add_style_class (button->priv->button, "text-button");
+
break;
case GTK_TOOLBAR_BOTH_HORIZ:
@@ -537,14 +538,14 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_container_add (GTK_CONTAINER (box), label);
}
gtk_container_add (GTK_CONTAINER (button->priv->button), box);
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "image-button");
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "text-button");
+ gtk_widget_add_style_class (button->priv->button, "image-button");
+ gtk_widget_add_style_class (button->priv->button, "text-button");
break;
case GTK_TOOLBAR_TEXT:
gtk_container_add (GTK_CONTAINER (button->priv->button), label);
- gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "text-button");
- gtk_style_context_remove_class (gtk_widget_get_style_context (button->priv->button), "image-button");
+ gtk_widget_add_style_class (button->priv->button, "text-button");
+ gtk_widget_remove_style_class (button->priv->button, "image-button");
break;
}
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 1a6d17deb4..eeb9f46613 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -354,8 +354,7 @@ gtk_viewport_init (GtkViewport *viewport)
priv->hadjustment = NULL;
priv->vadjustment = NULL;
- gtk_style_context_add_class (gtk_widget_get_style_context (widget),
- GTK_STYLE_CLASS_FRAME);
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_FRAME);
viewport_set_adjustment (viewport, GTK_ORIENTATION_HORIZONTAL, NULL);
viewport_set_adjustment (viewport, GTK_ORIENTATION_VERTICAL, NULL);
}
@@ -451,11 +450,10 @@ viewport_set_adjustment (GtkViewport *viewport,
**/
void
gtk_viewport_set_shadow_type (GtkViewport *viewport,
- GtkShadowType type)
+ GtkShadowType type)
{
GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport);
GtkWidget *widget;
- GtkStyleContext *context;
g_return_if_fail (GTK_IS_VIEWPORT (viewport));
@@ -465,13 +463,10 @@ gtk_viewport_set_shadow_type (GtkViewport *viewport,
{
priv->shadow_type = type;
- context = gtk_widget_get_style_context (widget);
if (type != GTK_SHADOW_NONE)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
+ gtk_widget_add_style_class (GTK_WIDGET (viewport), GTK_STYLE_CLASS_FRAME);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
-
- gtk_widget_queue_resize (widget);
+ gtk_widget_remove_style_class (GTK_WIDGET (viewport), GTK_STYLE_CLASS_FRAME);
g_object_notify (G_OBJECT (viewport), "shadow-type");
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index f29b2936ca..69160a2e5c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5476,16 +5476,13 @@ _gtk_widget_set_has_default (GtkWidget *widget,
gboolean has_default)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
- GtkStyleContext *context;
priv->has_default = has_default;
- context = _gtk_widget_get_style_context (widget);
-
if (has_default)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_DEFAULT);
else
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_DEFAULT);
+ gtk_widget_remove_style_class (widget, GTK_STYLE_CLASS_DEFAULT);
}
/**
@@ -9770,13 +9767,10 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
else if (strcmp (tagname, "style") == 0)
{
StyleParserData *style_data = (StyleParserData *)user_data;
- GtkStyleContext *context;
GSList *l;
- context = _gtk_widget_get_style_context (GTK_WIDGET (buildable));
-
for (l = style_data->classes; l; l = l->next)
- gtk_style_context_add_class (context, (const gchar *)l->data);
+ gtk_widget_add_style_class (GTK_WIDGET (buildable), (const char *)l->data);
gtk_widget_reset_style (GTK_WIDGET (buildable));
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a396f9e991..97b295899d 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3690,13 +3690,9 @@ gtk_window_enable_csd (GtkWindow *window)
/* We need a visual with alpha for client shadows */
if (priv->use_client_shadow)
- {
- gtk_style_context_add_class (gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_CSD);
- }
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_CSD);
else
- {
- gtk_style_context_add_class (gtk_widget_get_style_context (widget), "solid-csd");
- }
+ gtk_widget_add_style_class (widget, "solid-csd");
priv->client_decorated = TRUE;
}
@@ -3755,7 +3751,7 @@ gtk_window_set_titlebar (GtkWindow *window,
if (titlebar == NULL)
{
priv->client_decorated = FALSE;
- gtk_style_context_remove_class (gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_CSD);
+ gtk_widget_remove_style_class (widget, GTK_STYLE_CLASS_CSD);
goto out;
}
@@ -3777,8 +3773,7 @@ gtk_window_set_titlebar (GtkWindow *window,
on_titlebar_title_notify (GTK_HEADER_BAR (titlebar), NULL, window);
}
- gtk_style_context_add_class (gtk_widget_get_style_context (titlebar),
- GTK_STYLE_CLASS_TITLEBAR);
+ gtk_widget_add_style_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
out:
if (was_mapped)
@@ -4787,7 +4782,6 @@ create_titlebar (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *titlebar;
- GtkStyleContext *context;
titlebar = gtk_header_bar_new ();
g_object_set (titlebar,
@@ -4795,9 +4789,8 @@ create_titlebar (GtkWindow *window)
"has-subtitle", FALSE,
"show-title-buttons", TRUE,
NULL);
- context = gtk_widget_get_style_context (titlebar);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLEBAR);
- gtk_style_context_add_class (context, "default-decoration");
+ gtk_widget_add_style_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
+ gtk_widget_add_style_class (titlebar, "default-decoration");
return titlebar;
}
@@ -5702,56 +5695,50 @@ static void
update_window_style_classes (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GtkStyleContext *context;
+ GtkWidget *widget = GTK_WIDGET (window);
guint edge_constraints;
- context = gtk_widget_get_style_context (GTK_WIDGET (window));
edge_constraints = priv->edge_constraints;
if (!priv->edge_constraints)
{
if (priv->tiled)
- gtk_style_context_add_class (context, "tiled");
+ gtk_widget_add_style_class (widget, "titled");
else
- gtk_style_context_remove_class (context, "tiled");
+ gtk_widget_remove_style_class (widget, "tiled");
}
else
{
if (edge_constraints & GDK_SURFACE_STATE_TOP_TILED)
- gtk_style_context_add_class (context, "tiled-top");
+ gtk_widget_add_style_class (widget, "titled-top");
else
- gtk_style_context_remove_class (context, "tiled-top");
+ gtk_widget_remove_style_class (widget, "tiled-top");
if (edge_constraints & GDK_SURFACE_STATE_RIGHT_TILED)
- gtk_style_context_add_class (context, "tiled-right");
+ gtk_widget_add_style_class (widget, "titled-right");
else
- gtk_style_context_remove_class (context, "tiled-right");
+ gtk_widget_remove_style_class (widget, "tiled-right");
if (edge_constraints & GDK_SURFACE_STATE_BOTTOM_TILED)
- gtk_style_context_add_class (context, "tiled-bottom");
+ gtk_widget_add_style_class (widget, "titled-bottom");
else
- gtk_style_context_remove_class (context, "tiled-bottom");
+ gtk_widget_remove_style_class (widget, "tiled-bottom");
if (edge_constraints & GDK_SURFACE_STATE_LEFT_TILED)
- gtk_style_context_add_class (context, "tiled-left");
+ gtk_widget_add_style_class (widget, "titled-left");
else
- gtk_style_context_remove_class (context, "tiled-left");
+ gtk_widget_remove_style_class (widget, "tiled-left");
}
if (priv->maximized)
- gtk_style_context_add_class (context, "maximized");
- else
- gtk_style_context_remove_class (context, "maximized");
-
- if (priv->maximized)
- gtk_style_context_add_class (context, "maximized");
+ gtk_widget_add_style_class (widget, "maximized");
else
- gtk_style_context_remove_class (context, "maximized");
+ gtk_widget_remove_style_class (widget, "maximized");
if (priv->fullscreen)
- gtk_style_context_add_class (context, "fullscreen");
+ gtk_widget_add_style_class (widget, "fullscreen");
else
- gtk_style_context_remove_class (context, "fullscreen");
+ gtk_widget_remove_style_class (widget, "fullscreen");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]