Commit 15efd9e3 authored by Christian Hergert's avatar Christian Hergert

prefs: add IdePreferencesWindow

This will simplify things going forward so we can use templates
for the window and upcoming CSD headerbar.
parent 0394cf8d
......@@ -33,7 +33,7 @@
#include "application/ide-application-private.h"
#include "greeter/ide-greeter-perspective.h"
#include "keybindings/ide-shortcuts-window.h"
#include "preferences/ide-preferences-perspective.h"
#include "preferences/ide-preferences-window.h"
#include "workbench/ide-workbench.h"
#include "util/ide-flatpak.h"
......@@ -43,10 +43,9 @@ ide_application_actions_preferences (GSimpleAction *action,
gpointer user_data)
{
IdeApplication *self = user_data;
IdePreferencesPerspective *perspective;
GList *windows;
GtkWindow *toplevel = NULL;
GtkWindow *window;
GList *windows;
IDE_ENTRY;
......@@ -59,38 +58,30 @@ ide_application_actions_preferences (GSimpleAction *action,
windows = gtk_application_get_windows (GTK_APPLICATION (self));
for (; windows != NULL; windows = windows->next)
{
GtkWindow *ele = windows->data;
GtkWindow *win = windows->data;
if (g_object_get_data (G_OBJECT (ele), "PREFERENCES"))
if (IDE_IS_PREFERENCES_WINDOW (win))
{
gtk_window_present (ele);
gtk_window_present (win);
return;
}
if (toplevel == NULL && IDE_IS_WORKBENCH (ele))
toplevel = ele;
if (toplevel == NULL && IDE_IS_WORKBENCH (win))
toplevel = win;
}
/* Create a new window for preferences, with enough space for
* 2 columns of preferences. The window manager will automatically
* maximize the window if necessary.
*/
window = g_object_new (GTK_TYPE_WINDOW,
window = g_object_new (IDE_TYPE_PREFERENCES_WINDOW,
"transient-for", toplevel,
"title", _("Preferences"),
"default-width", 1300,
"default-height", 800,
"window-position", GTK_WIN_POS_CENTER_ON_PARENT,
NULL);
g_object_set_data (G_OBJECT (window), "PREFERENCES", "1");
gtk_application_add_window (GTK_APPLICATION (self), window);
perspective = g_object_new (IDE_TYPE_PREFERENCES_PERSPECTIVE,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (perspective));
gtk_window_present (GTK_WINDOW (window));
gtk_window_present (window);
IDE_EXIT;
}
......
......@@ -120,6 +120,7 @@ G_BEGIN_DECLS
#include "logging/ide-log.h"
#include "preferences/ide-preferences-addin.h"
#include "preferences/ide-preferences-perspective.h"
#include "preferences/ide-preferences-window.h"
#include "projects/ide-project-edit.h"
#include "projects/ide-project-file.h"
#include "projects/ide-project-files.h"
......
......@@ -79,6 +79,7 @@
<file preprocess="xml-stripblanks" alias="ide-omni-bar.ui">workbench/ide-omni-bar.ui</file>
<file preprocess="xml-stripblanks" alias="ide-omni-pausable-row.ui">workbench/ide-omni-pausable-row.ui</file>
<file preprocess="xml-stripblanks" alias="ide-preferences-language-row.ui">preferences/ide-preferences-language-row.ui</file>
<file preprocess="xml-stripblanks" alias="ide-preferences-window.ui">preferences/ide-preferences-window.ui</file>
<file preprocess="xml-stripblanks" alias="ide-run-button.ui">runner/ide-run-button.ui</file>
<file preprocess="xml-stripblanks" alias="ide-transfer-row.ui">transfers/ide-transfer-row.ui</file>
<file preprocess="xml-stripblanks" alias="ide-transfers-button.ui">transfers/ide-transfers-button.ui</file>
......
/* ide-preferences-window.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "ide-preferences-window"
#include "ide-preferences-window.h"
struct _IdePreferencesWindow
{
GtkWindow parent_instance;
};
G_DEFINE_TYPE (IdePreferencesWindow, ide_preferences_window, GTK_TYPE_WINDOW)
static void
ide_preferences_window_class_init (IdePreferencesWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-preferences-window.ui");
}
static void
ide_preferences_window_init (IdePreferencesWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/* ide-preferences-window.h
*
* Copyright (C) 2017 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/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define IDE_TYPE_PREFERENCES_WINDOW (ide_preferences_window_get_type())
G_DECLARE_FINAL_TYPE (IdePreferencesWindow, ide_preferences_window, IDE, PREFERENCES_WINDOW, GtkWindow)
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="IdePreferencesWindow" parent="GtkWindow">
<child>
<object class="IdePreferencesPerspective" id="perspective">
<property name="visible">true</property>
</object>
</child>
</template>
</interface>
preferences_headers = [
'ide-preferences-addin.h',
'ide-preferences-perspective.h',
'ide-preferences-window.h',
]
preferences_sources = [
'ide-preferences-addin.c',
'ide-preferences-perspective.c',
'ide-preferences-window.c',
]
preferences_private_sources = [
......
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