summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-11-02 11:59:22 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-11-02 11:59:22 -0500
commit64ad490bc170f1d6f41ace97b7be9f103167898b (patch)
treea57afc3a219cdf19a54b954a2f608819b2851e23 /demos
parentd2d7a4bcab94570eb27fd6d4547d78fb688921d0 (diff)
downloadgtk+-64ad490bc170f1d6f41ace97b7be9f103167898b.tar.gz
gtk-demo: Tweak tagged entry styling
Move the tags closer together, and avoid resizing too much.
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/demotaggedentry.c20
-rw-r--r--demos/gtk-demo/tagged_entry.c1
-rw-r--r--demos/gtk-demo/tagstyle.css6
3 files changed, 18 insertions, 9 deletions
diff --git a/demos/gtk-demo/demotaggedentry.c b/demos/gtk-demo/demotaggedentry.c
index 8d5c93edff..8a3ca5e9a3 100644
--- a/demos/gtk-demo/demotaggedentry.c
+++ b/demos/gtk-demo/demotaggedentry.c
@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
static void
demo_tagged_entry_init (DemoTaggedEntry *entry)
{
+ GtkCssProvider *provider;
+
entry->text = gtk_text_new ();
gtk_widget_set_hexpand (entry->text, TRUE);
gtk_widget_set_vexpand (entry->text, TRUE);
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
gtk_editable_init_delegate (GTK_EDITABLE (entry));
+ gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
+ gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
+ gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
+ gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ 800);
+ g_object_unref (provider);
}
static void
@@ -212,7 +224,6 @@ static void
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
{
GtkGesture *gesture;
- GtkCssProvider *provider;
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
@@ -222,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
-
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
- gtk_style_context_add_provider_for_display (gdk_display_get_default (),
- GTK_STYLE_PROVIDER (provider),
- 800);
- g_object_unref (provider);
}
static void
diff --git a/demos/gtk-demo/tagged_entry.c b/demos/gtk-demo/tagged_entry.c
index c07858b546..02c336a4c6 100644
--- a/demos/gtk-demo/tagged_entry.c
+++ b/demos/gtk-demo/tagged_entry.c
@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
+ gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
diff --git a/demos/gtk-demo/tagstyle.css b/demos/gtk-demo/tagstyle.css
index c470a5e2e2..0d1eacb30f 100644
--- a/demos/gtk-demo/tagstyle.css
+++ b/demos/gtk-demo/tagstyle.css
@@ -1,5 +1,5 @@
tag {
- margin: 4px;
+ margin: 4px 0px;
padding: 4px;
border-radius: 4px;
background: lightskyblue;
@@ -17,3 +17,7 @@ tag button {
padding: 0;
border: 1px solid white;
}
+
+entry.tagged {
+ border-spacing: 4px;
+}