Commit 6fd8d4b4 authored by Christian Hergert's avatar Christian Hergert
Browse files

window: implement preferences as sidepanel in window

This does the first part of things to allow selecting an alternate
style-scheme by moving the preferences into the window for live and
direct application/preview.

Related #79
parent 98208adc
......@@ -548,6 +548,30 @@ editor_window_actions_focus_neighbor_cb (GtkWidget *widget,
adw_tab_view_select_next_page (self->tab_view);
}
static void
editor_window_actions_show_preferences_cb (GtkWidget *widget,
const char *action_name,
GVariant *param)
{
EditorWindow *self = (EditorWindow *)widget;
g_assert (EDITOR_IS_WINDOW (self));
gtk_revealer_set_reveal_child (self->preferences_revealer, 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));
gtk_revealer_set_reveal_child (self->preferences_revealer, FALSE);
}
void
_editor_window_class_actions_init (EditorWindowClass *klass)
{
......@@ -637,6 +661,14 @@ _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,
editor_window_actions_show_preferences_cb);
}
void
......
......@@ -51,6 +51,7 @@ struct _EditorWindow
GtkMenuButton *primary_menu;
GtkMenuButton *options_menu;
GtkMenuButton *export_menu;
GtkRevealer *preferences_revealer;
/* Borrowed References */
EditorPage *visible_page;
......
......@@ -27,6 +27,9 @@
#include "editor-application.h"
#include "editor-document.h"
#include "editor-open-popover-private.h"
#include "editor-preferences-font.h"
#include "editor-preferences-spin.h"
#include "editor-preferences-switch.h"
#include "editor-save-changes-dialog-private.h"
#include "editor-session-private.h"
#include "editor-theme-selector-private.h"
......@@ -406,12 +409,13 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorWindow, pages);
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, preferences_revealer);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, primary_menu);
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);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, tab_view);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, title);
gtk_widget_class_bind_template_child (widget_class, EditorWindow, stack);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_w, GDK_CONTROL_MASK, "win.close-page-or-window", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_o, GDK_CONTROL_MASK, "win.open", NULL);
......@@ -440,6 +444,9 @@ editor_window_class_init (EditorWindowClass *klass)
g_type_ensure (EDITOR_TYPE_OPEN_POPOVER);
g_type_ensure (EDITOR_TYPE_POSITION_LABEL);
g_type_ensure (EDITOR_TYPE_PREFERENCES_FONT);
g_type_ensure (EDITOR_TYPE_PREFERENCES_SPIN);
g_type_ensure (EDITOR_TYPE_PREFERENCES_SWITCH);
}
static void
......
......@@ -111,40 +111,158 @@
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<style>
<class name="view"/>
</style>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkBox" id="pages">
<property name="orientation">vertical</property>
<object class="GtkStack" id="stack">
<property name="hexpand">true</property>
<style>
<class name="view"/>
</style>
<child>
<object class="AdwTabBar" id="tab_bar">
<property name="view">tab_view</property>
<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>
</object>
</child>
</object>
</child>
<child>
<object class="AdwTabView" id="tab_view">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
</object>
</child>
</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">• Use the open button
<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">• Use 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>
</property>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="preferences_revealer">
<property name="transition-type">slide-left</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkSeparator">
<property name="orientation">vertical</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="propagate-natural-width">true</property>
<property name="propagate-natural-height">true</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkBox">
<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">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">
<property name="title" translatable="yes">Custom Font</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>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
......
......@@ -56,7 +56,7 @@
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
<attribute name="action">win.show-preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
......
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