[libdazzle] theme: add default styling for pillbox



commit 2d8e9376bc329be3a6b660768a01edba64c0c188
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 5 16:01:28 2017 -0700

    theme: add default styling for pillbox
    
    Also includes a test to render some pillboxes.

 data/themes/shared/shared-pillbox.css |    7 +++-
 tests/meson.build                     |    6 +++
 tests/test-pill-box.c                 |   61 +++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletions(-)
---
diff --git a/data/themes/shared/shared-pillbox.css b/data/themes/shared/shared-pillbox.css
index ad31f2b..c4f89a8 100644
--- a/data/themes/shared/shared-pillbox.css
+++ b/data/themes/shared/shared-pillbox.css
@@ -1,4 +1,9 @@
 dzlpillbox {
   border-radius: 3px;
-  background-color: @wm_bg_b;
+  background-color: mix(@borders, @theme_bg_color, .5);
+}
+
+dzlpillbox:backdrop {
+  border-radius: 3px;
+  background-color: mix(@borders, @theme_unfocused_bg_color, .75);
 }
diff --git a/tests/meson.build b/tests/meson.build
index bf04a5d..7fc8eed 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -226,3 +226,9 @@ test_levenshtein = executable('test-levenshtein', 'test-levenshtein.c',
      link_args: test_link_args,
   dependencies: libdazzle_deps + [libdazzle_dep],
 )
+
+test_pill_box = executable('test-pill-box', 'test-pill-box.c',
+        c_args: test_cflags,
+     link_args: test_link_args,
+  dependencies: libdazzle_deps + [libdazzle_dep],
+)
diff --git a/tests/test-pill-box.c b/tests/test-pill-box.c
new file mode 100644
index 0000000..85907a0
--- /dev/null
+++ b/tests/test-pill-box.c
@@ -0,0 +1,61 @@
+#include <dazzle.h>
+
+static const gchar *words[] = {
+  "Autotools",
+  "Meson",
+  "CMake",
+  "waf",
+  "scons",
+  "shell",
+  NULL
+};
+
+static void
+load_css (void)
+{
+  g_autoptr(GtkCssProvider) provider = NULL;
+
+  provider = dzl_css_provider_new ("/org/gnome/dazzle/themes");
+  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+                                             GTK_STYLE_PROVIDER (provider),
+                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+}
+
+int
+main (int argc,
+      char *argv[])
+{
+  GtkWidget *window;
+  GtkWidget *box;
+  GtkWidget *pill;
+
+  gtk_init (&argc, &argv);
+
+  load_css ();
+
+  window = g_object_new (GTK_TYPE_WINDOW,
+                         "title", "Test PillBox",
+                         "border-width", 24,
+                         NULL);
+  box = g_object_new (GTK_TYPE_BOX,
+                      "spacing", 3,
+                      "visible", TRUE,
+                      NULL);
+  gtk_container_add (GTK_CONTAINER (window), box);
+
+  for (guint i = 0; words[i]; i++)
+    {
+      pill = g_object_new (DZL_TYPE_PILL_BOX,
+                           "label", words[i],
+                           "visible", TRUE,
+                           NULL);
+      gtk_container_add (GTK_CONTAINER (box), pill);
+    }
+
+  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
+  gtk_window_present (GTK_WINDOW (window));
+
+  gtk_main ();
+
+  return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]