Commit bc86cac5 authored by Christian Hergert's avatar Christian Hergert
Browse files

preferences: give access to style schemes

This gives access to selecting a style scheme in the preferences panel
within the window.

It still has an issue that our style-variant is overriding things in that
setting 'solarized-dark' will use 'solarized-light' if the application is
in light mode. That will require further work.

Fixes #79
parent 95d4f403
Pipeline #301684 passed with stages
in 4 minutes and 28 seconds
......@@ -52,6 +52,7 @@ struct _EditorWindow
GtkMenuButton *options_menu;
GtkMenuButton *export_menu;
GtkRevealer *preferences_revealer;
AdwPreferencesGroup *scheme_group;
/* Borrowed References */
EditorPage *visible_page;
......@@ -28,6 +28,7 @@
#include "editor-document.h"
#include "editor-open-popover-private.h"
#include "editor-preferences-font.h"
#include "editor-preferences-radio.h"
#include "editor-preferences-spin.h"
#include "editor-preferences-switch.h"
#include "editor-save-changes-dialog-private.h"
......@@ -275,6 +276,8 @@ static void
editor_window_constructed (GObject *object)
EditorWindow *self = (EditorWindow *)object;
GtkSourceStyleSchemeManager *sm;
const char * const *scheme_ids;
GtkApplication *app;
EditorSession *session;
GtkPopover *popover;
......@@ -304,6 +307,33 @@ editor_window_constructed (GObject *object)
options_menu = gtk_application_get_menu_by_id (GTK_APPLICATION (app), "options-menu");
gtk_menu_button_set_menu_model (self->options_menu, G_MENU_MODEL (options_menu));
/* Populate schemes for preferences */
sm = gtk_source_style_scheme_manager_get_default ();
if ((scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (sm)))
EditorPreferencesRadio *group = NULL;
for (guint i = 0; scheme_ids[i]; i++)
GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme (sm, scheme_ids[i]);
const char *name = gtk_source_style_scheme_get_name (scheme);
EditorPreferencesRadio *radio;
radio = g_object_new (EDITOR_TYPE_PREFERENCES_RADIO,
"schema-id", "org.gnome.TextEditor",
"schema-key", "style-scheme",
"schema-value", scheme_ids[i],
"title", name,
adw_preferences_group_add (self->scheme_group, GTK_WIDGET (radio));
if (group == NULL)
group = radio;
editor_preferences_radio_set_group (radio, group);
static void
......@@ -411,6 +441,7 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorWindow, position_label);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, preferences_revealer);
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);
......@@ -257,6 +257,11 @@ Or, press Ctrl+W to close the window.</property>
<object class="AdwPreferencesGroup" id="scheme_group">
<property name="margin-top">12</property>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment