[gnome-text-editor] preferences: switch to preferences window
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] preferences: switch to preferences window
- Date: Wed, 1 Dec 2021 04:09:50 +0000 (UTC)
commit aa2f5063cfa302f26710eea055faebd1b13651b9
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 30 20:09:43 2021 -0800
preferences: switch to preferences window
This moves us back to a AdwPreferencesWindow but using a new design. It
does need some more work still, but this is far enough to be generally
useful while we figure out the rest of the tweaks.
It still needs:
* Preview the custom font (by setting up CSS for the sourceview)
* Show the proper scheme after light/dark has changed
* Various other tweaks
But either way good enough to get some feedback.
Related #183
src/TextEditor.css | 6 +
src/editor-preferences-dialog-private.h | 35 ++++
src/editor-preferences-dialog.c | 312 ++++++++++++++++++++++++++++++++
src/editor-preferences-dialog.ui | 125 +++++++++++++
src/editor-preferences-font.c | 9 +-
src/editor-window-actions.c | 22 +--
src/editor-window-private.h | 2 -
src/editor-window.c | 63 -------
src/editor-window.ui | 194 +++-----------------
src/meson.build | 1 +
src/org.gnome.TextEditor.gresource.xml | 1 +
11 files changed, 518 insertions(+), 252 deletions(-)
---
diff --git a/src/TextEditor.css b/src/TextEditor.css
index e1ebd09..aa6f8f1 100644
--- a/src/TextEditor.css
+++ b/src/TextEditor.css
@@ -4,6 +4,12 @@
}
+/* EditorPreferencesDialog */
+.org-gnome-TextEditor.preferences textview.preview {
+ line-height: 1.5;
+}
+
+
/* EditorThemeSelector */
.org-gnome-TextEditor themeselector {
margin: 9px;
diff --git a/src/editor-preferences-dialog-private.h b/src/editor-preferences-dialog-private.h
new file mode 100644
index 0000000..16aba2a
--- /dev/null
+++ b/src/editor-preferences-dialog-private.h
@@ -0,0 +1,35 @@
+/* editor-preferences-dialog.h
+ *
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <adwaita.h>
+
+#include "editor-types.h"
+
+G_BEGIN_DECLS
+
+#define EDITOR_TYPE_PREFERENCES_DIALOG (editor_preferences_dialog_get_type())
+
+G_DECLARE_FINAL_TYPE (EditorPreferencesDialog, editor_preferences_dialog, EDITOR, PREFERENCES_DIALOG,
AdwPreferencesWindow)
+
+GtkWidget *editor_preferences_dialog_new (EditorWindow *transient_for);
+
+G_END_DECLS
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
new file mode 100644
index 0000000..6992d2a
--- /dev/null
+++ b/src/editor-preferences-dialog.c
@@ -0,0 +1,312 @@
+/* editor-preferences-dialog.c
+ *
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include <adwaita.h>
+#include <gtksourceview/gtksource.h>
+
+#include "editor-page.h"
+#include "editor-preferences-dialog-private.h"
+#include "editor-session.h"
+#include "editor-window.h"
+#include "editor-utils-private.h"
+
+struct _EditorPreferencesDialog
+{
+ AdwPreferencesWindow parent_instance;
+ GSettings *settings;
+ GtkSwitch *use_system_font;
+ GtkGrid *scheme_group;
+ GtkSourceBuffer *buffer;
+ GtkSourceView *source_view;
+};
+
+G_DEFINE_TYPE (EditorPreferencesDialog, editor_preferences_dialog, ADW_TYPE_PREFERENCES_WINDOW)
+
+/* TODO: How and what should be translated here? */
+static const struct {
+ const char *id;
+ const char *example;
+} lang_previews[] = {
+ { "markdown",
+ "# Markdown\n"
+ " 1. Numbered Lists\n"
+ " * Unnumbered and [Links](https://gnome.org)\n"
+ " * `Preformatted Text`\n"
+ " * _Emphasis_ or *Emphasis* **Combined**\n"
+ "> Block quotes too!"
+ },
+ { "c",
+ "#include <stdio.h>\n"
+ "#define EXIT_SUCCESS 0\n"
+ "static const struct { int i; double d; char c; } alias;\n"
+ "int main (int argc, char *argv[]) {\n"
+ " printf (\"Hello, World! %d %f\\n\", 1, 2.0);\n"
+ " return EXIT_SUCCESS; /* comment */\n"
+ "}"
+ },
+ { "python3",
+ "from gi.repository import GObject, Gtk\n"
+ "class MyObject(GObject.Object):\n"
+ " def __init__(self, *args, **kwargs):\n"
+ " super().__init__(*args, **kwargs)\n"
+ },
+ {
+ "js",
+ "/* JavaScript */\n"
+ "const { GLib, Gtk } = imports.gi;\n"
+ "var MyObject = class MyObject extends GLib.Object {\n"
+ " constructor(params = {}) {\n"
+ " super();\n"
+ " this._field = null;\n"
+ " }\n"
+ "}"
+ },
+};
+
+static const char *
+get_preview (GtkSourceLanguage *lang)
+{
+ if (lang != NULL)
+ {
+ const char *id = gtk_source_language_get_id (lang);
+
+ for (guint i = 0; i < G_N_ELEMENTS (lang_previews); i++)
+ {
+ if (g_strcmp0 (lang_previews[i].id, id) == 0)
+ return lang_previews[i].example;
+ }
+ }
+
+ return NULL;
+}
+
+static void
+set_preview_language (EditorPreferencesDialog *self,
+ GtkSourceLanguage *lang,
+ const char *text)
+{
+ if (lang == NULL && text == NULL)
+ {
+ GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default ();
+ lang = gtk_source_language_manager_get_language (manager, lang_previews[0].id);
+ text = lang_previews[0].example;
+ }
+
+ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (self->buffer), text, -1);
+ gtk_source_buffer_set_language (self->buffer, lang);
+ gtk_source_buffer_set_highlight_syntax (self->buffer, lang != NULL);
+}
+
+static void
+guess_preview_language (EditorPreferencesDialog *self)
+{
+ GtkWindow *transient_for;
+
+ g_assert (EDITOR_IS_PREFERENCES_DIALOG (self));
+
+ if ((transient_for = gtk_window_get_transient_for (GTK_WINDOW (self))) &&
+ EDITOR_IS_WINDOW (transient_for))
+ {
+ EditorPage *page = editor_window_get_visible_page (EDITOR_WINDOW (transient_for));
+ EditorDocument *document;
+
+ if ((document = editor_page_get_document (page)))
+ {
+ GtkSourceLanguage *lang = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (document));
+ const char *text = get_preview (lang);
+
+ if (text)
+ {
+ set_preview_language (self, lang, text);
+ return;
+ }
+ }
+ }
+
+ set_preview_language (self, NULL, NULL);
+}
+
+static void
+update_style_scheme_selection (EditorPreferencesDialog *self)
+{
+ g_autofree char *id = NULL;
+
+ g_assert (EDITOR_IS_PREFERENCES_DIALOG (self));
+
+ id = g_settings_get_string (self->settings, "style-scheme");
+
+ for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->scheme_group));
+ child;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ GtkSourceStyleSchemePreview *preview = GTK_SOURCE_STYLE_SCHEME_PREVIEW (child);
+ GtkSourceStyleScheme *scheme = gtk_source_style_scheme_preview_get_scheme (preview);
+ const char *scheme_id = gtk_source_style_scheme_get_id (scheme);
+ gboolean selected = g_strcmp0 (scheme_id, id) == 0;
+
+ gtk_source_style_scheme_preview_set_selected (preview, selected);
+
+ if (selected)
+ gtk_source_buffer_set_style_scheme (self->buffer, scheme);
+ }
+}
+
+static gboolean
+scheme_is_dark (const char *id)
+{
+ return strstr (id, "-dark") != NULL;
+}
+
+static void
+update_style_schemes (EditorPreferencesDialog *self)
+{
+ GtkSourceStyleSchemeManager *sm;
+ const char * const *scheme_ids;
+ gboolean is_dark;
+
+ g_assert (EDITOR_IS_PREFERENCES_DIALOG (self));
+
+ is_dark = adw_style_manager_get_dark (adw_style_manager_get_default ());
+
+ /* Populate schemes for preferences */
+ sm = gtk_source_style_scheme_manager_get_default ();
+ if ((scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (sm)))
+ {
+ guint j = 0;
+
+ for (guint i = 0; scheme_ids[i]; i++)
+ {
+ GtkSourceStyleScheme *scheme;
+ GtkWidget *preview;
+
+ if (is_dark != scheme_is_dark (scheme_ids[i]))
+ continue;
+
+ scheme = gtk_source_style_scheme_manager_get_scheme (sm, scheme_ids[i]);
+ preview = gtk_source_style_scheme_preview_new (scheme);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (preview), "app.style-scheme");
+ gtk_actionable_set_action_target (GTK_ACTIONABLE (preview), "s", scheme_ids[i]);
+ gtk_widget_set_hexpand (preview, TRUE);
+ gtk_grid_attach (self->scheme_group, preview, j % 3, j / 3, 1, 1);
+
+ j++;
+ }
+
+ update_style_scheme_selection (self);
+ }
+}
+
+static gboolean
+bind_background_pattern (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ if (g_variant_get_boolean (variant))
+ g_value_set_enum (value, GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID);
+ else
+ g_value_set_enum (value, GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE);
+ return TRUE;
+}
+
+
+static void
+editor_preferences_dialog_constructed (GObject *object)
+{
+ EditorPreferencesDialog *self = (EditorPreferencesDialog *)object;
+
+ G_OBJECT_CLASS (editor_preferences_dialog_parent_class)->constructed (object);
+
+ update_style_schemes (self);
+ guess_preview_language (self);
+}
+
+static void
+editor_preferences_dialog_dispose (GObject *object)
+{
+ EditorPreferencesDialog *self = (EditorPreferencesDialog *)object;
+
+ g_clear_object (&self->settings);
+
+ G_OBJECT_CLASS (editor_preferences_dialog_parent_class)->dispose (object);
+}
+
+static void
+editor_preferences_dialog_class_init (EditorPreferencesDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->constructed = editor_preferences_dialog_constructed;
+ object_class->dispose = editor_preferences_dialog_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/TextEditor/ui/editor-preferences-dialog.ui");
+ 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);
+}
+
+static void
+editor_preferences_dialog_init (EditorPreferencesDialog *self)
+{
+ AdwStyleManager *style_manager;
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ g_object_set (self,
+ "application", g_application_get_default (),
+ NULL);
+
+ 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);
+ g_settings_bind (self->settings, "highlight-current-line",
+ self->source_view, "highlight-current-line",
+ G_SETTINGS_BIND_GET);
+ g_settings_bind_with_mapping (self->settings, "show-grid",
+ self->source_view, "background-pattern",
+ G_SETTINGS_BIND_GET,
+ bind_background_pattern, NULL, NULL, NULL);
+ g_signal_connect_object (self->settings,
+ "changed::style-scheme",
+ G_CALLBACK (update_style_scheme_selection),
+ self,
+ G_CONNECT_SWAPPED);
+
+ style_manager = adw_style_manager_get_default ();
+ g_signal_connect_object (style_manager,
+ "notify::color-scheme",
+ G_CALLBACK (update_style_scheme_selection),
+ self,
+ G_CONNECT_SWAPPED);
+}
+
+GtkWidget *
+editor_preferences_dialog_new (EditorWindow *transient_for)
+{
+ g_return_val_if_fail (EDITOR_IS_WINDOW (transient_for), NULL);
+
+ return g_object_new (EDITOR_TYPE_PREFERENCES_DIALOG,
+ "transient-for", transient_for,
+ NULL);
+}
diff --git a/src/editor-preferences-dialog.ui b/src/editor-preferences-dialog.ui
new file mode 100644
index 0000000..1212622
--- /dev/null
+++ b/src/editor-preferences-dialog.ui
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk" version="4.0"/>
+ <requires lib="libadwaita" version="1.0"/>
+ <template class="EditorPreferencesDialog" parent="AdwPreferencesWindow">
+ <property name="default-height">700</property>
+ <style>
+ <class name="org-gnome-TextEditor"/>
+ <class name="preferences"/>
+ </style>
+ <child>
+ <object class="AdwPreferencesPage">
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Appearance</property>
+ <child>
+ <object class="GtkFrame">
+ <property name="margin-bottom">24</property>
+ <child>
+ <object class="GtkSourceView" id="source_view">
+ <property name="editable">false</property>
+ <property name="cursor-visible">false</property>
+ <property name="top-margin">8</property>
+ <property name="bottom-margin">8</property>
+ <property name="left-margin">12</property>
+ <property name="right-margin">12</property>
+ <property name="monospace">true</property>
+ <property name="show-line-numbers">true</property>
+ <property name="buffer">
+ <object class="GtkSourceBuffer" id="buffer">
+ <property name="text">
+
+
+</property>
+ </object>
+ </property>
+ <style>
+ <class name="preview"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid" id="scheme_group">
+ <property name="hexpand">true</property>
+ <property name="column-spacing">9</property>
+ <property name="row-spacing">9</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="AdwExpanderRow">
+ <child type="action">
+ <object class="GtkSwitch" id="use_system_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"/>
+ </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>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="EditorPreferencesSwitch" id="grid">
+ <property name="title" translatable="yes">Display Grid Pattern</property>
+ <property name="schema-key">show-grid</property>
+ </object>
+ </child>
+ <child>
+ <object class="EditorPreferencesSwitch" id="highlight_current_line">
+ <property name="title" translatable="yes">Highlight Current Line</property>
+ <property name="schema-key">highlight-current-line</property>
+ </object>
+ </child>
+ <child>
+ <object class="EditorPreferencesSwitch" id="map">
+ <property name="title" translatable="yes">Display Overview Map</property>
+ <property name="schema-key">show-map</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Right Margin</property>
+ <child>
+ <object class="EditorPreferencesSpin" id="right_margin">
+ <property name="title" translatable="yes">Margin Position</property>
+ <property name="schema-key">right-margin-position</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Behavior</property>
+ <child>
+ <object class="EditorPreferencesSwitch" id="session">
+ <property name="title" translatable="yes">Restore Session</property>
+ <property name="subtitle" translatable="yes">Return to your previous session when Text
Editor is started</property>
+ <property name="schema-key">restore-session</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/editor-preferences-font.c b/src/editor-preferences-font.c
index ac31a05..1c3b68b 100644
--- a/src/editor-preferences-font.c
+++ b/src/editor-preferences-font.c
@@ -94,14 +94,15 @@ editor_preferences_font_activated (AdwActionRow *row)
PangoFontDescription *font_desc;
g_autofree gchar *font = NULL;
GtkWidget *dialog;
- GtkRoot *root;
+ GtkWidget *window;
g_assert (ADW_IS_ACTION_ROW (self));
- root = gtk_widget_get_root (GTK_WIDGET (row));
- dialog = gtk_font_chooser_dialog_new (_("Select Font"), GTK_WINDOW (root));
- font = g_settings_get_string (self->settings, self->schema_key);
+ window = gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_WINDOW);
+ dialog = gtk_font_chooser_dialog_new (_("Select Font"), GTK_WINDOW (window));
+ gtk_window_set_modal (GTK_WINDOW (window), TRUE);
+ font = g_settings_get_string (self->settings, self->schema_key);
font_desc = pango_font_description_from_string (font);
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (dialog), font_desc);
diff --git a/src/editor-window-actions.c b/src/editor-window-actions.c
index 8900cf6..48b9d9b 100644
--- a/src/editor-window-actions.c
+++ b/src/editor-window-actions.c
@@ -28,6 +28,7 @@
#include "editor-document.h"
#include "editor-language-dialog.h"
#include "editor-page-private.h"
+#include "editor-preferences-dialog-private.h"
#include "editor-save-changes-dialog-private.h"
#include "editor-session-private.h"
#include "editor-window-private.h"
@@ -531,23 +532,12 @@ editor_window_actions_show_preferences_cb (GtkWidget *widget,
GVariant *param)
{
EditorWindow *self = (EditorWindow *)widget;
+ GtkWidget *dialog;
g_assert (EDITOR_IS_WINDOW (self));
- adw_flap_set_locked (self->flap, FALSE);
- adw_flap_set_reveal_flap (self->flap, TRUE);
-}
-
-static void
-editor_window_actions_hide_preferences_cb (GtkWidget *widget,
- const char *action_name,
- GVariant *param)
-{
- EditorWindow *self = (EditorWindow *)widget;
-
- g_assert (EDITOR_IS_WINDOW (self));
-
- adw_flap_set_reveal_flap (self->flap, FALSE);
+ dialog = editor_preferences_dialog_new (self);
+ gtk_window_present (GTK_WINDOW (dialog));
}
static void
@@ -685,10 +675,6 @@ _editor_window_class_actions_init (EditorWindowClass *klass)
"page.begin-replace",
NULL,
editor_window_actions_begin_replace_cb);
- gtk_widget_class_install_action (widget_class,
- "win.hide-preferences",
- NULL,
- editor_window_actions_hide_preferences_cb);
gtk_widget_class_install_action (widget_class,
"win.show-preferences",
NULL,
diff --git a/src/editor-window-private.h b/src/editor-window-private.h
index 74954a1..58dd24a 100644
--- a/src/editor-window-private.h
+++ b/src/editor-window-private.h
@@ -51,8 +51,6 @@ struct _EditorWindow
GtkMenuButton *primary_menu;
GtkMenuButton *options_menu;
GtkMenuButton *export_menu;
- GtkGrid *scheme_group;
- AdwFlap *flap;
GtkWidget *zoom_label;
GMenu *options_menu_model;
diff --git a/src/editor-window.c b/src/editor-window.c
index e1819f9..20b21ab 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -47,29 +47,6 @@ enum {
static GParamSpec *properties[N_PROPS];
-static void
-update_style_scheme_cb (EditorWindow *self,
- const char *key,
- GSettings *settings)
-{
- g_autofree char *id = NULL;
-
- g_assert (EDITOR_IS_WINDOW (self));
-
- id = g_settings_get_string (settings, "style-scheme");
-
- for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->scheme_group));
- child;
- child = gtk_widget_get_next_sibling (child))
- {
- GtkSourceStyleSchemePreview *preview = GTK_SOURCE_STYLE_SCHEME_PREVIEW (child);
- GtkSourceStyleScheme *scheme = gtk_source_style_scheme_preview_get_scheme (preview);
- const char *scheme_id = gtk_source_style_scheme_get_id (scheme);
-
- gtk_source_style_scheme_preview_set_selected (preview, g_strcmp0 (scheme_id, id) == 0);
- }
-}
-
static void
update_subtitle_visibility_cb (EditorWindow *self)
{
@@ -367,8 +344,6 @@ static void
editor_window_constructed (GObject *object)
{
EditorWindow *self = (EditorWindow *)object;
- GtkSourceStyleSchemeManager *sm;
- const char * const *scheme_ids;
EditorSession *session;
GtkPopover *popover;
GtkWidget *zoom_box;
@@ -428,24 +403,6 @@ editor_window_constructed (GObject *object)
gtk_box_append (GTK_BOX (zoom_box), self->zoom_label);
gtk_box_append (GTK_BOX (zoom_box), zoom_in);
gtk_popover_menu_add_child (GTK_POPOVER_MENU (popover), zoom_box, "zoom");
-
- /* Populate schemes for preferences */
- sm = gtk_source_style_scheme_manager_get_default ();
- if ((scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (sm)))
- {
- for (guint i = 0; scheme_ids[i]; i++)
- {
- GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme (sm, scheme_ids[i]);
- GtkWidget *preview = gtk_source_style_scheme_preview_new (scheme);
-
- gtk_actionable_set_action_name (GTK_ACTIONABLE (preview), "app.style-scheme");
- gtk_actionable_set_action_target (GTK_ACTIONABLE (preview), "s", scheme_ids[i]);
- gtk_widget_set_hexpand (preview, TRUE);
- gtk_grid_attach (self->scheme_group, preview, i % 2, i / 2, 1, 1);
- }
-
- update_style_scheme_cb (self, "style-scheme", self->settings);
- }
}
static gboolean
@@ -604,18 +561,6 @@ on_tab_view_setup_menu_cb (EditorWindow *self,
editor_window_set_visible_page (self, epage);
}
-static void
-on_notify_reveal_flap_cb (EditorWindow *self,
- GParamSpec *pspec,
- AdwFlap *flap)
-{
- g_assert (EDITOR_IS_WINDOW (self));
- g_assert (ADW_IS_FLAP (flap));
-
- if (!adw_flap_get_reveal_flap (flap))
- adw_flap_set_locked (flap, TRUE);
-}
-
static AdwTabView *
on_tab_view_create_window_cb (EditorWindow *self,
AdwTabView *tab_view)
@@ -764,7 +709,6 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/TextEditor/ui/editor-window.ui");
gtk_widget_class_bind_template_child (widget_class, EditorWindow, empty);
- gtk_widget_class_bind_template_child (widget_class, EditorWindow, flap);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, is_modified);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_button);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_popover);
@@ -774,7 +718,6 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorWindow, position_box);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, position_label);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, primary_menu);
- gtk_widget_class_bind_template_child (widget_class, EditorWindow, scheme_group);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, stack);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, subtitle);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, tab_bar);
@@ -782,7 +725,6 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorWindow, title);
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_close_page_cb);
- gtk_widget_class_bind_template_callback (widget_class, on_notify_reveal_flap_cb);
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_setup_menu_cb);
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_create_window_cb);
@@ -838,11 +780,6 @@ editor_window_init (EditorWindow *self)
G_CALLBACK (update_subtitle_visibility_cb),
self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (self->settings,
- "changed::style-scheme",
- G_CALLBACK (update_style_scheme_cb),
- self,
- G_CONNECT_SWAPPED);
g_signal_connect_swapped (adw_tab_view_get_pages (self->tab_view),
"items-changed",
diff --git a/src/editor-window.ui b/src/editor-window.ui
index 5288149..f59142d 100644
--- a/src/editor-window.ui
+++ b/src/editor-window.ui
@@ -122,181 +122,45 @@
</object>
</child>
<child>
- <object class="AdwFlap" id="flap">
- <property name="flap-position">end</property>
- <property name="transition-type">over</property>
- <property name="reveal-flap">false</property>
- <property name="locked">true</property>
- <signal name="notify::reveal-flap" handler="on_notify_reveal_flap_cb" swapped="true"/>
- <child type="separator">
- <object class="GtkSeparator">
+ <object class="GtkStack" id="stack">
+ <property name="hexpand">true</property>
+ <style>
+ <class name="view"/>
+ </style>
+ <child>
+ <object class="GtkBox" id="pages">
<property name="orientation">vertical</property>
- </object>
- </child>
- <child type="content">
- <object class="GtkStack" id="stack">
- <property name="hexpand">true</property>
- <style>
- <class name="view"/>
- </style>
<child>
- <object class="GtkBox" id="pages">
- <property name="orientation">vertical</property>
- <child>
- <object class="AdwTabBar" id="tab_bar">
- <property name="view">tab_view</property>
- </object>
- </child>
- <child>
- <object class="AdwTabView" id="tab_view">
- <property name="hexpand">true</property>
- <property name="vexpand">true</property>
- <property name="menu-model">tab_menu</property>
- <signal name="close-page" handler="on_tab_view_close_page_cb" swapped="true"/>
- <signal name="setup-menu" handler="on_tab_view_setup_menu_cb" swapped="true"/>
- <signal name="create-window" handler="on_tab_view_create_window_cb" swapped="true"/>
- </object>
- </child>
+ <object class="AdwTabBar" id="tab_bar">
+ <property name="view">tab_view</property>
</object>
</child>
<child>
- <object class="AdwStatusPage" id="empty">
- <property name="icon-name">text-editor-symbolic</property>
- <property name="title" translatable="yes">Start or Open a Document</property>
- <property name="child">
- <object class="GtkLabel">
- <property name="label" translatable="yes">• Press the Open button
-• Press the New tab button
-• Press Ctrl+N to start a new document
-• Press Ctrl+O to browse for a document
-
-Or, press Ctrl+W to close the window.</property>
- </object>
- </property>
+ <object class="AdwTabView" id="tab_view">
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
+ <property name="menu-model">tab_menu</property>
+ <signal name="close-page" handler="on_tab_view_close_page_cb" swapped="true"/>
+ <signal name="setup-menu" handler="on_tab_view_setup_menu_cb" swapped="true"/>
+ <signal name="create-window" handler="on_tab_view_create_window_cb" swapped="true"/>
</object>
</child>
</object>
</child>
- <child type="flap">
- <object class="GtkScrolledWindow">
- <property name="propagate-natural-width">true</property>
- <property name="propagate-natural-height">true</property>
- <property name="hscrollbar-policy">never</property>
- <style>
- <class name="preferences"/>
- </style>
- <child>
- <object class="GtkBox">
- <property name="hexpand">false</property>
- <property name="orientation">vertical</property>
- <property name="width-request">300</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="margin-top">12</property>
- <property name="margin-bottom">12</property>
- <child>
- <object class="GtkCenterBox">
- <property name="orientation">horizontal</property>
- <child type="center">
- <object class="GtkLabel">
- <property name="label" translatable="yes">Preferences</property>
- <property name="xalign">.5</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child type="end">
- <object class="GtkButton">
- <property name="icon-name">window-close-symbolic</property>
- <property name="action-name">win.hide-preferences</property>
- <style>
- <class name="image-button"/>
- <class name="circular"/>
- <class name="flat"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="AdwPreferencesGroup">
- <property name="title" translatable="yes">Behavior</property>
- <property name="margin-top">24</property>
- <child>
- <object class="EditorPreferencesSwitch" id="session">
- <property name="title" translatable="yes">Restore Session</property>
- <property name="schema-key">restore-session</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="AdwPreferencesGroup">
- <property name="title" translatable="yes">Font</property>
- <property name="margin-top">12</property>
- <child>
- <object class="EditorPreferencesSwitch" id="use_system_font">
- <property name="title" translatable="yes">Use System Font</property>
- <property name="schema-key">use-system-font</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"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="AdwPreferencesGroup">
- <property name="title" translatable="yes">Right Margin</property>
- <property name="margin-top">24</property>
- <child>
- <object class="EditorPreferencesSpin" id="right_margin">
- <property name="title" translatable="yes">Margin Position</property>
- <property name="schema-key">right-margin-position</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="AdwPreferencesGroup">
- <property name="title" translatable="yes">Appearance</property>
- <property name="margin-top">24</property>
- <child>
- <object class="EditorPreferencesSwitch" id="grid">
- <property name="title" translatable="yes">Display Grid Pattern</property>
- <property name="schema-key">show-grid</property>
- </object>
- </child>
- <child>
- <object class="EditorPreferencesSwitch" id="highlight_current_line">
- <property name="title" translatable="yes">Highlight Current Line</property>
- <property name="schema-key">highlight-current-line</property>
- </object>
- </child>
- <child>
- <object class="EditorPreferencesSwitch" id="map">
- <property name="title" translatable="yes">Display Overview Map</property>
- <property name="schema-key">show-map</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="scheme_group">
- <property name="hexpand">true</property>
- <property name="column-spacing">9</property>
- <property name="row-spacing">9</property>
- <property name="margin-top">12</property>
- </object>
- </child>
+ <child>
+ <object class="AdwStatusPage" id="empty">
+ <property name="icon-name">text-editor-symbolic</property>
+ <property name="title" translatable="yes">Start or Open a Document</property>
+ <property name="child">
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">• Press the Open button
+ • Press the New tab button
+ • Press Ctrl+N to start a new document
+ • Press Ctrl+O to browse for a document
+
+ Or, press Ctrl+W to close the window.</property>
</object>
- </child>
+ </property>
</object>
</child>
</object>
diff --git a/src/meson.build b/src/meson.build
index 1f8e497..0bcb463 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,6 +20,7 @@ editor_sources = [
'editor-page-vim.c',
'editor-path.c',
'editor-position-label.c',
+ 'editor-preferences-dialog.c',
'editor-preferences-font.c',
'editor-preferences-radio.c',
'editor-preferences-spin.c',
diff --git a/src/org.gnome.TextEditor.gresource.xml b/src/org.gnome.TextEditor.gresource.xml
index f2d1e20..b866a2e 100644
--- a/src/org.gnome.TextEditor.gresource.xml
+++ b/src/org.gnome.TextEditor.gresource.xml
@@ -7,6 +7,7 @@
<file preprocess="xml-stripblanks">editor-open-popover.ui</file>
<file preprocess="xml-stripblanks">editor-page.ui</file>
<file preprocess="xml-stripblanks">editor-position-label.ui</file>
+ <file preprocess="xml-stripblanks">editor-preferences-dialog.ui</file>
<file preprocess="xml-stripblanks">editor-search-bar.ui</file>
<file preprocess="xml-stripblanks">editor-search-entry.ui</file>
<file preprocess="xml-stripblanks">editor-sidebar-row.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]