[gnome-builder] prefs: add experimental features preferences page
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: add experimental features preferences page
- Date: Tue, 24 Mar 2015 00:39:41 +0000 (UTC)
commit 2bc052fc36cf11b640f06c11f46bf6b418eb1cad
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 23 14:11:55 2015 -0700
prefs: add experimental features preferences page
Currently this allows enabling the *very* experimental clang autocompletion.
But i assume others will land here in the not to distant future.
configure.ac | 1 +
data/gsettings.mk | 4 +-
.../org.gnome.builder.experimental.gschema.xml.in | 9 +++
data/ui/gb-preferences-page-experimental.ui | 63 ++++++++++++++++++
data/ui/gb-preferences-window.ui | 9 +++
libide/c/ide-c-language.c | 7 ++-
src/gnome-builder.mk | 2 +
src/preferences/gb-preferences-page-experimental.c | 68 ++++++++++++++++++++
src/preferences/gb-preferences-page-experimental.h | 33 ++++++++++
src/preferences/gb-preferences-window.c | 2 +
src/resources/gnome-builder.gresource.xml | 1 +
11 files changed, 197 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 186f885..8a45915 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,7 @@ AC_CONFIG_FILES([
data/libide-1.0.pc
data/gsettings/org.gnome.builder.editor.gschema.xml
data/gsettings/org.gnome.builder.editor.language.gschema.xml
+ data/gsettings/org.gnome.builder.experimental.gschema.xml
po/Makefile.in
])
diff --git a/data/gsettings.mk b/data/gsettings.mk
index 7df2292..cb77de0 100644
--- a/data/gsettings.mk
+++ b/data/gsettings.mk
@@ -1,6 +1,8 @@
gsettingsschema_in_files = \
data/gsettings/org.gnome.builder.editor.gschema.xml.in \
- data/gsettings/org.gnome.builder.editor.language.gschema.xml.in
+ data/gsettings/org.gnome.builder.editor.language.gschema.xml.in \
+ data/gsettings/org.gnome.builder.experimental.gschema.xml.in \
+ $(NULL)
gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
.PRECIOUS: $(gsettings_SCHEMAS)
diff --git a/data/gsettings/org.gnome.builder.experimental.gschema.xml.in
b/data/gsettings/org.gnome.builder.experimental.gschema.xml.in
new file mode 100644
index 0000000..2ee037c
--- /dev/null
+++ b/data/gsettings/org.gnome.builder.experimental.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="org.gnome.builder.experimental" path="/org/gnome/builder/experimental/"
gettext-domain="gnome-builder">
+ <key name="clang-autocompletion" type="b">
+ <default>false</default>
+ <summary>Clang based autocompletion.</summary>
+ <description>Use clang for autocompletion in the C and C++ languages.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/ui/gb-preferences-page-experimental.ui b/data/ui/gb-preferences-page-experimental.ui
new file mode 100644
index 0000000..4c2a4ec
--- /dev/null
+++ b/data/ui/gb-preferences-page-experimental.ui
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="GbPreferencesPageExperimental" parent="GbPreferencesPage">
+ <child>
+ <object class="GtkBox">
+ <property name="visible">true</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="all_container">
+ <property name="visible">true</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="clang_autocompletion_container">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkSwitch" id="clang_autocompletion_switch">
+ <property name="action-name">settings.clang-autocompletion</property>
+ <property name="hexpand">false</property>
+ <property name="vexpand">false</property>
+ <property name="valign">center</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Clang
Auto-Completion</b></property>
+ <property name="use-markup">true</property>
+ <property name="margin-start">6</property>
+ <property name="margin-top">6</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Use clang for autocompletion in the C and
C++ languages.</property>
+ <property name="margin-start">6</property>
+ <property name="margin-bottom">6</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/gb-preferences-window.ui b/data/ui/gb-preferences-window.ui
index 91e8623..480759b 100644
--- a/data/ui/gb-preferences-window.ui
+++ b/data/ui/gb-preferences-window.ui
@@ -141,6 +141,15 @@
<property name="title" translatable="yes">Keybindings</property>
</packing>
</child>
+ <child>
+ <object class="GbPreferencesPageExperimental" id="experimental_page">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">experimental</property>
+ <property name="title" translatable="yes">Experimental</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/libide/c/ide-c-language.c b/libide/c/ide-c-language.c
index 7557c99..6747a7e 100644
--- a/libide/c/ide-c-language.c
+++ b/libide/c/ide-c-language.c
@@ -48,12 +48,17 @@ static GList *
ide_c_language_get_completion_providers (IdeLanguage *language)
{
GList *providers = NULL;
+ g_autoptr(GSettings) settings = NULL;
g_return_val_if_fail (IDE_IS_C_LANGUAGE (language), NULL);
providers = g_list_append (providers, g_object_new (IDE_TYPE_C_FORMAT_PROVIDER, NULL));
- if (g_getenv ("IDE_ENABLE_EXPERIMENTAL") != NULL)
+ /*
+ * Only enable clang autocompletion if the experimental feature is enabled.
+ */
+ settings = g_settings_new ("org.gnome.builder.experimental");
+ if (g_settings_get_boolean (settings, "clang-autocompletion"))
providers = g_list_append (providers, g_object_new (IDE_TYPE_CLANG_COMPLETION_PROVIDER, NULL));
return providers;
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index fc0bf9e..ce233f3 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -73,6 +73,8 @@ libgnome_builder_la_SOURCES = \
src/nautilus/nautilus-floating-bar.h \
src/preferences/gb-preferences-page-editor.c \
src/preferences/gb-preferences-page-editor.h \
+ src/preferences/gb-preferences-page-experimental.c \
+ src/preferences/gb-preferences-page-experimental.h \
src/preferences/gb-preferences-page-git.c \
src/preferences/gb-preferences-page-git.h \
src/preferences/gb-preferences-page-keybindings.c \
diff --git a/src/preferences/gb-preferences-page-experimental.c
b/src/preferences/gb-preferences-page-experimental.c
new file mode 100644
index 0000000..5d0956d
--- /dev/null
+++ b/src/preferences/gb-preferences-page-experimental.c
@@ -0,0 +1,68 @@
+/* gb-preferences-page-experimental.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-preferences-page-experimental.h"
+#include "gb-widget.h"
+
+struct _GbPreferencesPageExperimental
+{
+ GbPreferencesPage parent_instance;
+
+ GtkWidget *clang_autocompletion_container;
+ GtkWidget *clang_autocompletion_switch;
+};
+
+G_DEFINE_TYPE (GbPreferencesPageExperimental,
+ gb_preferences_page_experimental,
+ GB_TYPE_PREFERENCES_PAGE)
+
+static void
+gb_preferences_page_experimental_class_init (GbPreferencesPageExperimentalClass *klass)
+{
+ GB_WIDGET_CLASS_TEMPLATE (klass, "gb-preferences-page-experimental.ui");
+ GB_WIDGET_CLASS_BIND (klass, GbPreferencesPageExperimental, clang_autocompletion_container);
+ GB_WIDGET_CLASS_BIND (klass, GbPreferencesPageExperimental, clang_autocompletion_switch);
+}
+
+static void
+gb_preferences_page_experimental_init (GbPreferencesPageExperimental *self)
+{
+ g_autoptr(GSettings) settings = NULL;
+ GAction *action;
+ GSimpleActionGroup *group;
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ settings = g_settings_new ("org.gnome.builder.experimental");
+
+ group = g_simple_action_group_new ();
+
+ action = g_settings_create_action (settings, "clang-autocompletion");
+ g_action_map_add_action (G_ACTION_MAP (group), action);
+ g_clear_object (&action);
+
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "settings", G_ACTION_GROUP (group));
+
+ /* To translators: This is a list of keywords for the preferences page */
+ gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
+ _("experimental clang autocompletion auto complete"),
+ self->clang_autocompletion_container,
+ NULL);
+}
diff --git a/src/preferences/gb-preferences-page-experimental.h
b/src/preferences/gb-preferences-page-experimental.h
new file mode 100644
index 0000000..d26330c
--- /dev/null
+++ b/src/preferences/gb-preferences-page-experimental.h
@@ -0,0 +1,33 @@
+/* gb-preferences-page-experimental.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#ifndef GB_PREFERENCES_PAGE_EXPERIMENTAL_H
+#define GB_PREFERENCES_PAGE_EXPERIMENTAL_H
+
+#include "gb-preferences-page.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_PREFERENCES_PAGE_EXPERIMENTAL (gb_preferences_page_experimental_get_type())
+
+G_DECLARE_FINAL_TYPE (GbPreferencesPageExperimental, gb_preferences_page_experimental,
+ GB, PREFERENCES_PAGE_EXPERIMENTAL, GbPreferencesPage)
+
+G_END_DECLS
+
+#endif /* GB_PREFERENCES_PAGE_EXPERIMENTAL_H */
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index 326261e..dcf9b4f 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -19,6 +19,7 @@
#include <glib/gi18n.h>
#include "gb-preferences-page-editor.h"
+#include "gb-preferences-page-experimental.h"
#include "gb-preferences-page-git.h"
#include "gb-preferences-page-keybindings.h"
#include "gb-preferences-page-language.h"
@@ -326,6 +327,7 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
GB_WIDGET_CLASS_BIND_PRIVATE (widget_class, GbPreferencesWindow, stack);
g_type_ensure (GB_TYPE_PREFERENCES_PAGE_EDITOR);
+ g_type_ensure (GB_TYPE_PREFERENCES_PAGE_EXPERIMENTAL);
g_type_ensure (GB_TYPE_PREFERENCES_PAGE_GIT);
g_type_ensure (GB_TYPE_PREFERENCES_PAGE_KEYBINDINGS);
g_type_ensure (GB_TYPE_PREFERENCES_PAGE_LANGUAGE);
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index d864857..b68cf16 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -30,6 +30,7 @@
<file alias="ui/gb-editor-workspace.ui">../../data/ui/gb-editor-workspace.ui</file>
<file alias="ui/gb-html-view.ui">../../data/ui/gb-html-view.ui</file>
<file alias="ui/gb-preferences-page-editor.ui">../../data/ui/gb-preferences-page-editor.ui</file>
+ <file
alias="ui/gb-preferences-page-experimental.ui">../../data/ui/gb-preferences-page-experimental.ui</file>
<file alias="ui/gb-preferences-page-git.ui">../../data/ui/gb-preferences-page-git.ui</file>
<file
alias="ui/gb-preferences-page-keybindings.ui">../../data/ui/gb-preferences-page-keybindings.ui</file>
<file alias="ui/gb-preferences-page-language.ui">../../data/ui/gb-preferences-page-language.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]