[gtk/pango2] fontexplorer: Some reshuffling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/pango2] fontexplorer: Some reshuffling
- Date: Sun, 10 Jul 2022 15:40:56 +0000 (UTC)
commit 30f0d360d3dd054a81d14a092cd4e3852e261cf5
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 10 10:20:11 2022 -0400
fontexplorer: Some reshuffling
Move the view controls to the headerbar, to get
a clean view space.
demos/font-explorer/fontcolors.c | 42 +++---
demos/font-explorer/fontcolors.h | 3 -
demos/font-explorer/fontexplorer.css | 25 ++--
demos/font-explorer/fontexplorerwin.c | 21 ++-
demos/font-explorer/fontexplorerwin.ui | 249 +++++++++++++++++----------------
demos/font-explorer/fontfeatures.c | 51 ++++---
demos/font-explorer/fontfeatures.h | 3 -
demos/font-explorer/fontvariations.c | 43 +++---
demos/font-explorer/fontvariations.h | 3 -
demos/font-explorer/glyphsview.ui | 3 +
demos/font-explorer/infoview.ui | 2 +-
demos/font-explorer/plainview.c | 2 +-
demos/font-explorer/plainview.ui | 8 +-
demos/font-explorer/sampleeditor.ui | 4 +
demos/font-explorer/waterfallview.c | 4 +-
demos/font-explorer/waterfallview.ui | 2 +-
16 files changed, 223 insertions(+), 242 deletions(-)
---
diff --git a/demos/font-explorer/fontcolors.c b/demos/font-explorer/fontcolors.c
index ffb99de209..8434d676aa 100644
--- a/demos/font-explorer/fontcolors.c
+++ b/demos/font-explorer/fontcolors.c
@@ -4,7 +4,8 @@
#include <hb-ot.h>
enum {
- PROP_FONT_DESC = 1,
+ PROP_FONT_MAP = 1,
+ PROP_FONT_DESC,
PROP_PALETTE,
NUM_PROPERTIES
};
@@ -23,7 +24,7 @@ struct _FontColors
char *palette;
GtkCheckButton *default_check;
- Pango2FontMap *map;
+ Pango2FontMap *font_map;
};
struct _FontColorsClass
@@ -39,10 +40,7 @@ get_font (FontColors *self)
Pango2Context *context;
Pango2Font *font;
- context = pango2_context_new ();
- if (self->map)
- pango2_context_set_font_map (context, self->map);
-
+ context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
@@ -185,6 +183,8 @@ reset (GSimpleAction *action,
static void
font_colors_init (FontColors *self)
{
+ self->font_map = g_object_ref (pango2_font_map_get_default ());
+
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
gtk_widget_init_template (GTK_WIDGET (self));
@@ -209,8 +209,7 @@ font_colors_finalize (GObject *object)
g_clear_pointer (&self->font_desc, pango2_font_description_free);
g_free (self->palette);
-
- g_clear_object (&self->map);
+ g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_colors_parent_class)->finalize (object);
}
@@ -225,15 +224,20 @@ font_colors_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_FONT_MAP:
+ g_set_object (&self->font_map, g_value_get_object (value));
+ break;
+
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
- update_colors (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
+
+ update_colors (self);
}
static void
@@ -265,6 +269,11 @@ font_colors_class_init (FontColorsClass *class)
object_class->get_property = font_colors_get_property;
object_class->set_property = font_colors_set_property;
+ properties[PROP_FONT_MAP] =
+ g_param_spec_object ("font-map", "", "",
+ PANGO2_TYPE_FONT_MAP,
+ G_PARAM_READWRITE);
+
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
@@ -285,23 +294,8 @@ font_colors_class_init (FontColorsClass *class)
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontcolors");
}
-FontColors *
-font_colors_new (void)
-{
- return g_object_new (FONT_COLORS_TYPE, NULL);
-}
-
GAction *
font_colors_get_reset_action (FontColors *self)
{
return G_ACTION (self->reset_action);
}
-
-void
-font_colors_set_font_map (FontColors *self,
- Pango2FontMap *map)
-{
- g_set_object (&self->map, map);
- update_colors (self);
-}
-
diff --git a/demos/font-explorer/fontcolors.h b/demos/font-explorer/fontcolors.h
index 8417239638..40d5e0de5c 100644
--- a/demos/font-explorer/fontcolors.h
+++ b/demos/font-explorer/fontcolors.h
@@ -12,7 +12,4 @@ typedef struct _FontColorsClass FontColorsClass;
GType font_colors_get_type (void);
-FontColors * font_colors_new (void);
-void font_colors_set_font_map (FontColors *self,
- Pango2FontMap *map);
GAction * font_colors_get_reset_action (FontColors *self);
diff --git a/demos/font-explorer/fontexplorer.css b/demos/font-explorer/fontexplorer.css
index 9e6ae9d9f8..4bbb9cb017 100644
--- a/demos/font-explorer/fontexplorer.css
+++ b/demos/font-explorer/fontexplorer.css
@@ -14,24 +14,17 @@ fontcolors > grid {
samplechooser {
border-spacing: 10px;
}
-plainview {
- padding: 10px;
- border-spacing: 10px;
-}
-waterfallview {
- padding: 10px;
- border-spacing: 10px;
+plainview .content {
+ padding: 20px;
}
-infoview {
- padding: 10px;
- border-spacing: 10px;
+waterfallview .content {
+ padding: 20px;
}
-glyphsview {
- padding: 10px;
- border-spacing: 10px;
+glyphsview .content {
+ padding: 20px;
}
-sampleeditor {
- padding: 10px;
+infoview .content {
+ padding: 20px;
border-spacing: 10px;
}
gridview > child {
@@ -41,7 +34,7 @@ glyphview {
padding: 0;
border: 0.6px solid gray;
}
-grid.fontinfo {
+.viewcontrols {
padding: 20px;
border-spacing: 10px;
}
diff --git a/demos/font-explorer/fontexplorerwin.c b/demos/font-explorer/fontexplorerwin.c
index e6432e1b33..64e6de4855 100644
--- a/demos/font-explorer/fontexplorerwin.c
+++ b/demos/font-explorer/fontexplorerwin.c
@@ -23,6 +23,7 @@ struct _FontExplorerWindow
Pango2FontMap *font_map;
GtkFontButton *fontbutton;
+ GtkLabel *path;
FontControls *controls;
FontFeatures *features;
FontVariations *variations;
@@ -206,6 +207,7 @@ font_explorer_window_class_init (FontExplorerWindowClass *class)
"/org/gtk/fontexplorer/fontexplorerwin.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, fontbutton);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, path);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, controls);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, variations);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, colors);
@@ -218,8 +220,6 @@ font_explorer_window_class_init (FontExplorerWindowClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, edit_toggle);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), update_view);
-
- gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontexplorer");
}
FontExplorerWindow *
@@ -236,9 +236,10 @@ font_explorer_window_load (FontExplorerWindow *self,
Pango2FontMap *map;
Pango2HbFace *face;
Pango2FontDescription *desc;
- char *title;
+ char *basename;
path = g_file_peek_path (file);
+ basename = g_path_get_basename (path);
face = pango2_hb_face_new_from_file (path, 0, -2, NULL, NULL);
desc = pango2_font_face_describe (PANGO2_FONT_FACE (face));
@@ -247,10 +248,6 @@ font_explorer_window_load (FontExplorerWindow *self,
pango2_font_map_add_face (map, PANGO2_FONT_FACE (face));
pango2_font_map_set_fallback (map, pango2_font_map_get_default ());
- font_features_set_font_map (self->features, map);
- font_variations_set_font_map (self->variations, map);
- font_colors_set_font_map (self->colors, map);
-
g_set_object (&self->font_map, map);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONT_MAP]);
@@ -259,12 +256,10 @@ font_explorer_window_load (FontExplorerWindow *self,
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (self->fontbutton), desc);
gtk_widget_hide (GTK_WIDGET (self->fontbutton));
-
- title = g_strdup_printf ("%s — %s",
- pango2_font_description_get_family (desc),
- path);
- gtk_window_set_title (GTK_WINDOW (self), title);
- g_free (title);
+ gtk_widget_show (GTK_WIDGET (self->path));
+ gtk_label_set_label (self->path, basename);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self->path), path);
pango2_font_description_free (desc);
+ g_free (basename);
}
diff --git a/demos/font-explorer/fontexplorerwin.ui b/demos/font-explorer/fontexplorerwin.ui
index 67b946634c..eac3ca3b81 100644
--- a/demos/font-explorer/fontexplorerwin.ui
+++ b/demos/font-explorer/fontexplorerwin.ui
@@ -26,6 +26,42 @@
<property name="action-name">win.reset</property>
</object>
</child>
+ <child type="title">
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkToggleButton" id="plain_toggle">
+ <property name="label">Plain</property>
+ <property name="active">1</property>
+ <signal name="toggled" handler="update_view"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="waterfall_toggle">
+ <property name="label">Waterfall</property>
+ <property name="group">plain_toggle</property>
+ <signal name="toggled" handler="update_view"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="glyphs_toggle">
+ <property name="label">Glyphs</property>
+ <property name="group">plain_toggle</property>
+ <signal name="toggled" handler="update_view"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="info_toggle">
+ <property name="label">Info</property>
+ <property name="group">plain_toggle</property>
+ <signal name="toggled" handler="update_view"/>
+ </object>
+ </child>
+ </object>
+ </child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
@@ -34,6 +70,15 @@
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
+ <child type="end">
+ <object class="GtkToggleButton" id="edit_toggle">
+ <property name="hexpand">1</property>
+ <property name="halign">end</property>
+ <property name="icon-name">document-edit-symbolic</property>
+ <property name="tooltip-text" translatable="yes">Edit the sample</property>
+ <signal name="toggled" handler="update_view"/>
+ </object>
+ </child>
</object>
</child>
<child>
@@ -52,6 +97,14 @@
<property name="level">family|style</property>
</object>
</child>
+ <child>
+ <object class="GtkLabel" id="path">
+ <property name="visible">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
<child>
<object class="FontControls" id="controls">
</object>
@@ -61,17 +114,20 @@
</child>
<child>
<object class="FontVariations" id="variations">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
<child>
<object class="FontFeatures" id="features">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="language" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
<child>
<object class="FontColors" id="colors">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
@@ -80,139 +136,84 @@
</object>
</child>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
+ <object class="GtkStack" id="stack">
+ <property name="hexpand">1</property>
<child>
- <object class="GtkStack" id="stack">
- <property name="hexpand">1</property>
- <child>
- <object class="GtkStackPage">
- <property name="name">plain</property>
- <property name="child">
- <object class="PlainView">
- <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
- <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
- <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
- <property name="size" bind-source="controls" bind-flags="sync-create"/>
- <property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
- <property name="line-height" bind-source="controls" bind-flags="sync-create"/>
- <property name="foreground" bind-source="controls" bind-flags="sync-create"/>
- <property name="background" bind-source="controls" bind-flags="sync-create"/>
- <property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
- <property name="features" bind-source="features" bind-flags="sync-create"/>
- <property name="variations" bind-source="variations" bind-flags="sync-create"/>
- <property name="palette" bind-source="colors" bind-flags="sync-create"/>
- </object>
- </property>
- </object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">waterfall</property>
- <property name="child">
- <object class="WaterfallView">
- <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
- <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
- <property name="size" bind-source="controls" bind-flags="sync-create"/>
- <property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
- <property name="line-height" bind-source="controls" bind-flags="sync-create"/>
- <property name="foreground" bind-source="controls" bind-flags="sync-create"/>
- <property name="background" bind-source="controls" bind-flags="sync-create"/>
- <property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
- <property name="features" bind-source="features" bind-flags="sync-create"/>
- <property name="variations" bind-source="variations" bind-flags="sync-create"/>
- <property name="palette" bind-source="colors" bind-flags="sync-create"/>
- </object>
- </property>
- </object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">glyphs</property>
- <property name="child">
- <object class="GlyphsView">
- <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
- <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
- <property name="variations" bind-source="variations" bind-flags="sync-create"/>
- <property name="palette" bind-source="colors" bind-flags="sync-create"/>
- </object>
- </property>
+ <object class="GtkStackPage">
+ <property name="name">plain</property>
+ <property name="child">
+ <object class="PlainView">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
+ <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
+ <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
+ <property name="size" bind-source="controls" bind-flags="sync-create"/>
+ <property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
+ <property name="line-height" bind-source="controls" bind-flags="sync-create"/>
+ <property name="foreground" bind-source="controls" bind-flags="sync-create"/>
+ <property name="background" bind-source="controls" bind-flags="sync-create"/>
+ <property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
+ <property name="features" bind-source="features" bind-flags="sync-create"/>
+ <property name="variations" bind-source="variations" bind-flags="sync-create"/>
+ <property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">info</property>
- <property name="child">
- <object class="InfoView">
- <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
- <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
- <property name="size" bind-source="controls" bind-flags="sync-create"/>
- <property name="variations" bind-source="variations" bind-flags="sync-create"/>
- </object>
- </property>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">waterfall</property>
+ <property name="child">
+ <object class="WaterfallView">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
+ <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
+ <property name="size" bind-source="controls" bind-flags="sync-create"/>
+ <property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
+ <property name="line-height" bind-source="controls" bind-flags="sync-create"/>
+ <property name="foreground" bind-source="controls" bind-flags="sync-create"/>
+ <property name="background" bind-source="controls" bind-flags="sync-create"/>
+ <property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
+ <property name="features" bind-source="features" bind-flags="sync-create"/>
+ <property name="variations" bind-source="variations" bind-flags="sync-create"/>
+ <property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">edit</property>
- <property name="child">
- <object class="SampleEditor" id="sampleeditor">
- <property name="sample-text" bind-source="samplechooser" bind-flags="sync-create"/>
- <property name="editing" bind-source="edit_toggle" bind-property="active"
bind-flags="sync-create"/>
- </object>
- </property>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">glyphs</property>
+ <property name="child">
+ <object class="GlyphsView">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
+ <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
+ <property name="variations" bind-source="variations" bind-flags="sync-create"/>
+ <property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
- </child>
+ </property>
</object>
</child>
<child>
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <child>
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <style>
- <class name="linked"/>
- </style>
- <child>
- <object class="GtkToggleButton" id="plain_toggle">
- <property name="label">Plain</property>
- <property name="active">1</property>
- <signal name="toggled" handler="update_view"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="waterfall_toggle">
- <property name="label">Waterfall</property>
- <property name="group">plain_toggle</property>
- <signal name="toggled" handler="update_view"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="glyphs_toggle">
- <property name="label">Glyphs</property>
- <property name="group">plain_toggle</property>
- <signal name="toggled" handler="update_view"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="info_toggle">
- <property name="label">Info</property>
- <property name="group">plain_toggle</property>
- <signal name="toggled" handler="update_view"/>
- </object>
- </child>
+ <object class="GtkStackPage">
+ <property name="name">info</property>
+ <property name="child">
+ <object class="InfoView">
+ <property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
+ <property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
+ <property name="size" bind-source="controls" bind-flags="sync-create"/>
+ <property name="variations" bind-source="variations" bind-flags="sync-create"/>
</object>
- </child>
- <child>
- <object class="GtkToggleButton" id="edit_toggle">
- <property name="hexpand">1</property>
- <property name="halign">end</property>
- <property name="icon-name">document-edit-symbolic</property>
- <property name="tooltip-text" translatable="yes">Edit the sample</property>
- <signal name="toggled" handler="update_view"/>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">edit</property>
+ <property name="child">
+ <object class="SampleEditor" id="sampleeditor">
+ <property name="sample-text" bind-source="samplechooser" bind-flags="sync-create"/>
+ <property name="editing" bind-source="edit_toggle" bind-property="active"
bind-flags="sync-create"/>
</object>
- </child>
+ </property>
</object>
</child>
</object>
diff --git a/demos/font-explorer/fontfeatures.c b/demos/font-explorer/fontfeatures.c
index 6920c5c5b2..2fc6d0fb7a 100644
--- a/demos/font-explorer/fontfeatures.c
+++ b/demos/font-explorer/fontfeatures.c
@@ -8,7 +8,8 @@
enum {
- PROP_FONT_DESC = 1,
+ PROP_FONT_MAP = 1,
+ PROP_FONT_DESC,
PROP_LANGUAGE,
PROP_FEATURES,
NUM_PROPERTIES
@@ -33,7 +34,7 @@ struct _FontFeatures
Pango2Language *lang;
GList *feature_items;
- Pango2FontMap *map;
+ Pango2FontMap *font_map;
};
struct _FontFeaturesClass
@@ -49,10 +50,7 @@ get_font (FontFeatures *self)
Pango2Context *context;
Pango2Font *font;
- context = pango2_context_new ();
- if (self->map)
- pango2_context_set_font_map (context, self->map);
-
+ context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
@@ -608,6 +606,8 @@ reset (GSimpleAction *action,
static void
font_features_init (FontFeatures *self)
{
+ self->font_map = g_object_ref (pango2_font_map_get_default ());
+
gtk_widget_init_template (GTK_WIDGET (self));
self->font_desc = pango2_font_description_from_string ("sans 12");
@@ -638,7 +638,7 @@ font_features_finalize (GObject *object)
FontFeatures *self = FONT_FEATURES (object);
g_clear_pointer (&self->font_desc, pango2_font_description_free);
- g_clear_object (&self->map);
+ g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_features_parent_class)->finalize (object);
}
@@ -653,32 +653,40 @@ font_features_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_FONT_MAP:
+ g_set_object (&self->font_map, g_value_get_object (value));
+ break;
+
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
- update_features (self);
break;
case PROP_LANGUAGE:
self->lang = pango2_language_from_string (g_value_get_string (value));
- update_features (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
+
+ update_features (self);
}
static void
font_features_get_property (GObject *object,
- unsigned int prop_id,
- GValue *value,
- GParamSpec *pspec)
+ unsigned int prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
FontFeatures *self = FONT_FEATURES (object);
switch (prop_id)
{
+ case PROP_FONT_MAP:
+ g_value_set_object (value, self->font_map);
+ break;
+
case PROP_FEATURES:
g_value_take_string (value, get_features (self));
break;
@@ -698,6 +706,11 @@ font_features_class_init (FontFeaturesClass *class)
object_class->get_property = font_features_get_property;
object_class->set_property = font_features_set_property;
+ properties[PROP_FONT_MAP] =
+ g_param_spec_object ("font-map", "", "",
+ PANGO2_TYPE_FONT_MAP,
+ G_PARAM_READWRITE);
+
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
@@ -724,22 +737,8 @@ font_features_class_init (FontFeaturesClass *class)
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontfeatures");
}
-FontFeatures *
-font_features_new (void)
-{
- return g_object_new (FONT_FEATURES_TYPE, NULL);
-}
-
GAction *
font_features_get_reset_action (FontFeatures *self)
{
return G_ACTION (self->reset_action);
}
-
-void
-font_features_set_font_map (FontFeatures *self,
- Pango2FontMap *map)
-{
- g_set_object (&self->map, map);
- update_features (self);
-}
diff --git a/demos/font-explorer/fontfeatures.h b/demos/font-explorer/fontfeatures.h
index c0877ed6fc..49351185c1 100644
--- a/demos/font-explorer/fontfeatures.h
+++ b/demos/font-explorer/fontfeatures.h
@@ -12,7 +12,4 @@ typedef struct _FontFeaturesClass FontFeaturesClass;
GType font_features_get_type (void);
-FontFeatures * font_features_new (void);
-void font_features_set_font_map (FontFeatures *self,
- Pango2FontMap *map);
GAction * font_features_get_reset_action (FontFeatures *self);
diff --git a/demos/font-explorer/fontvariations.c b/demos/font-explorer/fontvariations.c
index 5926df29be..a138dd116f 100644
--- a/demos/font-explorer/fontvariations.c
+++ b/demos/font-explorer/fontvariations.c
@@ -4,7 +4,8 @@
#include <hb-ot.h>
enum {
- PROP_FONT_DESC = 1,
+ PROP_FONT_MAP = 1,
+ PROP_FONT_DESC,
PROP_VARIATIONS,
NUM_PROPERTIES
};
@@ -25,7 +26,7 @@ struct _FontVariations
GHashTable *axes;
GHashTable *instances;
- Pango2FontMap *map;
+ Pango2FontMap *font_map;
};
struct _FontVariationsClass
@@ -41,9 +42,7 @@ get_font (FontVariations *self)
Pango2Context *context;
Pango2Font *font;
- context = pango2_context_new ();
- if (self->map)
- pango2_context_set_font_map (context, self->map);
+ context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
@@ -378,6 +377,8 @@ reset (GSimpleAction *action,
static void
font_variations_init (FontVariations *self)
{
+ self->font_map = g_object_ref (pango2_font_map_get_default ());
+
gtk_widget_init_template (GTK_WIDGET (self));
self->reset_action = g_simple_action_new ("reset", NULL);
@@ -409,7 +410,7 @@ font_variations_finalize (GObject *object)
FontVariations *self = FONT_VARIATIONS (object);
g_clear_pointer (&self->font_desc, pango2_font_description_free);
- g_clear_object (&self->map);
+ g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_variations_parent_class)->finalize (object);
}
@@ -424,15 +425,20 @@ font_variations_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_FONT_MAP:
+ g_set_object (&self->font_map, g_value_get_object (value));
+ break;
+
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
- update_variations (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
+
+ update_variations (self);
}
static void
@@ -445,6 +451,10 @@ font_variations_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_FONT_MAP:
+ g_value_set_object (value, self->font_map);
+ break;
+
case PROP_VARIATIONS:
g_value_take_string (value, get_variations (self));
break;
@@ -464,6 +474,11 @@ font_variations_class_init (FontVariationsClass *class)
object_class->get_property = font_variations_get_property;
object_class->set_property = font_variations_set_property;
+ properties[PROP_FONT_MAP] =
+ g_param_spec_object ("font-map", "", "",
+ PANGO2_TYPE_FONT_MAP,
+ G_PARAM_READWRITE);
+
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
@@ -484,22 +499,8 @@ font_variations_class_init (FontVariationsClass *class)
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontvariations");
}
-FontVariations *
-font_variations_new (void)
-{
- return g_object_new (FONT_VARIATIONS_TYPE, NULL);
-}
-
GAction *
font_variations_get_reset_action (FontVariations *self)
{
return G_ACTION (self->reset_action);
}
-
-void
-font_variations_set_font_map (FontVariations *self,
- Pango2FontMap *map)
-{
- g_set_object (&self->map, map);
- update_variations (self);
-}
diff --git a/demos/font-explorer/fontvariations.h b/demos/font-explorer/fontvariations.h
index 91e932694f..a2fa51a477 100644
--- a/demos/font-explorer/fontvariations.h
+++ b/demos/font-explorer/fontvariations.h
@@ -12,7 +12,4 @@ typedef struct _FontVariationsClass FontVariationsClass;
GType font_variations_get_type (void);
-FontVariations * font_variations_new (void);
-void font_variations_set_font_map (FontVariations *self,
- Pango2FontMap *map);
GAction * font_variations_get_reset_action (FontVariations *self);
diff --git a/demos/font-explorer/glyphsview.ui b/demos/font-explorer/glyphsview.ui
index 344d8d36d9..dc5a2f0df2 100644
--- a/demos/font-explorer/glyphsview.ui
+++ b/demos/font-explorer/glyphsview.ui
@@ -12,6 +12,9 @@
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkGridView" id="glyphs">
+ <style>
+ <class name="content"/>
+ </style>
<property name="factory">
<object class="GtkSignalListItemFactory">
<signal name="setup" handler="setup_glyph"/>
diff --git a/demos/font-explorer/infoview.ui b/demos/font-explorer/infoview.ui
index ad34072dbe..b1893e03c7 100644
--- a/demos/font-explorer/infoview.ui
+++ b/demos/font-explorer/infoview.ui
@@ -13,7 +13,7 @@
<child>
<object class="GtkGrid" id="info">
<style>
- <class name="fontinfo"/>
+ <class name="content"/>
</style>
</object>
</child>
diff --git a/demos/font-explorer/plainview.c b/demos/font-explorer/plainview.c
index 1c5fe12b50..c800345b2a 100644
--- a/demos/font-explorer/plainview.c
+++ b/demos/font-explorer/plainview.c
@@ -131,7 +131,7 @@ update_view (PlainView *self)
fg = gdk_rgba_to_string (&self->foreground);
bg = gdk_rgba_to_string (&self->background);
- css = g_strdup_printf (".view_background { caret-color: %s; background-color: %s; }", fg, bg);
+ css = g_strdup_printf (".content { caret-color: %s; background-color: %s; }", fg, bg);
gtk_css_provider_load_from_data (self->bg_provider, css, strlen (css));
g_free (css);
g_free (fg);
diff --git a/demos/font-explorer/plainview.ui b/demos/font-explorer/plainview.ui
index 462ffe3882..4621993565 100644
--- a/demos/font-explorer/plainview.ui
+++ b/demos/font-explorer/plainview.ui
@@ -3,13 +3,13 @@
<template class="PlainView" parent="GtkWidget">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
- <style>
- <class name="view"/>
- </style>
<child>
<object class="GtkScrolledWindow" id="swin">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
+ <style>
+ <class name="view"/>
+ </style>
<child>
<object class="GtkLabel" id="content">
<property name="label">Content</property>
@@ -22,7 +22,7 @@
<property name="halign">fill</property>
<property name="valign">fill</property>
<style>
- <class name="view_background"/>
+ <class name="content"/>
</style>
</object>
</child>
diff --git a/demos/font-explorer/sampleeditor.ui b/demos/font-explorer/sampleeditor.ui
index 77d1f71f91..4c5785b1e1 100644
--- a/demos/font-explorer/sampleeditor.ui
+++ b/demos/font-explorer/sampleeditor.ui
@@ -13,6 +13,10 @@
<child>
<object class="GtkTextView" id="edit">
<property name="wrap-mode">word-char</property>
+ <property name="left-margin">20</property>
+ <property name="right-margin">20</property>
+ <property name="top-margin">20</property>
+ <property name="bottom-margin">20</property>
</object>
</child>
</object>
diff --git a/demos/font-explorer/waterfallview.c b/demos/font-explorer/waterfallview.c
index 0689a63cdc..ea76e33877 100644
--- a/demos/font-explorer/waterfallview.c
+++ b/demos/font-explorer/waterfallview.c
@@ -106,7 +106,7 @@ update_view (WaterfallView *self)
Pango2AttrList *attrs;
char *fg, *bg, *css;
GString *str;
- int sizes[] = { 7, 8, 9, 10, 12, 14, 16, 20, 24, 30, 40, 50, 60, 70, 90 };
+ int sizes[] = { 7, 8, 9, 10, 12, 14, 16, 20, 24, 30, 40, 50, 60, 70, 90, 120 };
int start, end, text_len;
desc = pango2_font_description_copy_static (self->font_desc);
@@ -151,7 +151,7 @@ update_view (WaterfallView *self)
fg = gdk_rgba_to_string (&self->foreground);
bg = gdk_rgba_to_string (&self->background);
- css = g_strdup_printf (".view_background { caret-color: %s; background-color: %s; }", fg, bg);
+ css = g_strdup_printf (".content { caret-color: %s; background-color: %s; }", fg, bg);
gtk_css_provider_load_from_data (self->bg_provider, css, strlen (css));
g_free (css);
g_free (fg);
diff --git a/demos/font-explorer/waterfallview.ui b/demos/font-explorer/waterfallview.ui
index d70c97dddf..97eabe8ce9 100644
--- a/demos/font-explorer/waterfallview.ui
+++ b/demos/font-explorer/waterfallview.ui
@@ -21,7 +21,7 @@
<property name="halign">fill</property>
<property name="valign">fill</property>
<style>
- <class name="view_background"/>
+ <class name="content"/>
</style>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]