summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-04-10 12:08:16 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-04-10 12:09:57 -0400
commit394ea32e93cab4253e7dd595f2a13824421f6d03 (patch)
tree7e6505f11199c5ebc47da50d249324bf09609a19 /demos
parent2bd36d490b3a0c8138a2ad3aa246a0876ae0718b (diff)
downloadgtk+-394ea32e93cab4253e7dd595f2a13824421f6d03.tar.gz
Use gtk_widget_add/remove_css_class more
Replace most uses of gtk_style_context_add/remove_class by the new APIs. The only remaining uses of the old API are in save/restore situations.
Diffstat (limited to 'demos')
-rw-r--r--demos/constraint-editor/constraint-view.c4
-rw-r--r--demos/gtk-demo/bluroverlay.c26
-rw-r--r--demos/gtk-demo/dnd.c4
-rw-r--r--demos/gtk-demo/fishbowl.c2
-rw-r--r--demos/gtk-demo/fixed.c2
-rw-r--r--demos/gtk-demo/headerbar.c2
-rw-r--r--demos/gtk-demo/password_entry.c2
-rw-r--r--demos/gtk-demo/rotated_text.c3
-rw-r--r--demos/gtk-demo/sidebar.c2
-rw-r--r--demos/gtk-demo/sliding_puzzle.c2
-rw-r--r--demos/gtk-demo/tagged_entry.c4
-rw-r--r--demos/widget-factory/widget-factory.c6
12 files changed, 27 insertions, 32 deletions
diff --git a/demos/constraint-editor/constraint-view.c b/demos/constraint-editor/constraint-view.c
index 56d4703872..141a40327c 100644
--- a/demos/constraint-editor/constraint-view.c
+++ b/demos/constraint-editor/constraint-view.c
@@ -214,7 +214,7 @@ constraint_view_add_child (ConstraintView *view,
label = gtk_label_new (name);
frame = gtk_frame_new (NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
+ gtk_widget_add_css_class (frame, "child");
gtk_widget_set_name (frame, name);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_set_parent (frame, GTK_WIDGET (view));
@@ -257,7 +257,7 @@ constraint_view_add_guide (ConstraintView *view,
G_BINDING_DEFAULT);
frame = gtk_frame_new (NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
+ gtk_widget_add_css_class (frame, "guide");
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
diff --git a/demos/gtk-demo/bluroverlay.c b/demos/gtk-demo/bluroverlay.c
index e7054bc621..b2644c0815 100644
--- a/demos/gtk-demo/bluroverlay.c
+++ b/demos/gtk-demo/bluroverlay.c
@@ -131,13 +131,11 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
GtkAlign valign, halign;
gboolean is_left, is_right, is_top, is_bottom;
gboolean has_left, has_right, has_top, has_bottom;
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (child);
- has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
- has_right = gtk_style_context_has_class (context, GTK_STYLE_CLASS_RIGHT);
- has_top = gtk_style_context_has_class (context, GTK_STYLE_CLASS_TOP);
- has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
+ has_left = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_LEFT);
+ has_right = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_RIGHT);
+ has_top = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_TOP);
+ has_bottom = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_BOTTOM);
is_left = is_right = is_top = is_bottom = FALSE;
@@ -160,24 +158,24 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
is_bottom = (child_allocation->y + child_allocation->height == height);
if (has_left && !is_left)
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_LEFT);
else if (!has_left && is_left)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_widget_add_css_class (child, GTK_STYLE_CLASS_LEFT);
if (has_right && !is_right)
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_RIGHT);
else if (!has_right && is_right)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_widget_add_css_class (child, GTK_STYLE_CLASS_RIGHT);
if (has_top && !is_top)
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_TOP);
else if (!has_top && is_top)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_css_class (child, GTK_STYLE_CLASS_TOP);
if (has_bottom && !is_bottom)
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_BOTTOM);
else if (!has_bottom && is_bottom)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_css_class (child, GTK_STYLE_CLASS_BOTTOM);
}
static void
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index c5b52203f3..c9491ae958 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -81,7 +81,7 @@ deserialize_widget (GtkDemoWidget *demo)
else if (demo->type == GTK_TYPE_SPINNER)
{
widget = g_object_new (demo->type, "spinning", demo->active, NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
+ gtk_widget_add_css_class (widget, "demo");
}
else
{
@@ -114,7 +114,7 @@ new_spinner_cb (GtkWidget *button,
GtkWidget *widget;
widget = gtk_spinner_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
+ gtk_widget_add_css_class (widget, "demo");
gtk_spinner_start (GTK_SPINNER (widget));
gtk_fixed_put (fixed, widget, pos_x, pos_y);
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index a9585107f5..e1da414751 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -62,7 +62,7 @@ create_blurred_button (void)
{
GtkWidget *w = gtk_button_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
+ gtk_widget_add_css_class (w, "blurred-button");
return w;
}
diff --git a/demos/gtk-demo/fixed.c b/demos/gtk-demo/fixed.c
index 95715c992a..cf1d642f20 100644
--- a/demos/gtk-demo/fixed.c
+++ b/demos/gtk-demo/fixed.c
@@ -52,7 +52,7 @@ create_faces (void)
/* Add a face */
faces[i].face = gtk_frame_new (NULL);
gtk_widget_set_size_request (faces[i].face, face_size, face_size);
- gtk_style_context_add_class (gtk_widget_get_style_context (faces[i].face), faces[i].css_class);
+ gtk_widget_add_css_class (faces[i].face, faces[i].css_class);
gtk_container_add (GTK_CONTAINER (fixed), faces[i].face);
/* Set up the transformation for each face */
diff --git a/demos/gtk-demo/headerbar.c b/demos/gtk-demo/headerbar.c
index dff42be3a4..8bd78fb227 100644
--- a/demos/gtk-demo/headerbar.c
+++ b/demos/gtk-demo/headerbar.c
@@ -42,7 +42,7 @@ do_headerbar (GtkWidget *do_widget)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
+ gtk_widget_add_css_class (box, "linked");
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_container_add (GTK_CONTAINER (box), button);
diff --git a/demos/gtk-demo/password_entry.c b/demos/gtk-demo/password_entry.c
index caabde9599..5d957ced43 100644
--- a/demos/gtk-demo/password_entry.c
+++ b/demos/gtk-demo/password_entry.c
@@ -74,7 +74,7 @@ do_password_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), entry2);
button = gtk_button_new_with_mnemonic ("_Done");
- gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
+ gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index b7967880da..eef6f7ca35 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -190,8 +190,7 @@ do_rotated_text (GtkWidget *do_widget)
/* Add a drawing area */
drawing_area = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (box), drawing_area);
- gtk_style_context_add_class (gtk_widget_get_style_context (drawing_area),
- GTK_STYLE_CLASS_VIEW);
+ gtk_widget_add_css_class (drawing_area, GTK_STYLE_CLASS_VIEW);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
rotated_text_draw,
diff --git a/demos/gtk-demo/sidebar.c b/demos/gtk-demo/sidebar.c
index 3b092eac92..2b64ec2264 100644
--- a/demos/gtk-demo/sidebar.c
+++ b/demos/gtk-demo/sidebar.c
@@ -63,7 +63,7 @@ do_sidebar (GtkWidget *do_widget)
if (i == 0)
{
widget = gtk_image_new_from_icon_name ("org.gtk.Demo4");
- gtk_style_context_add_class (gtk_widget_get_style_context (widget), "icon-dropshadow");
+ gtk_widget_add_css_class (widget, "icon-dropshadow");
gtk_image_set_pixel_size (GTK_IMAGE (widget), 256);
}
else
diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c
index 2a606fc2fc..d95cc14126 100644
--- a/demos/gtk-demo/sliding_puzzle.c
+++ b/demos/gtk-demo/sliding_puzzle.c
@@ -419,7 +419,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
gtk_widget_set_margin_bottom (tweaks, 10);
choices = gtk_flow_box_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (choices), GTK_STYLE_CLASS_VIEW);
+ gtk_widget_add_css_class (choices, GTK_STYLE_CLASS_VIEW);
add_choice (choices, puzzle);
add_choice (choices, gtk_nuclear_animation_new ());
media = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
diff --git a/demos/gtk-demo/tagged_entry.c b/demos/gtk-demo/tagged_entry.c
index 97c68d46be..9a588c6c2b 100644
--- a/demos/gtk-demo/tagged_entry.c
+++ b/demos/gtk-demo/tagged_entry.c
@@ -25,7 +25,7 @@ add_tag (GtkButton *button, DemoTaggedEntry *entry)
DemoTaggedEntryTag *tag;
tag = demo_tagged_entry_tag_new ("Blue");
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (tag)), "blue");
+ gtk_widget_add_css_class (GTK_WIDGET (tag), "blue");
demo_tagged_entry_tag_set_has_close_button (tag, TRUE);
g_signal_connect (tag, "button-clicked", G_CALLBACK (closed_cb), entry);
@@ -98,7 +98,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_button_new_with_mnemonic ("_Done");
- gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
+ gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 56088fcca5..40ce3e286c 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -481,13 +481,11 @@ static void
on_record_button_toggled (GtkToggleButton *button,
gpointer user_data)
{
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET (button));
if (gtk_toggle_button_get_active (button))
- gtk_style_context_remove_class (context, "destructive-action");
+ gtk_widget_remove_css_class (GTK_WIDGET (button), "destructive-action");
else
- gtk_style_context_add_class (context, "destructive-action");
+ gtk_widget_add_css_class (GTK_WIDGET (button), "destructive-action");
}
static void