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

preferences: remove preferences window

This is now part of EditorWindow and is no longer needed from the
standpoint of a dedicated window.

Related #79
parent 6fd8d4b4
Pipeline #301653 passed with stages
in 5 minutes and 39 seconds
......@@ -27,7 +27,6 @@
#include "editor-application-private.h"
#include "editor-page.h"
#include "editor-preferences-window.h"
#include "editor-save-changes-dialog-private.h"
#include "editor-session-private.h"
#include "editor-window.h"
......@@ -45,39 +44,6 @@ static const gchar *artists[] = {
NULL
};
static void
editor_application_actions_preferences_cb (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
EditorApplication *self = user_data;
EditorPreferencesWindow *prefs;
EditorWindow *active = NULL;
GList *windows;
g_assert (EDITOR_IS_APPLICATION (self));
windows = gtk_application_get_windows (GTK_APPLICATION (self));
for (const GList *iter = windows; iter; iter = iter->next)
{
GtkWindow *window = iter->data;
if (active == NULL && EDITOR_IS_WINDOW (window))
active = EDITOR_WINDOW (window);
if (EDITOR_IS_PREFERENCES_WINDOW (window))
{
gtk_window_present (window);
return;
}
}
prefs = editor_preferences_window_new (self);
gtk_window_set_transient_for (GTK_WINDOW (prefs), GTK_WINDOW (active));
gtk_window_present (GTK_WINDOW (prefs));
}
static void
editor_application_actions_new_window_cb (GSimpleAction *action,
GVariant *param,
......@@ -233,7 +199,6 @@ _editor_application_actions_init (EditorApplication *self)
{
static const GActionEntry actions[] = {
{ "new-window", editor_application_actions_new_window_cb },
{ "preferences", editor_application_actions_preferences_cb },
{ "about", editor_application_actions_about_cb },
{ "help", editor_application_actions_help_cb },
{ "quit", editor_application_actions_quit },
......
/* editor-preferences-window.c
*
* Copyright 2020 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
*/
#define G_LOG_DOMAIN "editor-preferences-window"
#include "config.h"
#include "editor-preferences-font.h"
#include "editor-preferences-radio.h"
#include "editor-types.h"
#include "editor-preferences-spin.h"
#include "editor-preferences-switch.h"
#include "editor-preferences-window.h"
struct _EditorPreferencesWindow
{
GtkWindow parent_instance;
};
G_DEFINE_TYPE (EditorPreferencesWindow, editor_preferences_window, ADW_TYPE_PREFERENCES_WINDOW)
static void
editor_preferences_window_row_activated_cb (EditorPreferencesWindow *self,
AdwActionRow *row,
GtkListBox *list_box)
{
g_assert (EDITOR_IS_PREFERENCES_WINDOW (self));
g_assert (ADW_IS_ACTION_ROW (row));
g_assert (GTK_IS_LIST_BOX (list_box));
}
static void
editor_preferences_window_close_cb (GtkWidget *widget,
const char *action,
GVariant *param)
{
gtk_window_close (GTK_WINDOW (widget));
}
static void
editor_preferences_window_class_init (EditorPreferencesWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/TextEditor/ui/editor-preferences-window.ui");
gtk_widget_class_bind_template_callback (widget_class, editor_preferences_window_row_activated_cb);
gtk_widget_class_install_action (widget_class,
"win.close",
NULL,
editor_preferences_window_close_cb);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_w, GDK_CONTROL_MASK, "win.close", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "win.close", NULL);
g_type_ensure (EDITOR_TYPE_PREFERENCES_FONT);
g_type_ensure (ADW_TYPE_ACTION_ROW);
g_type_ensure (EDITOR_TYPE_PREFERENCES_RADIO);
g_type_ensure (EDITOR_TYPE_PREFERENCES_SPIN);
g_type_ensure (EDITOR_TYPE_PREFERENCES_SWITCH);
}
static void
editor_preferences_window_init (EditorPreferencesWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
gtk_window_set_default_size (GTK_WINDOW (self), 500, -1);
}
EditorPreferencesWindow *
editor_preferences_window_new (EditorApplication *application)
{
return g_object_new (EDITOR_TYPE_PREFERENCES_WINDOW,
"application", application,
NULL);
}
/* editor-preferences-window.h
*
* Copyright 2020 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 "editor-types.h"
G_BEGIN_DECLS
#define EDITOR_TYPE_PREFERENCES_WINDOW (editor_preferences_window_get_type())
G_DECLARE_FINAL_TYPE (EditorPreferencesWindow, editor_preferences_window, EDITOR, PREFERENCES_WINDOW, AdwPreferencesWindow)
EditorPreferencesWindow *editor_preferences_window_new (EditorApplication *application);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="4.0"/>
<template class="EditorPreferencesWindow" parent="AdwPreferencesWindow">
<property name="resizable">false</property>
<property name="title" translatable="yes">Preferences</property>
<property name="search-enabled">False</property>
<child>
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Font</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>
<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>
<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>
</template>
</interface>
......@@ -24,7 +24,6 @@ editor_sources = [
'editor-preferences-radio.c',
'editor-preferences-spin.c',
'editor-preferences-switch.c',
'editor-preferences-window.c',
'editor-print-operation.c',
'editor-save-changes-dialog.c',
'editor-search-bar.c',
......
......@@ -7,7 +7,6 @@
<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-window.ui</file>
<file preprocess="xml-stripblanks">editor-search-bar.ui</file>
<file preprocess="xml-stripblanks">editor-sidebar-row.ui</file>
<file preprocess="xml-stripblanks">editor-sidebar.ui</file>
......
Supports Markdown
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