[gnome-builder] libide/tweaks: add section type
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: add section type
- Date: Sun, 31 Jul 2022 04:39:48 +0000 (UTC)
commit 98cd3f275c938d8b9ae18f4b12bd5b7bddb33cac
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 30 21:39:39 2022 -0700
libide/tweaks: add section type
Better to have an object for sections so that merging and sorting can
happen automatically.
src/libide/tweaks/example.ui | 44 ++++++++++++++------------
src/libide/tweaks/ide-tweaks-init.c | 1 +
src/libide/tweaks/ide-tweaks-section.c | 56 ++++++++++++++++++++++++++++++++++
src/libide/tweaks/ide-tweaks-section.h | 39 +++++++++++++++++++++++
src/libide/tweaks/ide-tweaks.c | 4 +--
src/libide/tweaks/libide-tweaks.h | 1 +
src/libide/tweaks/meson.build | 2 ++
7 files changed, 126 insertions(+), 21 deletions(-)
---
diff --git a/src/libide/tweaks/example.ui b/src/libide/tweaks/example.ui
index 4b1d29288..128cb0a60 100644
--- a/src/libide/tweaks/example.ui
+++ b/src/libide/tweaks/example.ui
@@ -2,27 +2,30 @@
<interface>
<template class="IdeTweaks">
<child>
- <object class="IdeTweaksPage" id="appearance">
- <property name="section">visual</property>
- <property name="title" translatable="yes">Appearance</property>
+ <object class="IdeTweaksSection" id="visual">
<child>
- <object class="IdeTweaksGroup" id="appearance_group">
+ <object class="IdeTweaksPage" id="appearance">
<property name="title" translatable="yes">Appearance</property>
<child>
- <object class="IdeTweaksCustom" id="appearance_selector">
+ <object class="IdeTweaksGroup" id="appearance_group">
+ <property name="title" translatable="yes">Appearance</property>
+ <child>
+ <object class="IdeTweaksCustom" id="appearance_selector">
+ </object>
+ </child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="IdeTweaksGroup" id="style">
- <property name="title" translatable="yes">Style</property>
<child>
- <object class="IdeTweaksCustom" id="style_preview">
- </object>
- </child>
- <child>
- <object class="IdeTweaksCustom" id="style_scheme_selector">
+ <object class="IdeTweaksGroup" id="style">
+ <property name="title" translatable="yes">Style</property>
+ <child>
+ <object class="IdeTweaksCustom" id="style_preview">
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksCustom" id="style_scheme_selector">
+ </object>
+ </child>
</object>
</child>
</object>
@@ -30,11 +33,14 @@
</object>
</child>
<child>
- <object class="IdeTweaksPage" id="languages">
- <property name="section">programming</property>
- <property name="title" translatable="yes">Languages</property>
+ <object class="IdeTweaksSection" id="programming">
<child>
- <object class="IdeTweaksSubpageGenerator" id="source_languages">
+ <object class="IdeTweaksPage" id="languages">
+ <property name="title" translatable="yes">Languages</property>
+ <child>
+ <object class="IdeTweaksSubpageGenerator" id="source_languages">
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/libide/tweaks/ide-tweaks-init.c b/src/libide/tweaks/ide-tweaks-init.c
index e7ab4eb41..9d4d03474 100644
--- a/src/libide/tweaks/ide-tweaks-init.c
+++ b/src/libide/tweaks/ide-tweaks-init.c
@@ -34,6 +34,7 @@ _ide_tweaks_init (void)
g_type_ensure (IDE_TYPE_TWEAKS_GROUP);
g_type_ensure (IDE_TYPE_TWEAKS_ITEM);
g_type_ensure (IDE_TYPE_TWEAKS_PAGE);
+ g_type_ensure (IDE_TYPE_TWEAKS_SECTION);
g_type_ensure (IDE_TYPE_TWEAKS_SUBPAGE);
g_type_ensure (IDE_TYPE_TWEAKS_SUBPAGE_GENERATOR);
g_type_ensure (IDE_TYPE_TWEAKS_VARIABLE);
diff --git a/src/libide/tweaks/ide-tweaks-section.c b/src/libide/tweaks/ide-tweaks-section.c
new file mode 100644
index 000000000..e8a30efe2
--- /dev/null
+++ b/src/libide/tweaks/ide-tweaks-section.c
@@ -0,0 +1,56 @@
+/* ide-tweaks-section.c
+
+ * Copyright 2022 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 "ide-tweaks-section"
+
+#include "config.h"
+
+#include "ide-tweaks-page.h"
+#include "ide-tweaks-section.h"
+
+struct _IdeTweaksSection
+{
+ IdeTweaksItem parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (IdeTweaksSection, ide_tweaks_section, IDE_TYPE_TWEAKS_ITEM)
+
+static gboolean
+ide_tweaks_section_accepts (IdeTweaksItem *item,
+ IdeTweaksItem *child)
+{
+ g_assert (IDE_IS_TWEAKS_ITEM (item));
+ g_assert (IDE_IS_TWEAKS_ITEM (child));
+
+ return IDE_IS_TWEAKS_PAGE (child);
+}
+
+static void
+ide_tweaks_section_class_init (IdeTweaksSectionClass *klass)
+{
+ IdeTweaksItemClass *item_class = IDE_TWEAKS_ITEM_CLASS (klass);
+
+ item_class->accepts = ide_tweaks_section_accepts;
+}
+
+static void
+ide_tweaks_section_init (IdeTweaksSection *self)
+{
+}
diff --git a/src/libide/tweaks/ide-tweaks-section.h b/src/libide/tweaks/ide-tweaks-section.h
new file mode 100644
index 000000000..d999aff69
--- /dev/null
+++ b/src/libide/tweaks/ide-tweaks-section.h
@@ -0,0 +1,39 @@
+/* ide-tweaks-section.h
+ *
+ * Copyright 2022 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
+
+#if !defined (IDE_TWEAKS_INSIDE) && !defined (IDE_TWEAKS_COMPILATION)
+# error "Only <libide-tweaks.h> can be included directly."
+#endif
+
+#include "ide-tweaks-item.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_TWEAKS_SECTION (ide_tweaks_section_get_type())
+
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (IdeTweaksSection, ide_tweaks_section, IDE, TWEAKS_SECTION, IdeTweaksItem)
+
+IDE_AVAILABLE_IN_ALL
+IdeTweaksSection *ide_tweaks_section_new (void);
+
+G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks.c b/src/libide/tweaks/ide-tweaks.c
index aed9e4790..6192d63ae 100644
--- a/src/libide/tweaks/ide-tweaks.c
+++ b/src/libide/tweaks/ide-tweaks.c
@@ -25,7 +25,7 @@
#include <gtk/gtk.h>
#include "ide-tweaks.h"
-#include "ide-tweaks-page.h"
+#include "ide-tweaks-section.h"
struct _IdeTweaks
{
@@ -48,7 +48,7 @@ ide_tweaks_accepts (IdeTweaksItem *item,
g_assert (IDE_IS_TWEAKS_ITEM (item));
g_assert (IDE_IS_TWEAKS_ITEM (child));
- return IDE_IS_TWEAKS_PAGE (child);
+ return IDE_IS_TWEAKS_SECTION (child);
}
static void
diff --git a/src/libide/tweaks/libide-tweaks.h b/src/libide/tweaks/libide-tweaks.h
index 664aae70e..88eef35f5 100644
--- a/src/libide/tweaks/libide-tweaks.h
+++ b/src/libide/tweaks/libide-tweaks.h
@@ -26,6 +26,7 @@
# include "ide-tweaks-group.h"
# include "ide-tweaks-item.h"
# include "ide-tweaks-page.h"
+# include "ide-tweaks-section.h"
# include "ide-tweaks-subpage.h"
# include "ide-tweaks-subpage-generator.h"
# include "ide-tweaks-variable.h"
diff --git a/src/libide/tweaks/meson.build b/src/libide/tweaks/meson.build
index adff4ee19..59a85da9d 100644
--- a/src/libide/tweaks/meson.build
+++ b/src/libide/tweaks/meson.build
@@ -13,6 +13,7 @@ libide_tweaks_public_headers = [
'ide-tweaks-group.h',
'ide-tweaks-item.h',
'ide-tweaks-page.h',
+ 'ide-tweaks-section.h',
'ide-tweaks-subpage.h',
'ide-tweaks-subpage-generator.h',
'ide-tweaks-variable.h',
@@ -30,6 +31,7 @@ libide_tweaks_public_sources = [
'ide-tweaks-item.c',
'ide-tweaks-group.c',
'ide-tweaks-page.c',
+ 'ide-tweaks-section.c',
'ide-tweaks-subpage.c',
'ide-tweaks-subpage-generator.c',
'ide-tweaks-variable.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]