[gtk/matthiasc/for-master: 2/3] gtk-demo: Visual improvement to solitaire
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/3] gtk-demo: Visual improvement to solitaire
- Date: Wed, 12 Aug 2020 03:26:47 +0000 (UTC)
commit 3340a5ee042095b25cf4529ea9af84fc173cf188
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Aug 11 23:03:31 2020 -0400
gtk-demo: Visual improvement to solitaire
Make the fields visible.
demos/gtk-demo/peg_solitaire.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/demos/gtk-demo/peg_solitaire.c b/demos/gtk-demo/peg_solitaire.c
index 379a336e47..1f5dfa30d8 100644
--- a/demos/gtk-demo/peg_solitaire.c
+++ b/demos/gtk-demo/peg_solitaire.c
@@ -334,6 +334,14 @@ create_board (GtkWidget *window)
int x, y;
GtkDragSource *source;
GtkDropTarget *target;
+ GtkCssProvider *provider;
+ const char css[] =
+ ".solitaire-field {"
+ " border: 1px solid lightgray;"
+ "}";
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, css, -1);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
@@ -352,6 +360,10 @@ create_board (GtkWidget *window)
continue;
image = gtk_image_new ();
+ gtk_style_context_add_provider (gtk_widget_get_style_context (image),
+ GTK_STYLE_PROVIDER (provider),
+ 800);
+ gtk_widget_add_css_class (image, "solitaire-field");
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
if (x != 3 || y != 3)
{
@@ -393,6 +405,8 @@ create_board (GtkWidget *window)
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (target));
}
}
+
+ g_object_unref (provider);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]