[gnome-text-editor] preferences: invert use-system-font to custom-font
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] preferences: invert use-system-font to custom-font
- Date: Wed, 1 Dec 2021 18:19:50 +0000 (UTC)
commit e4c0932375eba08c59d7c8d73efffce6617b63e1
Author: Christian Hergert <chergert redhat com>
Date: Wed Dec 1 10:18:37 2021 -0800
preferences: invert use-system-font to custom-font
Also remove the "Custom Font" title from the second row and just make the
font name the action-row title.
Related #183
src/editor-preferences-dialog.c | 8 ++++----
src/editor-preferences-dialog.ui | 10 ++++------
src/editor-preferences-font.c | 20 +++-----------------
3 files changed, 11 insertions(+), 27 deletions(-)
---
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
index 9fec4f3..8932530 100644
--- a/src/editor-preferences-dialog.c
+++ b/src/editor-preferences-dialog.c
@@ -33,7 +33,7 @@ struct _EditorPreferencesDialog
{
AdwPreferencesWindow parent_instance;
GSettings *settings;
- GtkSwitch *use_system_font;
+ GtkSwitch *use_custom_font;
GtkFlowBox *scheme_group;
GtkSourceBuffer *buffer;
GtkSourceView *source_view;
@@ -262,7 +262,7 @@ editor_preferences_dialog_class_init (EditorPreferencesDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, buffer);
gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, scheme_group);
gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, source_view);
- gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, use_system_font);
+ gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, use_custom_font);
}
static void
@@ -278,8 +278,8 @@ editor_preferences_dialog_init (EditorPreferencesDialog *self)
self->settings = g_settings_new ("org.gnome.TextEditor");
g_settings_bind (self->settings, "use-system-font",
- self->use_system_font, "active",
- G_SETTINGS_BIND_DEFAULT);
+ self->use_custom_font, "active",
+ G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
g_settings_bind (self->settings, "highlight-current-line",
self->source_view, "highlight-current-line",
G_SETTINGS_BIND_GET);
diff --git a/src/editor-preferences-dialog.ui b/src/editor-preferences-dialog.ui
index 242ad35..1690a99 100644
--- a/src/editor-preferences-dialog.ui
+++ b/src/editor-preferences-dialog.ui
@@ -53,22 +53,20 @@
<object class="AdwPreferencesGroup">
<child>
<object class="AdwExpanderRow">
+ <property name="title" translatable="yes">Custom Font</property>
+ <property name="expanded" bind-source="use_custom_font" bind-property="active"
bind-flags="sync-create|bidirectional"/>
<child type="action">
- <object class="GtkSwitch" id="use_system_font">
+ <object class="GtkSwitch" id="use_custom_font">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="EditorPreferencesFont" id="custom_font">
- <!-- translators: the surrounding span region is used to prevent word wrapping in
display -->
- <property name="title" translatable="yes"><span allow_breaks='false'>Custom
Font</span></property>
<property name="schema-key">custom-font</property>
- <property name="sensitive" bind-source="use_system_font" bind-property="active"
bind-flags="sync-create|invert-boolean"/>
+ <property name="sensitive" bind-source="use_custom_font" bind-property="active"
bind-flags="sync-create"/>
</object>
</child>
- <property name="title" translatable="yes">System Font</property>
- <property name="expanded" bind-source="use_system_font" bind-property="active"
bind-flags="sync-create|bidirectional|invert-boolean"/>
</object>
</child>
</object>
diff --git a/src/editor-preferences-font.c b/src/editor-preferences-font.c
index 1c3b68b..ead997f 100644
--- a/src/editor-preferences-font.c
+++ b/src/editor-preferences-font.c
@@ -30,8 +30,6 @@ struct _EditorPreferencesFont
{
AdwActionRow row;
- GtkLabel *font_label;
-
GSettings *settings;
gchar *schema_id;
gchar *schema_key;
@@ -64,7 +62,7 @@ editor_preferences_font_constructed (GObject *object)
self->settings = g_settings_new (self->schema_id);
g_settings_bind (self->settings, self->schema_key,
- self->font_label, "label",
+ self, "title",
G_SETTINGS_BIND_GET);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (object), TRUE);
@@ -208,25 +206,13 @@ editor_preferences_font_class_init (EditorPreferencesFontClass *klass)
static void
editor_preferences_font_init (EditorPreferencesFont *self)
{
- GtkBox *box;
GtkImage *image;
- box = g_object_new (GTK_TYPE_BOX, "spacing", 12, NULL);
- adw_action_row_add_suffix (ADW_ACTION_ROW (self), GTK_WIDGET (box));
-
- self->font_label = g_object_new (GTK_TYPE_LABEL,
- "can-focus", FALSE,
- "ellipsize", PANGO_ELLIPSIZE_MIDDLE,
- "selectable", FALSE,
- "halign", GTK_ALIGN_END,
- "hexpand", TRUE,
- NULL);
- gtk_box_append (box, GTK_WIDGET (self->font_label));
-
image = g_object_new (GTK_TYPE_IMAGE,
"icon-name", "go-next-symbolic",
"hexpand", FALSE,
"margin-start", 12,
+ "halign", GTK_ALIGN_END,
NULL);
- gtk_box_append (box, GTK_WIDGET (image));
+ adw_action_row_add_suffix (ADW_ACTION_ROW (self), GTK_WIDGET (image));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]